Search in sources :

Example 56 with IMenuManager

use of org.eclipse.jface.action.IMenuManager in project azure-tools-for-java by Microsoft.

the class QueueFileEditor method createTablePopUp.

private void createTablePopUp(Composite parent) {
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            if (tableViewer.getSelection().isEmpty()) {
                return;
            }
            if (tableViewer.getSelection() instanceof IStructuredSelection) {
                manager.add(fileEditorVirtualNode.createPopupAction(OPEN));
                Action action = fileEditorVirtualNode.createPopupAction(DEQUEUE);
                if (queueTable.getSelectionIndex() != 0) {
                    action.setEnabled(false);
                }
                manager.add(action);
            }
        }
    });
    Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
    tableViewer.getControl().setMenu(menu);
}
Also used : Action(org.eclipse.jface.action.Action) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 57 with IMenuManager

use of org.eclipse.jface.action.IMenuManager in project azure-tools-for-java by Microsoft.

the class ServiceExplorerView method hookContextMenu.

private void hookContextMenu() {
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            if (viewer.getSelection().isEmpty()) {
                return;
            }
            if (viewer.getSelection() instanceof IStructuredSelection) {
                IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
                Node node = ((TreeNode) selection.getFirstElement()).node;
                if (node.hasNodeActions()) {
                    for (final NodeAction nodeAction : node.getNodeActions()) {
                        ImageDescriptor imageDescriptor = nodeAction.getIconPath() != null ? Activator.getImageDescriptor("icons/" + nodeAction.getIconPath()) : null;
                        Action action = new Action(nodeAction.getName(), imageDescriptor) {

                            public void run() {
                                nodeAction.fireNodeActionEvent();
                            }
                        };
                        action.setEnabled(nodeAction.isEnabled());
                        manager.add(action);
                    }
                }
            }
        }
    });
    Menu menu = menuMgr.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
}
Also used : NodeAction(com.microsoft.tooling.msservices.serviceexplorer.NodeAction) Action(org.eclipse.jface.action.Action) NodeAction(com.microsoft.tooling.msservices.serviceexplorer.NodeAction) Node(com.microsoft.tooling.msservices.serviceexplorer.Node) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 58 with IMenuManager

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

the class BrokerStatusView method createAsTable.

/**
	 * Create app server table
	 * 
	 * @param comp the parent composite
	 * 
	 */
private void createAsTable(Composite comp) {
    Composite asComposite = new Composite(comp, SWT.NONE);
    GridData gdAs = new GridData(SWT.FILL, SWT.FILL, true, true);
    asComposite.setLayoutData(gdAs);
    asComposite.setLayout(new GridLayout());
    asTableViewer = new TableViewer(asComposite, SWT.FULL_SELECTION | SWT.NO_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    Table asTable = asTableViewer.getTable();
    asTable.setHeaderVisible(true);
    asTable.setLinesVisible(true);
    asTable.setLayoutData(gdAs);
    TableLayout asLayout = new TableLayout();
    setAsLayout(asLayout);
    asTable.setLayout(asLayout);
    TableColumn tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsId);
    tblColumn.setToolTipText(Messages.tblAsId);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsProcess);
    tblColumn.setToolTipText(Messages.tblAsProcess);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsQps);
    tblColumn.setToolTipText(Messages.tblAsQps);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsLqs);
    tblColumn.setToolTipText(Messages.tblAsLqs);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsPort);
    tblColumn.setToolTipText(Messages.tblAsPort);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsSize);
    tblColumn.setToolTipText(Messages.tblAsSize);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsStatus);
    tblColumn.setToolTipText(Messages.tblAsStatus);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsDb);
    tblColumn.setToolTipText(Messages.tblAsDb);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsHost);
    tblColumn.setToolTipText(Messages.tblAsHost);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsLastAccess);
    tblColumn.setToolTipText(Messages.tblAsLastAccess);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsLct);
    tblColumn.setToolTipText(Messages.tblAsLct);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsClientIp);
    tblColumn.setToolTipText(Messages.tblAsClientIp);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsCur);
    tblColumn.setToolTipText(Messages.tblAsCur);
    asTableViewer.setContentProvider(new ApplyServerContentProvider());
    asTableViewer.setLabelProvider(new ApplyServerLabelProvider());
    asTableViewer.setInput(asinfoLst);
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            IStructuredSelection selection = (IStructuredSelection) asTableViewer.getSelection();
            ApplyServerInfo as = (ApplyServerInfo) (selection.toArray()[0]);
            RestartAction restartAcion = new RestartAction(as.getAs_id());
            manager.add(restartAcion);
        }
    });
    Menu contextMenu = menuManager.createContextMenu(asTableViewer.getControl());
    asTableViewer.getControl().setMenu(contextMenu);
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableColumn(org.eclipse.swt.widgets.TableColumn) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) IMenuListener(org.eclipse.jface.action.IMenuListener) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 59 with IMenuManager

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

the class ActionAdvisor method showMenu.

public void showMenu(IMenuManager menuManager) {
    ActionManager manager = ActionManager.getInstance();
    MenuManager fileMenu = new MenuManager(Messages.mnu_fileMenuName, IActionConstants.MENU_FILE);
    MenuManager editMenu = new MenuManager(Messages.mnu_editMenuName, IActionConstants.MENU_EDIT);
    MenuManager toolsMenu = new MenuManager(Messages.mnu_toolsMenuName, IActionConstants.MENU_TOOLS);
    MenuManager actionMenu = new MenuManager(Messages.mnu_actionMenuName, IActionConstants.MENU_ACTION);
    // MenuManager helpMenu = new MenuManager(Messages.mnu_helpMneuName,
    // IWorkbenchActionConstants.M_HELP);
    // fill in file menu
    fileMenu.add(manager.getAction(ConnectHostAction.ID));
    fileMenu.add(manager.getAction(DisConnectHostAction.ID));
    fileMenu.add(new Separator());
    fileMenu.add(manager.getAction(AddHostAction.ID));
    fileMenu.add(manager.getAction(EditHostAction.ID));
    fileMenu.add(manager.getAction(DeleteHostAction.ID));
    fileMenu.add(new Separator());
    fileMenu.add(manager.getAction(CubridServerImportAction.ID));
    fileMenu.add(manager.getAction(CubridServerExportAction.ID));
    fileMenu.add(new Separator());
    fileMenu.add(closeAction);
    fileMenu.add(closeAllAction);
    fileMenu.add(new Separator());
    fileMenu.add(manager.getAction(OpenQueryAction.ID));
    fileMenu.add(saveAction);
    fileMenu.add(saveasAction);
    fileMenu.add(saveAllAction);
    fileMenu.add(new Separator());
    //		fileMenu.add(manager.getAction(OpenSchemaEditorAction.ID));
    //		fileMenu.add(new Separator());
    fileMenu.add(manager.getAction(RestoreQueryEditorAction.ID));
    fileMenu.add(new Separator());
    fileMenu.add(manager.getAction(ImportHostsAction.ID));
    fileMenu.add(SelectWorkspaceDialog.getWorkspaceMenu(ApplicationType.CUBRID_MANAGER.getShortName(), Version.buildVersionId));
    fileMenu.add(new Separator());
    ActionContributionItem preferencesActionItem = new ActionContributionItem(preferenceAction);
    fileMenu.add(preferencesActionItem);
    if (Util.isMac()) {
        preferencesActionItem.setVisible(false);
    }
    fileMenu.add(manager.getAction(RefreshAction.ID));
    fileMenu.add(new Separator());
    fileMenu.add(quitAction);
    fileMenu.add(new Separator());
    // fill in edit menu
    editMenu.add(undoRetargetAction);
    editMenu.add(redoRetargetAction);
    editMenu.add(new Separator());
    editMenu.add(copyRetargetAction);
    editMenu.add(cutRetargetAction);
    editMenu.add(pasteRetargetAction);
    editMenu.add(new Separator());
    editMenu.add(findRetargetAction);
    editMenu.add(manager.getAction(GotoLineAction.ID));
    // fill in the run menu
    toolsMenu.add(manager.getAction(QueryNewAction.ID));
    toolsMenu.add(manager.getAction(QueryNewCustomAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(StartServiceAction.ID));
    toolsMenu.add(manager.getAction(StopServiceAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(StartDatabaseAction.ID));
    toolsMenu.add(manager.getAction(StopDatabaseAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(StartBrokerEnvAction.ID));
    toolsMenu.add(manager.getAction(StopBrokerEnvAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(ChangeManagerPasswordAction.ID));
    toolsMenu.add(manager.getAction(UserManagementAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(BrokerLogParserAction.ID));
    toolsMenu.add(manager.getAction(BrokerLogTopMergeAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(SchemaCommentInstallAction.ID));
    toolsMenu.add(manager.getAction(ServiceDashboardAction.ID));
    menuManager.insertBefore(getMenuInsertPoint(menuManager), fileMenu);
    menuManager.insertBefore(getMenuInsertPoint(menuManager), editMenu);
    menuManager.insertBefore(getMenuInsertPoint(menuManager), toolsMenu);
    menuManager.insertBefore(getMenuInsertPoint(menuManager), actionMenu);
    menuManager.update(true);
}
Also used : ActionManager(com.cubrid.common.ui.spi.action.ActionManager) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Example 60 with IMenuManager

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

the class PerspectiveChangedListener method showPerspective.

public void showPerspective(PerspectiveChangeEvent event) {
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
        ICoolBarManager coolBarManager = window.getCoolBarManager2();
        IMenuManager menuManager = window.getMenuBarManager();
        ActionAdvisor.getInstance().showToolbar(coolBarManager);
        ActionAdvisor.getInstance().showMenu(menuManager);
    }
    ActionManager.getInstance().setMenuProvider(menuProvider);
    LayoutManager.getInstance().setStatusLineContrItem(cubridStatusLineContrItem);
    LayoutManager.getInstance().setTitleLineContrItem(cubridTitleLineContrItem);
    cubridTitleLineContrItem.changeTitleForNavigator(null);
    LayoutManager.getInstance().setWorkbenchContrItem(cubridWorkbenchContrItem);
    CubridNavigatorView cubridNavigatorView = CubridNavigatorView.findNavigationView();
    if (cubridNavigatorView != null) {
        cubridNavigatorView.setFocus();
    }
}
Also used : WorkbenchWindow(org.eclipse.ui.internal.WorkbenchWindow) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) IMenuManager(org.eclipse.jface.action.IMenuManager) ICoolBarManager(org.eclipse.jface.action.ICoolBarManager)

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