Search in sources :

Example 11 with ActionManager

use of com.cubrid.common.ui.spi.action.ActionManager 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);
    // fill in file menu
    fileMenu.add(manager.getAction(OpenQueryConnAction.ID));
    fileMenu.add(manager.getAction(CloseQueryConnAction.ID));
    fileMenu.add(new Separator());
    fileMenu.add(manager.getAction(NewQueryConnAction.ID));
    fileMenu.add(manager.getAction(EditQueryConnAction.ID));
    fileMenu.add(manager.getAction(DeleteQueryConnAction.ID));
    fileMenu.add(new Separator());
    fileMenu.add(manager.getAction(ConnectionUrlImportAction.ID));
    fileMenu.add(manager.getAction(ConnectionUrlExportAction.ID));
    fileMenu.add(new Separator());
    fileMenu.add(manager.getAction(ConnectionImportAction.ID));
    fileMenu.add(manager.getAction(ConnectionExportAction.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(RestoreQueryEditorAction.ID));
    fileMenu.add(new Separator());
    fileMenu.add(manager.getAction(ImportConnsAction.ID));
    fileMenu.add(SelectWorkspaceDialog.getWorkspaceMenu(ApplicationType.CUBRID_QUERY_BROWSER.getShortName(), Version.buildVersionId));
    fileMenu.add(new Separator());
    ActionContributionItem preferencesActionItem = new ActionContributionItem(preferenceAction);
    fileMenu.add(preferencesActionItem);
    if (Util.isMac()) {
    }
    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 tools menu
    toolsMenu.add(manager.getAction(QueryNewAction.ID));
    toolsMenu.add(manager.getAction(QueryNewCustomAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(OIDNavigatorAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(NewTableAction.ID));
    toolsMenu.add(manager.getAction(CreateViewAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(CreateSerialAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(NewTriggerAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(AddFunctionAction.ID));
    toolsMenu.add(manager.getAction(AddProcedureAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(ExportWizardAction.ID));
    toolsMenu.add(manager.getAction(ImportWizardAction.ID));
    //		toolsMenu.add(new Separator());
    //		fileMenu.add(manager.getAction(OpenSchemaEditorAction.ID));
    fileMenu.add(new Separator());
    IMenuManager perparedMenu = new MenuManager(com.cubrid.common.ui.spi.Messages.preparedTableDataMenuName);
    toolsMenu.add(perparedMenu);
    perparedMenu.add(manager.getAction(PstmtOneDataAction.ID));
    perparedMenu.add(manager.getAction(PstmtMultiDataAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(BrokerLogParserAction.ID));
    toolsMenu.add(manager.getAction(BrokerLogTopMergeAction.ID));
    toolsMenu.add(manager.getAction(BrokerConfOpenFileAction.ID));
    toolsMenu.add(new Separator());
    toolsMenu.add(manager.getAction(SchemaCommentInstallAction.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) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Example 12 with ActionManager

use of com.cubrid.common.ui.spi.action.ActionManager in project cubrid-manager by CUBRID.

the class CubridHostNavigatorView method hookRetragetActions.

/**
	 * Hook the global actions in bars
	 */
protected void hookRetragetActions() {
    ActionManager manager = ActionManager.getInstance();
    IActionBars bar = this.getViewSite().getActionBars();
    bar.setGlobalActionHandler(ActionFactory.COPY.getId(), manager.getAction(CopyHostAction.ID));
    bar.setGlobalActionHandler(ActionFactory.PASTE.getId(), manager.getAction(PasteHostAction.ID));
    bar.updateActionBars();
}
Also used : ActionManager(com.cubrid.common.ui.spi.action.ActionManager) IActionBars(org.eclipse.ui.IActionBars)

Example 13 with ActionManager

use of com.cubrid.common.ui.spi.action.ActionManager in project cubrid-manager by CUBRID.

the class ServiceDashboardEditor method createPartControl.

public void createPartControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.None);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    composite.setLayout(layout);
    Composite buttonComp = new Composite(composite, SWT.None);
    buttonComp.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 24));
    Composite dataComp = new Composite(composite, SWT.None);
    dataComp.setLayout(new FillLayout());
    dataComp.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    /*Create button*/
    createButtonComposite(buttonComp);
    serviceTreeViewer = new TreeViewer(dataComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    serviceTreeViewer.getTree().setHeaderVisible(true);
    serviceTreeViewer.getTree().setLinesVisible(true);
    ColumnViewerToolTipSupport.enableFor(serviceTreeViewer, ToolTip.NO_RECREATE);
    final TreeColumn hostColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    hostColumn.setText(Messages.columnGroupOrHost);
    hostColumn.setWidth(200);
    serviceTreeViewer.setSorter(ServiceDashboardEditorSorter.Name_ASC);
    setColumnSorter(hostColumn, ServiceDashboardEditorSorter.Name_ASC, ServiceDashboardEditorSorter.Name_DESC);
    /*TreeColumn statusColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
		statusColumn.setText(Messages.columnStatus);
		statusColumn.setWidth(100);*/
    final TreeColumn ipColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    ipColumn.setText(Messages.columnAddress);
    ipColumn.setWidth(100);
    setColumnSorter(ipColumn, ServiceDashboardEditorSorter.Address_ASC, ServiceDashboardEditorSorter.Address_DESC);
    TreeColumn portColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    portColumn.setText(Messages.columnPort);
    portColumn.pack();
    setColumnSorter(portColumn, ServiceDashboardEditorSorter.Port_ASC, ServiceDashboardEditorSorter.Port_DESC);
    TreeColumn userColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    userColumn.setText(Messages.columnUser);
    userColumn.pack();
    setColumnSorter(userColumn, ServiceDashboardEditorSorter.User_ASC, ServiceDashboardEditorSorter.User_DESC);
    TreeViewerColumn volumnColumnData = new TreeViewerColumn(serviceTreeViewer, SWT.LEFT);
    volumnColumnData.getColumn().setText(Messages.columnData);
    volumnColumnData.getColumn().setToolTipText(Messages.columnDataTip);
    volumnColumnData.getColumn().pack();
    setColumnSorter(volumnColumnData.getColumn(), ServiceDashboardEditorSorter.Data_ASC, ServiceDashboardEditorSorter.Data_DESC);
    TreeViewerColumn volumnColumnIndex = new TreeViewerColumn(serviceTreeViewer, SWT.LEFT);
    volumnColumnIndex.getColumn().setText(Messages.columnIndex);
    volumnColumnIndex.getColumn().setToolTipText(Messages.columnIndexTip);
    volumnColumnIndex.getColumn().pack();
    setColumnSorter(volumnColumnIndex.getColumn(), ServiceDashboardEditorSorter.Index_ASC, ServiceDashboardEditorSorter.Index_DESC);
    TreeViewerColumn volumnColumnTemp = new TreeViewerColumn(serviceTreeViewer, SWT.LEFT);
    volumnColumnTemp.getColumn().setText(Messages.columnTemp);
    volumnColumnTemp.getColumn().setToolTipText(Messages.columnTempTip);
    volumnColumnTemp.getColumn().pack();
    setColumnSorter(volumnColumnTemp.getColumn(), ServiceDashboardEditorSorter.Temp_ASC, ServiceDashboardEditorSorter.Temp_DESC);
    TreeViewerColumn volumnColumnGeneric = new TreeViewerColumn(serviceTreeViewer, SWT.LEFT);
    volumnColumnGeneric.getColumn().setText(Messages.columnGeneric);
    volumnColumnGeneric.getColumn().setToolTipText(Messages.columnGenericTip);
    volumnColumnGeneric.getColumn().pack();
    setColumnSorter(volumnColumnGeneric.getColumn(), ServiceDashboardEditorSorter.Generic_ASC, ServiceDashboardEditorSorter.Generic_DESC);
    TreeColumn tpsColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    tpsColumn.setText(Messages.columnTps);
    tpsColumn.setWidth(50);
    setColumnSorter(tpsColumn, ServiceDashboardEditorSorter.Tps_ASC, ServiceDashboardEditorSorter.Tps_DESC);
    TreeColumn qpsColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    qpsColumn.setText(Messages.columnQps);
    qpsColumn.setWidth(50);
    setColumnSorter(qpsColumn, ServiceDashboardEditorSorter.Qps_ASC, ServiceDashboardEditorSorter.Qps_DESC);
    TreeColumn errorColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    errorColumn.setText(Messages.columnErrorQ);
    errorColumn.setWidth(50);
    setColumnSorter(errorColumn, ServiceDashboardEditorSorter.ErrorQ_ASC, ServiceDashboardEditorSorter.ErrorQ_DESC);
    TreeColumn memColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    memColumn.setText(Messages.columnMemory);
    memColumn.setWidth(100);
    setColumnSorter(memColumn, ServiceDashboardEditorSorter.Memory_ASC, ServiceDashboardEditorSorter.Memory_DESC);
    TreeColumn diskColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    diskColumn.setText(Messages.columnDisk);
    diskColumn.setWidth(60);
    setColumnSorter(diskColumn, ServiceDashboardEditorSorter.Disk_ASC, ServiceDashboardEditorSorter.Disk_DESC);
    TreeColumn cpuColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    cpuColumn.setText(Messages.columnCpu);
    cpuColumn.pack();
    setColumnSorter(cpuColumn, ServiceDashboardEditorSorter.Cpu_ASC, ServiceDashboardEditorSorter.Cpu_DESC);
    TreeColumn dbColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    dbColumn.setText(Messages.columnDbOnOff);
    dbColumn.setWidth(80);
    setColumnSorter(dbColumn, ServiceDashboardEditorSorter.DbStatus_ASC, ServiceDashboardEditorSorter.DbStatus_DESC);
    TreeColumn verColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    verColumn.setText(Messages.columnVersion);
    verColumn.setWidth(70);
    setColumnSorter(verColumn, ServiceDashboardEditorSorter.Version_ASC, ServiceDashboardEditorSorter.Version_DESC);
    TreeColumn brokerPortColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    brokerPortColumn.setText(Messages.columnBrokerPort);
    brokerPortColumn.setWidth(120);
    setColumnSorter(brokerPortColumn, ServiceDashboardEditorSorter.BrokerPort_ASC, ServiceDashboardEditorSorter.BrokerPort_DESC);
    serviceTreeViewer.setContentProvider(new ServiceDashboardContentProvider());
    serviceTreeViewer.setLabelProvider(new ServiceDashboardLabelProvider());
    addCellTip(volumnColumnData, 1);
    addCellTip(volumnColumnIndex, 2);
    addCellTip(volumnColumnTemp, 3);
    addCellTip(volumnColumnGeneric, 4);
    serviceTreeViewer.getTree().addMouseListener(new MouseListener() {

        public void mouseUp(MouseEvent e) {
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseDoubleClick(MouseEvent e) {
            CubridServer[] servers = getSelectedServer();
            if (servers.length == 1) {
                if (!servers[0].isConnected()) {
                    ActionManager manager = ActionManager.getInstance();
                    final ConnectHostAction connectHostAction = (ConnectHostAction) manager.getAction(ConnectHostAction.ID);
                    connectHostAction.doRun(getSelectedServer());
                    loadAllData();
                }
            }
        }
    });
    initMenu(serviceTreeViewer.getTree());
}
Also used : ActionManager(com.cubrid.common.ui.spi.action.ActionManager) GridLayout(org.eclipse.swt.layout.GridLayout) MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeColumn(org.eclipse.swt.widgets.TreeColumn) ConnectHostAction(com.cubrid.cubridmanager.ui.host.action.ConnectHostAction) DisConnectHostAction(com.cubrid.cubridmanager.ui.host.action.DisConnectHostAction) FillLayout(org.eclipse.swt.layout.FillLayout) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn)

Example 14 with ActionManager

use of com.cubrid.common.ui.spi.action.ActionManager in project cubrid-manager by CUBRID.

the class CubridStatusLineContrItem method updateStatusLineForRestoreQueryEditor.

private void updateStatusLineForRestoreQueryEditor() {
    final int countOfRestorableQueryEditors = ApplicationPersistUtil.getInstance().countOfRestorableQueryEditorsAtLastSession();
    if (countOfRestorableQueryEditors <= 0) {
        return;
    }
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    StatusLineManager statusLineManager = null;
    if (window instanceof WorkbenchWindow) {
        statusLineManager = ((WorkbenchWindow) window).getStatusLineManager();
    }
    if (statusLineManager == null) {
        return;
    }
    IContributionItem scaleItem = new ControlContribution(RESTORE_QUERY_EDITORS_CONTR_ID) {

        protected Control createControl(Composite parent) {
            Button btn = new Button(parent, SWT.None);
            String buttonTitle = Messages.bind(Messages.restoreQueryEditorTitle, countOfRestorableQueryEditors);
            btn.setText(buttonTitle);
            btn.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent e) {
                    ActionManager manager = ActionManager.getInstance();
                    IAction action = manager.getAction(RestoreQueryEditorAction.ID);
                    if (action != null && action instanceof RestoreQueryEditorAction) {
                        ((RestoreQueryEditorAction) action).run();
                    }
                }
            });
            return btn;
        }

        ;
    };
    statusLineManager.add(scaleItem);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) WorkbenchWindow(org.eclipse.ui.internal.WorkbenchWindow) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Composite(org.eclipse.swt.widgets.Composite) IAction(org.eclipse.jface.action.IAction) StatusLineManager(org.eclipse.jface.action.StatusLineManager) IContributionItem(org.eclipse.jface.action.IContributionItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ControlContribution(org.eclipse.jface.action.ControlContribution) ActionManager(com.cubrid.common.ui.spi.action.ActionManager) RestoreQueryEditorAction(com.cubrid.common.ui.common.action.RestoreQueryEditorAction) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 15 with ActionManager

use of com.cubrid.common.ui.spi.action.ActionManager in project cubrid-manager by CUBRID.

the class ActionAdvisor method init.

private void init() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
        ActionManager manager = ActionManager.getInstance();
        // standard actions provided by the workbench
        closeAction = ActionFactory.CLOSE.create(window);
        closeAction.setText(Messages.closeActionName);
        // register(closeAction);
        closeAllAction = ActionFactory.CLOSE_ALL.create(window);
        closeAllAction.setText(Messages.closeAllActionName);
        // register(closeAllAction);
        saveAction = ActionFactory.SAVE.create(window);
        saveAction.setText(Messages.saveActionName);
        // register(saveAction);
        saveasAction = ActionFactory.SAVE_AS.create(window);
        saveasAction.setText(Messages.saveAsActionName);
        // register(saveasAction);
        saveAllAction = ActionFactory.SAVE_ALL.create(window);
        saveAllAction.setText(Messages.saveAllActionName);
        // register(saveAllAction);
        // retarget actions provided by the workbench
        undoRetargetAction = ActionFactory.UNDO.create(window);
        undoRetargetAction.setText(com.cubrid.common.ui.spi.Messages.undoActionName);
        // register(undoRetargetAction);
        redoRetargetAction = ActionFactory.REDO.create(window);
        redoRetargetAction.setText(com.cubrid.common.ui.spi.Messages.redoActionName);
        // register(redoRetargetAction);
        copyRetargetAction = ActionFactory.COPY.create(window);
        copyRetargetAction.setText(com.cubrid.common.ui.spi.Messages.copyActionName);
        // register(copyRetargetAction);
        cutRetargetAction = ActionFactory.CUT.create(window);
        cutRetargetAction.setText(com.cubrid.common.ui.spi.Messages.cutActionName);
        // register(cutRetargetAction);
        pasteRetargetAction = ActionFactory.PASTE.create(window);
        pasteRetargetAction.setText(com.cubrid.common.ui.spi.Messages.pasteActionName);
        // register(pasteRetargetAction);
        findRetargetAction = ActionFactory.FIND.create(window);
        findRetargetAction.setText(com.cubrid.common.ui.spi.Messages.findReplaceActionName);
        // register(findRetargetAction);
        serviceDashboardAction = (ServiceDashboardAction) manager.getAction(ServiceDashboardAction.ID);
        if (serviceDashboardAction != null) {
            serviceDashboardAction.setText(com.cubrid.common.ui.spi.Messages.serviceDashboardActionName);
        // register(serviceDashboardAction);
        }
        // customized actions for CUBRID Manager
        // common action
        preferenceAction = new OpenPreferenceAction(window.getShell(), Messages.openPreferenceActionName, null);
        // register(preferenceAction);
        // It must be needed to use a
        preferenceAction.setId("preferences");
        // Preferences Menu of an
        // Application Menu on Mac.
        manager.registerAction(preferenceAction);
        quitAction = new QuitAction(Messages.exitActionName);
        reportBugAction = (ReportBugAction) manager.getAction(ReportBugAction.ID);
        reportBugAction.setCurrentVersion(Version.buildVersionId);
    }
}
Also used : ActionManager(com.cubrid.common.ui.spi.action.ActionManager) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) QuitAction(com.cubrid.cubridmanager.ui.common.action.QuitAction) OpenPreferenceAction(com.cubrid.common.ui.common.action.OpenPreferenceAction)

Aggregations

ActionManager (com.cubrid.common.ui.spi.action.ActionManager)19 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)7 IMenuManager (org.eclipse.jface.action.IMenuManager)7 MenuManager (org.eclipse.jface.action.MenuManager)7 Separator (org.eclipse.jface.action.Separator)7 IAction (org.eclipse.jface.action.IAction)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 DropDownAction (com.cubrid.common.ui.common.action.DropDownAction)3 IToolBarManager (org.eclipse.jface.action.IToolBarManager)3 Composite (org.eclipse.swt.widgets.Composite)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 GroupSettingAction (com.cubrid.common.ui.common.action.GroupSettingAction)2 OpenPreferenceAction (com.cubrid.common.ui.common.action.OpenPreferenceAction)2 RestoreQueryEditorAction (com.cubrid.common.ui.common.action.RestoreQueryEditorAction)2 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)2 QuitAction (com.cubrid.cubridmanager.ui.common.action.QuitAction)2 ControlContribution (org.eclipse.jface.action.ControlContribution)2 IContributionItem (org.eclipse.jface.action.IContributionItem)2 StatusLineManager (org.eclipse.jface.action.StatusLineManager)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2