Search in sources :

Example 36 with ToolBarManager

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

the class ApplicationActionBarAdvisor method fillCoolBar.

/**
	 * Fills the cool bar with the main toolbars for the window.
	 *
	 * @param coolBar the cool bar manager
	 */
protected void fillCoolBar(ICoolBarManager coolBarManager) {
    ActionManager manager = ActionManager.getInstance();
    coolBarManager.setLockLayout(true);
    IToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT | SWT.WRAP | SWT.BOTTOM);
    coolBarManager.add(new ToolBarContributionItem(toolbarManager, IActionConstants.TOOL_NEW1));
    Bundle cqbBundle = Platform.getBundle(ApplicationUtil.CQB_PLUGIN_ID);
    /* Active the CQB plugin */
    if (cqbBundle != null) {
        try {
            cqbBundle.start();
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
        }
    }
    Bundle cmBundle = Platform.getBundle(ApplicationUtil.CM_PLUGIN_ID);
    /* Active the CM plugin */
    if (cmBundle != null) {
        try {
            cmBundle.start();
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
        }
    }
    // Change view actions
    if (cqbBundle != null) {
        DropDownAction viewAction = new DropDownAction(Messages.modeActionBig, IAction.AS_DROP_DOWN_MENU, CubridManagerAppPlugin.getImageDescriptor("icons/cubridmanager32.gif"));
        viewAction.setDisabledImageDescriptor(CubridManagerAppPlugin.getImageDescriptor("icons/cubridmanager32.gif"));
        MenuManager viewActionManager = viewAction.getMenuManager();
        viewActionManager.add(manager.getAction(OpenCMPerspectiveAction.ID));
        viewActionManager.add(manager.getAction(OpenCQBPerspectiveAction.ID));
        ActionContributionItem viewItems = new ActionContributionItem(viewAction);
        viewItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
        viewItems.setId(IPerspectiveConstance.PERSPECTIVE_ACTION_CONTRIBUTION_ID);
        toolbarManager.add(viewItems);
        toolbarManager.add(new Separator());
    }
    /*TOOLS-3988 There still is the install option after installing cmt plugin.*/
    Bundle bundle = Platform.getBundle(ApplicationUtil.CMT_PLUGIN_ID);
    if (bundle == null) {
        toolbarManager.add(new Separator());
        IAction action = ActionManager.getInstance().getAction(InstallMigrationToolkitAction.ID);
        if (action != null) {
            ActionContributionItem item = new ActionContributionItem(action);
            item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
            toolbarManager.add(item);
            item.setId(IPerspectiveConstance.MIGRATION_ACTION_CONTRIBUTION_ID);
        }
    } else {
        /*Active the CMT plugin */
        try {
            bundle.start();
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
        }
    }
    // Help
    toolbarManager.add(new Separator());
    DropDownAction helpDropAction = new DropDownAction(Messages.helpActionNameBig, IAction.AS_DROP_DOWN_MENU, CubridManagerUIPlugin.getImageDescriptor("icons/action/help_big.png"));
    helpDropAction.setDisabledImageDescriptor(CubridManagerUIPlugin.getImageDescriptor("icons/action/help_big.png"));
    MenuManager helpActionManager = helpDropAction.getMenuManager();
    helpActionManager.add(manager.getAction(HelpDocumentAction.ID));
    if ("ko".equals(Messages.language)) {
        helpActionManager.add(newFeatureAction);
    }
    helpActionManager.add(new Separator());
    helpActionManager.add(createItem(ReportBugAction.ID));
    helpActionManager.add(new Separator());
    helpActionManager.add(manager.getAction(ViewServerVersionAction.ID));
    helpActionManager.add(clientVersionAction);
    ActionContributionItem helpItems = new ActionContributionItem(helpDropAction);
    helpItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    helpItems.setId(IPerspectiveConstance.HELP_ACTION_CONTRIBUTION_ID);
    toolbarManager.add(helpItems);
    ControlContribution searchContribution = new ControlContribution(SearchContributionComposite.class.getName()) {

        protected Control createControl(Composite parent) {
            return new SearchContributionComposite(parent, SWT.None);
        }
    };
    searchContribution.setId(IPerspectiveConstance.SEARCH_ACTION_CONTRIBUTION_ID);
    toolbarManager.add(new Separator());
    toolbarManager.add(searchContribution);
}
Also used : IAction(org.eclipse.jface.action.IAction) SearchContributionComposite(com.cubrid.common.ui.common.control.SearchContributionComposite) Composite(org.eclipse.swt.widgets.Composite) Bundle(org.osgi.framework.Bundle) ControlContribution(org.eclipse.jface.action.ControlContribution) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) ActionManager(com.cubrid.common.ui.spi.action.ActionManager) ToolBarContributionItem(org.eclipse.jface.action.ToolBarContributionItem) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) DropDownAction(com.cubrid.common.ui.common.action.DropDownAction) IToolBarManager(org.eclipse.jface.action.IToolBarManager) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) SearchContributionComposite(com.cubrid.common.ui.common.control.SearchContributionComposite) Separator(org.eclipse.jface.action.Separator)

Example 37 with ToolBarManager

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

the class ActionBuilder method buildToolBar.

/**
	 * Build CUBRID Manager toolBar
	 *
	 * @param parent the coolbar manager
	 * @return the toolbar manager
	 */
public IToolBarManager[] buildToolBar(ICoolBarManager parent) {
    IToolBarManager newToolbarManager = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
    newToolbarManager.add(ActionManager.getInstance().getAction(AddHostAction.ID));
    newToolbarManager.add(ActionManager.getInstance().getAction(CreateDatabaseAction.ID));
    newToolbarManager.add(ActionManager.getInstance().getAction(QueryNewAction.ID));
    parent.add(newToolbarManager);
    IToolBarManager statusToolbarManager = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
    statusToolbarManager.add(ActionManager.getInstance().getAction(StartRetargetAction.ID));
    statusToolbarManager.add(ActionManager.getInstance().getAction(StopRetargetAction.ID));
    parent.add(statusToolbarManager);
    return new IToolBarManager[] { newToolbarManager, statusToolbarManager };
}
Also used : IToolBarManager(org.eclipse.jface.action.IToolBarManager) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 38 with ToolBarManager

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

the class ApplicationActionBarAdvisor method createToolItem.

private IToolBarManager createToolItem(ICoolBarManager coolBar) {
    IToolBarManager toolBar = new ToolBarManager(coolBar.getStyle());
    coolBar.add(new ToolBarContributionItem(toolBar, "findreplace"));
    toolBar.add(findAction);
    return toolBar;
}
Also used : ToolBarContributionItem(org.eclipse.jface.action.ToolBarContributionItem) IToolBarManager(org.eclipse.jface.action.IToolBarManager) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 39 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project linuxtools by eclipse.

the class ValgrindViewPart method createDynamicContent.

/**
 * Returns a refreshable view specific of a Valgrind tool.
 *
 * @param description     the content description
 * @param toolID          the Valgrind tool identifier
 * @return                the Valgrind tool view
 * @throws CoreException  the toolbar is disposed
 */
public IValgrindToolView createDynamicContent(String description, String toolID) throws CoreException {
    setContentDescription(description);
    // remove tool specific toolbar controls
    IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();
    ToolBar tb = ((ToolBarManager) toolbar).getControl();
    if (tb == null || tb.isDisposed()) {
        // $NON-NLS-1$
        throw new CoreException(new Status(IStatus.ERROR, ValgrindUIPlugin.PLUGIN_ID, "Toolbar is disposed"));
    }
    if (dynamicActions != null) {
        for (ActionContributionItem item : dynamicActions) {
            toolbar.remove(item);
        }
    }
    // remove old view controls
    if (dynamicView != null) {
        dynamicView.dispose();
    }
    // remove old messages
    if (messages != null) {
        messagesViewer.getTreeViewer().setInput(null);
        messages = null;
    }
    for (Control child : dynamicViewHolder.getChildren()) {
        if (!child.isDisposed()) {
            child.dispose();
        }
    }
    if (toolID != null) {
        dynamicView = ValgrindUIPlugin.getDefault().getToolView(toolID);
        dynamicView.createPartControl(dynamicViewHolder);
        // create toolbar items
        IAction[] actions = dynamicView.getToolbarActions();
        if (actions != null) {
            dynamicActions = new ActionContributionItem[actions.length];
            for (int i = 0; i < actions.length; i++) {
                dynamicActions[i] = new ActionContributionItem(actions[i]);
                toolbar.appendToGroup(TOOLBAR_LOC_GROUP_ID, dynamicActions[i]);
            }
        }
    } else {
        dynamicView = null;
    }
    // remove old menu items
    IMenuManager menu = getViewSite().getActionBars().getMenuManager();
    menu.removeAll();
    // was content was created?
    hasDynamicContent = dynamicViewHolder.getChildren().length > 0;
    if (hasDynamicContent) {
        menu.add(showCoreAction);
        menu.add(showToolAction);
    }
    menu.update(true);
    toolbar.update(true);
    // Update to notify the workbench items have been changed
    getViewSite().getActionBars().updateActionBars();
    dynamicViewHolder.layout(true);
    return dynamicView;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) Control(org.eclipse.swt.widgets.Control) CoreException(org.eclipse.core.runtime.CoreException) IAction(org.eclipse.jface.action.IAction) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBar(org.eclipse.swt.widgets.ToolBar) IMenuManager(org.eclipse.jface.action.IMenuManager) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 40 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project dbeaver by serge-rider.

the class GISTextViewer method createControl.

@Override
protected Control createControl(Composite editPlaceholder) {
    Composite composite = UIUtils.createPlaceholder(editPlaceholder, 1);
    CSSUtils.setCSSClass(composite, DBStyles.COLORED_BY_CONNECTION_TYPE);
    Composite controlPanel = UIUtils.createPlaceholder(composite, 1);
    controlPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
    controlPanel.setLayout(new FillLayout());
    Control textControl = super.createControl(controlPanel);
    // new Composite(composite, SWT.NONE);
    Composite bottomPanel = UIUtils.createPlaceholder(composite, 1);
    bottomPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    CSSUtils.setCSSClass(bottomPanel, DBStyles.COLORED_BY_CONNECTION_TYPE);
    ToolBar bottomToolbar = new ToolBar(bottomPanel, SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
    toolBarManager = new ToolBarManager(bottomToolbar);
    return textControl;
}
Also used : Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) FillLayout(org.eclipse.swt.layout.FillLayout) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Aggregations

ToolBarManager (org.eclipse.jface.action.ToolBarManager)237 Composite (org.eclipse.swt.widgets.Composite)86 ToolBar (org.eclipse.swt.widgets.ToolBar)80 Action (org.eclipse.jface.action.Action)70 GridData (org.eclipse.swt.layout.GridData)62 IToolBarManager (org.eclipse.jface.action.IToolBarManager)61 Control (org.eclipse.swt.widgets.Control)51 GridLayout (org.eclipse.swt.layout.GridLayout)49 Separator (org.eclipse.jface.action.Separator)39 List (java.util.List)35 SWT (org.eclipse.swt.SWT)33 ArrayList (java.util.ArrayList)32 IAction (org.eclipse.jface.action.IAction)29 IMenuManager (org.eclipse.jface.action.IMenuManager)27 IContributionItem (org.eclipse.jface.action.IContributionItem)25 MenuManager (org.eclipse.jface.action.MenuManager)25 Images (name.abuchen.portfolio.ui.Images)24 Messages (name.abuchen.portfolio.ui.Messages)24 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)24 Inject (javax.inject.Inject)23