Example usage for org.eclipse.jface.action ActionContributionItem setMode

List of usage examples for org.eclipse.jface.action ActionContributionItem setMode

Introduction

In this page you can find the example usage for org.eclipse.jface.action ActionContributionItem setMode.

Prototype

public void setMode(int mode) 

Source Link

Document

Sets the presentation mode, which is the bitwise-or of the MODE_* constants.

Usage

From source file:at.rc.tacos.client.modelManager.MyToolbarManager.java

License:Open Source License

/**
 * Customized add method to fore the rendering of the action text
 * //from ww  w . j av a  2s  .  co  m
 * @param action
 *            the action to add
 */

@Override
public void add(IAction action) {
    ActionContributionItem contributionItem = new ActionContributionItem(action);
    contributionItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    add(contributionItem);
}

From source file:com.amalto.workbench.editors.DataClusterBrowserMainPage.java

License:Open Source License

protected void hookToolBarItem() {
    FormEditor editor = getEditor();//from w w w .  j  a va2  s. c o  m
    if (editor instanceof XObjectBrowser) {
        XObjectBrowser xobjectEditor = (XObjectBrowser) editor;
        // remove refresh action
        xobjectEditor.getToolBar().getToolBarManager().removeAll();
        //
        ActionContributionItem manageAutoIncrementItem = new ActionContributionItem(
                new ManageAutoIncrementAction());
        manageAutoIncrementItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
        xobjectEditor.getToolBar().addActions(manageAutoIncrementItem);
    }
}

From source file:com.arm.cmsis.pack.installer.ui.views.ExamplesView.java

License:Open Source License

private void fillLocalToolBar(IToolBarManager manager) {
    ActionContributionItem aci = new ActionContributionItem(fShowInstOnlyAction);
    aci.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    manager.add(aci);//from  ww w  .j  a  v a  2 s . co  m
    manager.add(new Separator());
    manager.add(fHelpAction);
    manager.add(new Separator());
    PackInstallerViewUtils.addManagementCommandsToLocalToolBar(this, manager);
}

From source file:com.github.haixing_hu.swt.toolbar.ForceTextToolBarManager.java

License:Open Source License

/**
 * Adds an action to this tool bar manager.
 * <p>/*from w w w. j  a va 2s. com*/
 * <b>NOTE:</b> Overrides the {@link ContributionManager#add(IAction)} method
 * in order to force displaying text in each tool item.
 *
 * @param action
 *          The action to be added.
 */
@Override
public void add(IAction action) {
    Assert.isNotNull(action, "Action must not be null"); //$NON-NLS-1$
    final ActionContributionItem item = new ActionContributionItem(action);
    item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    add(item);
}

From source file:com.idega.app.eplatform.BrowserActionBarAdvisor.java

License:Open Source License

protected void fillCoolBar(ICoolBarManager coolBar) {
    IToolBarManager toolBar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
    coolBar.add(new ToolBarContributionItem(toolBar, "standard")); //$NON-NLS-1$

    // For the Back and Forward actions, force their text to be shown on the toolbar,
    // not just their image.  For the remaining actions, the ActionContributionItem
    // is created implicitly with the default presentation mode.
    ActionContributionItem backCI = new ActionContributionItem(backAction);
    backCI.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    toolBar.add(backCI);/*w ww  . j  a  v a 2 s  .  c o m*/

    ActionContributionItem forwardCI = new ActionContributionItem(forwardAction);
    forwardCI.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    toolBar.add(forwardCI);

    toolBar.add(stopAction);
    toolBar.add(refreshAction);
    toolBar.add(openinbrowserAction);
}

From source file:com.mindquarry.desktop.client.action.ImageAndTextToolbarManager.java

License:Open Source License

@Override
public void appendToGroup(String groupName, IAction action) {
    ActionContributionItem item = new ActionContributionItem(action);
    item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    appendToGroup(groupName, item);//  www .j a  v  a 2s  .  c o m
}

From source file:com.sap.dirigible.ide.ui.rap.managers.CoolBarManager.java

License:Open Source License

private void modifyModeForceText(final IContributionItem item) {
    if (item instanceof ActionContributionItem) {
        ActionContributionItem actionItem = (ActionContributionItem) item;
        actionItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    } else if (item instanceof CommandContributionItem) {
        CommandContributionItem commandItem = (CommandContributionItem) item;
        commandItem.setMode(CommandContributionItem.MODE_FORCE_TEXT);
    }//from  ww  w  .j  av  a  2  s  . c  o  m
}

From source file:com.vectrace.MercurialEclipse.views.AbstractRootView.java

License:Open Source License

protected static IContributionItem makeActionContribution(IAction a) {
    ActionContributionItem c = new ActionContributionItem(a);
    c.setMode(c.getMode() | ActionContributionItem.MODE_FORCE_TEXT);
    return c;// w w  w.ja v  a2s  .  c o  m
}

From source file:gda.rcp.ApplicationWorkbenchAdvisor.java

License:Open Source License

/**
 * This method adds a part listener which enables the text next to the icon in the views' toolbar. Also enables the
 * text for the views that are open during workbench window creation(for the default perspective).
 * //from w ww  .  j  a va  2s .com
 * @param workbenchWindow
 */
private void applyViewMenuText(final IWorkbenchWindow workbenchWindow) {
    if (GDAClientActivator.getDefault().getPreferenceStore().getBoolean(GdaRootPreferencePage.SHOW_MENU_TEXT)) {
        workbenchWindow.getPartService().addPartListener(new MenuDisplayPartListener());
        IViewReference[] viewReferences = workbenchWindow.getActivePage().getViewReferences();
        for (IViewReference vr : viewReferences) {
            IViewPart view = vr.getView(false);
            if (view != null) {
                IToolBarManager toolBarManager = view.getViewSite().getActionBars().getToolBarManager();
                IContributionItem[] items = toolBarManager.getItems();
                for (IContributionItem iContributionItem : items) {
                    if (iContributionItem instanceof ActionContributionItem) {
                        ActionContributionItem commandContributionItem = (ActionContributionItem) iContributionItem;
                        commandContributionItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
                        commandContributionItem.update();
                    }
                    if (iContributionItem instanceof CommandContributionItem) {
                        // As per https://bugs.eclipse.org/bugs/show_bug.cgi?id=256340 the
                        // CommandContributionItem
                        // doesn't expose the setMode() method. Therefore, setting the mode using reflection.
                        CommandContributionItem commandContributionItem = (CommandContributionItem) iContributionItem;
                        commandContributionItem.getData().mode = CommandContributionItem.MODE_FORCE_TEXT;
                        commandContributionItem.getId();
                        Class<? extends CommandContributionItem> class1 = commandContributionItem.getClass();
                        try {
                            Field field = class1.getDeclaredField("mode");
                            field.setAccessible(true);
                            field.set(commandContributionItem, new Integer(1));
                        } catch (SecurityException e) {
                            logger.error("Security exception - cant access private member", e);
                        } catch (IllegalArgumentException e) {
                            logger.error("IllegalArgumentException - Problem setting mode", e);
                        } catch (IllegalAccessException e) {
                            logger.error("IllegalAccessException - Problem setting mode", e);
                        } catch (NoSuchFieldException e) {
                            logger.error("NoSuchFieldException - Problem setting mode", e);
                        }
                        commandContributionItem.update();
                    }
                }
                if (toolBarManager instanceof ToolBarManager) {
                    ToolBarManager tm = (ToolBarManager) toolBarManager;
                    tm.getControl().pack(true);
                }
            }
        }
        workbenchWindow.getActivePage().savePerspective();
        workbenchWindow.getActivePage().resetPerspective();
    }
}

From source file:it.eng.spagobi.studio.core.actions.DocumentsWizardMenuAction.java

License:Mozilla Public License

public void init(IWorkbenchWindow window) {
    Action actionHome = new Action("&Home", ImageDescriptor.createFromFile(null, "metadata.png")) {
        public void run() {
            System.out.println("HOME");
        }//from   w  w  w  .  ja v a 2  s  .  co  m
    };
    //actionHome.setAccelerator(SWT.CTRL + 'H');

    ActionContributionItem item = new ActionContributionItem(actionHome);
    item.setMode(ActionContributionItem.MODE_FORCE_TEXT);

}