Search in sources :

Example 51 with Separator

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

the class ItemListControl method fillCustomActions.

@Override
protected void fillCustomActions(IContributionManager contributionManager) {
    super.fillCustomActions(contributionManager);
    final DBNNode rootNode = getRootNode();
    if (rootNode instanceof DBNDatabaseFolder && ((DBNDatabaseFolder) rootNode).getItemsMeta() != null) {
        contributionManager.add(new Action("Filter", DBeaverIcons.getImageDescriptor(UIIcon.FILTER)) {

            @Override
            public void run() {
                NavigatorHandlerFilterConfig.configureFilters(getShell(), rootNode);
            }
        });
    }
    IWorkbenchSite workbenchSite = getWorkbenchSite();
    if (workbenchSite != null) {
        contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_REFRESH));
    }
    if (rootNode instanceof DBNDatabaseNode) {
        contributionManager.add(new Separator());
        contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_OPEN));
        contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_CREATE));
        contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_DELETE));
    }
    if (rootNode instanceof DBNDatabaseNode && rootNode.isPersisted()) {
        boolean hasReorder = false;
        List<Class<?>> childrenTypes = ((DBNDatabaseNode) rootNode).getChildrenTypes(null);
        for (Class<?> chilType : childrenTypes) {
            if (EntityEditorsRegistry.getInstance().getObjectManager(chilType, DBEObjectReorderer.class) != null) {
                hasReorder = true;
                break;
            }
        }
        if (hasReorder) {
            contributionManager.add(new Separator());
            contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_MOVE_UP));
            contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_MOVE_DOWN));
        }
    }
    if (workbenchSite instanceof MultiPageEditorSite) {
        final MultiPageEditorPart editor = ((MultiPageEditorSite) workbenchSite).getMultiPageEditor();
        if (editor instanceof EntityEditor) {
            contributionManager.add(new Separator());
            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));
        }
    }
}
Also used : IWorkbenchSite(org.eclipse.ui.IWorkbenchSite) Action(org.eclipse.jface.action.Action) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) MultiPageEditorPart(org.eclipse.ui.part.MultiPageEditorPart) DBNDatabaseFolder(org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder) DBEObjectReorderer(org.jkiss.dbeaver.model.edit.DBEObjectReorderer) EntityEditor(org.jkiss.dbeaver.ui.editors.entity.EntityEditor) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) MultiPageEditorSite(org.eclipse.ui.part.MultiPageEditorSite) Separator(org.eclipse.jface.action.Separator)

Example 52 with Separator

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

the class DataSourceTransactionModeContributor method fillContributionItems.

@Override
protected void fillContributionItems(final List<IContributionItem> menuItems) {
    IWorkbenchWindow window = DBeaverUI.getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    IEditorPart activePart = window.getActivePage().getActiveEditor();
    DBPDataSourceContainer container = AbstractDataSourceHandler.getDataSourceContainer(activePart);
    DBPDataSource dataSource = null;
    if (container != null) {
        dataSource = container.getDataSource();
    }
    if (dataSource == null) {
        return;
    }
    final DBPDataSourceInfo dsInfo = dataSource.getInfo();
    DBCTransactionManager txnManager = DBUtils.getTransactionManager(dataSource.getDefaultContext(false));
    if (txnManager != null) {
        menuItems.add(ActionUtils.makeCommandContribution(window, CoreCommands.CMD_TOGGLE_AUTOCOMMIT, CommandContributionItem.STYLE_CHECK));
        menuItems.add(new Separator());
        // Transactions
        DBPTransactionIsolation txnLevelCurrent = null;
        try {
            txnLevelCurrent = txnManager.getTransactionIsolation();
        } catch (DBCException ex) {
            log.warn("Can't determine current transaction isolation level", ex);
        }
        for (DBPTransactionIsolation txi : CommonUtils.safeCollection(dsInfo.getSupportedTransactionsIsolation())) {
            if (!txi.isEnabled()) {
                continue;
            }
            menuItems.add(ActionUtils.makeActionContribution(new TransactionIsolationAction(dataSource, txi, txi.equals(txnLevelCurrent)), true));
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DBPTransactionIsolation(org.jkiss.dbeaver.model.DBPTransactionIsolation) DBCException(org.jkiss.dbeaver.model.exec.DBCException) IEditorPart(org.eclipse.ui.IEditorPart) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) DBPDataSourceInfo(org.jkiss.dbeaver.model.DBPDataSourceInfo) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) Separator(org.eclipse.jface.action.Separator) DBCTransactionManager(org.jkiss.dbeaver.model.exec.DBCTransactionManager)

Example 53 with Separator

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

the class ToolsContextMenuHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
    final Shell activeShell = HandlerUtil.getActiveShell(event);
    if (part == null || activeShell == null) {
        return null;
    }
    final Control focusControl = activeShell.getDisplay().getFocusControl();
    if (focusControl == null) {
        return null;
    }
    Point location = getLocationFromControl(activeShell, focusControl);
    if (menuManager != null) {
        menuManager.dispose();
    }
    menuManager = new MenuManager();
    menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_CONNECT));
    menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_DISCONNECT));
    menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_INVALIDATE));
    if (part instanceof IEditorPart) {
        menuManager.add(new Separator());
        menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_COMMIT));
        menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_ROLLBACK));
        {
            final MenuManager txnMenu = new MenuManager(DBeaverActivator.getPluginResourceBundle().getString("command.org.jkiss.dbeaver.core.transaction_mode.name"));
            txnMenu.add(new DataSourceTransactionModeContributor());
            menuManager.add(txnMenu);
        }
    }
    menuManager.add(new Separator());
    {
        menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_SQL_EDITOR_OPEN));
    /*
            final MenuManager toolsMenu = new MenuManager(
                DBeaverActivator.getPluginResourceBundle().getString("menu.database.tools"));
            toolsMenu.add(new DataSourceToolsContributor());
            menuManager.add(toolsMenu);
*/
    }
    if (part instanceof IEditorPart) {
        menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_LINK_EDITOR, "Find in navigator", null));
    }
    final Menu contextMenu = menuManager.createContextMenu(focusControl);
    if (location != null) {
        contextMenu.setLocation(location);
    }
    contextMenu.setVisible(true);
    contextMenu.addMenuListener(new MenuAdapter() {

        @Override
        public void menuShown(MenuEvent e) {
            int keyIndex = 1;
            for (MenuItem item : contextMenu.getItems()) {
                if (/*item.getMenu() == null && */
                !CommonUtils.isEmpty(item.getText())) {
                    item.setText(String.valueOf(keyIndex) + ". " + item.getText());
                    keyIndex++;
                    if (keyIndex >= 10) {
                        break;
                    }
                }
            }
        }
    });
    return null;
}
Also used : MenuAdapter(org.eclipse.swt.events.MenuAdapter) Point(org.eclipse.swt.graphics.Point) IEditorPart(org.eclipse.ui.IEditorPart) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) MenuManager(org.eclipse.jface.action.MenuManager) Separator(org.eclipse.jface.action.Separator) MenuEvent(org.eclipse.swt.events.MenuEvent)

Example 54 with Separator

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

the class MySQLSessionEditor method createSessionViewer.

@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
    return new SessionManagerViewer(this, parent, new MySQLSessionManager((MySQLDataSource) executionContext.getDataSource())) {

        @Override
        protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
            contributionManager.add(killSessionAction);
            contributionManager.add(terminateQueryAction);
            contributionManager.add(new Separator());
        }

        @Override
        protected void onSessionSelect(DBAServerSession session) {
            super.onSessionSelect(session);
            killSessionAction.setEnabled(session != null);
            terminateQueryAction.setEnabled(session != null && !CommonUtils.isEmpty(session.getActiveQuery()));
        }
    };
}
Also used : SessionManagerViewer(org.jkiss.dbeaver.ui.views.session.SessionManagerViewer) DBAServerSession(org.jkiss.dbeaver.model.admin.sessions.DBAServerSession) MySQLDataSource(org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource) DBAServerSessionManager(org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager) MySQLSessionManager(org.jkiss.dbeaver.ext.mysql.model.session.MySQLSessionManager) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Example 55 with Separator

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

the class ExasolServerSessionEditor method createSessionViewer.

@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
    return new SessionManagerViewer(this, parent, new ExasolServerSessionManager((ExasolDataSource) executionContext.getDataSource())) {

        @Override
        @SuppressWarnings("rawtypes")
        protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
            contributionManager.add(killSessionAction);
            contributionManager.add(terminateQueryAction);
            contributionManager.add(new Separator());
        }

        @Override
        protected void onSessionSelect(DBAServerSession session) {
            super.onSessionSelect(session);
            killSessionAction.setEnabled(session != null);
            terminateQueryAction.setEnabled(session != null && !CommonUtils.isEmpty(session.getActiveQuery()));
        }
    };
}
Also used : SessionManagerViewer(org.jkiss.dbeaver.ui.views.session.SessionManagerViewer) DBAServerSession(org.jkiss.dbeaver.model.admin.sessions.DBAServerSession) DBAServerSessionManager(org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager) ExasolDataSource(org.jkiss.dbeaver.ext.exasol.model.ExasolDataSource) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Aggregations

Separator (org.eclipse.jface.action.Separator)89 MenuManager (org.eclipse.jface.action.MenuManager)39 IMenuManager (org.eclipse.jface.action.IMenuManager)37 IAction (org.eclipse.jface.action.IAction)14 Menu (org.eclipse.swt.widgets.Menu)10 Action (org.eclipse.jface.action.Action)9 IMenuListener (org.eclipse.jface.action.IMenuListener)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 ActionManager (com.cubrid.common.ui.spi.action.ActionManager)7 IToolBarManager (org.eclipse.jface.action.IToolBarManager)7 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)6 GroupMarker (org.eclipse.jface.action.GroupMarker)6 IContributionManager (org.eclipse.jface.action.IContributionManager)5 TreeViewer (org.eclipse.jface.viewers.TreeViewer)5 IActionBars (org.eclipse.ui.IActionBars)5 DBAServerSession (org.jkiss.dbeaver.model.admin.sessions.DBAServerSession)5 DBAServerSessionManager (org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager)5 SessionManagerViewer (org.jkiss.dbeaver.ui.views.session.SessionManagerViewer)5 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4