Search in sources :

Example 1 with DatabaseNavigatorView

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

the class NavigatorHandlerObjectBase method showScript.

protected static boolean showScript(IWorkbenchWindow workbenchWindow, DBECommandContext commandContext, String dialogTitle) {
    Collection<? extends DBECommand> commands = commandContext.getFinalCommands();
    StringBuilder script = new StringBuilder();
    for (DBECommand command : commands) {
        script.append(SQLUtils.generateScript(commandContext.getExecutionContext().getDataSource(), command.getPersistActions(), false));
    }
    DatabaseNavigatorView view = UIUtils.findView(workbenchWindow, DatabaseNavigatorView.class);
    if (view != null) {
        ViewSQLDialog dialog = new ViewSQLDialog(view.getSite(), commandContext.getExecutionContext(), dialogTitle, UIIcon.SQL_PREVIEW, script.toString());
        dialog.setShowSaveButton(true);
        return dialog.open() == IDialogConstants.PROCEED_ID;
    } else {
        return false;
    }
}
Also used : DBECommand(org.jkiss.dbeaver.model.edit.DBECommand) DatabaseNavigatorView(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView) ViewSQLDialog(org.jkiss.dbeaver.ui.dialogs.sql.ViewSQLDialog)

Example 2 with DatabaseNavigatorView

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

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 3 with DatabaseNavigatorView

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

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)

Example 4 with DatabaseNavigatorView

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

the class NavigatorHandlerObjectBase method showScript.

protected static boolean showScript(IWorkbenchWindow workbenchWindow, DBECommandContext commandContext, Map<String, Object> options, String dialogTitle) {
    Collection<? extends DBECommand> commands = commandContext.getFinalCommands();
    StringBuilder script = new StringBuilder();
    for (DBECommand command : commands) {
        script.append(SQLUtils.generateScript(commandContext.getExecutionContext().getDataSource(), command.getPersistActions(options), false));
    }
    DatabaseNavigatorView view = UIUtils.findView(workbenchWindow, DatabaseNavigatorView.class);
    if (view != null) {
        ViewSQLDialog dialog = new ViewSQLDialog(view.getSite(), commandContext.getExecutionContext(), dialogTitle, UIIcon.SQL_PREVIEW, script.toString());
        dialog.setShowSaveButton(true);
        return dialog.open() == IDialogConstants.PROCEED_ID;
    } else {
        return false;
    }
}
Also used : DBECommand(org.jkiss.dbeaver.model.edit.DBECommand) DatabaseNavigatorView(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView) ViewSQLDialog(org.jkiss.dbeaver.ui.dialogs.sql.ViewSQLDialog)

Example 5 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)

Aggregations

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