Search in sources :

Example 6 with DatabaseNavigatorView

use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView in project dbeaver by serge-rider.

the class NavigatorHandlerFilterObjectType method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    if (activePart instanceof DatabaseNavigatorView) {
        DatabaseNavigatorTree navigatorTree = ((DatabaseNavigatorView) activePart).getNavigatorTree();
        DatabaseNavigatorTreeFilterObjectType objectType = CommonUtils.valueOf(DatabaseNavigatorTreeFilterObjectType.class, event.getParameter("type"), DatabaseNavigatorTreeFilterObjectType.table);
        if (objectType == navigatorTree.getFilterObjectType()) {
            return null;
        }
        navigatorTree.setFilterObjectType(objectType);
        navigatorTree.getViewer().getControl().setRedraw(false);
        try {
            navigatorTree.getViewer().refresh();
        } finally {
            navigatorTree.getViewer().getControl().setRedraw(true);
        }
    }
    ActionUtils.fireCommandRefresh(NavigatorCommands.CMD_FILTER_CONNECTIONS);
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DatabaseNavigatorView(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView) DatabaseNavigatorTreeFilterObjectType(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTreeFilterObjectType) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree)

Example 7 with DatabaseNavigatorView

use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView in project dbeaver by serge-rider.

the class NavigatorHandlerConnectionFilter method updateElement.

@Override
public void updateElement(UIElement element, Map parameters) {
    IWorkbenchPartSite partSite = UIUtils.getWorkbenchPartSite(element.getServiceLocator());
    if (partSite != null && partSite.getPart() instanceof DatabaseNavigatorView) {
        DatabaseNavigatorTree navigatorTree = ((DatabaseNavigatorView) partSite.getPart()).getNavigatorTree();
        element.setIcon(DBeaverIcons.getImageDescriptor(navigatorTree.isFilterShowConnected() ? UIIcon.FILTER_RESET : UIIcon.FILTER_APPLY));
        String actionName = navigatorTree.isFilterShowConnected() ? "Show all" : "Show connected only";
        element.setText(actionName);
        element.setTooltip(actionName);
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) DatabaseNavigatorView(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree)

Example 8 with DatabaseNavigatorView

use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView in project dbeaver by dbeaver.

the class NavigatorHandlerFilterObjectType method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    if (activePart instanceof DatabaseNavigatorView) {
        DatabaseNavigatorTree navigatorTree = ((DatabaseNavigatorView) activePart).getNavigatorTree();
        DatabaseNavigatorTreeFilterObjectType objectType = CommonUtils.valueOf(DatabaseNavigatorTreeFilterObjectType.class, event.getParameter("type"), DatabaseNavigatorTreeFilterObjectType.table);
        if (objectType == navigatorTree.getFilterObjectType()) {
            return null;
        }
        navigatorTree.setFilterObjectType(objectType);
        navigatorTree.getViewer().getControl().setRedraw(false);
        try {
            navigatorTree.getViewer().refresh();
        } finally {
            navigatorTree.getViewer().getControl().setRedraw(true);
        }
    }
    ActionUtils.fireCommandRefresh(NavigatorCommands.CMD_FILTER_CONNECTIONS);
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DatabaseNavigatorView(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView) DatabaseNavigatorTreeFilterObjectType(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTreeFilterObjectType) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree)

Example 9 with DatabaseNavigatorView

use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView in project dbeaver by dbeaver.

the class NavigatorHandlerFilterObjectType method updateElement.

@Override
public void updateElement(UIElement element, Map parameters) {
    DatabaseNavigatorTreeFilterObjectType objectType = CommonUtils.valueOf(DatabaseNavigatorTreeFilterObjectType.class, CommonUtils.toString(parameters.get("type")), DatabaseNavigatorTreeFilterObjectType.table);
    DatabaseNavigatorTreeFilterObjectType curObjectType = DatabaseNavigatorTreeFilterObjectType.table;
    IWorkbenchPartSite partSite = UIUtils.getWorkbenchPartSite(element.getServiceLocator());
    if (partSite != null && partSite.getPart() instanceof DatabaseNavigatorView) {
        curObjectType = ((DatabaseNavigatorView) partSite.getPart()).getNavigatorTree().getFilterObjectType();
    }
    String text, toolTip;
    switch(objectType) {
        case connection:
            text = "Filter connections";
            toolTip = "Filter connections by name";
            break;
        case container:
            text = "Filter databases or schemas";
            toolTip = "Filter containers (databases or schemas) by name";
            break;
        case table:
            text = "Filter tables, procedures";
            toolTip = "Filter objects (tables, procedures, users, etc) by name";
            break;
        default:
            return;
    }
    element.setText(text);
    element.setTooltip(toolTip);
    element.setChecked(objectType == curObjectType);
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) DatabaseNavigatorView(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView) DatabaseNavigatorTreeFilterObjectType(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTreeFilterObjectType)

Example 10 with DatabaseNavigatorView

use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView in project dbeaver by dbeaver.

the class NavigatorHandlerConnectionFilter method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    if (activePart instanceof DatabaseNavigatorView) {
        DatabaseNavigatorTree navigatorTree = ((DatabaseNavigatorView) activePart).getNavigatorTree();
        navigatorTree.setFilterShowConnected(!navigatorTree.isFilterShowConnected());
        navigatorTree.getViewer().getControl().setRedraw(false);
        try {
            navigatorTree.getViewer().refresh();
        } finally {
            navigatorTree.getViewer().getControl().setRedraw(true);
        }
    }
    ActionUtils.fireCommandRefresh(NavigatorCommands.CMD_FILTER_CONNECTIONS);
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DatabaseNavigatorView(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree)

Aggregations

DatabaseNavigatorView (org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView)10 DatabaseNavigatorTree (org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree)6 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)4 IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)4 DatabaseNavigatorTreeFilterObjectType (org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTreeFilterObjectType)4 DBECommand (org.jkiss.dbeaver.model.edit.DBECommand)2 ViewSQLDialog (org.jkiss.dbeaver.ui.dialogs.sql.ViewSQLDialog)2