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;
}
}
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);
}
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;
}
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;
}
}
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;
}
Aggregations