Search in sources :

Example 6 with MPart

use of org.eclipse.e4.ui.model.application.ui.basic.MPart 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;
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) EModelService(org.eclipse.e4.ui.workbench.modeling.EModelService) MPlaceholder(org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) MApplication(org.eclipse.e4.ui.model.application.MApplication)

Example 7 with MPart

use of org.eclipse.e4.ui.model.application.ui.basic.MPart in project whole by wholeplatform.

the class EntityLocationHyperlink method linkActivated.

public void linkActivated() {
    try {
        IEclipseContext context = (IEclipseContext) PlatformUI.getWorkbench().getService(IEclipseContext.class);
        EPartService partService = context.get(EPartService.class);
        Collection<MPart> parts = partService.getParts();
        for (MPart part : parts) {
            IEclipseContext partContext = part.getContext();
            if (partContext == null)
                continue;
            IModelInput modelInput = partContext.get(IModelInput.class);
            if (modelInput != null && ((IFilePersistenceProvider) modelInput.getPersistenceProvider()).getStore().equals(file)) {
                partService.activate(part, true);
                IEntityPartViewer viewer = partContext.get(IEntityPartViewer.class);
                IEntity entityContents = viewer.getEntityContents();
                final IEntity entity = EntityUtils.getEntity(entityContents, location);
                viewer.selectAndReveal(entity);
            }
        }
    } catch (Exception e) {
        E4CompatibilityPlugin.log(e);
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) IModelInput(org.whole.lang.ui.input.IModelInput) IEntity(org.whole.lang.model.IEntity) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IFilePersistenceProvider(org.whole.lang.codebase.IFilePersistenceProvider) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 8 with MPart

use of org.eclipse.e4.ui.model.application.ui.basic.MPart 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 9 with MPart

use of org.eclipse.e4.ui.model.application.ui.basic.MPart 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);
    }
}
Also used : MApplicationElement(org.eclipse.e4.ui.model.application.MApplicationElement) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) Selector(org.eclipse.e4.ui.workbench.Selector)

Example 10 with MPart

use of org.eclipse.e4.ui.model.application.ui.basic.MPart in project portfolio by buchen.

the class ImportIBHandler method execute.

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell) throws IOException {
    Client client = MenuHelper.getActiveClient(part);
    if (client == null)
        return;
    try {
        Extractor extractor = new IBFlexStatementExtractor(client);
        FileDialog fileDialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
        fileDialog.setText(extractor.getLabel());
        fileDialog.setFilterNames(new String[] { // $NON-NLS-1$
        MessageFormat.format("{0} ({1})", extractor.getLabel(), extractor.getFilterExtension()) });
        fileDialog.setFilterExtensions(new String[] { extractor.getFilterExtension() });
        fileDialog.open();
        String[] filenames = fileDialog.getFileNames();
        if (filenames.length == 0)
            return;
        List<Extractor.InputFile> files = new ArrayList<>();
        for (String filename : filenames) files.add(new Extractor.InputFile(new File(fileDialog.getFilterPath(), filename)));
        IPreferenceStore preferences = ((PortfolioPart) part.getObject()).getPreferenceStore();
        Dialog wizwardDialog = new WizardDialog(Display.getDefault().getActiveShell(), new ImportExtractedItemsWizard(client, extractor, preferences, files));
        wizwardDialog.open();
    } catch (IllegalArgumentException e) {
        PortfolioPlugin.log(e);
        MessageDialog.openError(shell, Messages.LabelError, e.getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) IBFlexStatementExtractor(name.abuchen.portfolio.datatransfer.IBFlexStatementExtractor) PortfolioPart(name.abuchen.portfolio.ui.PortfolioPart) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) Dialog(org.eclipse.jface.dialogs.Dialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ImportExtractedItemsWizard(name.abuchen.portfolio.ui.wizards.datatransfer.ImportExtractedItemsWizard) IBFlexStatementExtractor(name.abuchen.portfolio.datatransfer.IBFlexStatementExtractor) Extractor(name.abuchen.portfolio.datatransfer.Extractor) Client(name.abuchen.portfolio.model.Client) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Execute(org.eclipse.e4.core.di.annotations.Execute) CanExecute(org.eclipse.e4.core.di.annotations.CanExecute)

Aggregations

Execute (org.eclipse.e4.core.di.annotations.Execute)20 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)19 Client (name.abuchen.portfolio.model.Client)12 CanExecute (org.eclipse.e4.core.di.annotations.CanExecute)11 File (java.io.File)7 MPartStack (org.eclipse.e4.ui.model.application.ui.basic.MPartStack)7 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)6 PortfolioPart (name.abuchen.portfolio.ui.PortfolioPart)5 WizardDialog (org.eclipse.jface.wizard.WizardDialog)5 FileDialog (org.eclipse.swt.widgets.FileDialog)5 Dialog (org.eclipse.jface.dialogs.Dialog)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3 StringWriter (java.io.StringWriter)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 List (java.util.List)2 Named (javax.inject.Named)2 Extractor (name.abuchen.portfolio.datatransfer.Extractor)2