@Override public void selectionChanged(IStructuredSelection selection) { try { setEnabled(canEnable(selection)); } catch (JavaModelException exception) { if (JavaModelUtil.isExceptionToBeLogged(exception)) JavaPlugin.log(exception); setEnabled(false); } }
/** * Note: This constructor is for internal use only. Clients should not call this * constructor. * @param editor the compilation unit editor * * @noreference This constructor is not intended to be referenced by clients. */ public OverrideMethodsAction(final CompilationUnitEditor editor) { this(editor.getEditorSite()); fEditor= editor; setEnabled(checkEnabledEditor()); }
public void run(IStructuredSelection selection) { try { final IType type= getSelectedType(selection); if (type == null) { MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.OverrideMethodsAction_not_applicable); notifyResult(false); return; } if (!ElementValidator.check(type, getShell(), getDialogTitle(), false) || !ActionUtil.isEditable(getShell(), type)) { notifyResult(false); return; } run(getShell(), type); } catch (CoreException exception) { ExceptionHandler.handle(exception, getShell(), getDialogTitle(), ActionMessages.OverrideMethodsAction_error_actionfailed); } }
private void run(Shell shell, IType type) throws CoreException { final OverrideMethodDialog dialog= new OverrideMethodDialog(shell, fEditor, type, false); if (!dialog.hasMethodsToOverride()) { MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.OverrideMethodsAction_error_nothing_found); notifyResult(false); return; notifyResult(false); return; notifyResult(false); return; int insertPos= dialog.getInsertOffset(); AddUnimplementedMethodsOperation operation= (AddUnimplementedMethodsOperation) createRunnable(astRoot, typeBinding, methodToOverride, insertPos, dialog.getGenerateComment()); IRunnableContext context= JavaPlugin.getActiveWorkbenchWindow(); if (context == null) final String[] created= operation.getCreatedMethods(); if (created == null || created.length == 0) MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.OverrideMethodsAction_error_nothing_found); } catch (InvocationTargetException exception) { ExceptionHandler.handle(exception, shell, getDialogTitle(), null); } catch (InterruptedException exception) { target.endCompoundChange(); notifyResult(true);
ISelection selection= fSelectionProvider.getSelection(); fOverrideMethods= new OverrideMethodsAction(site); fOverrideMethods.setActionDefinitionId(IJavaEditorActionDefinitionIds.OVERRIDE_METHODS); fOverrideMethods.update(selection); fAddGetterSetter.update(selection); fAddDelegateMethods.update(selection);
editor.setAction("SortMembers", fSortMembers); //$NON-NLS-1$ fOverrideMethods= new OverrideMethodsAction(editor); fOverrideMethods.setActionDefinitionId(IJavaEditorActionDefinitionIds.OVERRIDE_METHODS); editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$
IWorkspaceRunnable operation = OverrideMethodsAction.createRunnable(unit, binding, null, -1, true); operation.run(monitor); cu.reconcile(ICompilationUnit.NO_AST, false, null, null);
private void run(Shell shell, IType type) throws CoreException { final OverrideMethodDialog dialog= new OverrideMethodDialog(shell, fEditor, type, false); if (!dialog.hasMethodsToOverride()) { MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.OverrideMethodsAction_error_nothing_found); notifyResult(false); return; notifyResult(false); return; notifyResult(false); return; int insertPos= dialog.getInsertOffset(); AddUnimplementedMethodsOperation operation= (AddUnimplementedMethodsOperation) createRunnable(astRoot, typeBinding, methodToOverride, insertPos, dialog.getGenerateComment()); IRunnableContext context= JavaPlugin.getActiveWorkbenchWindow(); if (context == null) final String[] created= operation.getCreatedMethods(); if (created == null || created.length == 0) MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.OverrideMethodsAction_error_nothing_found); } catch (InvocationTargetException exception) { ExceptionHandler.handle(exception, shell, getDialogTitle(), null); } catch (InterruptedException exception) { target.endCompoundChange(); notifyResult(true);
ISelection selection= fSelectionProvider.getSelection(); fOverrideMethods= new OverrideMethodsAction(site); fOverrideMethods.setActionDefinitionId(IJavaEditorActionDefinitionIds.OVERRIDE_METHODS); fOverrideMethods.update(selection); fAddGetterSetter.update(selection); fAddDelegateMethods.update(selection);
editor.setAction("SortMembers", fSortMembers); //$NON-NLS-1$ fOverrideMethods= new OverrideMethodsAction(editor); fOverrideMethods.setActionDefinitionId(IJavaEditorActionDefinitionIds.OVERRIDE_METHODS); editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$
@Override public void run(IStructuredSelection selection) { try { final IType type= getSelectedType(selection); if (type == null) { MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.OverrideMethodsAction_not_applicable); notifyResult(false); return; } if (!ElementValidator.check(type, getShell(), getDialogTitle(), false) || !ActionUtil.isEditable(getShell(), type)) { notifyResult(false); return; } run(getShell(), type); } catch (CoreException exception) { ExceptionHandler.handle(exception, getShell(), getDialogTitle(), ActionMessages.OverrideMethodsAction_error_actionfailed); } }
private void run(Shell shell, IType type) throws CoreException { final OverrideMethodDialog dialog= new OverrideMethodDialog(shell, fEditor, type, false); if (!dialog.hasMethodsToOverride()) { MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.OverrideMethodsAction_error_nothing_found); notifyResult(false); return; notifyResult(false); return; notifyResult(false); return; int insertPos= dialog.getInsertOffset(); AddUnimplementedMethodsOperation operation= (AddUnimplementedMethodsOperation) createRunnable(astRoot, typeBinding, methodToOverride, insertPos, dialog.getGenerateComment()); IRunnableContext context= JavaPlugin.getActiveWorkbenchWindow(); if (context == null) final String[] created= operation.getCreatedMethods(); if (created == null || created.length == 0) MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.OverrideMethodsAction_error_nothing_found); } catch (InvocationTargetException exception) { ExceptionHandler.handle(exception, shell, getDialogTitle(), null); } catch (InterruptedException exception) { target.endCompoundChange(); notifyResult(true);
ISelection selection= provider.getSelection(); fOverrideMethods= new OverrideMethodsAction(site); fOverrideMethods.setActionDefinitionId(IJavaEditorActionDefinitionIds.OVERRIDE_METHODS); fOverrideMethods.update(selection); fAddGetterSetter.update(selection); fAddDelegateMethods.update(selection);
@Override public void selectionChanged(IStructuredSelection selection) { try { setEnabled(canEnable(selection)); } catch (JavaModelException exception) { if (JavaModelUtil.isExceptionToBeLogged(exception)) JavaPlugin.log(exception); setEnabled(false); } }
/** * Note: This constructor is for internal use only. Clients should not call this * constructor. * @param editor the compilation unit editor * * @noreference This constructor is not intended to be referenced by clients. */ public OverrideMethodsAction(final CompilationUnitEditor editor) { this(editor.getEditorSite()); fEditor= editor; setEnabled(checkEnabledEditor()); }
editor.setAction("SortMembers", fSortMembers); //$NON-NLS-1$ fOverrideMethods= new OverrideMethodsAction(editor); fOverrideMethods.setActionDefinitionId(IJavaEditorActionDefinitionIds.OVERRIDE_METHODS); editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$
@Override public void run(IStructuredSelection selection) { try { final IType type= getSelectedType(selection); if (type == null) { MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.OverrideMethodsAction_not_applicable); notifyResult(false); return; } if (!ElementValidator.check(type, getShell(), getDialogTitle(), false) || !ActionUtil.isEditable(getShell(), type)) { notifyResult(false); return; } run(getShell(), type); } catch (CoreException exception) { ExceptionHandler.handle(exception, getShell(), getDialogTitle(), ActionMessages.OverrideMethodsAction_error_actionfailed); } }
public void selectionChanged(IStructuredSelection selection) { try { setEnabled(canEnable(selection)); } catch (JavaModelException exception) { if (JavaModelUtil.isExceptionToBeLogged(exception)) JavaPlugin.log(exception); setEnabled(false); } }
/** * Note: This constructor is for internal use only. Clients should not call this * constructor. * @param editor the compilation unit editor */ public OverrideMethodsAction(final CompilationUnitEditor editor) { this(editor.getEditorSite()); fEditor= editor; setEnabled(checkEnabledEditor()); }
@Override public void run(ITextSelection selection) { try { final IType type= SelectionConverter.getTypeAtOffset(fEditor); if (type != null) { if (!ElementValidator.check(type, getShell(), getDialogTitle(), false) || !ActionUtil.isEditable(fEditor, getShell(), type)) { notifyResult(false); return; } if (type.isAnnotation()) { MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.OverrideMethodsAction_annotation_not_applicable); notifyResult(false); return; } run(getShell(), type); } else { MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.OverrideMethodsAction_not_applicable); } } catch (JavaModelException e) { ExceptionHandler.handle(e, getShell(), getDialogTitle(), null); } catch (CoreException e) { ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.OverrideMethodsAction_error_actionfailed); } }