Example usage for org.eclipse.jface.action IAction setDescription

List of usage examples for org.eclipse.jface.action IAction setDescription

Introduction

In this page you can find the example usage for org.eclipse.jface.action IAction setDescription.

Prototype

void setDescription(String text);

Source Link

Document

Sets this action's description.

Usage

From source file:com.amalto.workbench.compare.Utilities.java

License:Open Source License

public static void initAction(IAction a, ResourceBundle bundle, String prefix) {

    String labelKey = "label"; //$NON-NLS-1$
    String tooltipKey = "tooltip"; //$NON-NLS-1$
    String imageKey = "image"; //$NON-NLS-1$
    String descriptionKey = "description"; //$NON-NLS-1$

    if (prefix != null && prefix.length() > 0) {
        labelKey = prefix + labelKey;/* ww w .  j a v  a 2s .c o m*/
        tooltipKey = prefix + tooltipKey;
        imageKey = prefix + imageKey;
        descriptionKey = prefix + descriptionKey;
    }

    a.setText(getString(bundle, labelKey, labelKey));
    a.setToolTipText(getString(bundle, tooltipKey, null));
    a.setDescription(getString(bundle, descriptionKey, null));

    String relPath = getString(bundle, imageKey, null);
    if (relPath != null && relPath.trim().length() > 0) {

        String dPath;
        String ePath;

        if (relPath.indexOf("/") >= 0) { //$NON-NLS-1$
            String path = relPath.substring(1);
            dPath = 'd' + path;
            ePath = 'e' + path;
        } else {
            dPath = "dlcl16/" + relPath; //$NON-NLS-1$
            ePath = "elcl16/" + relPath; //$NON-NLS-1$
        }

        // ImageDescriptor id= CompareUIPlugin.getImageDescriptor(dPath); // we set the disabled image first (see PR
        // 1GDDE87)
        // if (id != null)
        // a.setDisabledImageDescriptor(id);
        // id= CompareUIPlugin.getImageDescriptor(ePath);
        // if (id != null) {
        // a.setImageDescriptor(id);
        // a.setHoverImageDescriptor(id);
        // }
    }
}

From source file:com.amalto.workbench.compare.Utilities.java

License:Open Source License

public static void initToggleAction(IAction a, ResourceBundle bundle, String prefix, boolean checked) {

    String tooltip = null;/*ww  w .  ja v  a 2 s  . co m*/
    if (checked)
        tooltip = getString(bundle, prefix + "tooltip.checked", null); //$NON-NLS-1$
    else
        tooltip = getString(bundle, prefix + "tooltip.unchecked", null); //$NON-NLS-1$
    if (tooltip == null)
        tooltip = getString(bundle, prefix + "tooltip", null); //$NON-NLS-1$

    if (tooltip != null)
        a.setToolTipText(tooltip);

    String description = null;
    if (checked)
        description = getString(bundle, prefix + "description.checked", null); //$NON-NLS-1$
    else
        description = getString(bundle, prefix + "description.unchecked", null); //$NON-NLS-1$
    if (description == null)
        description = getString(bundle, prefix + "description", null); //$NON-NLS-1$

    if (description != null)
        a.setDescription(description);

}

From source file:com.drgarbage.controlflowgraphfactory.editors.ControlFlowGraphEditorContextMenuProvider.java

License:Apache License

/**
 * Called when the context menu is about to show. Actions, 
 * whose state is enabled, will appear in the context menu.
 * @see org.eclipse.gef.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager)
 *//*from w w w  .j  a v  a  2  s .com*/
public void buildContextMenu(IMenuManager menu) {

    /* undo/redo actions */
    menu.add(new Separator(GEFActionConstants.GROUP_UNDO));

    menu.appendToGroup(GEFActionConstants.GROUP_UNDO, // target group id
            getAction(ActionFactory.UNDO.getId())); // action to add
    menu.appendToGroup(GEFActionConstants.GROUP_UNDO, getAction(ActionFactory.REDO.getId()));

    /* copy and paste actions  */
    menu.add(new Separator());
    IAction action = getAction(ActionFactory.COPY.getId());
    if (action != null)
        menu.add(action);

    action = getAction(ActionFactory.PASTE.getId());
    if (action != null)
        menu.add(action);

    action = getAction(ActionFactory.CUT.getId());
    if (action != null)
        menu.add(action);

    /* edit actions */
    menu.add(new Separator());

    menu.add(getAction(ActionFactory.DELETE.getId()));
    menu.add(getAction(ActionFactory.SELECT_ALL.getId()));

    /* direct editing of nodes action */
    action = getAction(GEFActionConstants.DIRECT_EDIT);
    action.setDescription(ControlFlowFactoryMessages.DirectTextEditAction_Text);
    action.setText(ControlFlowFactoryMessages.DirectTextEditAction_Description);
    menu.add(action);

    /* Add zoom actions to the menu */
    menu.add(new Separator());
    menu.add(getAction(GEFActionConstants.ZOOM_IN));
    menu.add(getAction(GEFActionConstants.ZOOM_OUT));

    /* graph layout algorithm action */
    menu.add(new Separator());
    IMenuManager submenu = new MenuManager(
            ControlFlowFactoryMessages.ControlFlowFactory_SubMenuGrphAlgorithms_Text);
    menu.add(submenu);
    action = getAction(ByteCodelLayoutAlgorithmAction.ID);
    if (action != null)
        submenu.add(action);

    action = getAction(HierarchicalLayoutAlgorithmAction.ID);
    if (action != null)
        submenu.add(action);

    submenu = new MenuManager(ControlFlowFactoryMessages.ControlFlowFactory_SubMenuAlignElements_Text);
    menu.add(submenu);
    action = getAction(HorizontalLeftOrderAction.ID);
    if (action != null)
        submenu.add(action);

    action = getAction(HorizontalCenterOrderAction.ID);
    if (action != null)
        submenu.add(action);

    action = getAction(HorizontalRightOrderAction.ID);
    if (action != null)
        submenu.add(action);

    submenu.add(new Separator());

    action = getAction(VerticalTopOrderAction.ID);
    if (action != null)
        submenu.add(action);

    action = getAction(VerticalCenterOrderAction.ID);
    if (action != null)
        submenu.add(action);

    action = getAction(VerticalBottomOrderAction.ID);
    if (action != null)
        submenu.add(action);

    /* size action */
    submenu = new MenuManager(ControlFlowFactoryMessages.ControlFlowFactory_SubMenuResizeElements_Text);
    menu.add(submenu);
    action = getAction(MinWidhtAction.ID);
    if (action != null)
        submenu.add(action);

    action = getAction(MaxWidhtAction.ID);
    if (action != null)
        submenu.add(action);

    action = getAction(MinHeightAction.ID);
    if (action != null)
        submenu.add(action);

    action = getAction(MaxHeightAction.ID);
    if (action != null)
        submenu.add(action);

    /* print action */
    menu.add(new Separator());

    /* export actions */
    action = getAction(PrintAction.ID);
    if (action != null)
        menu.add(action);

    action = getAction(ExportAsImageAction.ID);
    if (action != null)
        menu.add(action);

    action = getAction(ExportGraphAction.ID);
    if (action != null)
        menu.add(action);

}

From source file:com.google.dart.tools.ui.actions.NavigateActionGroup.java

License:Open Source License

/**
 * Returns the edit action managed by this action group.
 * //from w  w w  .j  a  va  2  s  .  c  om
 * @return the edit action. Returns <code>null</code> if the group doesn't provide any edit action
 */
public IAction getEditAction() {
    IAction editAction = openEditorActionGroup.getOpenAction();
    editAction.setText(ActionMessages.EditAction_label);
    editAction.setDescription(ActionMessages.EditAction_description);
    return editAction;
}

From source file:com.google.dart.tools.ui.internal.compare.DartCompareUtilities.java

License:Open Source License

/**
 * Initialize the given Action from a ResourceBundle.
 *//*from ww  w.  j  a  v a 2  s .  c om*/
static void initAction(IAction a, ResourceBundle bundle, String prefix) {

    String labelKey = "label"; //$NON-NLS-1$
    String tooltipKey = "tooltip"; //$NON-NLS-1$
    String imageKey = "image"; //$NON-NLS-1$
    String descriptionKey = "description"; //$NON-NLS-1$

    if (prefix != null && prefix.length() > 0) {
        labelKey = prefix + labelKey;
        tooltipKey = prefix + tooltipKey;
        imageKey = prefix + imageKey;
        descriptionKey = prefix + descriptionKey;
    }

    a.setText(getString(bundle, labelKey, labelKey));
    a.setToolTipText(getString(bundle, tooltipKey, null));
    a.setDescription(getString(bundle, descriptionKey, null));

    String relPath = getString(bundle, imageKey, null);
    if (relPath != null && relPath.trim().length() > 0) {

        String dPath;
        String ePath;

        if (relPath.indexOf("/") >= 0) { //$NON-NLS-1$
            String path = relPath.substring(1);
            dPath = 'd' + path;
            ePath = 'e' + path;
        } else {
            dPath = "dlcl16/" + relPath; //$NON-NLS-1$
            ePath = "elcl16/" + relPath; //$NON-NLS-1$
        }

        ImageDescriptor id = DartCompareUtilities.getImageDescriptor(dPath); // we set the disabled image first (see PR 1GDDE87)
        if (id != null) {
            a.setDisabledImageDescriptor(id);
        }
        id = DartCompareUtilities.getImageDescriptor(ePath);
        if (id != null) {
            a.setImageDescriptor(id);
            a.setHoverImageDescriptor(id);
        }
    }
}

From source file:com.google.dart.tools.ui.internal.compare.DartCompareUtilities.java

License:Open Source License

static void initToggleAction(IAction a, ResourceBundle bundle, String prefix, boolean checked) {

    String tooltip = null;/*  w ww . j  a  va 2s  .  c om*/
    if (checked) {
        tooltip = getString(bundle, prefix + "tooltip.checked", null); //$NON-NLS-1$
    } else {
        tooltip = getString(bundle, prefix + "tooltip.unchecked", null); //$NON-NLS-1$
    }
    if (tooltip == null) {
        tooltip = getString(bundle, prefix + "tooltip", null); //$NON-NLS-1$
    }

    if (tooltip != null) {
        a.setToolTipText(tooltip);
    }

    String description = null;
    if (checked) {
        description = getString(bundle, prefix + "description.checked", null); //$NON-NLS-1$
    } else {
        description = getString(bundle, prefix + "description.unchecked", null); //$NON-NLS-1$
    }
    if (description == null) {
        description = getString(bundle, prefix + "description", null); //$NON-NLS-1$
    }

    if (description != null) {
        a.setDescription(description);
    }
}

From source file:ext.org.eclipse.jdt.internal.ui.compare.JavaCompareUtilities.java

License:Open Source License

static void initAction(IAction a, ResourceBundle bundle, String prefix) {

    String labelKey = "label"; //$NON-NLS-1$
    String tooltipKey = "tooltip"; //$NON-NLS-1$
    String imageKey = "image"; //$NON-NLS-1$
    String descriptionKey = "description"; //$NON-NLS-1$

    if (prefix != null && prefix.length() > 0) {
        labelKey = prefix + labelKey;//w w w  . j  ava2s  . c  om
        tooltipKey = prefix + tooltipKey;
        imageKey = prefix + imageKey;
        descriptionKey = prefix + descriptionKey;
    }

    a.setText(getString(bundle, labelKey, labelKey));
    a.setToolTipText(getString(bundle, tooltipKey, null));
    a.setDescription(getString(bundle, descriptionKey, null));

    String relPath = getString(bundle, imageKey, null);
    if (relPath != null && relPath.trim().length() > 0) {

        String dPath;
        String ePath;

        if (relPath.indexOf("/") >= 0) { //$NON-NLS-1$
            String path = relPath.substring(1);
            dPath = 'd' + path;
            ePath = 'e' + path;
        } else {
            dPath = "dlcl16/" + relPath; //$NON-NLS-1$
            ePath = "elcl16/" + relPath; //$NON-NLS-1$
        }

        ImageDescriptor id = JavaCompareUtilities.getImageDescriptor(dPath); // we set the disabled image first (see PR 1GDDE87)
        if (id != null)
            a.setDisabledImageDescriptor(id);
        id = JavaCompareUtilities.getImageDescriptor(ePath);
        if (id != null) {
            a.setImageDescriptor(id);
            a.setHoverImageDescriptor(id);
        }
    }
}

From source file:ext.org.eclipse.jdt.internal.ui.compare.JavaCompareUtilities.java

License:Open Source License

static void initToggleAction(IAction a, ResourceBundle bundle, String prefix, boolean checked) {

    String tooltip = null;//from   w ww .  jav a2s  .c om
    if (checked)
        tooltip = getString(bundle, prefix + "tooltip.checked", null); //$NON-NLS-1$
    else
        tooltip = getString(bundle, prefix + "tooltip.unchecked", null); //$NON-NLS-1$
    if (tooltip == null)
        tooltip = getString(bundle, prefix + "tooltip", null); //$NON-NLS-1$

    if (tooltip != null)
        a.setToolTipText(tooltip);

    String description = null;
    if (checked)
        description = getString(bundle, prefix + "description.checked", null); //$NON-NLS-1$
    else
        description = getString(bundle, prefix + "description.unchecked", null); //$NON-NLS-1$
    if (description == null)
        description = getString(bundle, prefix + "description", null); //$NON-NLS-1$

    if (description != null)
        a.setDescription(description);
}

From source file:ext.org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.java

License:Open Source License

@Override
protected void createActions() {

    super.createActions();

    IAction action = getAction(ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION);
    if (action != null) {
        PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
        action.setText(JavaEditorMessages.getBundleForConstructedKeys()
                .getString("ContentAssistContextInformation.label")); //$NON-NLS-1$
        action.setToolTipText(JavaEditorMessages.getBundleForConstructedKeys()
                .getString("ContentAssistContextInformation.tooltip")); //$NON-NLS-1$
        action.setDescription(JavaEditorMessages.getBundleForConstructedKeys()
                .getString("ContentAssistContextInformation.description")); //$NON-NLS-1$
    }//from w  w  w.  ja v a  2s . c  o  m

    action = new TextOperationAction(JavaEditorMessages.getBundleForConstructedKeys(), "Uncomment.", this, //$NON-NLS-1$
            ITextOperationTarget.STRIP_PREFIX);
    action.setActionDefinitionId(IJavaEditorActionDefinitionIds.UNCOMMENT);
    setAction("Uncomment", action); //$NON-NLS-1$
    markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
    PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION);

    action = new ToggleCommentAction(JavaEditorMessages.getBundleForConstructedKeys(), "ToggleComment.", this); //$NON-NLS-1$
    action.setActionDefinitionId(IJavaEditorActionDefinitionIds.TOGGLE_COMMENT);
    setAction("ToggleComment", action); //$NON-NLS-1$
    markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
    PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.TOGGLE_COMMENT_ACTION);
    configureToggleCommentAction();

    action = new TextOperationAction(JavaEditorMessages.getBundleForConstructedKeys(), "Format.", this, //$NON-NLS-1$
            ISourceViewer.FORMAT);
    action.setActionDefinitionId(IJavaEditorActionDefinitionIds.FORMAT);
    setAction("Format", action); //$NON-NLS-1$
    markAsStateDependentAction("Format", true); //$NON-NLS-1$
    markAsSelectionDependentAction("Format", true); //$NON-NLS-1$
    PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.FORMAT_ACTION);

    action = new AddBlockCommentAction(JavaEditorMessages.getBundleForConstructedKeys(), "AddBlockComment.", //$NON-NLS-1$
            this);
    action.setActionDefinitionId(IJavaEditorActionDefinitionIds.ADD_BLOCK_COMMENT);
    setAction("AddBlockComment", action); //$NON-NLS-1$
    markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
    markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$
    PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);

    action = new RemoveBlockCommentAction(JavaEditorMessages.getBundleForConstructedKeys(),
            "RemoveBlockComment.", this); //$NON-NLS-1$
    action.setActionDefinitionId(IJavaEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);
    setAction("RemoveBlockComment", action); //$NON-NLS-1$
    markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
    markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
    PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.REMOVE_BLOCK_COMMENT_ACTION);

    action = new IndentAction(JavaEditorMessages.getBundleForConstructedKeys(), "Indent.", this, false); //$NON-NLS-1$
    action.setActionDefinitionId(IJavaEditorActionDefinitionIds.INDENT);
    setAction("Indent", action); //$NON-NLS-1$
    markAsStateDependentAction("Indent", true); //$NON-NLS-1$
    markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
    PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.INDENT_ACTION);

    action = new IndentAction(JavaEditorMessages.getBundleForConstructedKeys(), "Indent.", this, true); //$NON-NLS-1$
    setAction("IndentOnTab", action); //$NON-NLS-1$
    markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
    markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$

    // override the text editor actions with indenting move line actions
    JavaMoveLinesAction[] moveLinesActions = JavaMoveLinesAction
            .createMoveCopyActionSet(JavaEditorMessages.getBundleForConstructedKeys(), this);
    ResourceAction rAction = moveLinesActions[0];
    rAction.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION);
    rAction.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_UP);
    setAction(ITextEditorActionConstants.MOVE_LINE_UP, rAction);

    rAction = moveLinesActions[1];
    rAction.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION);
    rAction.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_DOWN);
    setAction(ITextEditorActionConstants.MOVE_LINE_DOWN, rAction);

    rAction = moveLinesActions[2];
    rAction.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION);
    rAction.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_UP);
    setAction(ITextEditorActionConstants.COPY_LINE_UP, rAction);

    rAction = moveLinesActions[3];
    rAction.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION);
    rAction.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_DOWN);
    setAction(ITextEditorActionConstants.COPY_LINE_DOWN, rAction);

    if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
        // don't replace Shift Right - have to make sure their enablement is mutually exclusive
        //         removeActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT);
        setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
    }

    fGenerateActionGroup = new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
    fRefactorActionGroup = new RefactorActionGroup(this, ITextEditorActionConstants.GROUP_EDIT, false);
    ActionGroup surroundWith = new SurroundWithActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);

    fActionGroups.addGroup(surroundWith);
    fActionGroups.addGroup(fRefactorActionGroup);
    fActionGroups.addGroup(fGenerateActionGroup);

    // We have to keep the context menu group separate to have better control over positioning
    fContextMenuGroup = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup, fRefactorActionGroup,
            surroundWith, new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT) });

    fCorrectionCommands = new CorrectionCommandInstaller(); // allow shortcuts for quick fix/assist
    fCorrectionCommands.registerCommands(this);
}

From source file:gov.nasa.ensemble.common.ui.editor.AbstractEnsembleEditorPart.java

License:Open Source License

private void copyAttributes(IAction actionHandler, ActionFactory actionFactory) {
    IWorkbenchWindow workbenchWindow = getSite().getWorkbenchWindow();
    IWorkbenchAction factoryAction = actionFactory.create(workbenchWindow);
    // the following two lines are commented out to suppress shortcuts on the context menu
    //      actionHandler.setAccelerator(factoryAction.getAccelerator());      
    //      actionHandler.setActionDefinitionId(factoryAction.getActionDefinitionId());
    actionHandler.setDescription(factoryAction.getDescription());
    actionHandler.setDisabledImageDescriptor(factoryAction.getDisabledImageDescriptor());
    actionHandler.setHoverImageDescriptor(factoryAction.getHoverImageDescriptor());
    actionHandler.setId(factoryAction.getId());
    actionHandler.setImageDescriptor(factoryAction.getImageDescriptor());
    actionHandler.setText(factoryAction.getText());
    actionHandler.setToolTipText(factoryAction.getToolTipText());
}