Search in sources :

Example 1 with MPartStack

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);
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) INatExample(org.eclipse.nebula.widgets.nattable.examples.INatExample)

Example 2 with MPartStack

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();
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) MTrimBar(org.eclipse.e4.ui.model.application.ui.basic.MTrimBar) MPerspectiveStack(org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack) MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu) CoreException(org.eclipse.core.runtime.CoreException) MPerspective(org.eclipse.e4.ui.model.application.ui.advanced.MPerspective) MTrimmedWindow(org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) MPartSashContainer(org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 3 with MPartStack

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);
    }
}
Also used : NewClientWizard(name.abuchen.portfolio.ui.wizards.client.NewClientWizard) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) Client(name.abuchen.portfolio.model.Client) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 4 with MPartStack

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);
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) File(java.io.File) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 5 with MPartStack

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);
    }
}
Also used : ProgressMonitorInputStream(name.abuchen.portfolio.util.ProgressMonitorInputStream) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) InputStreamReader(java.io.InputStreamReader) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) ProgressMonitorInputStream(name.abuchen.portfolio.util.ProgressMonitorInputStream) InputStream(java.io.InputStream) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) TokenReplacingReader(name.abuchen.portfolio.util.TokenReplacingReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TokenReplacingReader(name.abuchen.portfolio.util.TokenReplacingReader) Client(name.abuchen.portfolio.model.Client) Execute(org.eclipse.e4.core.di.annotations.Execute)

Aggregations

MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)7 MPartStack (org.eclipse.e4.ui.model.application.ui.basic.MPartStack)7 Execute (org.eclipse.e4.core.di.annotations.Execute)6 File (java.io.File)3 Client (name.abuchen.portfolio.model.Client)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 NewClientWizard (name.abuchen.portfolio.ui.wizards.client.NewClientWizard)1 ProgressMonitorInputStream (name.abuchen.portfolio.util.ProgressMonitorInputStream)1 TokenReplacingReader (name.abuchen.portfolio.util.TokenReplacingReader)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)1 MPerspective (org.eclipse.e4.ui.model.application.ui.advanced.MPerspective)1 MPerspectiveStack (org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack)1 MPartSashContainer (org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer)1 MTrimBar (org.eclipse.e4.ui.model.application.ui.basic.MTrimBar)1