Search in sources :

Example 1 with IContributionItem

use of org.eclipse.jface.action.IContributionItem in project translationstudio8 by heartsome.

the class ApplicationWorkbenchWindowAdvisor method postWindowCreate.

/**
	 * 删除 RCP 自带的工具栏按钮
	 */
public void postWindowCreate() {
    IActionBarConfigurer actionBarConfigurer = getWindowConfigurer().getActionBarConfigurer();
    IContributionItem[] coolItems = actionBarConfigurer.getCoolBarManager().getItems();
    for (int i = 0; i < coolItems.length; i++) {
        if (coolItems[i] instanceof ToolBarContributionItem) {
            ToolBarContributionItem toolbarItem = (ToolBarContributionItem) coolItems[i];
            if (toolbarItem.getId().equals("org.eclipse.ui.WorkingSetActionSet") || toolbarItem.getId().equals("org.eclipse.ui.edit.text.actionSet.annotationNavigation") || toolbarItem.getId().equals("org.eclipse.ui.edit.text.actionSet.navigation")) {
                toolbarItem.getToolBarManager().removeAll();
            }
        }
    }
    actionBarConfigurer.getCoolBarManager().update(true);
    addAutoPluginMenu();
}
Also used : ToolBarContributionItem(org.eclipse.jface.action.ToolBarContributionItem) IContributionItem(org.eclipse.jface.action.IContributionItem) IActionBarConfigurer(org.eclipse.ui.application.IActionBarConfigurer)

Example 2 with IContributionItem

use of org.eclipse.jface.action.IContributionItem in project tdi-studio-se by Talend.

the class TalendFlyoutPaletteComposite method createActionMenu.

private Menu createActionMenu(Control parent) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
    final MenuManager manager = new MenuManager();
    MenuManager mgr = new MenuManager(PaletteMessages.DOCK_LABEL);
    changeDockActionClass.getDeclaredConstructors();
    // reflect the constructor of ChangeDockAction
    Constructor changeDockActionConstructor = changeDockActionClass.getDeclaredConstructor(FlyoutPaletteComposite.class, String.class, int.class);
    changeDockActionConstructor.setAccessible(true);
    // instance of ChangeDockAction for left
    Object changeDockActionInstance = changeDockActionConstructor.newInstance(this, PaletteMessages.LEFT_LABEL, PositionConstants.WEST);
    if (changeDockActionInstance instanceof IAction) {
        mgr.add((IAction) changeDockActionInstance);
    }
    // instance of ChangeDockAction for right
    changeDockActionInstance = changeDockActionConstructor.newInstance(this, PaletteMessages.RIGHT_LABEL, PositionConstants.EAST);
    if (changeDockActionInstance instanceof IAction) {
        mgr.add((IAction) changeDockActionInstance);
    }
    // instance of ResizeAction
    Constructor resizeActionConstructor = resizeActionClass.getDeclaredConstructor(FlyoutPaletteComposite.class);
    resizeActionConstructor.setAccessible(true);
    Object resizeActionInstance = resizeActionConstructor.newInstance(this);
    if (resizeActionInstance instanceof IAction) {
        mgr.add((IAction) resizeActionInstance);
    }
    manager.add(mgr);
    mgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager menuMgr) {
            IContributionItem[] items = menuMgr.getItems();
            for (IContributionItem item : items) {
                ((ActionContributionItem) item).update();
            }
        }
    });
    //
    // ShowStandardAction showStandardAction = ShowStandardAction.getInstance();
    // ShowFavoriteAction showFavoriteAction = ShowFavoriteAction.getInstance();
    // manager.add(showStandardAction);
    // manager.add(showFavoriteAction);
    // if (ShowFavoriteAction.state) {
    // showStandardAction.doSetEnable();
    // }
    OpenPaletteFilterAction openPaletteFilterAction = OpenPaletteFilterAction.getInstance();
    manager.add(openPaletteFilterAction);
    manager.add(mgr);
    addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            manager.dispose();
        }
    });
    return manager.createContextMenu(this);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) IAction(org.eclipse.jface.action.IAction) OpenPaletteFilterAction(org.talend.repository.ui.actions.OpenPaletteFilterAction) Constructor(java.lang.reflect.Constructor) IContributionItem(org.eclipse.jface.action.IContributionItem) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 3 with IContributionItem

use of org.eclipse.jface.action.IContributionItem in project tdi-studio-se by Talend.

the class AbstractFilteredTree method updateStatusLine.

/**
     * Updates the status line.
     * 
     * @param selection the selection
     */
public void updateStatusLine(IStructuredSelection selection) {
    IStatusLineManager manager = actionBars.getStatusLineManager();
    IContributionItem[] items = manager.getItems();
    StatusLineContributionItem selfTimeStatusLineItem = null;
    for (IContributionItem item : items) {
        if (item instanceof StatusLineContributionItem) {
            selfTimeStatusLineItem = (StatusLineContributionItem) item;
        }
    }
    // create the status line
    if (selfTimeStatusLineItem == null) {
        //$NON-NLS-1$
        selfTimeStatusLineItem = new StatusLineContributionItem("SelfTimeContributionItem");
        manager.add(selfTimeStatusLineItem);
    }
    // clear the status line
    if (selection == null) {
        selfTimeStatusLineItem.setText(Util.ZERO_LENGTH_STRING);
        return;
    }
    // set text on status line
    double percentage = 0;
    double time = 0;
    for (Object object : selection.toArray()) {
        if (object instanceof IMethodNode) {
            percentage += ((IMethodNode) object).getSelfTimeInPercentage();
            time += ((IMethodNode) object).getSelfTime();
        }
    }
    String text = Util.ZERO_LENGTH_STRING;
    if (percentage != 0) {
        //$NON-NLS-1$
        text = String.format("Self Time: %.0fms  %.1f", time, percentage) + '%';
    }
    selfTimeStatusLineItem.setText(text);
}
Also used : StatusLineContributionItem(org.eclipse.jface.action.StatusLineContributionItem) IMethodNode(org.talend.designer.runtime.visualization.internal.core.cpu.IMethodNode) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) IContributionItem(org.eclipse.jface.action.IContributionItem)

Example 4 with IContributionItem

use of org.eclipse.jface.action.IContributionItem in project cubrid-manager by CUBRID.

the class AbsActionAdvisor method getToolbarManaeger.

protected IToolBarManager getToolbarManaeger(ICoolBarManager coolBarManager) {
    IToolBarManager newToolbarManager = null;
    for (IContributionItem item : coolBarManager.getItems()) {
        if (item instanceof ToolBarContributionItem && "new1".equals(item.getId())) {
            ToolBarContributionItem toolBarContributionItem = (ToolBarContributionItem) item;
            newToolbarManager = toolBarContributionItem.getToolBarManager();
            break;
        // }
        }
    }
    return newToolbarManager;
}
Also used : ToolBarContributionItem(org.eclipse.jface.action.ToolBarContributionItem) IToolBarManager(org.eclipse.jface.action.IToolBarManager) IContributionItem(org.eclipse.jface.action.IContributionItem)

Example 5 with IContributionItem

use of org.eclipse.jface.action.IContributionItem in project bndtools by bndtools.

the class OpenExtConfigsContributionItem method getContributionItems.

@Override
protected IContributionItem[] getContributionItems() {
    try {
        IFile buildFile = Central.getWorkspaceBuildFile();
        if (buildFile == null)
            return EMPTY;
        IContainer cnfDir = buildFile.getParent();
        IFolder extDir = cnfDir.getFolder(new Path("ext"));
        if (extDir == null || !extDir.exists())
            return EMPTY;
        IResource[] extFiles = extDir.members();
        List<IContributionItem> result = new ArrayList<IContributionItem>(extFiles.length);
        for (final IResource extFile : extFiles) {
            if (extFile.getType() == IResource.FILE && "bnd".equalsIgnoreCase(extFile.getFileExtension())) {
                Action action = new Action() {

                    @Override
                    public void run() {
                        try {
                            FileEditorInput input = new FileEditorInput((IFile) extFile);
                            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                            page.openEditor(input, "bndtools.bndWorkspaceConfigEditor", true);
                        } catch (PartInitException e) {
                            ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", "Unable to open editor", e.getStatus());
                        }
                    }
                };
                action.setText("Open " + extFile.getProjectRelativePath());
                action.setImageDescriptor(extFileImg);
                result.add(new ActionContributionItem(action));
            }
        }
        return result.toArray(new IContributionItem[0]);
    } catch (Exception e) {
        logger.logError("Unable to find default config files", e);
        return EMPTY;
    }
}
Also used : Path(org.eclipse.core.runtime.Path) Action(org.eclipse.jface.action.Action) IFile(org.eclipse.core.resources.IFile) IContributionItem(org.eclipse.jface.action.IContributionItem) ArrayList(java.util.ArrayList) PartInitException(org.eclipse.ui.PartInitException) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IContributionItem (org.eclipse.jface.action.IContributionItem)15 IMenuManager (org.eclipse.jface.action.IMenuManager)5 MenuManager (org.eclipse.jface.action.MenuManager)5 IAction (org.eclipse.jface.action.IAction)4 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)3 IStatusLineManager (org.eclipse.jface.action.IStatusLineManager)3 IToolBarManager (org.eclipse.jface.action.IToolBarManager)3 StatusLineContributionItem (org.eclipse.jface.action.StatusLineContributionItem)3 RestoreQueryEditorAction (com.cubrid.common.ui.common.action.RestoreQueryEditorAction)2 ActionManager (com.cubrid.common.ui.spi.action.ActionManager)2 ArrayList (java.util.ArrayList)2 ControlContribution (org.eclipse.jface.action.ControlContribution)2 ICoolBarManager (org.eclipse.jface.action.ICoolBarManager)2 IMenuListener (org.eclipse.jface.action.IMenuListener)2 StatusLineManager (org.eclipse.jface.action.StatusLineManager)2 ToolBarContributionItem (org.eclipse.jface.action.ToolBarContributionItem)2 IPreferenceNode (org.eclipse.jface.preference.IPreferenceNode)2 PreferenceManager (org.eclipse.jface.preference.PreferenceManager)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2