Example usage for org.eclipse.jface.action Action setActionDefinitionId

List of usage examples for org.eclipse.jface.action Action setActionDefinitionId

Introduction

In this page you can find the example usage for org.eclipse.jface.action Action setActionDefinitionId.

Prototype

@Override
    public void setActionDefinitionId(String id) 

Source Link

Usage

From source file:ar.com.tadp.xml.rinzo.core.RinzoXMLEditor.java

License:Open Source License

protected void createActions() {
    super.createActions();
    Action action = new ContentAssistAction(XMLEditorPlugin.getDefault().getResourceBundle(),
            "ContentAssistProposal.", this);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
    setAction("ContentAssistProposal", action);
    markAsStateDependentAction("ContentAssistProposal", true);
}

From source file:ca.uwaterloo.gsd.fsml.xmleditor.editors.XMLEditor.java

License:Open Source License

@Override
protected void createActions() {
    super.createActions();

    Action action = new ContentAssistAction(new MyResources(), "ContentAssistProposal.", this);
    String id = ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS;
    action.setActionDefinitionId(id);
    setAction("ContentAssistProposal", action);
    markAsStateDependentAction("ContentAssistProposal", true);
}

From source file:ccw.editors.clojure.ClojureEditor.java

License:Open Source License

@Override
protected void createActions() {
    super.createActions();

    // @todo push many (if not most) of these into ClojureSourceViewer (somehow, that's SWT and actions are eclipse-land :-/)
    Action action;

    action = new GotoNextMemberAction(this);
    action.setActionDefinitionId(IClojureEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
    setAction(GotoNextMemberAction.ID, action);

    action = new GotoPreviousMemberAction(this);
    action.setActionDefinitionId(IClojureEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
    setAction(GotoPreviousMemberAction.ID, action);

    action = new SelectTopLevelSExpressionAction(this);
    action.setActionDefinitionId(IClojureEditorActionDefinitionIds.SELECT_TOP_LEVEL_S_EXPRESSION);
    setAction(SelectTopLevelSExpressionAction.ID, action);

    action = new EvaluateTopLevelSExpressionAction(this);
    action.setActionDefinitionId(IClojureEditorActionDefinitionIds.EVALUATE_TOP_LEVEL_S_EXPRESSION);
    setAction(EvaluateTopLevelSExpressionAction.ID, action);

    action = new LoadFileAction(this);
    action.setActionDefinitionId(IClojureEditorActionDefinitionIds.LOAD_FILE);
    setAction(LoadFileAction.ID, action);

    action = new SwitchNamespaceAction(this);
    action.setActionDefinitionId(IClojureEditorActionDefinitionIds.SWITCH_NS);
    setAction(SwitchNamespaceAction.ID, action);

    action = new CompileLibAction(this);
    action.setActionDefinitionId(IClojureEditorActionDefinitionIds.COMPILE_LIB);
    setAction(CompileLibAction.ID, action);

    action = new RunTestsAction(this, CCWPlugin.getDefault().getColorCache());
    action.setActionDefinitionId(IClojureEditorActionDefinitionIds.RUN_TESTS);
    setAction(RunTestsAction.RUN_TESTS_ID, action);
    /*/*w  w  w . j a  v a2  s.  c  o  m*/
    action = new FormatAction(this);
    action.setActionDefinitionId(IClojureEditorActionDefinitionIds.FORMAT_CODE);
    setAction(FormatAction.ID, action);
     */

    action = new Action() {
        @Override
        public void run() {
            // is this code dead?
            new ClojureLaunchShortcut().launch(ClojureEditor.this, null /* default run mode*/);
        };
    };
    action.setActionDefinitionId(IClojureEditorActionDefinitionIds.LAUNCH_REPL);
    setAction("ClojureLaunchAction", action);

    //      TODO: same for content-assist handler ? markAsStateDependentAction(CONTENT_ASSIST_PROPOSAL, true);

    action = new Action() {
        @Override
        public void run() {
            viewer.updateStructuralEditingModeStatusField();
        };
    };
    action.setActionDefinitionId(ClojureSourceViewer.STATUS_CATEGORY_STRUCTURAL_EDITION);
    setAction(ClojureSourceViewer.STATUS_CATEGORY_STRUCTURAL_EDITION, action);

}

From source file:com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor.java

License:Open Source License

/**
 * Creates the XML source editor.//w ww . ja  v  a  2  s  .co  m
 * <p/>
 * Memorizes the index page of the source editor (it's always the last page, but the number
 * of pages before can change.)
 * <br/>
 * Retrieves the underlying XML model from the StructuredEditor and attaches a listener to it.
 * Finally triggers modelChanged() on the model listener -- derived classes can use this
 * to initialize the model the first time.
 * <p/>
 * Called only once <em>after</em> createFormPages.
 */
private void createTextEditor() {
    try {
        mTextEditor = new StructuredTextEditor() {
            @Override
            protected void createActions() {
                super.createActions();

                Action action = new RenameResourceXmlTextAction(mTextEditor);
                action.setActionDefinitionId(IJavaEditorActionDefinitionIds.RENAME_ELEMENT);
                setAction(IJavaEditorActionDefinitionIds.RENAME_ELEMENT, action);
            }
        };
        int index = addPage(mTextEditor, getEditorInput());
        mTextPageIndex = index;
        setPageText(index, mTextEditor.getTitle());
        setPageImage(index, IconFactory.getInstance().getIcon(ICON_XML_PAGE));

        if (!(mTextEditor.getTextViewer().getDocument() instanceof IStructuredDocument)) {
            Status status = new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID,
                    "Error opening the Android XML editor. Is the document an XML file?");
            throw new RuntimeException("Android XML Editor Error", new CoreException(status));
        }

        IStructuredModel xml_model = getModelForRead();
        if (xml_model != null) {
            try {
                mXmlModelStateListener = new XmlModelStateListener();
                xml_model.addModelStateListener(mXmlModelStateListener);
                mXmlModelStateListener.modelChanged(xml_model);
            } catch (Exception e) {
                AdtPlugin.log(e, "Error while loading editor"); //$NON-NLS-1$
            } finally {
                xml_model.releaseFromRead();
            }
        }
    } catch (PartInitException e) {
        ErrorDialog.openError(getSite().getShell(), "Android XML Editor Error", null, e.getStatus());
    }
}

From source file:com.android.ide.eclipse.adt.internal.editors.layout.gle2.LayoutCanvas.java

License:Open Source License

/**
 * Helper for {@link #setupGlobalActionHandlers()}.
 * Copies the action attributes form the given {@link ActionFactory}'s action to
 * our action.//from   w  ww.  j  a v a 2 s  .co m
 * <p/>
 * {@link ActionFactory} provides access to the standard global actions in Eclipse.
 * <p/>
 * This allows us to grab the standard labels and icons for the
 * global actions such as copy, cut, paste, delete and select-all.
 */
private void copyActionAttributes(Action action, ActionFactory factory) {
    IWorkbenchAction wa = factory.create(mEditorDelegate.getEditor().getEditorSite().getWorkbenchWindow());
    action.setId(wa.getId());
    action.setText(wa.getText());
    action.setEnabled(wa.isEnabled());
    action.setDescription(wa.getDescription());
    action.setToolTipText(wa.getToolTipText());
    action.setAccelerator(wa.getAccelerator());
    action.setActionDefinitionId(wa.getActionDefinitionId());
    action.setImageDescriptor(wa.getImageDescriptor());
    action.setHoverImageDescriptor(wa.getHoverImageDescriptor());
    action.setDisabledImageDescriptor(wa.getDisabledImageDescriptor());
    action.setHelpListener(wa.getHelpListener());
}

From source file:com.aptana.editor.common.AbstractThemeableEditor.java

License:Open Source License

@Override
protected void createActions() {
    super.createActions();
    setAction(FilterThroughCommandAction.COMMAND_ID, FilterThroughCommandAction.create(this));
    this.fThemeableEditorFindBarExtension.createFindBarActions();

    // Code formatter setup
    Action action = new TextOperationAction(Messages.getBundleForConstructedKeys(), "Format.", this, //$NON-NLS-1$
            ISourceViewer.FORMAT);//ww  w  .j a v  a 2 s.com
    action.setActionDefinitionId(ICommonConstants.FORMATTER_ACTION_DEFINITION_ID);
    setAction(ICommonConstants.FORMATTER_ACTION_ID, action);
    markAsStateDependentAction(ICommonConstants.FORMATTER_ACTION_ID, true);
    markAsSelectionDependentAction(ICommonConstants.FORMATTER_ACTION_ID, true);

    // Folding setup
    foldingActionsGroup = new FoldingActionsGroup(this);
}

From source file:com.aptana.ide.editor.erb.ERBSourceEditor.java

License:Open Source License

@Override
protected void createActions() {
    super.createActions();

    Action action = new OpenAction(this);
    action.setActionDefinitionId(IERBEditorActionConstants.OPEN_EDITOR);
    setAction(IERBEditorActionConstants.OPEN_EDITOR, action); //$NON-NLS-1$

    action = new ExtractPartialAction(this);
    action.setActionDefinitionId(IERBEditorActionConstants.EXTRACT_PARTIAL_ACTION);
    setAction(IERBEditorActionConstants.EXTRACT_PARTIAL_ACTION, action);
    // PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IERBHelpContextIds.EXTRACT_PARTIAL_ACTION);

    action = new ContentAssistAction(RubyPlugin.getDefault().getPluginProperties(), "ContentAssistProposal.",
            this);
    action.setActionDefinitionId(IERBEditorActionConstants.CONTENT_ASSIST_PROPOSALS);
    setAction(IERBEditorActionConstants.CONTENT_ASSIST_PROPOSALS, action);
}

From source file:com.aptana.ide.editors.unified.UnifiedEditor.java

License:Open Source License

/**
 * @see org.eclipse.ui.editors.text.TextEditor#createActions()
 *///w ww . ja v a 2  s .  c  om
protected void createActions() {
    super.createActions();

    // Add bookmark action
    final BookmarkRulerAction bra = new BookmarkRulerAction();
    Action bookmarkAction = new Action() {

        public void run() {
            bra.run(this);
        }

    };
    bra.setActiveEditor(bookmarkAction, this);
    setAction(ADD_BOOKMARK, bookmarkAction);

    // Add task action
    final TaskRulerAction tra = new TaskRulerAction();
    Action taskAction = new Action() {
        public void run() {
            tra.run(this);
        }

    };
    tra.setActiveEditor(taskAction, this);
    setAction(ADD_TASK, taskAction);

    Action action = new ContentAssistAction(UnifiedMessages.getResourceBundle(), "ContentAssistProposal.", //$NON-NLS-1$
            this);
    String id = ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS;
    action.setActionDefinitionId(id);
    setAction("ContentAssistProposal", action); //$NON-NLS-1$
    markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$

    action = new GotoMatchingBracketAction(this);
    action.setActionDefinitionId(UnifiedActionContributor.GOTO_MATCHING_BRACKET_ID);
    setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);

    Action actionContext = new TextOperationAction(UnifiedMessages.getResourceBundle(),
            "ContentAssistContextInformation.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
    actionContext.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
    setAction("ContentAssistContextInformation", actionContext); //$NON-NLS-1$
    markAsStateDependentAction("ContentAssistContextInformation", true); //$NON-NLS-1$
    // PlatformUI.getWorkbench().getHelpSystem().setHelp(action,
    // IJavaHelpContextIds.PARAMETER_HINTS_ACTION);

    FoldingExtensionPointLoader.createFoldingActions(this);

    _formatAction = new CodeFormatAction();
}

From source file:com.bdaum.zoom.rcp.internal.ApplicationActionBarAdvisor.java

License:Open Source License

@Override
protected void makeActions(IWorkbenchWindow window) {
    Action quitAction = new Action(Messages.getString("ApplicationActionBarAdvisor.quit")) { //$NON-NLS-1$
        @Override/*from   w w  w  .  j a  v a2s.  c  o m*/
        public void run() {
            BatchActivator.setFastExit(false);
            getActionBarConfigurer().getWindowConfigurer().getWindow().getWorkbench().close();
        }
    };
    quitAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_EXIT);
    quitAction.setToolTipText(
            NLS.bind(Messages.getString("ApplicationActionBarAdvisor.exit_app"), Constants.APPLICATION_NAME)); //$NON-NLS-1$
    quitAction.setId(ActionFactory.QUIT.getId());
    register(quitAction);
    IWorkbenchAction prefAction = ActionFactory.PREFERENCES.create(window);
    prefAction.setActionDefinitionId(IWorkbenchCommandConstants.WINDOW_PREFERENCES);
    register(prefAction);
    register(ActionFactory.PRINT.create(window));
    register(ActionFactory.EDIT_ACTION_SETS.create(window));
    register(ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(window));
    register(ActionFactory.RESET_PERSPECTIVE.create(window));
    register(ActionFactory.SAVE_PERSPECTIVE.create(window));
    register(ActionFactory.CLOSE_ALL_PERSPECTIVES.create(window));
    register(ActionFactory.CLOSE_PERSPECTIVE.create(window));
    IWorkbenchAction helpAction = ActionFactory.HELP_CONTENTS.create(window);
    helpAction.setActionDefinitionId(IWorkbenchCommandConstants.HELP_HELP_CONTENTS);
    register(helpAction);
    register(ActionFactory.HELP_SEARCH.create(window));
    register(ActionFactory.ABOUT.create(window));
    register(ActionFactory.INTRO.create(window));
    statusLineItem = new StatusLineContributionItem("ModeContributionItem"); //$NON-NLS-1$
    undoStatusLineItem = new ClickableStatusLineContributionItem("UndoContributionItem", //$NON-NLS-1$
            ActionFactory.UNDO.create(window));
    redoStatusLineItem = new ClickableStatusLineContributionItem("RedoContributionItem", //$NON-NLS-1$
            ActionFactory.REDO.create(window));
}

From source file:com.boothen.jsonedit.editor.JsonTextEditor.java

License:Open Source License

@Override
protected void createActions() {
    super.createActions();

    Action outline = new TextOperationAction(Messages.RESOURCE_BUNDLE, "ShowOutline.", this, SHOW_OUTLINE,
            true);/*w w  w.  java2  s .  c o  m*/
    outline.setActionDefinitionId(QUICK_OUTLINE_ACTION_ID);
    setAction(QUICK_OUTLINE_ACTION_ID, outline);

    Action format = new TextOperationAction(Messages.RESOURCE_BUNDLE, "Format.", this, ISourceViewer.FORMAT);
    format.setActionDefinitionId(FORMAT_ACTION_ID);
    setAction(FORMAT_ACTION_ID, format);
    markAsStateDependentAction(FORMAT_ACTION_ID, true);
    markAsSelectionDependentAction(FORMAT_ACTION_ID, true);
}