use of org.jkiss.dbeaver.model.navigator.DBNDatabaseNode in project dbeaver by dbeaver.
the class CheckboxTreeManager method updateCheckStates.
public void updateCheckStates() {
Set<DBNDatabaseNode> parentList = new LinkedHashSet<>();
for (Object element : viewer.getCheckedElements()) {
for (DBNNode node = ((DBNDatabaseNode) element).getParentNode(); node != null; node = node.getParentNode()) {
if (node instanceof DBNDatabaseNode) {
parentList.add((DBNDatabaseNode) node);
viewer.setChecked(node, true);
}
}
}
updateElementsCheck(parentList.toArray(), true, false);
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseNode in project dbeaver by dbeaver.
the class DatabaseNavigatorContentProvider method getChildren.
@Override
public Object[] getChildren(final Object parent) {
if (parent instanceof TreeLoadNode) {
return null;
}
if (!(parent instanceof DBNNode)) {
log.error("Bad parent type: " + parent);
return null;
}
// view.getNavigatorModel().findNode(parent);
final DBNNode parentNode = (DBNNode) parent;
/*
if (parentNode == null) {
log.error("Can't find parent node '" + ((DBSObject) parent).getName() + "' in model");
return EMPTY_CHILDREN;
}
*/
if (!parentNode.hasChildren(true)) {
return EMPTY_CHILDREN;
}
if (parentNode instanceof DBNDatabaseNode && ((DBNDatabaseNode) parentNode).needsInitialization()) {
return TreeLoadVisualizer.expandChildren(navigatorTree.getViewer(), new TreeLoadService("Loading", ((DBNDatabaseNode) parentNode)));
} else {
try {
// Read children with null monitor cos' it's not a lazy node
// and no blocking process will occur
DBNNode[] children = NavigatorUtils.getNodeChildrenFiltered(new VoidProgressMonitor(), parentNode, true);
if (ArrayUtils.isEmpty(children)) {
return EMPTY_CHILDREN;
} else {
return children;
}
} catch (Throwable ex) {
DBUserInterface.getInstance().showError("Navigator error", ex.getMessage(), ex);
// Collapse this item
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
navigatorTree.getViewer().collapseToLevel(parent, 1);
navigatorTree.getViewer().refresh(parent);
}
});
return EMPTY_CHILDREN;
}
}
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseNode in project dbeaver by dbeaver.
the class EntityEditor method saveCommandContext.
private boolean saveCommandContext(final DBRProgressMonitor monitor, Map<String, Object> options) {
monitor.beginTask("Save entity", 1);
Throwable error = null;
final DBECommandContext commandContext = getCommandContext();
if (commandContext == null) {
log.warn("Null command context");
return true;
}
try {
commandContext.saveChanges(monitor, options);
} catch (DBException e) {
error = e;
}
if (getDatabaseObject() instanceof DBPStatefulObject) {
try {
((DBPStatefulObject) getDatabaseObject()).refreshObjectState(monitor);
} catch (DBCException e) {
// Just report an error
log.error(e);
}
}
if (error == null) {
// Refresh underlying node
// It'll refresh database object and all it's descendants
// So we'll get actual data from database
final DBNDatabaseNode treeNode = getEditorInput().getNavigatorNode();
try {
DBeaverUI.runInProgressService(monitor1 -> {
try {
treeNode.refreshNode(monitor1, DBNEvent.FORCE_REFRESH);
} catch (DBException e) {
throw new InvocationTargetException(e);
}
});
} catch (InvocationTargetException e) {
error = e.getTargetException();
} catch (InterruptedException e) {
// ok
}
}
monitor.done();
if (error == null) {
return true;
} else {
// Try to handle error in nested editors
final Throwable vError = error;
DBeaverUI.syncExec(() -> {
final IErrorVisualizer errorVisualizer = getAdapter(IErrorVisualizer.class);
if (errorVisualizer != null) {
errorVisualizer.visualizeError(monitor, vError);
}
});
// Show error dialog
DBeaverUI.asyncExec(() -> DBUserInterface.getInstance().showError("Can't save '" + getDatabaseObject().getName() + "'", null, vError));
return false;
}
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseNode in project dbeaver by dbeaver.
the class EntityEditor method createTopRightControl.
@Override
protected Control createTopRightControl(Composite composite) {
// Path
ToolBar breadcrumbsPanel = new ToolBar(composite, SWT.HORIZONTAL | SWT.RIGHT);
breadcrumbsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Make base node path
DBNDatabaseNode node = getEditorInput().getNavigatorNode();
List<DBNDatabaseNode> nodeList = new ArrayList<>();
for (DBNNode n = node; n != null; n = n.getParentNode()) {
if (n instanceof DBNDatabaseNode) {
nodeList.add(0, (DBNDatabaseNode) n);
}
}
for (final DBNDatabaseNode databaseNode : nodeList) {
createPathRow(breadcrumbsPanel, databaseNode);
}
return breadcrumbsPanel;
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseNode in project dbeaver by dbeaver.
the class TabbedFolderPageProperties method detachPropertiesPanel.
private void detachPropertiesPanel() {
boolean attached = isAttached();
String title = attached ? "Detach properties to top panel" : "Move properties to tab";
if (UIUtils.confirmAction(part.getSite().getShell(), title, title + " will require to reopen editor.\nAre you sure?")) {
DBPPreferenceStore prefs = DBeaverCore.getGlobalPreferenceStore();
prefs.setValue(DBeaverPreferences.ENTITY_EDITOR_DETACH_INFO, attached);
IEditorPart editor;
if (part.getSite() instanceof MultiPageEditorSite) {
editor = ((MultiPageEditorSite) part.getSite()).getMultiPageEditor();
} else {
editor = (IEditorPart) part;
}
if (editor != null) {
DBNDatabaseNode node = null;
if (editor.getEditorInput() instanceof DatabaseEditorInput) {
node = ((DatabaseEditorInput) editor.getEditorInput()).getNavigatorNode();
}
DBeaverUI.getActiveWorkbenchWindow().getActivePage().closeEditor(editor, false);
if (node != null) {
NavigatorHandlerObjectOpen.openEntityEditor(node, null, DBeaverUI.getActiveWorkbenchWindow());
}
}
}
}
Aggregations