@Override
  protected void createActions() {
    super.createActions();
    ResourceBundle bundle = EditorMessages.getBundleForConstructedKeys();

    showOutline = new ShowOutlineAction(bundle, "ShowOutline.", this);
    showOutline.setActionDefinitionId(EditorActionDefinitionIds.SHOW_OUTLINE);
    setAction(EditorActionDefinitionIds.SHOW_OUTLINE, showOutline);
    markAsContentDependentAction(EditorActionDefinitionIds.SHOW_OUTLINE, true);

    quickSearch = new QuickSearchAction(bundle, "QuickSearch.", this);
    quickSearch.setActionDefinitionId(EditorActionDefinitionIds.QUICK_SEARCH);
    setAction(EditorActionDefinitionIds.QUICK_SEARCH, quickSearch);
    markAsContentDependentAction(EditorActionDefinitionIds.QUICK_SEARCH, true);

    jumpToDeclaration = new JumpToDeclarationAction(bundle, "JumpToDeclaration.", this);
    jumpToDeclaration.setActionDefinitionId(EditorActionDefinitionIds.JUMP_TO_DECLARATION);
    setAction(EditorActionDefinitionIds.JUMP_TO_DECLARATION, jumpToDeclaration);
    markAsContentDependentAction(EditorActionDefinitionIds.JUMP_TO_DECLARATION, true);

    toggleComment = new ToggleCommentAction(bundle, "ToggleComment.", this);
    toggleComment.setActionDefinitionId(EditorActionDefinitionIds.TOGGLE_COMMENT);
    setAction(EditorActionDefinitionIds.TOGGLE_COMMENT, toggleComment);
    markAsContentDependentAction(EditorActionDefinitionIds.JUMP_TO_DECLARATION, true);
  }
Beispiel #2
0
 /**
  * Needed for content assistant in the Text viewer. This ensures actions such as key press would
  * trigger content assistant
  */
 @SuppressWarnings("deprecation")
 protected void createActions() {
   super.createActions();
   ResourceBundle bundle = T24BasicPlugin.getDefault().getResourceBundle();
   String id = ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS;
   Action action = new ContentAssistAction(bundle, "ContentAssistProposal", this);
   action.setActionDefinitionId(id);
   setAction("ContentAssistProposal", action);
   this.markAsContentDependentAction(id, true);
   ResourceAction printAction =
       new TextOperationAction(bundle, "Editor.Print.", this, ITextOperationTarget.PRINT, true);
   String printid = IWorkbenchActionDefinitionIds.PRINT;
   printAction.setHelpContextId(IAbstractTextEditorHelpContextIds.PRINT_ACTION);
   printAction.setActionDefinitionId(printid);
   setAction(ITextEditorActionConstants.PRINT, new PrintActionDecorator(printAction));
   this.markAsContentDependentAction(printid, true);
 }
  @Override
  protected void createActions() {
    super.createActions();
    // TODO: Figure out how to do this later.
    //  	fFoldingGroup= new FoldingActionGroup(this, getSourceViewer());

    // Sticky hover support
    ResourceAction resAction =
        new TextOperationAction(
            AutoconfEditorMessages.getResourceBundle(),
            "ShowToolTip.",
            this,
            ISourceViewer.INFORMATION,
            true); //$NON-NLS-1$
    resAction =
        new InformationDispatchAction(
            AutoconfEditorMessages.getResourceBundle(),
            "ShowToolTip.",
            (TextOperationAction) resAction); // $NON-NLS-1$
    resAction.setActionDefinitionId(IAutotoolEditorActionDefinitionIds.SHOW_TOOLTIP);
    setAction("ShowToolTip", resAction); // $NON-NLS-1$
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(resAction, IAutotoolHelpContextIds.SHOW_TOOLTIP_ACTION);

    // Content assist
    Action action =
        new ContentAssistAction(
            AutoconfEditorMessages.getResourceBundle(),
            "ContentAssistProposal.",
            this); //$NON-NLS-1$
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
    setAction("ContentAssistProposal", action); // $NON-NLS-1$
    markAsStateDependentAction("ContentAssistProposal", true); // $NON-NLS-1$
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(action, IAutotoolHelpContextIds.CONTENT_ASSIST);
  }
 /**
  * {@inheritDoc} Extended to support the toggle comment.
  *
  * @see org.eclipse.ui.editors.text.TextEditor#createActions()
  */
 @Override
 protected void createActions() {
   super.createActions();
   createToggleCommentAction();
 }
  @Override
  protected void createActions() {
    super.createActions();
    try {
      setAction(VALIDATE_DRL_ON_SAVE, new ValidateDrlOnSaveAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(VALIDATE_DRL, new ValidateDrlAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(
          EXPORT_TO_HTML,
          new BasicExportAction(
              this,
              DrlPublisherPlugin.getURL("xsl/docbook/html/docbook.xsl"),
              "Export to HTML",
              "HTML",
              "html",
              false));
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(EXPORT_TO_PDF, new PdfExportAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }
    /*
    		try {
    			setAction(EXPORT_TO_HH, new BasicExportAction(this, DrlPublisherPlugin.getURL("xsl/docbook/htmlhelp/htmlhelp.xsl"), "Export to HTML Help", "HTML help", "hh", false));
    		} catch (Exception e) {
    			e.printStackTrace();
    		}

    		try {
    			setAction(EXPORT_TO_DB, new BasicExportAction(this, null, "Export to DocBook", "DocBook", "db", true));
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    */

    try {
      TemplatesDocument templatesDocument = new TemplatesDocument();
      for (int i = 0; i < templatesDocument.numOfTemplates; i++) {
        INSERT_TEMPLATES[i] = templatesDocument.templates[i].name;
        setAction(INSERT_TEMPLATES[i], new InsertTemplateAction(this, INSERT_TEMPLATES[i]));
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(SELECT_INTO_INF_ELEMENT, new SelectIntoInfElementAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(INSERT_INTO_DICTIONARY, new InsertIntoDictionaryAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(SEARCH_DICT_ENTRY, new SearchDictEntryAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(INSERT_INTO_DIRECTORY, new InsertIntoDirectoryAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(REPLACE_WITH_NEST, new ReplaceWithNestAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(SEARCH_DIR_REF, new SearchDirRefAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(EXTRACT_INSERT_AFTER, new ExtractInsertAfterAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(EXTRACT_INSERT_BEFORE, new ExtractInsertBeforeAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(REPLACE_WITH_INFELMREF, new ReplaceWithInfElemRef(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    // lebedkova
    try {
      setAction(RENAME, new RenameAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      setAction(SELECT_INTO_INF_PRODUCT, new SelectIntoInfProductAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {
      setAction(SELECT_INTO_COND_BLOCK, new SelectIntoCondBlockAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {
      setAction(SPLIT_INF_ELEM, new SplitInfElemAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {
      setAction(MAKE_REF_OPTIONAL, new MakeRefOptionalAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {
      setAction(MAKE_REF_REQUIRED, new MakeRefRequiredAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    // smazhevsky
    try {
      setAction(HANDLE_DIFF_WITH_ANOTHER_INF_ELEM, new HandleDIffWithAnotherInfElemAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }
    // shutak
    try {
      setAction(FIND_CLONES_IN_INF_ELEM, new FindClonesInInfElemAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }

    // dluciv
    try {
      setAction(FIND_AND_BROWSE_VARIATIONS, new FindAndBrowseVariationsAction(this));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void createActions() {
    super.createActions();
    ResourceBundle resourceBundle =
        new ResourceBundle() {
          public Enumeration<String> getKeys() {
            List<String> keys = new ArrayList<String>(3);
            keys.add("SelectAnnotationRulerAction.QuickFix.label");
            keys.add("SelectAnnotationRulerAction.QuickFix.tooltip");
            keys.add("SelectAnnotationRulerAction.QuickFix.description");
            return Collections.enumeration(keys);
          }

          public Object handleGetObject(String key) {
            if (key.equals("SelectAnnotationRulerAction.QuickFix.label")) return "&Quick Fix";
            if (key.equals("SelectAnnotationRulerAction.QuickFix.tooltip")) return "Quick Fix";
            if (key.equals("SelectAnnotationRulerAction.QuickFix.description"))
              return "Runs Quick Fix on the annotation's line";
            return null;
          }
        };
    setAction(
        ITextEditorActionConstants.RULER_CLICK,
        new SelectMarkerRulerAction(
            resourceBundle, "SelectAnnotationRulerAction.", this, getVerticalRuler()) {
          public void run() {
            runWithEvent(null);
          }

          public void runWithEvent(Event event) {
            ITextOperationTarget operation =
                (ITextOperationTarget) getAdapter(ITextOperationTarget.class);
            final int opCode = ISourceViewer.QUICK_ASSIST;
            if (operation != null && operation.canDoOperation(opCode)) {
              Position position = getPosition();
              if (position != null) {
                selectAndReveal(position.getOffset(), position.getLength());
              }
              operation.doOperation(opCode);
            }
          }

          private Position getPosition() {
            AbstractMarkerAnnotationModel model = getAnnotationModel();
            IAnnotationAccessExtension annotationAccess = getAnnotationAccessExtension();

            IDocument document = getDocument();
            if (model == null) {
              return null;
            }

            Iterator<?> iter = model.getAnnotationIterator();
            int layer = Integer.MIN_VALUE;

            while (iter.hasNext()) {
              Annotation annotation = (Annotation) iter.next();
              if (annotation.isMarkedDeleted()) {
                continue;
              }

              if (annotationAccess != null) {
                int annotationLayer = annotationAccess.getLayer(annotation);
                if (annotationLayer < layer) {
                  continue;
                }
              }

              Position position = model.getPosition(annotation);
              if (!includesRulerLine(position, document)) {
                continue;
              }

              return position;
            }
            return null;
          }
        });
  }