use of org.jkiss.dbeaver.model.navigator.DBNDatabaseItem in project dbeaver by serge-rider.
the class NavigatorHandlerFilterClear method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
DBNNode node = NavigatorUtils.getSelectedNode(selection);
if (node instanceof DBNDatabaseItem) {
node = node.getParentNode();
}
if (node instanceof DBNDatabaseFolder) {
final DBNDatabaseFolder folder = (DBNDatabaseFolder) node;
DBXTreeItem itemsMeta = folder.getItemsMeta();
if (itemsMeta != null) {
folder.setNodeFilter(itemsMeta, new DBSObjectFilter());
NavigatorHandlerRefresh.refreshNavigator(Collections.singleton(folder));
}
}
return null;
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseItem in project dbeaver by serge-rider.
the class NavigatorHandlerFilterToggle method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
DBNNode node = NavigatorUtils.getSelectedNode(selection);
if (node instanceof DBNDatabaseItem) {
node = node.getParentNode();
}
if (node instanceof DBNDatabaseFolder) {
final DBNDatabaseFolder folder = (DBNDatabaseFolder) node;
DBXTreeItem itemsMeta = folder.getItemsMeta();
if (itemsMeta != null) {
final DBSObjectFilter nodeFilter = folder.getNodeFilter(itemsMeta, true);
if (nodeFilter != null) {
nodeFilter.setEnabled(!nodeFilter.isEnabled());
NavigatorHandlerRefresh.refreshNavigator(Collections.singleton(folder));
}
}
}
return null;
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseItem in project dbeaver by dbeaver.
the class NavigatorHandlerFilterToggle method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
DBNNode node = NavigatorUtils.getSelectedNode(selection);
if (node instanceof DBNDatabaseItem) {
node = node.getParentNode();
}
if (node instanceof DBNDatabaseFolder) {
final DBNDatabaseFolder folder = (DBNDatabaseFolder) node;
DBXTreeItem itemsMeta = folder.getItemsMeta();
if (itemsMeta != null) {
final DBSObjectFilter nodeFilter = folder.getNodeFilter(itemsMeta, true);
if (nodeFilter != null) {
nodeFilter.setEnabled(!nodeFilter.isEnabled());
NavigatorHandlerRefresh.refreshNavigator(Collections.singleton(folder));
}
}
}
return null;
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseItem in project dbeaver by serge-rider.
the class NavigatorHandlerFilterClear method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
DBNNode node = NavigatorUtils.getSelectedNode(selection);
if (node instanceof DBNDatabaseItem) {
node = node.getParentNode();
}
if (node instanceof DBNDatabaseFolder) {
final DBNDatabaseFolder folder = (DBNDatabaseFolder) node;
DBXTreeItem itemsMeta = folder.getItemsMeta();
if (itemsMeta != null) {
folder.setNodeFilter(itemsMeta, new DBSObjectFilter());
NavigatorHandlerRefresh.refreshNavigator(Collections.singleton(folder));
}
}
return null;
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseItem in project dbeaver by serge-rider.
the class NavigatorHandlerSetDefaultObject method markObjectAsActive.
@SuppressWarnings("unchecked")
private void markObjectAsActive(final DBNDatabaseNode databaseNode, IEditorPart activeEditor) {
DBNNode parentNode = databaseNode.getParentNode();
if (parentNode instanceof DBNDatabaseItem) {
markObjectAsActive((DBNDatabaseItem) parentNode, activeEditor);
return;
}
DBSObject object = databaseNode.getObject();
DBPDataSource dataSource = object.getDataSource();
final DBCExecutionContext editorContext;
if (activeEditor instanceof DBPContextProvider) {
editorContext = ((DBPContextProvider) activeEditor).getExecutionContext();
} else {
editorContext = null;
}
TasksJob.runTask("Change default object", monitor -> {
try {
DBExecUtils.tryExecuteRecover(monitor, dataSource, param -> {
try {
DBCExecutionContext defaultContext = dataSource.getDefaultInstance().getDefaultContext(monitor, false);
DBCExecutionContext[] contextsToChange;
if (editorContext != null && editorContext != defaultContext && editorContext.getDataSource() == defaultContext.getDataSource()) {
contextsToChange = new DBCExecutionContext[] { defaultContext, editorContext };
} else {
contextsToChange = new DBCExecutionContext[] { defaultContext };
}
for (DBCExecutionContext executionContext : contextsToChange) {
DBCExecutionContextDefaults contextDefaults = executionContext.getContextDefaults();
if (contextDefaults != null) {
if (object instanceof DBSCatalog && contextDefaults.supportsCatalogChange()) {
contextDefaults.setDefaultCatalog(monitor, (DBSCatalog) object, null);
} else if (object instanceof DBSSchema && contextDefaults.supportsSchemaChange()) {
contextDefaults.setDefaultSchema(monitor, (DBSSchema) object);
} else {
throw new DBCException("Internal error: active object change not supported");
}
}
}
} catch (DBException e) {
throw new InvocationTargetException(e);
}
});
} catch (Exception e) {
throw new InvocationTargetException(e);
}
});
}
Aggregations