예제 #1
0
 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 DartEditor) {
       enable =
           DartToolsPlugin.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();
       }
     }
   }
 }
 /* (non-Javadoc)
  * @see org.eclipse.ui.texteditor.TextEditorAction#setEditor(org.eclipse.ui.texteditor.ITextEditor)
  */
 @Override
 public void setEditor(ITextEditor editor) {
   super.setEditor(editor);
   fOperationTarget = null;
 }