use of org.jkiss.dbeaver.registry.editor.EntityEditorDescriptor in project dbeaver by dbeaver.
the class EntityEditor method addContributions.
private void addContributions(String position) {
EntityEditorsRegistry editorsRegistry = EntityEditorsRegistry.getInstance();
final DBSObject databaseObject = getEditorInput().getDatabaseObject();
DBPObject object;
if (databaseObject instanceof DBPDataSourceContainer && databaseObject.getDataSource() != null) {
object = databaseObject.getDataSource();
} else {
object = databaseObject;
}
List<EntityEditorDescriptor> descriptors = editorsRegistry.getEntityEditors(object, this, position);
for (EntityEditorDescriptor descriptor : descriptors) {
if (descriptor.getType() == EntityEditorDescriptor.Type.editor) {
addEditorTab(descriptor);
}
}
}
use of org.jkiss.dbeaver.registry.editor.EntityEditorDescriptor in project dbeaver by dbeaver.
the class EntityEditor method createPages.
@Override
protected void createPages() {
final IDatabaseEditorInput editorInput = getEditorInput();
if (editorInput instanceof DatabaseLazyEditorInput) {
try {
addPage(new ProgressEditorPart(this), editorInput);
setPageText(0, "Initializing ...");
setActivePage(0);
} catch (PartInitException e) {
log.error(e);
}
return;
} else if (editorInput instanceof ErrorEditorInput) {
ErrorEditorInput errorInput = (ErrorEditorInput) editorInput;
try {
addPage(new ErrorEditorPartEx(errorInput.getError()), errorInput);
setPageImage(0, UIUtils.getShardImage(ISharedImages.IMG_OBJS_ERROR_TSK));
setPageText(0, "Error");
setActivePage(0);
} catch (PartInitException e) {
log.error(e);
}
return;
}
// Command listener
commandListener = new DBECommandAdapter() {
@Override
public void onCommandChange(DBECommand command) {
DBeaverUI.syncExec(() -> firePropertyChange(IEditorPart.PROP_DIRTY));
}
};
DBECommandContext commandContext = getCommandContext();
if (commandContext != null) {
commandContext.addCommandListener(commandListener);
}
// Property listener
addPropertyListener((source, propId) -> {
if (propId == IEditorPart.PROP_DIRTY) {
EntityEditorPropertyTester.firePropertyChange(EntityEditorPropertyTester.PROP_DIRTY);
EntityEditorPropertyTester.firePropertyChange(EntityEditorPropertyTester.PROP_CAN_UNDO);
EntityEditorPropertyTester.firePropertyChange(EntityEditorPropertyTester.PROP_CAN_REDO);
}
});
super.createPages();
DBSObject databaseObject = editorInput.getDatabaseObject();
EditorDefaults editorDefaults = null;
if (databaseObject == null) {
// Weird
log.debug("Null database object in EntityEditor");
} else {
synchronized (defaultPageMap) {
editorDefaults = defaultPageMap.get(databaseObject.getClass().getName());
}
EntityEditorsRegistry editorsRegistry = EntityEditorsRegistry.getInstance();
// Add object editor page
EntityEditorDescriptor defaultEditor = editorsRegistry.getMainEntityEditor(databaseObject, this);
hasPropertiesEditor = false;
if (defaultEditor != null) {
hasPropertiesEditor = addEditorTab(defaultEditor);
}
if (hasPropertiesEditor) {
DBNNode node = editorInput.getNavigatorNode();
int propEditorIndex = getPageCount() - 1;
setPageText(propEditorIndex, CoreMessages.editors_entity_properties_text);
setPageToolTip(propEditorIndex, node.getNodeType() + CoreMessages.editors_entity_properties_tooltip_suffix);
setPageImage(propEditorIndex, DBeaverIcons.getImage(node.getNodeIconDefault()));
}
}
// Add contributed pages
addContributions(EntityEditorDescriptor.POSITION_PROPS);
addContributions(EntityEditorDescriptor.POSITION_START);
addContributions(EntityEditorDescriptor.POSITION_MIDDLE);
// Add contributed pages
addContributions(EntityEditorDescriptor.POSITION_END);
String defPageId = editorInput.getDefaultPageId();
String defFolderId = editorInput.getDefaultFolderId();
if (defPageId == null && editorDefaults != null) {
defPageId = editorDefaults.pageId;
}
if (defPageId != null) {
IEditorPart defEditorPage = editorMap.get(defPageId);
if (defEditorPage != null) {
setActiveEditor(defEditorPage);
}
} else {
setActiveEditor(getEditor(0));
}
this.activeEditor = getActiveEditor();
if (activeEditor instanceof ITabbedFolderContainer) {
if (defFolderId == null && editorDefaults != null) {
defFolderId = editorDefaults.folderId;
}
if (defFolderId != null) {
((ITabbedFolderContainer) activeEditor).switchFolder(defFolderId);
}
}
UIUtils.setHelp(getContainer(), IHelpContextIds.CTX_ENTITY_EDITOR);
}
use of org.jkiss.dbeaver.registry.editor.EntityEditorDescriptor in project dbeaver by dbeaver.
the class ObjectPropertiesEditor method makeDatabaseEditorTabs.
private void makeDatabaseEditorTabs(final IDatabaseEditor part, final List<TabbedFolderInfo> tabList) {
final DBNDatabaseNode node = part.getEditorInput().getNavigatorNode();
if (node == null) {
return;
}
final DBSObject object = node.getObject();
if (!node.getMeta().isStandaloneNode()) {
// Collect tabs from navigator tree model
DBRRunnableWithProgress tabsCollector = new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) {
collectNavigatorTabs(monitor, part, node, tabList);
}
};
try {
if (node.needsInitialization()) {
DBeaverUI.runInProgressService(tabsCollector);
} else {
tabsCollector.run(new VoidProgressMonitor());
}
} catch (InvocationTargetException e) {
log.error(e.getTargetException());
} catch (InterruptedException e) {
// just go further
}
}
// Query for entity editors
List<EntityEditorDescriptor> editors = EntityEditorsRegistry.getInstance().getEntityEditors(object, this, null);
if (!CommonUtils.isEmpty(editors)) {
for (EntityEditorDescriptor descriptor : editors) {
if (descriptor.getType() == EntityEditorDescriptor.Type.folder) {
tabList.add(new TabbedFolderInfo(descriptor.getId(), descriptor.getName(), descriptor.getIcon(), descriptor.getDescription(), descriptor.isEmbeddable(), new TabbedFolderPageEditor(this, descriptor)));
}
}
}
}
Aggregations