use of org.eclipse.e4.ui.model.application.ui.MElementContainer in project nebula.widgets.nattable by eclipse.
the class LifecycleManager method preSave.
@PreSave
void preSave(EModelService modelService, MApplication app) {
List<String> tags = new ArrayList<>();
tags.add(CLOSE_ON_SHUTDOWN_TAG);
List<MPart> elementsWithTags = modelService.findElements(app, null, MPart.class, tags);
for (MPart part : elementsWithTags) {
try {
part.setToBeRendered(false);
part.setVisible(false);
MElementContainer<MUIElement> parent = part.getParent();
parent.getChildren().remove(part);
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of org.eclipse.e4.ui.model.application.ui.MElementContainer in project portfolio by buchen.
the class LifeCycleManager method removePortfolioPartsWithoutPersistedFile.
private void removePortfolioPartsWithoutPersistedFile(MApplication app, EPartService partService, EModelService modelService) {
List<MPart> parts = modelService.findElements(app, MPart.class, EModelService.IN_ACTIVE_PERSPECTIVE, new Selector() {
@Override
public boolean select(MApplicationElement element) {
if (// $NON-NLS-1$
!"name.abuchen.portfolio.ui.part.portfolio".equals(element.getElementId()))
return false;
// $NON-NLS-1$
return element.getPersistedState().get("file") == null;
}
});
for (MPart part : parts) {
MElementContainer<MUIElement> parent = part.getParent();
if (parent.getSelectedElement().equals(part))
parent.setSelectedElement(null);
parent.getChildren().remove(part);
}
}
use of org.eclipse.e4.ui.model.application.ui.MElementContainer 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.MElementContainer 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