use of org.jkiss.dbeaver.model.navigator.DBNEmptyNode in project dbeaver by serge-rider.
the class DatabaseBrowserView method getNodeFromSecondaryId.
public static DBNNode getNodeFromSecondaryId(String id) throws DBException {
int divPos = id.indexOf('|');
if (divPos == -1) {
throw new DBException("Bad secondary ID: " + id);
}
String projectName = id.substring(0, divPos);
String nodePath = id.substring(divPos + 1).replace("~", ":");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (project == null) {
throw new DBException("Project '" + projectName + "' not found");
}
final DBNModel navigatorModel = DBWorkbench.getPlatform().getNavigatorModel();
DBNNode node = null;
DBPProject projectMeta = DBWorkbench.getPlatform().getWorkspace().getProject(project);
if (projectMeta != null) {
navigatorModel.ensureProjectLoaded(projectMeta);
node = navigatorModel.getNodeByPath(new VoidProgressMonitor(), projectMeta, nodePath);
}
if (node == null) {
log.error("Node " + nodePath + " not found for browse view");
node = new DBNEmptyNode();
}
return node;
}
use of org.jkiss.dbeaver.model.navigator.DBNEmptyNode in project dbeaver by serge-rider.
the class DatabaseBrowserView method getRootNode.
@Override
public DBNNode getRootNode() {
String secondaryId = getViewSite().getSecondaryId();
if (!CommonUtils.isEmpty(secondaryId)) {
try {
return getNodeFromSecondaryId(secondaryId);
} catch (DBException e) {
DBWorkbench.getPlatformUI().showError("Open database browser", "Can't find database navigator node", e);
}
}
DBNProject projectNode = getModel().getRoot().getProjectNode(DBWorkbench.getPlatform().getWorkspace().getActiveProject());
return projectNode == null ? new DBNEmptyNode() : projectNode.getDatabases();
}
Aggregations