use of org.jkiss.dbeaver.ui.editors.entity.EntityEditor in project dbeaver by serge-rider.
the class ItemListControl method fillCustomActions.
@Override
public void fillCustomActions(IContributionManager contributionManager) {
super.fillCustomActions(contributionManager);
final DBNNode rootNode = getRootNode();
if (rootNode instanceof DBNDatabaseFolder && ((DBNDatabaseFolder) rootNode).getItemsMeta() != null) {
contributionManager.add(new Action(UINavigatorMessages.obj_editor_properties_control_action_filter_setting, DBeaverIcons.getImageDescriptor(UIIcon.FILTER)) {
@Override
public void run() {
NavigatorHandlerFilterConfig.configureFilters(getShell(), rootNode);
}
});
}
addColumnConfigAction(contributionManager);
IWorkbenchSite workbenchSite = getWorkbenchSite();
if (rootNode instanceof DBNDatabaseFolder) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_OPEN));
{
if (ObjectPropertyTester.canCreateObject(rootNode, true)) {
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_CREATE));
} else if (ObjectPropertyTester.canCreateObject(rootNode, false)) {
contributionManager.add(new Action(null, Action.AS_DROP_DOWN_MENU) {
{
setActionDefinitionId(NavigatorCommands.CMD_OBJECT_CREATE);
}
@Override
public void run() {
super.run();
}
@Override
public IMenuCreator getMenuCreator() {
return new MenuCreator(control -> {
List<IContributionItem> items = NavigatorHandlerObjectCreateNew.fillCreateMenuItems((IWorkbenchPartSite) workbenchSite, rootNode);
MenuManager menuManager = new MenuManager();
for (IContributionItem cc : items) {
menuManager.add(cc);
}
return menuManager;
});
}
});
}
}
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_DELETE));
}
if (rootNode instanceof DBNDatabaseNode && rootNode.isPersisted()) {
boolean hasReorder = false;
List<Class<?>> childrenTypes = ((DBNDatabaseNode) rootNode).getChildrenTypes(null);
for (Class<?> chilType : childrenTypes) {
if (DBWorkbench.getPlatform().getEditorsRegistry().getObjectManager(chilType, DBEObjectReorderer.class) != null) {
hasReorder = true;
break;
}
}
if (hasReorder) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_MOVE_UP));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_MOVE_DOWN));
}
}
if (rootNode instanceof DBNDatabaseNode) {
// Expand/collapse
final List<DBXTreeNode> inlineMetas = collectInlineMetas((DBNDatabaseNode) rootNode, ((DBNDatabaseNode) rootNode).getMeta());
if (!inlineMetas.isEmpty()) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.NAVIGATE_COLLAPSE_ALL, null, UIIcon.TREE_COLLAPSE_ALL));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.NAVIGATE_EXPAND_ALL, null, UIIcon.TREE_EXPAND_ALL));
}
}
// Save/revert
if (workbenchSite instanceof MultiPageEditorSite) {
final MultiPageEditorPart editor = ((MultiPageEditorSite) workbenchSite).getMultiPageEditor();
if (editor instanceof EntityEditor) {
contributionManager.add(new Separator());
DatabaseEditorUtils.contributeStandardEditorActions(workbenchSite, contributionManager);
}
}
}
use of org.jkiss.dbeaver.ui.editors.entity.EntityEditor in project dbeaver by serge-rider.
the class WorkbenchContextListener method activatePartContexts.
void activatePartContexts(IWorkbenchPart part) {
IContextService contextService = PlatformUI.getWorkbench().getService(IContextService.class);
if (contextService == null) {
return;
}
try {
contextService.deferUpdates(true);
if (part instanceof INavigatorModelView) {
// We check for instanceof (do not use adapter) because otherwise it become active
// for all entity editor and clashes with SQL editor and other complex stuff.
// if (activationNavigator != null) {
// //log.debug("Double activation of navigator context");
// contextService.deactivateContext(activationNavigator);
// }
// activationNavigator = contextService.activateContext(INavigatorModelView.NAVIGATOR_CONTEXT_ID);
}
if (part instanceof SQLEditorBase || part.getAdapter(SQLEditorBase.class) != null) {
if (activationSQL != null) {
// log.debug("Double activation of SQL context");
contextService.deactivateContext(activationSQL);
}
activationSQL = contextService.activateContext(SQLEditorContributions.SQL_EDITOR_CONTEXT);
}
if (part.getAdapter(ResultSetViewer.class) != null || (part instanceof SQLEditor) || (part instanceof EntityEditor && ((EntityEditor) part).getDatabaseObject() instanceof DBSDataContainer)) {
if (activationResults != null) {
contextService.deactivateContext(activationResults);
}
activationResults = contextService.activateContext(RESULTS_CONTEXT_ID);
}
// Refresh auto-commit element state (#3315)
// Refresh OpenSeparateConnection
ActionUtils.fireCommandRefresh(ConnectionCommands.CMD_TOGGLE_AUTOCOMMIT, SQLEditorCommands.CMD_TOGGLE_SEPARATE_CONNECTION);
} finally {
contextService.deferUpdates(false);
}
}
use of org.jkiss.dbeaver.ui.editors.entity.EntityEditor in project dbeaver by dbeaver.
the class WorkbenchContextListener method activatePartContexts.
void activatePartContexts(IWorkbenchPart part) {
IContextService contextService = PlatformUI.getWorkbench().getService(IContextService.class);
if (contextService == null) {
return;
}
try {
contextService.deferUpdates(true);
if (part instanceof INavigatorModelView) {
// We check for instanceof (do not use adapter) because otherwise it become active
// for all entity editor and clashes with SQL editor and other complex stuff.
// if (activationNavigator != null) {
// //log.debug("Double activation of navigator context");
// contextService.deactivateContext(activationNavigator);
// }
// activationNavigator = contextService.activateContext(INavigatorModelView.NAVIGATOR_CONTEXT_ID);
}
if (part instanceof SQLEditorBase || part.getAdapter(SQLEditorBase.class) != null) {
if (activationSQL != null) {
// log.debug("Double activation of SQL context");
contextService.deactivateContext(activationSQL);
}
activationSQL = contextService.activateContext(SQLEditorContributions.SQL_EDITOR_CONTEXT);
}
if (part.getAdapter(ResultSetViewer.class) != null || (part instanceof SQLEditor) || (part instanceof EntityEditor && ((EntityEditor) part).getDatabaseObject() instanceof DBSDataContainer)) {
if (activationResults != null) {
contextService.deactivateContext(activationResults);
}
activationResults = contextService.activateContext(RESULTS_CONTEXT_ID);
}
// Refresh auto-commit element state (#3315)
// Refresh OpenSeparateConnection
ActionUtils.fireCommandRefresh(ConnectionCommands.CMD_TOGGLE_AUTOCOMMIT, SQLEditorCommands.CMD_TOGGLE_SEPARATE_CONNECTION);
} finally {
contextService.deferUpdates(false);
}
}
use of org.jkiss.dbeaver.ui.editors.entity.EntityEditor in project dbeaver by dbeaver.
the class SQLEditorNested method refreshPart.
@Override
public void refreshPart(Object source, boolean force) {
// Check if we are in saving process
// If so then no refresh needed (source text was updated during save)
IEditorSite editorSite = getEditorSite();
if (editorSite instanceof MultiPageEditorSite && ((MultiPageEditorSite) editorSite).getMultiPageEditor() instanceof EntityEditor && ((EntityEditor) ((MultiPageEditorSite) editorSite).getMultiPageEditor()).isSaveInProgress()) {
return;
}
final IDocumentProvider documentProvider = getDocumentProvider();
if (documentProvider instanceof SQLEditorNested.ObjectDocumentProvider) {
((SQLEditorNested.ObjectDocumentProvider) documentProvider).sourceText = null;
}
if (force) {
int caretOffset = getEditorControl().getCaretOffset();
super.setInput(getEditorInput());
// Try to keep cursor position
if (caretOffset < getEditorControl().getCharCount()) {
getEditorControl().setCaretOffset(caretOffset);
}
}
reloadSyntaxRules();
}
use of org.jkiss.dbeaver.ui.editors.entity.EntityEditor in project dbeaver by dbeaver.
the class ContentEditor method doSave.
@Override
public void doSave(final IProgressMonitor monitor) {
if (!isDirty()) {
// Nothing to save
return;
}
// Execute save in UI thread
UIUtils.syncExec(() -> {
try {
// Check for dirty parts
final List<IEditorPart> dirtyParts = new ArrayList<>();
for (ContentPartInfo partInfo : contentParts) {
if (partInfo.activated && partInfo.editorPart.isDirty()) {
dirtyParts.add(partInfo.editorPart);
}
}
IEditorPart dirtyPart = null;
if (dirtyParts.isEmpty()) {
// No modified parts - no additional save required
} else if (dirtyParts.size() == 1) {
// Single part modified - save it
dirtyPart = dirtyParts.get(0);
} else {
// Multiple parts modified - need to choose one
dirtyPart = SelectContentPartDialog.selectContentPart(getSite().getShell(), dirtyParts);
}
if (dirtyPart != null) {
saveInProgress = true;
try {
dirtyPart.doSave(monitor);
} finally {
saveInProgress = false;
}
}
// Set dirty flag - if error will occur during content save
// then document remains dirty
ContentEditor.this.dirty = true;
ContentEditorInput editorInput = getEditorInput();
editorInput.updateContentFromFile(new DefaultProgressMonitor(monitor), editorInput.getValue());
editorInput.getValueController().updateValue(editorInput.getValue(), true);
// Activate owner editor and focus on cell corresponding to this content editor
IWorkbenchPartSite parentEditorSite = editorInput.getValueController().getValueSite();
IWorkbenchPart parentEditor;
if (parentEditorSite instanceof MultiPageEditorSite) {
parentEditor = ((MultiPageEditorSite) parentEditorSite).getMultiPageEditor();
if (parentEditor instanceof EntityEditor) {
((EntityEditor) parentEditor).setActiveEditor(IEntityDataEditor.class);
}
} else {
parentEditor = parentEditorSite.getPart();
}
parentEditorSite.getWorkbenchWindow().getActivePage().activate(parentEditor);
// Close editor
closeValueEditor();
} catch (Exception e) {
DBWorkbench.getPlatformUI().showError("Can't save content", "Can't save content to database", e);
}
});
}
Aggregations