Search in sources :

Example 11 with MApplication

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

the class ThemeUtils method getDefaultThemeName.

public static String getDefaultThemeName() {
    MApplication application = PlatformUI.getWorkbench().getService(MApplication.class);
    IEclipseContext context = application.getContext();
    return (String) context.get("cssTheme");
}
Also used : IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) MApplication(org.eclipse.e4.ui.model.application.MApplication)

Example 12 with MApplication

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

the class ThemeUtils method getThemeEngine.

/**
 * @return The Theme engine. This might be null if THEME_ENABLED is false
 */
public static IThemeEngine getThemeEngine() {
    if (engine == null) {
        MApplication application = PlatformUI.getWorkbench().getService(MApplication.class);
        IEclipseContext context = application.getContext();
        engine = context.get(IThemeEngine.class);
    }
    return engine;
}
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 13 with MApplication

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

the class OpenErrorLogFileHandler method execute.

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, // 
@Named(E4Workbench.INSTANCE_LOCATION) Location instanceLocation, MApplication app, EPartService partService, EModelService modelService) {
    // $NON-NLS-1$
    File logfile = new File(instanceLocation.getURL().getFile(), ".metadata/.log");
    if (!logfile.exists()) {
        MessageDialog.openError(shell, Messages.LabelError, MessageFormat.format(Messages.MsgErrorOpeningFile, logfile.getAbsoluteFile()));
    } else {
        MPart part = partService.createPart(UIConstants.Part.TEXT_VIEWER);
        part.getPersistedState().put(UIConstants.File.PERSISTED_STATE_KEY, logfile.getAbsolutePath());
        MPartStack stack = (MPartStack) modelService.find(UIConstants.PartStack.MAIN, app);
        stack.getChildren().add(part);
        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 14 with MApplication

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

the class OpenFileHandler 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) {
    FileDialog dialog = new FileDialog(shell, SWT.OPEN);
    // $NON-NLS-1$ //$NON-NLS-2$
    dialog.setFilterExtensions(new String[] { "*.xml;*.zip;*.portfolio", "*.*" });
    dialog.setFilterNames(new String[] { Messages.LabelPortfolioPerformanceFile, Messages.LabelAllFiles });
    String fileSelected = dialog.open();
    if (fileSelected != null) {
        MPart part = partService.createPart(UIConstants.Part.PORTFOLIO);
        part.setLabel(new File(fileSelected).getName());
        part.setTooltip(fileSelected);
        part.getPersistedState().put(UIConstants.File.PERSISTED_STATE_KEY, fileSelected);
        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) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) Execute(org.eclipse.e4.core.di.annotations.Execute)

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