diff options
| author | Tom Schindl | 2016-04-18 08:07:30 +0000 |
|---|---|---|
| committer | Tom Schindl | 2016-04-18 08:07:30 +0000 |
| commit | e3a8c4e5bf44ca4ffbdad6cf790544f72baa2112 (patch) | |
| tree | 9224ac14e4410c83f680cc391d24fd6ea823e6e1 | |
| parent | ddb3b1b0cab050441baf2f862f4079b5701bb05d (diff) | |
| download | org.eclipse.rap.incubator.e4-e3a8c4e5bf44ca4ffbdad6cf790544f72baa2112.tar.gz org.eclipse.rap.incubator.e4-e3a8c4e5bf44ca4ffbdad6cf790544f72baa2112.tar.xz org.eclipse.rap.incubator.e4-e3a8c4e5bf44ca4ffbdad6cf790544f72baa2112.zip | |
Update E4Workbench bootstrapping to run each workbench instance on its
own service context
Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=487874
3 files changed, 37 insertions, 49 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java index e62fcb8..269d6e0 100644 --- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java +++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java @@ -1,20 +1,3 @@ -/******************************************************************************* - * Copyright (c) 2009, 2014 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Tristan Hume - <trishume@gmail.com> - - * Fix for Bug 2369 [Workbench] Would like to be able to save workspace without exiting - * Implemented workbench auto-save to correctly restore state in case of crash. - * Lars Vogel <Lars.Vogel@vogella.com> - Bug 366364, 445724, 446088 - * Terry Parker <tparker@google.com> - Bug 416673 - * Christian Georgi (SAP) - Bug 432480 - ******************************************************************************/ - package org.eclipse.e4.ui.internal.workbench.swt; import java.io.File; @@ -277,10 +260,12 @@ public class E4Application implements IApplication { // for compatibility layer: set the application in the OSGi service // context (see Workbench#getInstance()) - if (!E4Workbench.getServiceContext().containsKey(MApplication.class)) { - // first one wins. - E4Workbench.getServiceContext().set(MApplication.class, appModel); - } + // TODO: Remove in RAP we have no compat layer + // if (!E4Workbench.getServiceContext().containsKey(MApplication.class)) + // { + // // first one wins. + // E4Workbench.getServiceContext().set(MApplication.class, appModel); + // } // Set the app's context after adding itself appContext.set(MApplication.class, appModel); @@ -522,7 +507,8 @@ public class E4Application implements IApplication { // TODO This should go into a different bundle public static IEclipseContext createDefaultHeadlessContext() { - IEclipseContext serviceContext = E4Workbench.getServiceContext(); + IEclipseContext serviceContext = EclipseContextFactory + .createServiceContext(WorkbenchSWTActivator.getDefault().getContext()); IExtensionRegistry registry = RegistryFactory.getRegistry(); ExceptionHandler exceptionHandler = new ExceptionHandler(); diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/E4Workbench.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/E4Workbench.java index 4bef61f..0f8995a 100644 --- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/E4Workbench.java +++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/E4Workbench.java @@ -17,7 +17,6 @@ import java.util.Hashtable; import java.util.List; import java.util.UUID; import org.eclipse.e4.core.commands.ExpressionContext; -import org.eclipse.e4.core.contexts.EclipseContextFactory; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.services.contributions.IContributionFactory; import org.eclipse.e4.core.services.log.Logger; @@ -214,13 +213,14 @@ public class E4Workbench implements IWorkbench { public boolean isRestart() { return restart; } - - /** - * @return a context that can be used to lookup OSGi services - */ - public static IEclipseContext getServiceContext() { - return EclipseContextFactory.getServiceContext(Activator.getDefault().getContext()); - } + // TODO: Remove in RAP + // /** + // * @return a context that can be used to lookup OSGi services + // */ + // public static IEclipseContext getServiceContext() { + // return + // EclipseContextFactory.getServiceContext(Activator.getDefault().getContext()); + // } @Override public MApplication getApplication() { diff --git a/bundles/org.eclipse.rap.e4/src/org/eclipse/rap/e4/E4EntryPointFactory.java b/bundles/org.eclipse.rap.e4/src/org/eclipse/rap/e4/E4EntryPointFactory.java index 05c0661..bf676a2 100644 --- a/bundles/org.eclipse.rap.e4/src/org/eclipse/rap/e4/E4EntryPointFactory.java +++ b/bundles/org.eclipse.rap.e4/src/org/eclipse/rap/e4/E4EntryPointFactory.java @@ -33,9 +33,9 @@ public class E4EntryPointFactory implements EntryPointFactory { private static final String PLUGIN_ID = "org.eclipse.e4.ui.workbench.rap"; private String productName; - + private E4ApplicationConfig config; - + public E4EntryPointFactory(E4ApplicationConfig config) { this.config = config; } @@ -54,7 +54,7 @@ public class E4EntryPointFactory implements EntryPointFactory { } }; } - + private int createWorkbench() { Display display = new Display(); E4Application e4App = new E4Application(); @@ -65,7 +65,7 @@ public class E4EntryPointFactory implements EntryPointFactory { ServerPushSession session = new ServerPushSession(); session.start(); } - + // instanceLocation = (Location) workbench.getContext().get( // E4Workbench.INSTANCE_LOCATION); Shell shell = display.getActiveShell(); @@ -77,13 +77,14 @@ public class E4EntryPointFactory implements EntryPointFactory { // if (!checkInstanceLocation(instanceLocation, shell, // workbench.getContext())) // return EXIT_OK; - + if( workbench != null ) { IEclipseContext workbenchContext = workbench.getContext(); + IEclipseContext serviceContext = workbenchContext.getParent(); // Create and run the UI (if any) workbench.createAndRunUI(workbench.getApplication()); - + // Save the model into the targetURI if (e4App.lcManager != null) { ContextInjectionFactory.invoke(e4App.lcManager, PreSave.class, @@ -91,28 +92,29 @@ public class E4EntryPointFactory implements EntryPointFactory { } e4App.saveModel(); workbench.close(); + serviceContext.dispose(); if (workbench.isRestart()) { return IApplication.EXIT_RESTART; - } + } } return IApplication.EXIT_OK; } - + private IApplicationContext getApplicationContext(final E4ApplicationConfig config) { return new IApplicationContext() { - + public org.osgi.framework.Bundle getBrandingBundle() { return null; } - + @Override public void setResult(Object result, IApplication application) { // TODO Auto-generated method stub - + } - + @Override public String getBrandingProperty(String key) { if( IWorkbench.XMI_URI_ARG.equals(key) ) { @@ -128,42 +130,42 @@ public class E4EntryPointFactory implements EntryPointFactory { } return null; } - + @Override public String getBrandingName() { // TODO Auto-generated method stub return null; } - + @Override public String getBrandingId() { // TODO Auto-generated method stub return null; } - + @Override public String getBrandingDescription() { // TODO Auto-generated method stub return null; } - + @Override public String getBrandingApplication() { // TODO Auto-generated method stub return null; } - + @Override public Map getArguments() { Map<Object, Object> rv = new HashMap<Object, Object>(); rv.put(IApplicationContext.APPLICATION_ARGS, new String[0]); return rv; } - + @Override public void applicationRunning() { // TODO Auto-generated method stub - + } }; } |
