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(); } } } }
@Override protected void createActions() { super.createActions(); IAction a = (TextEditorAction) new AutoIndentAction( ResourceBundle.getBundle(RESOURCE_BUNDLE), "AutoIndent", null); setAction("AutoIndent", a); }