use of org.jkiss.dbeaver.model.impl.edit.DBECommandAdapter in project dbeaver by dbeaver.
the class TabbedFolderPageForm method createControl.
@Override
public void createControl(Composite parent) {
this.boldFont = UIUtils.makeBoldFont(parent.getFont());
// ScrolledComposite scrolled = new ScrolledComposite(parent, SWT.V_SCROLL);
// scrolled.setLayout(new GridLayout(1, false));
propertiesGroup = new Composite(parent, SWT.NONE);
// CSSUtils.setCSSClass(propertiesGroup, DBStyles.COLORED_BY_CONNECTION_TYPE);
curPropertySource = input.getPropertySource();
DBECommandContext commandContext = input.getCommandContext();
if (commandContext != null) {
commandContext.addCommandListener(new DBECommandAdapter() {
@Override
public void onCommandChange(DBECommand<?> command) {
UIUtils.asyncExec(() -> {
updateEditButtonsState();
if (command instanceof DBECommandProperty) {
// We need to exclude current prop from update
// Simple value compare on update is not enough because value can be transformed (e.g. uppercased)
// and it will differ from the value in edit control
Object propId = ((DBECommandProperty<?>) command).getHandler().getId();
updateOtherPropertyValues(propId);
}
});
}
@Override
public void onSave() {
UIUtils.asyncExec(() -> updateEditButtonsState());
}
@Override
public void onReset() {
UIUtils.asyncExec(() -> {
refreshProperties();
updateEditButtonsState();
});
}
});
}
propertiesGroup.addDisposeListener(e -> dispose());
refreshProperties();
}
use of org.jkiss.dbeaver.model.impl.edit.DBECommandAdapter in project dbeaver by serge-rider.
the class EntityEditor method createPages.
@Override
protected void createPages() {
super.createPages();
final IDatabaseEditorInput editorInput = getEditorInput();
if (editorInput instanceof DatabaseLazyEditorInput) {
try {
addPage(new ProgressEditorPart(this), editorInput);
setPageText(0, "Initializing ...");
Image tabImage = DBeaverIcons.getImage(UIIcon.REFRESH);
setPageImage(0, tabImage);
setActivePage(0);
((CTabFolder) getContainer()).setTabHeight(tabImage.getBounds().height + 2);
} 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) {
UIUtils.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);
}
});
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, UINavigatorMessages.editors_entity_properties_text);
setPageToolTip(propEditorIndex, node.getNodeType() + UINavigatorMessages.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) {
String folderId = defFolderId;
UIUtils.asyncExec(() -> {
((ITabbedFolderContainer) activeEditor).switchFolder(folderId);
});
}
}
UIUtils.setHelp(getContainer(), IHelpContextIds.CTX_ENTITY_EDITOR);
}
use of org.jkiss.dbeaver.model.impl.edit.DBECommandAdapter in project dbeaver by serge-rider.
the class TabbedFolderPageForm method createControl.
@Override
public void createControl(Composite parent) {
this.boldFont = UIUtils.makeBoldFont(parent.getFont());
// ScrolledComposite scrolled = new ScrolledComposite(parent, SWT.V_SCROLL);
// scrolled.setLayout(new GridLayout(1, false));
propertiesGroup = new Composite(parent, SWT.NONE);
// CSSUtils.setCSSClass(propertiesGroup, DBStyles.COLORED_BY_CONNECTION_TYPE);
curPropertySource = input.getPropertySource();
DBECommandContext commandContext = input.getCommandContext();
if (commandContext != null) {
commandContext.addCommandListener(new DBECommandAdapter() {
@Override
public void onCommandChange(DBECommand<?> command) {
UIUtils.asyncExec(() -> {
updateEditButtonsState();
if (command instanceof DBECommandProperty) {
// We need to exclude current prop from update
// Simple value compare on update is not enough because value can be transformed (e.g. uppercased)
// and it will differ from the value in edit control
Object propId = ((DBECommandProperty<?>) command).getHandler().getId();
updateOtherPropertyValues(propId);
}
});
}
@Override
public void onSave() {
UIUtils.asyncExec(() -> updateEditButtonsState());
}
@Override
public void onReset() {
UIUtils.asyncExec(() -> {
refreshProperties();
updateEditButtonsState();
});
}
});
}
propertiesGroup.addDisposeListener(e -> dispose());
refreshProperties();
}
use of org.jkiss.dbeaver.model.impl.edit.DBECommandAdapter in project dbeaver by dbeaver.
the class EntityEditor method createPages.
@Override
protected void createPages() {
super.createPages();
final IDatabaseEditorInput editorInput = getEditorInput();
if (editorInput instanceof DatabaseLazyEditorInput) {
try {
addPage(new ProgressEditorPart(this), editorInput);
setPageText(0, "Initializing ...");
Image tabImage = DBeaverIcons.getImage(UIIcon.REFRESH);
setPageImage(0, tabImage);
setActivePage(0);
((CTabFolder) getContainer()).setTabHeight(tabImage.getBounds().height + 2);
} 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) {
UIUtils.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);
}
});
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, UINavigatorMessages.editors_entity_properties_text);
setPageToolTip(propEditorIndex, node.getNodeType() + UINavigatorMessages.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) {
String folderId = defFolderId;
UIUtils.asyncExec(() -> {
((ITabbedFolderContainer) activeEditor).switchFolder(folderId);
});
}
}
UIUtils.setHelp(getContainer(), IHelpContextIds.CTX_ENTITY_EDITOR);
}
Aggregations