Search in sources :

Example 86 with IMenuManager

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

the class BuildInDBStructure method addContextMenu.

/**
     * qzhang Comment method "addContextMenu".
     */
private void addContextMenu() {
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("Menu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            manager.add(generateSelectAction);
        }
    });
    Menu contextMenu = menuMgr.createContextMenu(treeViewer.getTree());
    treeViewer.getTree().setMenu(contextMenu);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 87 with IMenuManager

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

the class DBStructureComposite method addContextMenu.

/**
     * Add context menu.
     * 
     * method description.
     * 
     * @param
     * @return
     * @exception
     */
private void addContextMenu() {
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("Menu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            fillContextMenu(manager);
        }

        @SuppressWarnings("unchecked")
        private void fillContextMenu(IMenuManager manager) {
            // GenerateSelectSQL
            manager.add(generateSelectAction);
            // open editor
            builderDialog.getConnParameters().setQueryObject(null);
            manager.add(openNewEditorAction);
            // Separator
            manager.add(separator);
            // refresh
            ((RefreshConnectionAction) refreshConnectionAction).init();
            manager.add(refreshConnectionAction);
            manager.add(separator);
            // metadata refresh
            manager.add(metadataRefreshAction);
            manager.add(separator);
            manager.add(openQueryAction);
            manager.add(deleteQueryAction);
            manager.add(showQueryPropertyAction);
        }
    });
    Menu contextMenu = menuMgr.createContextMenu(treeViewer.getTree());
    treeViewer.getTree().setMenu(contextMenu);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 88 with IMenuManager

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

the class OSGiRunLaunchDelegate method launch.

@Override
public void launch(final ILaunchConfiguration configuration, String mode, final ILaunch launch, IProgressMonitor monitor) throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor, 2);
    try {
        boolean dynamic = configuration.getAttribute(LaunchConstants.ATTR_DYNAMIC_BUNDLES, LaunchConstants.DEFAULT_DYNAMIC_BUNDLES);
        if (dynamic)
            registerLaunchPropertiesRegenerator(run, launch);
    } catch (Exception e) {
        throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error obtaining OSGi project launcher.", e));
    }
    display = Workbench.getInstance().getDisplay();
    display.syncExec(new Runnable() {

        @Override
        public void run() {
            dialog = new PopupDialog(new Shell(display), PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, false, true, true, true, false, "Errors in running OSGi Framework", "") {

                @Override
                protected Control createDialogArea(Composite parent) {
                    textArea = new Text(parent, SWT.LEAD | SWT.READ_ONLY | SWT.WRAP);
                    return textArea;
                }

                @Override
                protected void fillDialogMenu(IMenuManager dialogMenu) {
                    super.fillDialogMenu(dialogMenu);
                    Action dismissAction = new Action("Close") {

                        @Override
                        public void run() {
                            close();
                        }
                    };
                    dialogMenu.add(dismissAction);
                }

                @Override
                protected Control createInfoTextArea(Composite parent) {
                    Link link = new Link(parent, SWT.NONE);
                    link.setText("<a>Dismiss…</a> ");
                    link.addSelectionListener(new SelectionAdapter() {

                        @Override
                        public void widgetSelected(SelectionEvent e) {
                            close();
                        }
                    });
                    GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.FILL).applyTo(link);
                    return link;
                }

                @Override
                protected Point getDefaultSize() {
                    Point p = getShell().getSize();
                    p.x = Math.max(400, p.x / 2);
                    p.y = Math.max(200, p.y / 2);
                    return p;
                }

                @Override
                protected Point getInitialLocation(Point initialSize) {
                    Rectangle r = getShell().getBounds();
                    return new Point(r.x + r.width - initialSize.x, r.y + r.height - initialSize.y);
                }

                @Override
                public boolean close() {
                    if (textArea != null) {
                        textArea.setText("");
                    }
                    return super.close();
                }
            };
        }
    });
    super.launch(configuration, mode, launch, progress.newChild(1, SubMonitor.SUPPRESS_NONE));
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Action(org.eclipse.jface.action.Action) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SubMonitor(org.eclipse.core.runtime.SubMonitor) Rectangle(org.eclipse.swt.graphics.Rectangle) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) Shell(org.eclipse.swt.widgets.Shell) CoreException(org.eclipse.core.runtime.CoreException) PopupDialog(org.eclipse.jface.dialogs.PopupDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IMenuManager(org.eclipse.jface.action.IMenuManager) Link(org.eclipse.swt.widgets.Link)

Aggregations

IMenuManager (org.eclipse.jface.action.IMenuManager)88 MenuManager (org.eclipse.jface.action.MenuManager)72 IMenuListener (org.eclipse.jface.action.IMenuListener)48 Menu (org.eclipse.swt.widgets.Menu)43 Separator (org.eclipse.jface.action.Separator)31 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)16 IAction (org.eclipse.jface.action.IAction)9 TreeViewer (org.eclipse.jface.viewers.TreeViewer)9 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)8 GridData (org.eclipse.swt.layout.GridData)8 Action (org.eclipse.jface.action.Action)7 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)7 Composite (org.eclipse.swt.widgets.Composite)7 GridLayout (org.eclipse.swt.layout.GridLayout)6 List (java.util.List)5 ICoolBarManager (org.eclipse.jface.action.ICoolBarManager)5 FocusEvent (org.eclipse.swt.events.FocusEvent)5 ActionManager (com.cubrid.common.ui.spi.action.ActionManager)4 IContributionItem (org.eclipse.jface.action.IContributionItem)4 Point (org.eclipse.swt.graphics.Point)4