use of org.eclipse.e4.ui.model.application.ui.advanced.MPerspective 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.model.application.ui.advanced.MPerspective in project whole by wholeplatform.
the class E4ModelProcessor method initialize.
@Execute
protected void initialize() throws CoreException {
try {
ClasspathPersistenceProvider pp = new ClasspathPersistenceProvider("org/whole/product/e4/lw/WorkspaceConfiguration.xwl");
InterpreterOperation.interpret(XmlBuilderPersistenceKit.instance().readModel(pp));
MUIElement placeholderWindow = modelService.find(PLACEHOLDER_WINDOW_ID, application);
if (placeholderWindow == null || !placeholderWindow.getParent().getChildren().remove(placeholderWindow))
throw new IllegalStateException("Unable to remove placeholder window with id: '" + PLACEHOLDER_WINDOW_ID + "'");
MTrimmedWindow window = MBasicFactory.INSTANCE.createTrimmedWindow();
window.setLabel("Whole Language Workbench Window");
window.setX(500);
window.setY(20);
window.setWidth(800);
window.setHeight(1000);
MMenu mainMenu = MMenuFactory.INSTANCE.createMenu();
mainMenu.setElementId("menu:org.eclipse.ui.main.menu");
mainMenu.getChildren().add(createFileMenu());
mainMenu.getChildren().add(createEditMenu());
mainMenu.getChildren().add(createHelpMenu());
window.setMainMenu(mainMenu);
MTrimBar trimBar = MBasicFactory.INSTANCE.createTrimBar();
trimBar.setSide(SideValue.TOP);
trimBar.getChildren().add(createToolBar());
window.getTrimBars().add(trimBar);
MPerspectiveStack perspectiveStack = MAdvancedFactory.INSTANCE.createPerspectiveStack();
MPerspective perspective = MAdvancedFactory.INSTANCE.createPerspective();
perspective.setLabel("P1");
MPartSashContainer partSashContainer = MBasicFactory.INSTANCE.createPartSashContainer();
partSashContainer.setHorizontal(false);
MPartStack partStack = MBasicFactory.INSTANCE.createPartStack();
MPart part = MBasicFactory.INSTANCE.createPart();
part.setContributionURI("bundleclass://org.whole.lang.e4.ui/org.whole.lang.e4.ui.parts.E4GraphicalPart");
part.setLabel("Part1a");
part.setCloseable(true);
Map<String, String> persistedState = part.getPersistedState();
persistedState.put("basePersistenceKitId", "org.whole.lang.xml.codebase.XmlBuilderPersistenceKit");
persistedState.put("filePath", "/BaseProject/src/org/whole/lang/ExampleModel.xwl");
persistedState.put("overridePersistenceKitId", "org.whole.lang.xml.codebase.XmlBuilderPersistenceKit");
partStack.getChildren().add(part);
partSashContainer.getChildren().add(partStack);
perspective.getChildren().add(partSashContainer);
perspectiveStack.getChildren().add(perspective);
window.getChildren().add(perspectiveStack);
application.getChildren().add(window);
} catch (Exception e) {
System.out.println("Unable to configure the initial workspace");
e.printStackTrace();
}
}
use of org.eclipse.e4.ui.model.application.ui.advanced.MPerspective in project yamcs-studio by yamcs.
the class OPIView method findPlaceholder.
/**
* Find the MPlaceholder corresponding to this MPart in the MPerspective. This may have persisted information
* relevant to loading this OPIView.
*
* @return corresponding placeholder
*/
private MPlaceholder findPlaceholder() {
// do not remove casting - RAP 3.0 still needs it
final IEclipseContext localContext = (IEclipseContext) getViewSite().getService(IEclipseContext.class);
final MPart part = localContext.get(MPart.class);
final EModelService service = (EModelService) PlatformUI.getWorkbench().getService(EModelService.class);
final IEclipseContext globalContext = (IEclipseContext) 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;
}
Aggregations