private void saveCurrentActions(IActionBars actionBars) { copy = actionBars.getGlobalActionHandler(ActionFactory.COPY.getId()); paste = actionBars.getGlobalActionHandler(ActionFactory.PASTE.getId()); delete = actionBars.getGlobalActionHandler(ActionFactory.DELETE.getId()); selectAll = actionBars.getGlobalActionHandler(ActionFactory.SELECT_ALL.getId()); cut = actionBars.getGlobalActionHandler(ActionFactory.CUT.getId()); find = actionBars.getGlobalActionHandler(ActionFactory.FIND.getId()); undo = actionBars.getGlobalActionHandler(ActionFactory.UNDO.getId()); redo = actionBars.getGlobalActionHandler(ActionFactory.REDO.getId()); } }
private void saveCurrentActions(IActionBars actionBars) { copy = actionBars.getGlobalActionHandler(ActionFactory.COPY.getId()); paste = actionBars.getGlobalActionHandler(ActionFactory.PASTE.getId()); delete = actionBars.getGlobalActionHandler(ActionFactory.DELETE.getId()); selectAll = actionBars.getGlobalActionHandler(ActionFactory.SELECT_ALL.getId()); cut = actionBars.getGlobalActionHandler(ActionFactory.CUT.getId()); find = actionBars.getGlobalActionHandler(ActionFactory.FIND.getId()); undo = actionBars.getGlobalActionHandler(ActionFactory.UNDO.getId()); redo = actionBars.getGlobalActionHandler(ActionFactory.REDO.getId()); }
/** * Save the global actions from action bar so they are not overridden by the * detail pane. */ @Override protected void createContextMenu(Control menuControl) { super.createContextMenu(menuControl); IActionBars actionBars = getViewSite().getActionBars(); if (!fGlobalActionMap.containsKey(SELECT_ALL_ACTION)) { setGlobalAction(IDebugView.SELECT_ALL_ACTION, actionBars.getGlobalActionHandler(SELECT_ALL_ACTION)); } if (!fGlobalActionMap.containsKey(COPY_ACTION)) { setGlobalAction(COPY_ACTION, actionBars.getGlobalActionHandler(COPY_ACTION)); } if (!fGlobalActionMap.containsKey(PASTE_ACTION)) { setGlobalAction(PASTE_ACTION, actionBars.getGlobalActionHandler(PASTE_ACTION)); } }
/** * Copies the view's global action handlers created by createActions(), * into the page site's action bars. This is necessary because the page * book view resets the view site's global actions after each page switch * (see bug 264618). * * @param page Page to copy the global actions into. * * @since 3.5 */ private void setGlobalActionBarsToPage(IPageBookViewPage page) { IActionBars pageActionBars = page.getSite().getActionBars(); // Set the view site action bars created by createActions() to the // default page site. IActionBars bars = getViewSite().getActionBars(); pageActionBars.setGlobalActionHandler(FIND_ACTION, bars.getGlobalActionHandler(FIND_ACTION)); pageActionBars.setGlobalActionHandler(COPY_ACTION, bars.getGlobalActionHandler(COPY_ACTION)); }
@Override public void focusGained(FocusEvent e) { IActionBars actionBars= viewSite.getActionBars(); fViewCopyHandler= actionBars.getGlobalActionHandler(ActionFactory.COPY.getId()); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction); actionBars.updateActionBars(); } });
/** * Either the action handler itself has changed, or the configured action * handlers on the action bars have changed. Update self. */ protected void propagateChange(PropertyChangeEvent event) { if (event.getProperty().equals(IAction.ENABLED)) { Boolean bool = (Boolean) event.getNewValue(); setEnabled(bool.booleanValue()); } else if (event.getProperty().equals(IAction.CHECKED)) { Boolean bool = (Boolean) event.getNewValue(); setChecked(bool.booleanValue()); } else if (event.getProperty().equals(SubActionBars.P_ACTION_HANDLERS)) { if (event.getSource() instanceof IActionBars) { IActionBars bars = (IActionBars) event.getSource(); setActionHandler(bars.getGlobalActionHandler(getId())); } } }
/** * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) */ public void setActionBars(IActionBars actionBars) { // Override the undo and redo global action handlers // to use the contributor action handlers if (contributor instanceof IEditorPart) { IEditorPart editorPart = (IEditorPart) contributor; IActionBars editorActionBars = editorPart.getEditorSite() .getActionBars(); actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), editorActionBars.getGlobalActionHandler(ActionFactory.UNDO .getId())); actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), editorActionBars.getGlobalActionHandler(ActionFactory.REDO .getId())); } }
@Override public void focusGained(FocusEvent e) { IActionBars actionBars= viewSite.getActionBars(); fViewCopyHandler= actionBars.getGlobalActionHandler(ActionFactory.COPY.getId()); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction); actionBars.updateActionBars(); } });
public void focusGained(FocusEvent e) { IActionBars actionBars= viewSite.getActionBars(); fViewCopyHandler= actionBars.getGlobalActionHandler(ActionFactory.COPY.getId()); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction); actionBars.updateActionBars(); } });
public void setGlobalActionHandler(String actionID, IAction handler) { if (handler == null) { // Only remove the handler if it was set if (getGlobalActionHandler(actionID) != null) { getParent().setGlobalActionHandler(actionID, null); super.setGlobalActionHandler(actionID, null); } } else { // Only set the action handler if the parent doesn't if (getParent().getGlobalActionHandler(actionID) != null) { TeamUIPlugin.log(new TeamException(NLS.bind("Conflicting attempt to set action id {0} detected", actionID))); //$NON-NLS-1$ return; } super.setGlobalActionHandler(actionID, handler); } }
@Override public void setGlobalActionHandler(String actionID, IAction handler) { if (handler == null) { // Only remove the handler if it was set if (getGlobalActionHandler(actionID) != null) { getParent().setGlobalActionHandler(actionID, null); super.setGlobalActionHandler(actionID, null); } } else { // Only set the action handler if the parent doesn't if (getParent().getGlobalActionHandler(actionID) != null) { TeamUIPlugin.log(new TeamException(NLS.bind("Conflicting attempt to set action id {0} detected", actionID))); //$NON-NLS-1$ return; } super.setGlobalActionHandler(actionID, handler); } }
/** * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) */ @Override public void setActionBars(IActionBars actionBars) { // Override the undo and redo global action handlers // to use the contributor action handlers IActionBars partActionBars = null; if (contributor instanceof IEditorPart) { IEditorPart editorPart = (IEditorPart) contributor; partActionBars = editorPart.getEditorSite().getActionBars(); } else if (contributor instanceof IViewPart) { IViewPart viewPart = (IViewPart) contributor; partActionBars = viewPart.getViewSite().getActionBars(); } if (partActionBars != null) { IAction action = partActionBars.getGlobalActionHandler(ActionFactory.UNDO .getId()); if (action != null) { actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), action); } action = partActionBars.getGlobalActionHandler(ActionFactory.REDO .getId()); if (action != null) { actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), action); } } }
/** * <p> * Note: This method is for internal use only. Clients should not call this * method. * </p> * * @param anEvent * Supplied by the DoubleClick listener. */ protected void handleDoubleClick(DoubleClickEvent anEvent) { IAction openHandler = getViewSite().getActionBars().getGlobalActionHandler(ICommonActionConstants.OPEN); if(openHandler == null) { IStructuredSelection selection = (IStructuredSelection) anEvent .getSelection(); Object element = selection.getFirstElement(); TreeViewer viewer = getCommonViewer(); if (viewer.isExpandable(element)) { viewer.setExpandedState(element, !viewer.getExpandedState(element)); } } }
private static void initializeHighlightRange(IEditorPart editorPart) { if (editorPart instanceof ITextEditor) { IAction toggleAction= editorPart.getEditorSite().getActionBars().getGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY); boolean enable= toggleAction != null; if (enable && editorPart instanceof JavaEditor) enable= JavaPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS); else enable= enable && toggleAction.isEnabled() && toggleAction.isChecked(); if (enable) { if (toggleAction instanceof TextEditorAction) { // Reset the action ((TextEditorAction)toggleAction).setEditor(null); // Restore the action ((TextEditorAction)toggleAction).setEditor((ITextEditor)editorPart); } else { // Uncheck toggleAction.run(); // Check toggleAction.run(); } } } }
private static void initializeHighlightRange(IEditorPart editorPart) { if (editorPart instanceof ITextEditor) { IAction toggleAction= editorPart.getEditorSite().getActionBars().getGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY); boolean enable= toggleAction != null; if (enable && editorPart instanceof JavaEditor) enable= JavaPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS); else enable= enable && toggleAction.isEnabled() && toggleAction.isChecked(); if (enable) { if (toggleAction instanceof TextEditorAction) { // Reset the action ((TextEditorAction)toggleAction).setEditor(null); // Restore the action ((TextEditorAction)toggleAction).setEditor((ITextEditor)editorPart); } else { // Uncheck toggleAction.run(); // Check toggleAction.run(); } } } }
private static void initializeHighlightRange(IEditorPart editorPart) { if (editorPart instanceof ITextEditor) { IAction toggleAction= editorPart.getEditorSite().getActionBars().getGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY); boolean enable= toggleAction != null; if (enable && editorPart instanceof JavaEditor) enable= JavaPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS); else enable= enable && toggleAction.isEnabled() && toggleAction.isChecked(); if (enable) { if (toggleAction instanceof TextEditorAction) { // Reset the action ((TextEditorAction)toggleAction).setEditor(null); // Restore the action ((TextEditorAction)toggleAction).setEditor((ITextEditor)editorPart); } else { // Uncheck toggleAction.run(); // Check toggleAction.run(); } } } }