diff options
author | Oleg Besedin | 2012-01-09 19:55:43 +0000 |
---|---|---|
committer | Oleg Besedin | 2012-01-09 19:55:43 +0000 |
commit | 8fd52eac48e2360d6fce79a91ee0c284927d1566 (patch) | |
tree | 063ffbadbb682e8d8a899be1dfd9c13eb671ef74 | |
parent | 44a5177c51082223c8d50b5eef8d28019d953b6f (diff) | |
download | eclipse.platform.ui-8fd52eac48e2360d6fce79a91ee0c284927d1566.tar.gz eclipse.platform.ui-8fd52eac48e2360d6fce79a91ee0c284927d1566.tar.xz eclipse.platform.ui-8fd52eac48e2360d6fce79a91ee0c284927d1566.zip |
Bug 368187 - Services pre-API cleanupv20120109-1955
3 files changed, 0 insertions, 329 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 e0de93784b8..3b73474da3a 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 @@ -73,7 +73,6 @@ import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.jface.databinding.swt.SWTObservables; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.window.IShellProvider; import org.eclipse.osgi.service.datalocation.Location; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; @@ -511,12 +510,6 @@ public class E4Application implements IApplication { } }); - appContext.set(IShellProvider.class, new IShellProvider() { - public Shell getShell() { - return null; - } - }); - return appContext; } 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 6ad0156c604..1b8a2e91ae1 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 @@ -13,9 +13,7 @@ package org.eclipse.e4.ui.internal.workbench; import java.util.Iterator; import java.util.List; -import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.e4.core.commands.EHandlerService; -import org.eclipse.e4.core.contexts.ContextInjectionFactory; import org.eclipse.e4.core.contexts.EclipseContextFactory; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.services.contributions.IContributionFactory; @@ -27,14 +25,10 @@ import org.eclipse.e4.ui.model.application.commands.MHandlerContainer; import org.eclipse.e4.ui.model.application.ui.MContext; import org.eclipse.e4.ui.model.application.ui.MElementContainer; import org.eclipse.e4.ui.model.application.ui.MUIElement; -import org.eclipse.e4.ui.services.IServiceConstants; -import org.eclipse.e4.ui.services.IStylingEngine; -import org.eclipse.e4.ui.workbench.IExceptionHandler; import org.eclipse.e4.ui.workbench.IPresentationEngine; import org.eclipse.e4.ui.workbench.IWorkbench; import org.eclipse.e4.ui.workbench.modeling.ExpressionContext; import org.eclipse.emf.common.notify.Notifier; -import org.w3c.dom.css.CSSStyleDeclaration; public class E4Workbench implements IWorkbench { public static final String LOCAL_ACTIVE_SHELL = "localActiveShell"; //$NON-NLS-1$ @@ -156,35 +150,6 @@ public class E4Workbench implements IWorkbench { return appModel; } - // FIXME We should have one place to setup the generic context stuff (see - // E4Application#createDefaultContext()) - public static IEclipseContext createWorkbenchContext(final IEclipseContext applicationContext, - IExtensionRegistry registry, IExceptionHandler exceptionHandler, - IContributionFactory contributionFactory) { - Activator - .trace(Policy.DEBUG_CONTEXTS, - "createWorkbenchContext: initialize the workbench context with needed services", null); //$NON-NLS-1$ - final IEclipseContext mainContext = applicationContext.createChild("WorkbenchContext"); //$NON-NLS-1$ - mainContext.set(Logger.class.getName(), - ContextInjectionFactory.make(WorkbenchLogger.class, mainContext)); - - // setup for commands and handlers - if (contributionFactory != null) { - mainContext.set(IContributionFactory.class.getName(), contributionFactory); - } - mainContext.set(IServiceConstants.ACTIVE_PART, new ActivePartLookupFunction()); - // EHandlerService comes from a ContextFunction - // EContextService comes from a ContextFunction - mainContext.set(IExceptionHandler.class.getName(), exceptionHandler); - mainContext.set(IExtensionRegistry.class.getName(), registry); - mainContext.set(IServiceConstants.ACTIVE_SHELL, new ActiveChildLookupFunction( - IServiceConstants.ACTIVE_SHELL, null)); - - initializeNullStyling(mainContext); - - return mainContext; - } - public static void processHierarchy(Object me) { if (me instanceof MHandlerContainer) { MContext contextModel = (MContext) me; @@ -249,29 +214,4 @@ public class E4Workbench implements IWorkbench { return context; } - /* - * For use when there is no real styling engine present. Has no behaviour but conforms to - * IStylingEngine API. - * - * @param appContext - */ - private static void initializeNullStyling(IEclipseContext appContext) { - appContext.set(IStylingEngine.SERVICE_NAME, new IStylingEngine() { - public void setClassname(Object widget, String classname) { - } - - public void setId(Object widget, String id) { - } - - public void style(Object widget) { - } - - public CSSStyleDeclaration getStyle(Object widget) { - return null; - } - - public void setClassnameAndId(Object widget, String classname, String id) { - } - }); - } } diff --git a/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/RenderingTestCase.java b/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/RenderingTestCase.java deleted file mode 100644 index 7262627e496..00000000000 --- a/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/RenderingTestCase.java +++ /dev/null @@ -1,262 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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 - ******************************************************************************/ - -package org.eclipse.e4.ui.tests.workbench; - -import junit.framework.TestCase; -import org.eclipse.core.databinding.observable.Realm; -import org.eclipse.core.runtime.RegistryFactory; -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.ui.internal.workbench.E4Workbench; -import org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory; -import org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine; -import org.eclipse.e4.ui.model.application.MApplication; -import org.eclipse.e4.ui.model.application.impl.ApplicationFactoryImpl; -import org.eclipse.e4.ui.model.application.ui.basic.MWindow; -import org.eclipse.e4.ui.tests.Activator; -import org.eclipse.e4.ui.workbench.IPresentationEngine; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Widget; - -/** - * This is the base class for tests involving the interactions between the UI - * Model and the SWT Renderer. It is optimized to reduce the overhead - * <p> - * It provides various utility methods but also enforces automatic tests to - * ensure that all models rendered through it conform to the expected structural - * result: - * <ol> - * <li>All visible UI Model elements result in a widget</li> - * <li>The UI Model element and its SWT Widget are correctly 'bound'</li> - * <li>The correct SWT widget is created for a given UI Model element</li> - * <ul> - * <li>MWindow -> Shell</li> - * <li>MSashForm -> SashForm</li> - * <li>MStack -> CTabFol2der</li> - * <li>MContributedPart -> Composite</li> - * </ul> - * <li>The name of an MItem is correctly set in the resulting SWT widget</li> - * <li>The Image of an MItem is correctly set in the resulting SWT widget</li> - * <li>The Tooltip Text of an MItem is correctly set in the resulting SWT widget - * </li> - * </ol> - * </p> - */ -public class RenderingTestCase extends TestCase { - // 'constant' fields: static for all tests - protected static IContributionFactory contributionFactory = new ReflectionContributionFactory( - RegistryFactory.getRegistry()); - - protected static IEclipseContext serviceContext = EclipseContextFactory - .getServiceContext(Activator.getDefault().getBundle() - .getBundleContext()); - - protected static MApplication app = ApplicationFactoryImpl.eINSTANCE - .createApplication(); - - protected static Display display = Display.getCurrent() != null ? Display - .getCurrent() : new Display(); - - // 'transient' fields: re-created for each test - protected IPresentationEngine renderer; - protected IEclipseContext appContext; - protected Widget topWidget; - - protected long startTime; - - /** - * Test cases derived from this class are used to test the Model <-> (SWT) - * UI relationships. These tests will ensure that the correct controls are - * created and that the various listeners (data bindings...) behave - * correctly. - */ - public RenderingTestCase() { - } - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#setUp() - */ - @Override - protected void setUp() throws Exception { - System.out.println("Setup"); - startTime = System.currentTimeMillis(); - super.setUp(); - - // Create a fresh org.eclipse.e4.ui.model.application context for each - // test - IEclipseContext serviceContext = EclipseContextFactory - .getServiceContext(Activator.getDefault().getBundle() - .getBundleContext()); - - appContext = E4Workbench.createWorkbenchContext(serviceContext, - RegistryFactory.getRegistry(), null, null); - MApplication app = ApplicationFactoryImpl.eINSTANCE.createApplication(); - - appContext.set(MApplication.class.getName(), app); - appContext.set(IContributionFactory.class.getName(), - contributionFactory); - - app.setContext(appContext); - } - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#tearDown() - */ - @Override - protected void tearDown() throws Exception { - System.out.print("tearDown"); - super.tearDown(); - - // dispose the current context - appContext = null; - renderer = null; - - if (topWidget != null) { - if (!topWidget.isDisposed()) - topWidget.dispose(); - - // TBD: Should check the model to make sure it's been cleaned - // here... - topWidget = null; - } - System.out.println(" time: " - + (System.currentTimeMillis() - startTime) + "ms"); - } - - protected void processEventLoop() { - if (display != null) { - while (display.readAndDispatch()) - ; - } - } - - protected Widget createModel(final MWindow window) { - MApplication application = (MApplication) appContext - .get(MApplication.class.getName()); - application.getChildren().add(window); - - final Widget[] renderedObject = new Widget[1]; - renderedObject[0] = null; - Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() { - public void run() { - // Capture the expected 'invariant' results - // SWTResult expectedResults = createSWTResultTree(modelRoot); - - renderer = (PartRenderingEngine) contributionFactory.create( - PartRenderingEngine.engineURI, appContext); - Object o = renderer.createGui(window); - assertTrue("No widget rendered for: " + window.toString(), - o != null); - assertTrue("Rendered object is not a Widget: " - + o.getClass().getName(), o instanceof Widget); - - renderedObject[0] = (Widget) o; - - // Test the invariants - // checkResults(expectedResults, renderedObject[0]); - } - }); - return renderedObject[0]; - } - - public void checkResults(SWTResult expected, Widget renderedObject) { - // assertNotNull("The Control is Null " + expected.clazz.getName(), - // renderedObject); - // boolean classOK = (expected.clazz == renderedObject.getClass()); - // assertTrue("Class mismatch; expected: " + expected.clazz.getName() - // + " actual: " + renderedObject.getClass().getName(), classOK); - // if (expected.text != null) { - // if (renderedObject instanceof Shell) { - // String shellText = ((Shell) renderedObject).getText(); - // assertTrue("Text mismatch; expected: " + expected.text - // + " actual: " + shellText, expected.text - // .equals(shellText)); - // } - // } - // if (!expected.kids.isEmpty()) { - // if (renderedObject instanceof Composite) { - // Control[] controlKids = ((Composite) renderedObject) - // .getChildren(); - // // Special check to remove the 'Sash' elements from a SashForm - // if (renderedObject instanceof SashForm) { - // List<Control> nonSashes = new ArrayList<Control>(); - // for (int i = 0; i < controlKids.length; i++) { - // if (controlKids[i] instanceof Sash) - // continue; - // nonSashes.add(controlKids[i]); - // } - // controlKids = new Control[nonSashes.size()]; - // int count = 0; - // for (Iterator<Control> iterator = nonSashes.iterator(); iterator - // .hasNext();) { - // Control ctrl = iterator.next(); - // controlKids[count++] = ctrl; - // } - // // controlKids = (Control[]) nonSashes.toArray(); - // } - // - // assertTrue("Child count mismatch; expected: " - // + expected.kids.size() + "actual: " - // + controlKids.length, - // expected.kids.size() == controlKids.length); - // Iterator kidIter = expected.kids.iterator(); - // for (Control kid : controlKids) { - // SWTResult currKid = (SWTResult) kidIter.next(); - // checkResults(currKid, kid); - // } - // } - // } - } - - // public static SWTResult createSWTResultTree(MPart element) { - // if (!element.isVisible()) - // return null; - // - // // Determine the expected control type based on the model's type - // // NOTE: would be nice to get this from the various factories - // Class elementClass = element.getClass(); - // Class expectedClass = null; - // if (elementClass == WorkbenchWindowImpl.class) { - // expectedClass = Shell.class; - // } else if (elementClass == PartSashContainerImpl.class) { - // expectedClass = SashForm.class; - // } else if (elementClass == PartStackImpl.class) { - // expectedClass = CTabFolder.class; - // } else if (elementClass == PartImpl.class) { - // expectedClass = Composite.class; - // } - // - // // Capture the name - // String theName = null; - // if (element instanceof MItem) { - // theName = ((MItem) element).getName(); - // } - // - // // Create a result entry for each child element - // EList<?> list = element.getChildren(); - // SWTResult[] childList = null; - // if (!list.isEmpty()) { - // childList = new SWTResult[list.size()]; - // for (int i = 0; i < list.size(); i++) { - // childList[i] = createSWTResultTree((MPart) list.get(i)); - // } - // } - // return new SWTResult(expectedClass, theName, childList); - // } - -} |