use of org.eclipse.e4.ui.model.application.ui.basic.MPartStack in project nebula.widgets.nattable by eclipse.
the class NavigationPart method openExampleInTab.
private void openExampleInTab(final String examplePath) {
final INatExample example = getExample(examplePath);
if (example == null) {
return;
}
MPartStack stack = (MPartStack) modelService.find("org.eclipse.nebula.widgets.nattable.examples.e4.partstack.0", app);
MPart part = null;
if (examplePath.startsWith("/" + E4_EXAMPLES_PREFIX)) {
part = (MPart) modelService.find(example.getClass().getName(), app);
if (part == null) {
part = partService.createPart(example.getClass().getName());
part.getTags().add(LifecycleManager.CLOSE_ON_SHUTDOWN_TAG);
part.getTags().add(EPartService.REMOVE_ON_HIDE_TAG);
stack.getChildren().add(part);
}
} else {
part = partService.createPart("org.eclipse.nebula.widgets.nattable.examples.e4.partdescriptor.natexample");
part.getTags().add(LifecycleManager.CLOSE_ON_SHUTDOWN_TAG);
part.getTags().add(EPartService.REMOVE_ON_HIDE_TAG);
part.getTransientData().put("example", example);
part.getTransientData().put("examplePath", examplePath);
stack.getChildren().add(part);
}
part.setLabel(example.getName());
partService.showPart(part, PartState.ACTIVATE);
}
use of org.eclipse.e4.ui.model.application.ui.basic.MPartStack 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.basic.MPartStack 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.model.application.ui.basic.MPartStack 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);
}
use of org.eclipse.e4.ui.model.application.ui.basic.MPartStack in project portfolio by buchen.
the class OpenSampleHandler method execute.
@Execute
public void execute(//
@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, //
final MApplication app, final EPartService partService, final EModelService modelService, @Named(UIConstants.Parameter.SAMPLE_FILE) final String sampleFile) {
try {
IRunnableWithProgress loadResourceOperation = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try (InputStream in = this.getClass().getResourceAsStream(sampleFile)) {
InputStream inputStream = new ProgressMonitorInputStream(in, monitor);
Reader replacingReader = new TokenReplacingReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8), buildResourcesTokenResolver());
final Client client = ClientFactory.load(replacingReader);
fixTaxonomyLabels(client);
sync.asyncExec(() -> {
MPart part = partService.createPart(UIConstants.Part.PORTFOLIO);
part.setLabel(sampleFile.substring(sampleFile.lastIndexOf('/') + 1));
part.getTransientData().put(Client.class.getName(), client);
MPartStack stack = (MPartStack) modelService.find(UIConstants.PartStack.MAIN, app);
stack.getChildren().add(part);
partService.showPart(part, PartState.ACTIVATE);
});
} catch (IOException ignore) {
PortfolioPlugin.log(ignore);
}
}
};
new ProgressMonitorDialog(shell).run(true, true, loadResourceOperation);
} catch (InvocationTargetException | InterruptedException e) {
PortfolioPlugin.log(e);
}
}
Aggregations