Search in sources :

Example 1 with MApplication

use of org.eclipse.e4.ui.model.application.MApplication in project archi by archimatetool.

the class GeneralPreferencePage method init.

public void init(IWorkbench workbench) {
    // e4 method (taken from org.eclipse.ui.internal.dialogs.ViewsPreferencePage init(IWorkbench))
    MApplication application = workbench.getService(MApplication.class);
    IEclipseContext context = application.getContext();
    // This is "org.eclipse.e4.ui.css.theme.e4_default" //$NON-NLS-1$
    fDefaultTheme = (String) context.get("cssTheme");
    fThemeEngine = context.get(IThemeEngine.class);
    fCurrentTheme = fThemeEngine.getActiveTheme();
/*
        // e3 method
        Bundle bundle = FrameworkUtil.getBundle(ArchiPlugin.class);
        BundleContext context = bundle.getBundleContext();
        ServiceReference<IThemeManager> ref = context.getServiceReference(IThemeManager.class);
        IThemeManager themeManager = context.getService(ref);
        fThemeEngine = themeManager.getEngineForDisplay(Display.getCurrent());
        fDefaultTheme = "org.eclipse.e4.ui.css.theme.e4_default"; //$NON-NLS-1$
*/
}
Also used : IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IThemeEngine(org.eclipse.e4.ui.css.swt.theme.IThemeEngine) MApplication(org.eclipse.e4.ui.model.application.MApplication)

Example 2 with MApplication

use of org.eclipse.e4.ui.model.application.MApplication 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();
        }
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) ArrayList(java.util.ArrayList) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) PreSave(org.eclipse.e4.ui.workbench.lifecycle.PreSave)

Example 3 with MApplication

use of org.eclipse.e4.ui.model.application.MApplication 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 4 with MApplication

use of org.eclipse.e4.ui.model.application.MApplication in project n4js by eclipse.

the class N4JSApplicationWorkbenchWindowAdvisor method reviewDisabledCategoriesFromAppModel.

/**
 * The 'Show View' dialog behavior slightly changed with E4. Even if the views are properly removed via activities
 * (by the unique view IDs) the content provider creates the root category for the unavailable views as well since
 * it is using the {@link MApplication}.
 */
private void reviewDisabledCategoriesFromAppModel() {
    final IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    final MApplication service = workbenchWindow.getService(MApplication.class);
    for (Iterator<MPartDescriptor> itr = service.getDescriptors().iterator(); itr.hasNext(); ) /**/
    {
        final MPartDescriptor descriptor = itr.next();
        if (isView(descriptor) && isDisabledView(descriptor)) {
            itr.remove();
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) MPartDescriptor(org.eclipse.e4.ui.model.application.descriptor.basic.MPartDescriptor) MApplication(org.eclipse.e4.ui.model.application.MApplication)

Example 5 with MApplication

use of org.eclipse.e4.ui.model.application.MApplication 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)

Aggregations

MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)9 MApplication (org.eclipse.e4.ui.model.application.MApplication)6 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)5 Execute (org.eclipse.e4.core.di.annotations.Execute)5 MPartStack (org.eclipse.e4.ui.model.application.ui.basic.MPartStack)5 File (java.io.File)3 Client (name.abuchen.portfolio.model.Client)2 IThemeEngine (org.eclipse.e4.ui.css.swt.theme.IThemeEngine)2 MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)2 MPlaceholder (org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder)2 EModelService (org.eclipse.e4.ui.workbench.modeling.EModelService)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 ArrayList (java.util.ArrayList)1 NewClientWizard (name.abuchen.portfolio.ui.wizards.client.NewClientWizard)1 ProgressMonitorInputStream (name.abuchen.portfolio.util.ProgressMonitorInputStream)1 TokenReplacingReader (name.abuchen.portfolio.util.TokenReplacingReader)1