use of org.jkiss.dbeaver.model.navigator.DBNDatabaseNode in project dbeaver by serge-rider.
the class DBXTreeFolder method getChildren.
@NotNull
@Override
public List<DBXTreeNode> getChildren(DBNNode context) {
List<DBXTreeNode> children = super.getChildren(context);
if (!CommonUtils.isEmpty(contributedCategories) && context instanceof DBNDatabaseNode) {
// Add contributed editors
List<DBXTreeNode> childrenWithContributions = new ArrayList<>(children);
DBPDataSourceProviderRegistry dspRegistry = DBWorkbench.getPlatform().getDataSourceProviderRegistry();
DBPDataSourceContainer dataSource = ((DBNDatabaseNode) context).getDataSourceContainer();
for (String category : contributedCategories) {
DBPEditorContribution[] editors = dspRegistry.getContributedEditors(category, dataSource);
for (DBPEditorContribution editor : editors) {
DBXTreeObject editorNode = new DBXTreeObject(getSource(), // No parent - otherwise we'll have dups after each call
null, null, null, editor.getLabel(), editor.getDescription(), editor.getEditorId());
editorNode.setDefaultIcon(editor.getIcon());
childrenWithContributions.add(editorNode);
}
}
return childrenWithContributions;
}
return children;
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseNode in project dbeaver by serge-rider.
the class SQLToolTaskWizard method refreshOnFinish.
private void refreshOnFinish() throws Exception {
try {
getContainer().run(true, true, monitor -> {
monitor.beginTask("Object refreshing", objectList.size());
for (DBSObject object : objectList) {
try {
DBNDatabaseNode objectNode = DBNUtils.getNodeByObject(object);
if (objectNode != null) {
objectNode.refreshNode(new DefaultProgressMonitor(monitor), DBNEvent.FORCE_REFRESH);
if (monitor.isCanceled()) {
break;
}
monitor.worked(1);
}
} catch (Exception e) {
log.error("Error refreshing object '" + object.getName() + "'", e);
}
}
monitor.done();
});
} catch (InvocationTargetException e) {
throw new DBCException("Refresh error", e.getTargetException());
} catch (InterruptedException e) {
// ignore
}
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseNode in project dbeaver by serge-rider.
the class AbstractDataEditor method openNewContainer.
@Override
public void openNewContainer(DBRProgressMonitor monitor, @NotNull DBSDataContainer dataContainer, @NotNull DBDDataFilter newFilter) {
final DBCExecutionContext executionContext = getExecutionContext();
if (executionContext == null) {
log.error("Can't open new container - not execution context found");
return;
}
final DBNDatabaseNode targetNode = executionContext.getDataSource().getContainer().getPlatform().getNavigatorModel().getNodeByObject(monitor, dataContainer, false);
if (targetNode == null) {
UIUtils.showMessageBox(null, "Open link", "Can't navigate to '" + DBUtils.getObjectFullName(dataContainer, DBPEvaluationContext.UI) + "' - navigator node not found", SWT.ICON_ERROR);
return;
}
openNewDataEditor(targetNode, newFilter);
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseNode in project dbeaver by serge-rider.
the class CursorViewComposite method openNewContainer.
@Override
public void openNewContainer(DBRProgressMonitor monitor, @NotNull DBSDataContainer dataContainer, @NotNull DBDDataFilter newFilter) {
DBCExecutionContext executionContext = getExecutionContext();
if (executionContext == null) {
return;
}
final DBNDatabaseNode targetNode = executionContext.getDataSource().getContainer().getPlatform().getNavigatorModel().getNodeByObject(monitor, dataContainer, false);
if (targetNode == null) {
UIUtils.showMessageBox(null, "Open link", "Can't navigate to '" + DBUtils.getObjectFullName(dataContainer, DBPEvaluationContext.UI) + "' - navigator node not found", SWT.ICON_ERROR);
return;
}
AbstractDataEditor.openNewDataEditor(targetNode, newFilter);
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseNode in project dbeaver by serge-rider.
the class ToggleProcedureBreakpointTarget method toggleLineBreakpoints.
@Override
public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
IEditorPart editorPart = (IEditorPart) part;
IResource resource = extractResource(editorPart, selection);
if (resource == null) {
return;
}
DBSObject databaseObject = DebugUI.extractDatabaseObject(editorPart);
if (databaseObject == null) {
return;
}
DBNDatabaseNode node = DBWorkbench.getPlatform().getNavigatorModel().getNodeByObject(new VoidProgressMonitor(), databaseObject, false);
if (node == null) {
return;
}
String nodeItemPath = node.getNodeItemPath();
ITextSelection textSelection = (ITextSelection) selection;
int lineNumber = textSelection.getStartLine();
IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(DBGConstants.MODEL_IDENTIFIER_DATABASE);
for (IBreakpoint breakpoint : breakpoints) {
if (breakpoint instanceof IDatabaseBreakpoint) {
IDatabaseBreakpoint databaseBreakpoint = (IDatabaseBreakpoint) breakpoint;
if (nodeItemPath.equals(databaseBreakpoint.getNodePath())) {
if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
DebugUITools.deleteBreakpoints(new IBreakpoint[] { breakpoint }, part.getSite().getShell(), null);
return;
}
}
}
}
int charstart = -1, charend = -1;
DBGBreakpointDescriptor breakpointDescriptor = GeneralUtils.adapt(databaseObject, DBGBreakpointDescriptor.class);
if (breakpointDescriptor == null) {
throw new CoreException(GeneralUtils.makeErrorStatus("Object '" + DBUtils.getObjectFullName(databaseObject, DBPEvaluationContext.UI) + "' doesn't support breakpoints"));
}
// create line breakpoint (doc line numbers start at 0)
new DatabaseLineBreakpoint(databaseObject, node, resource, breakpointDescriptor, lineNumber + 1, charstart, charend, true);
}
Aggregations