Example usage for org.eclipse.jface.action IContributionManager add

List of usage examples for org.eclipse.jface.action IContributionManager add

Introduction

In this page you can find the example usage for org.eclipse.jface.action IContributionManager add.

Prototype

void add(IContributionItem item);

Source Link

Document

Adds a contribution item to this manager.

Usage

From source file:org.jkiss.dbeaver.ui.data.managers.stream.BinaryPanelEditor.java

License:Apache License

@Override
public void contributeActions(@NotNull IContributionManager manager, @NotNull final HexEditControl control)
        throws DBCException {
    manager.add(new Action("Switch Insert/Overwrite mode", DBeaverIcons.getImageDescriptor(UIIcon.CURSOR)) {
        @Override/* w  ww  .j a v  a 2  s  . co m*/
        public void run() {
            control.redrawCaret(true);
        }
    });
}

From source file:org.jkiss.dbeaver.ui.dialogs.data.ComplexObjectEditor.java

License:Open Source License

public void contributeActions(IContributionManager manager) {
    manager.add(addElementAction);
    manager.add(removeElementAction);
}

From source file:org.jkiss.dbeaver.ui.editors.DatabaseEditorUtils.java

License:Apache License

public static void contributeStandardEditorActions(IWorkbenchSite workbenchSite,
        IContributionManager contributionManager) {
    contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite,
            IWorkbenchCommandConstants.FILE_SAVE, null, UIIcon.SAVE, null, true));
    contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite,
            IWorkbenchCommandConstants.FILE_REVERT, null, UIIcon.RESET, null, true));
}

From source file:org.jkiss.dbeaver.ui.editors.sql.SQLEditorNested.java

License:Open Source License

protected void contributeEditorCommands(IContributionManager toolBarManager) {
    toolBarManager.add(
            ActionUtils.makeCommandContribution(getSite().getWorkbenchWindow(), CoreCommands.CMD_OPEN_FILE));
    toolBarManager.add(/*from   w  w w . j  av a 2 s.co  m*/
            ActionUtils.makeCommandContribution(getSite().getWorkbenchWindow(), CoreCommands.CMD_SAVE_FILE));
    String compileCommandId = getCompileCommandId();
    if (compileCommandId != null) {
        toolBarManager.add(new Separator());
        toolBarManager
                .add(ActionUtils.makeCommandContribution(getSite().getWorkbenchWindow(), compileCommandId));
        toolBarManager.add(new ViewLogAction());
    }
}

From source file:org.jkiss.dbeaver.ui.editors.sql.SQLSourceViewer.java

License:Apache License

@Override
protected void contributeEditorCommands(IContributionManager toolBarManager) {
    super.contributeEditorCommands(toolBarManager);
    toolBarManager.add(new Separator());
    toolBarManager.add(OPEN_CONSOLE_ACTION);
}

From source file:org.jkiss.dbeaver.ui.views.plan.ExplainPlanViewer.java

License:Open Source License

public ExplainPlanViewer(final IWorkbenchPart workbenchPart, Composite parent) {
    super();//from w  w  w .  j av  a  2s  . co m
    createActions();

    Composite composite = UIUtils.createPlaceholder(parent, 1);

    this.planPanel = UIUtils.createPartDivider(workbenchPart, composite, SWT.HORIZONTAL);
    this.planPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
    this.planPanel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    final GridLayout gl = new GridLayout(1, false);
    gl.marginWidth = 0;
    gl.marginHeight = 0;
    this.planPanel.setLayout(gl);
    {
        leftPanel = UIUtils.createPartDivider(workbenchPart, planPanel, SWT.VERTICAL);
        leftPanel.setLayoutData(new GridData(GridData.FILL_BOTH));

        this.planTree = new PlanNodesTree(leftPanel, SWT.SHEET) {
            @Override
            protected void fillCustomActions(IContributionManager contributionManager) {
                contributionManager.add(toggleViewAction);
                contributionManager.add(refreshPlanAction);
            }
        };
        this.planTree.setShowDivider(true);
        this.planTree.createProgressPanel(composite);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.horizontalIndent = 0;
        gd.verticalIndent = 0;
        planTree.setLayoutData(gd);

        sqlText = new Text(leftPanel, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);

        leftPanel.setWeights(new int[] { 80, 20 });
        leftPanel.setMaximizedControl(planTree);
    }
    {
        planProperties = new PropertyTreeViewer(planPanel, SWT.H_SCROLL | SWT.V_SCROLL);
    }

    planPanel.setWeights(new int[] { 70, 30 });
    //planPanel.setMaximizedControl(planTree);

    planTree.getControl().addPaintListener(new PaintListener() {
        @Override
        public void paintControl(PaintEvent e) {
            String message = null;
            if (planner == null) {
                message = "No connection or data source doesn't support execution plan";
            } else if (CommonUtils.isEmpty(sqlText.getText())) {

                message = "Select a query and run " + ActionUtils
                        .findCommandDescription(CoreCommands.CMD_EXPLAIN_PLAN, workbenchPart.getSite(), false);
            }
            if (message != null) {
                Rectangle bounds = planTree.getBounds();
                Point ext = e.gc.textExtent(message);
                e.gc.drawText(message, (bounds.width - ext.x) / 2, bounds.height / 3 + 20);
            }
        }
    });
    planTree.getItemsViewer().addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            showPlanNode();
        }
    });

    this.planTree.getControl().addTraverseListener(new TraverseListener() {
        @Override
        public void keyTraversed(TraverseEvent e) {
            if (toggleViewAction.isEnabled()
                    && (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) {
                toggleViewAction.run();
                e.doit = false;
                e.detail = SWT.TRAVERSE_NONE;
            }
        }
    });
}

From source file:org.jlibrary.client.actions.NewWizardMenu.java

License:Open Source License

private void fillMenu(IContributionManager innerMgr) {
    // Remove all.
    innerMgr.removeAll();/*from   w ww  . j a v a 2 s .  c  om*/
    innerMgr.add(newRepositoryAction);
    innerMgr.add(new Separator());
    innerMgr.add(newDirectoryAction);
    innerMgr.add(newDocumentAction);
    innerMgr.add(newResourceAction);
}

From source file:org.kalypso.ui.editor.mapeditor.GisMapOutlinePage.java

License:Open Source License

private void copyItems(final IContributionManager from, final IContributionManager to) {
    final IContributionItem[] items = from.getItems();
    for (final IContributionItem item : items)
        to.add(item);
}

From source file:org.modelversioning.emfprofile.application.registry.ui.observer.NestingCommonModelElementsInStereotypeApplications.java

License:Open Source License

/**
 * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection,
 * by inserting them before the specified contribution item <code>contributionID</code>.
 * If <code>contributionID</code> is <code>null</code>, they are simply added.
 *//*  w  ww .j  ava  2 s  . com*/
public void populateManager(IContributionManager manager, Collection<? extends IAction> actions,
        String contributionID) {
    if (actions != null) {
        for (IAction action : actions) {
            if (contributionID != null) {
                manager.insertBefore(contributionID, action);
            } else {
                manager.add(action);
            }
        }
    }
}

From source file:org.nightlabs.base.ui.action.registry.AbstractActionRegistry.java

License:Open Source License

protected static void addFlattenedMenu(IContributionManager dest, String parentID, IMenuManager menu) {
    String id = menu.getId();/*from w  w  w.  jav a 2 s.  c  o  m*/
    String sepName = (parentID == null || "".equals(parentID)) ? id : (parentID + '.' + id); //$NON-NLS-1$
    dest.add(new Separator(sepName));
    IContributionItem[] items = menu.getItems();
    for (int i = 0; i < items.length; ++i) {
        IContributionItem item = items[i];
        if (item instanceof IMenuManager) {
            String itemId = item.getId();
            String newParentID = (parentID == null || "".equals(parentID)) ? itemId : (parentID + '.' + itemId); //$NON-NLS-1$
            addFlattenedMenu(dest, newParentID, (IMenuManager) item);
        } else
            dest.add(item);
    }
}