use of org.eclipse.e4.ui.workbench.modeling.EModelService 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.workbench.modeling.EModelService in project org.csstudio.display.builder by kasemir.
the class RuntimeViewPart method findPlaceholder.
/**
* Find the MPlaceholder corresponding to this MPart in the MPerspective. This
* may have persisted information relevant to loading this view.
* @return corresponding placeholder or <code>null</code>
*/
private MPlaceholder findPlaceholder() {
final IEclipseContext localContext = getViewSite().getService(IEclipseContext.class);
final MPart part = localContext.get(MPart.class);
final EModelService service = PlatformUI.getWorkbench().getService(EModelService.class);
final IEclipseContext globalContext = PlatformUI.getWorkbench().getService(IEclipseContext.class);
final MApplication app = globalContext.get(MApplication.class);
final List<MPlaceholder> phs = service.findElements(app, null, MPlaceholder.class, null);
for (MPlaceholder ph : phs) if (ph.getRef() == part)
return ph;
return null;
}
use of org.eclipse.e4.ui.workbench.modeling.EModelService 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.workbench.modeling.EModelService in project portfolio by buchen.
the class NewFileHandler method execute.
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, //
@Optional @Named(IServiceConstants.ACTIVE_PART) MPart activePart, MApplication app, EPartService partService, EModelService modelService) {
NewClientWizard wizard = new NewClientWizard();
WizardDialog dialog = new WizardDialog(shell, wizard);
if (dialog.open() == Window.OK) {
MPart part = partService.createPart(UIConstants.Part.PORTFOLIO);
part.setLabel(Messages.LabelUnnamedXml);
part.getTransientData().put(Client.class.getName(), wizard.getClient());
if (activePart != null)
activePart.getParent().getChildren().add(part);
else
((MPartStack) modelService.find(UIConstants.PartStack.MAIN, app)).getChildren().add(part);
part.setVisible(true);
part.getParent().setVisible(true);
partService.showPart(part, PartState.ACTIVATE);
}
}
use of org.eclipse.e4.ui.workbench.modeling.EModelService in project portfolio by buchen.
the class OpenRecentFileHandler method execute.
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, //
@Optional @Named(IServiceConstants.ACTIVE_PART) MPart activePart, MApplication app, EPartService partService, EModelService modelService, @Named("name.abuchen.portfolio.ui.param.file") String file) {
MPart part = partService.createPart(UIConstants.Part.PORTFOLIO);
part.setLabel(new File(file).getName());
part.setTooltip(file);
part.getPersistedState().put(UIConstants.File.PERSISTED_STATE_KEY, file);
if (activePart != null)
activePart.getParent().getChildren().add(part);
else
((MPartStack) modelService.find(UIConstants.PartStack.MAIN, app)).getChildren().add(part);
part.setVisible(true);
part.getParent().setVisible(true);
partService.showPart(part, PartState.ACTIVATE);
}
Aggregations