use of org.jkiss.dbeaver.model.edit.DBEStructEditor in project dbeaver by serge-rider.
the class NavigatorHandlerObjectBase method getCommandTarget.
protected static CommandTarget getCommandTarget(IWorkbenchWindow workbenchWindow, DBNContainer container, Class<?> childType, boolean openEditor) throws DBException {
final Object parentObject = container.getValueObject();
DBSObject objectToSeek = null;
if (parentObject instanceof DBSObject) {
final DBEStructEditor parentStructEditor = EntityEditorsRegistry.getInstance().getObjectManager(parentObject.getClass(), DBEStructEditor.class);
if (parentStructEditor != null && RuntimeUtils.isTypeSupported(childType, parentStructEditor.getChildTypes())) {
objectToSeek = (DBSObject) parentObject;
}
}
if (objectToSeek != null) {
for (final IEditorReference editorRef : workbenchWindow.getActivePage().getEditorReferences()) {
final IEditorPart editor = editorRef.getEditor(false);
if (editor instanceof IDatabaseEditor) {
final IDatabaseEditorInput editorInput = ((IDatabaseEditor) editor).getEditorInput();
if (editorInput.getDatabaseObject() == objectToSeek) {
workbenchWindow.getActivePage().activate(editor);
switchEditorFolder(container, editor);
return new CommandTarget((IDatabaseEditor) editor);
}
}
}
if (openEditor && container instanceof DBNDatabaseNode) {
final IDatabaseEditor editor = (IDatabaseEditor) NavigatorHandlerObjectOpen.openEntityEditor((DBNDatabaseNode) container, null, workbenchWindow);
if (editor != null) {
switchEditorFolder(container, editor);
return new CommandTarget(editor);
}
}
}
if (container instanceof DBNDatabaseNode) {
// No editor found - create new command context
DBPDataSource dataSource = ((DBNDatabaseNode) container).getObject().getDataSource();
if (dataSource != null) {
return new CommandTarget(new SimpleCommandContext(dataSource.getDefaultContext(true), !openEditor));
}
}
return new CommandTarget();
}
Aggregations