use of org.eclipse.e4.ui.model.application.ui.basic.MTrimElement in project dbeaver by dbeaver.
the class DataSourceToolbarUtils method refreshSelectorToolbar.
public static void refreshSelectorToolbar(IWorkbenchWindow window) {
if (window instanceof WorkbenchWindow) {
MTrimBar topTrim = ((WorkbenchWindow) window).getTopTrim();
for (MTrimElement element : topTrim.getChildren()) {
if (CONNECTION_SELECTOR_TOOLBAR_ID.equals(element.getElementId())) {
boolean showConnectionSelector = false;
IEditorPart activeEditor = window.getActivePage().getActiveEditor();
DBPDataSourceContainer dataSourceContainer = null;
if (activeEditor instanceof IDataSourceContainerProvider) {
showConnectionSelector = true;
dataSourceContainer = ((IDataSourceContainerProvider) activeEditor).getDataSourceContainer();
}
if (element instanceof MElementContainer) {
Object widget = element.getWidget();
if (widget instanceof Composite) {
Composite controlsPanel = (Composite) widget;
Color bgColor = dataSourceContainer == null ? null : UIUtils.getConnectionTypeColor(dataSourceContainer.getConnectionConfiguration().getConnectionType());
Control[] childControl = controlsPanel.getChildren();
for (Control cc : childControl) {
// if (bgColor != null) {
// Color oldBackground = cc.getBackground();
// if (oldBackground != null) {
// RGB newBackground = UIUtils.blend(oldBackground.getRGB(), bgColor.getRGB(), 50);
// cc.setBackground(UIUtils.getSharedColor(newBackground));
// continue;
// }
// }
cc.setBackground(bgColor);
}
}
MElementContainer<? extends MUIElement> container = (MElementContainer<? extends MUIElement>) element;
for (MUIElement tbItem : container.getChildren()) {
// So we need to hide/show it to force text update
if (showConnectionSelector) {
tbItem.setVisible(false);
}
tbItem.setVisible(showConnectionSelector);
}
}
return;
}
}
}
// By some reason we can't locate the toolbar (#5712?). Let's just refresh elements then - its better than nothing
updateCommandsUI();
}
use of org.eclipse.e4.ui.model.application.ui.basic.MTrimElement in project dbeaver by serge-rider.
the class DataSourceToolbarUtils method refreshSelectorToolbar.
public static void refreshSelectorToolbar(IWorkbenchWindow window) {
if (window instanceof WorkbenchWindow) {
MTrimBar topTrim = ((WorkbenchWindow) window).getTopTrim();
for (MTrimElement element : topTrim.getChildren()) {
if (CONNECTION_SELECTOR_TOOLBAR_ID.equals(element.getElementId())) {
boolean showConnectionSelector = false;
IEditorPart activeEditor = window.getActivePage().getActiveEditor();
DBPDataSourceContainer dataSourceContainer = null;
if (activeEditor instanceof IDataSourceContainerProvider) {
showConnectionSelector = true;
dataSourceContainer = ((IDataSourceContainerProvider) activeEditor).getDataSourceContainer();
}
if (element instanceof MElementContainer) {
Object widget = element.getWidget();
if (widget instanceof Composite) {
Composite controlsPanel = (Composite) widget;
Color bgColor = dataSourceContainer == null ? null : UIUtils.getConnectionTypeColor(dataSourceContainer.getConnectionConfiguration().getConnectionType());
Control[] childControl = controlsPanel.getChildren();
for (Control cc : childControl) {
// if (bgColor != null) {
// Color oldBackground = cc.getBackground();
// if (oldBackground != null) {
// RGB newBackground = UIUtils.blend(oldBackground.getRGB(), bgColor.getRGB(), 50);
// cc.setBackground(UIUtils.getSharedColor(newBackground));
// continue;
// }
// }
cc.setBackground(bgColor);
}
}
MElementContainer<? extends MUIElement> container = (MElementContainer<? extends MUIElement>) element;
for (MUIElement tbItem : container.getChildren()) {
// So we need to hide/show it to force text update
if (showConnectionSelector) {
tbItem.setVisible(false);
}
tbItem.setVisible(showConnectionSelector);
}
}
return;
}
}
}
// By some reason we can't locate the toolbar (#5712?). Let's just refresh elements then - its better than nothing
updateCommandsUI();
}
Aggregations