/** * Note: This method is for internal use only. Clients should not call this method. * * @param selection the selection * * @noreference This method is not intended to be referenced by clients. */ public void run(JavaTextSelection selection) { run((ITextSelection)selection); }
/** * Notifies this action that the given text selection has changed. This default * implementation calls <code>selectionChanged(ISelection selection)</code>. * * @param selection the new selection */ public void selectionChanged(ITextSelection selection) { selectionChanged((ISelection)selection); }
private void registerAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection, ISelectionProvider specialSelectionProvider) { action.update(selection); provider.addSelectionChangedListener(action); if (specialSelectionProvider != null) action.setSpecialSelectionProvider(specialSelectionProvider); }
@Override public void run() { dispatchRun(getSelection()); }
/** * Sets actionDefinitionId, updates enablement, adds to fActions, * and adds selection changed listener if provider is not <code>null</code>. * * @param action the action * @param provider can be <code>null</code> * @param specialProvider a special selection provider or <code>null</code> * @param selection the selection * @param actionDefinitionId the action definition id */ private void initUpdatingAction(SelectionDispatchAction action, ISelectionProvider provider, ISelectionProvider specialProvider, ISelection selection, String actionDefinitionId) { action.setActionDefinitionId(actionDefinitionId); action.update(selection); if (provider != null) provider.addSelectionChangedListener(action); if (specialProvider != null) action.setSpecialSelectionProvider(specialProvider); fActions.add(action); }
public final boolean activate(final Refactoring ref, final Shell parent, final int saveMode) throws CoreException { final RefactoringStatus status= ref.checkInitialConditions(new NullProgressMonitor()); if (status.hasFatalError()) { final RefactoringStatusEntry entry= status.getEntryMatchingSeverity(RefactoringStatus.FATAL); if (entry.getCode() == RefactoringStatusCodes.OVERRIDES_ANOTHER_METHOD || entry.getCode() == RefactoringStatusCodes.METHOD_DECLARED_IN_INTERFACE) { String message= entry.getMessage(); final Object element= entry.getData(); message= message + RefactoringMessages.RefactoringErrorDialogUtil_okToPerformQuestion; if (element != null && MessageDialog.openQuestion(shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, message)) { final IStructuredSelection selection= new StructuredSelection(element); // TODO: should not hijack this // ModifiyParametersAction. // The action is set up on an editor, but we use it // as if it were set up on a ViewPart. boolean wasEnabled= action.isEnabled(); action.selectionChanged(selection); if (action.isEnabled()) { action.run(selection); } else { MessageDialog.openInformation(shell, ActionMessages.ModifyParameterAction_problem_title, ActionMessages.ModifyParameterAction_problem_message); } action.setEnabled(wasEnabled); } return false; } } return super.activate(ref, parent, saveMode); } };
/** * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(IStructuredSelection) */ protected void updateSelection(IStructuredSelection selection) { super.update(selection); }
/** * Sets actionDefinitionId, updates enablement, adds to fActions, * and adds selection changed listener if provider is not <code>null</code>. * * @param action * @param provider can be <code>null</code> * @param selection * @param actionDefinitionId */ private void initUpdatingAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection, String actionDefinitionId){ action.setActionDefinitionId(actionDefinitionId); action.update(selection); if (provider != null) provider.addSelectionChangedListener(action); fActions.add(action); }
fCopyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY); fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.ACTION_DEFINITION_ID); fPasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE); fDeleteAction= new DeleteAction(site); fDeleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE); fCutAction= new CutAction(site); fCutAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT); fActions= new SelectionDispatchAction[] { fCutAction, fCopyAction, fCopyQualifiedNameAction, fPasteAction, fDeleteAction }; } else { fActions[i].setSpecialSelectionProvider(specialSelectionProvider);
/** * Updates the action's enablement state according to the given selection. This * default implementation calls one of the <code>selectionChanged</code> * methods depending on the type of the passed selection. * * @param selection the selection this action is working on */ public void update(ISelection selection) { dispatchSelectionChanged(selection); }
IJavaElement element= SelectionConverter.selectJavaElement(types.toArray(new IType[types.size()]), fOpenAction.getShell(), ActionMessages.OpenAction_error_title, ActionMessages.OpenAction_select_element); if (element != null) { fOpenAction.run(new StructuredSelection(element)); fOpenAction.run(new StructuredSelection(type)); return;
/** * Notifies this action that the given selection has changed. This default * implementation sets the action's enablement state to <code>false</code>. * * @param selection the new selection */ public void selectionChanged(ISelection selection) { setEnabled(false); }
@Override public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); for (int i= 0; i < fActions.length; i++) { SelectionDispatchAction action= fActions[i]; if (action == fCutAction && !fCutAction.isEnabled()) continue; menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, action); } }
/** * Returns the selection provided by the site owning this action. * * @return the site's selection */ public ISelection getSelection() { ISelectionProvider selectionProvider= getSelectionProvider(); if (selectionProvider != null) return selectionProvider.getSelection(); else return null; }
private CCPActionGroup(IWorkbenchSite site) { fSite= site; fClipboard= new Clipboard(site.getShell().getDisplay()); fPasteAction= new PasteAction(fSite, fClipboard); fPasteAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.PASTE); fCopyAction= new CopyToClipboardAction(fSite, fClipboard); fCopyAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY); fCopyQualifiedNameAction= new CopyQualifiedNameAction(fSite); fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.ACTION_DEFINITION_ID); fCutAction= new CutAction(fSite, fClipboard); fCutAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.CUT); fDeleteAction= new DeleteAction(fSite); fDeleteAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.DELETE); fActions= new SelectionDispatchAction[] { fCutAction, fCopyAction, fCopyQualifiedNameAction, fPasteAction, fDeleteAction }; registerActionsAsSelectionChangeListeners(); }
boolean wasEnabled= action.isEnabled(); action.selectionChanged(selection); if (action.isEnabled()) { action.run(selection); } else { MessageDialog.openInformation(shell, ActionMessages.ModifyParameterAction_problem_title, ActionMessages.ModifyParameterAction_problem_message); action.setEnabled(wasEnabled);
private void registerAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection) { action.update(selection); provider.addSelectionChangedListener(action); }
/** * Sets actionDefinitionId, updates enablement, adds to fActions, * and adds selection changed listener if provider is not <code>null</code>. * * @param action the action * @param provider can be <code>null</code> * @param specialProvider a special selection provider or <code>null</code> * @param selection the selection * @param actionDefinitionId the action definition id */ private void initUpdatingAction(SelectionDispatchAction action, ISelectionProvider provider, ISelectionProvider specialProvider, ISelection selection, String actionDefinitionId) { action.setActionDefinitionId(actionDefinitionId); action.update(selection); if (provider != null) provider.addSelectionChangedListener(action); if (specialProvider != null) action.setSpecialSelectionProvider(specialProvider); fActions.add(action); }
@Override public void run() { dispatchRun(getSelection()); }
fCopyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY); fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.ACTION_DEFINITION_ID); fPasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE); fDeleteAction= new DeleteAction(site); fDeleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE); fCutAction= new CutAction(site); fCutAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT); fActions= new SelectionDispatchAction[] { fCutAction, fCopyAction, fCopyQualifiedNameAction, fPasteAction, fDeleteAction }; } else { fActions[i].setSpecialSelectionProvider(specialSelectionProvider);