Search in sources :

Example 1 with IWorkbenchSite

use of org.eclipse.ui.IWorkbenchSite 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)

Aggregations

Action (org.eclipse.jface.action.Action)1 Separator (org.eclipse.jface.action.Separator)1 IWorkbenchSite (org.eclipse.ui.IWorkbenchSite)1 MultiPageEditorPart (org.eclipse.ui.part.MultiPageEditorPart)1 MultiPageEditorSite (org.eclipse.ui.part.MultiPageEditorSite)1 DBEObjectReorderer (org.jkiss.dbeaver.model.edit.DBEObjectReorderer)1 DBNDatabaseFolder (org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder)1 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)1 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)1 EntityEditor (org.jkiss.dbeaver.ui.editors.entity.EntityEditor)1