Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdgar Mueller2014-09-12 13:09:14 +0000
committerEdgar Mueller2014-09-12 16:24:29 +0000
commit3bd43f3d616bee2d8842e6f73de783f4613a579b (patch)
tree51dc69a10385c0f64982af085d313869f6b7594b
parentb249ab430e6f7e586d4aee2982f8fcc74974f380 (diff)
downloadorg.eclipse.emf.ecp.core-reportService-feature.tar.gz
org.eclipse.emf.ecp.core-reportService-feature.tar.xz
org.eclipse.emf.ecp.core-reportService-feature.zip
WIP debug renderer & reportingreportService-feature
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/META-INF/MANIFEST.MF9
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/Activator.java15
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/DebugViewModelService.java55
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/ECPSWTViewRendererImpl.java49
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/EmptyVElementSWTRenderer.java76
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/SWTRendererFactoryImpl.java106
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/AmbiguousRendererPriorityError.java103
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/CustomControlInitFailedError.java71
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/ECPRendererDescriptionInitFailedError.java72
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/InvalidGridDescriptionError.java67
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/NoRendererFoundError.java70
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/NoRenderingPossibleError.java71
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/RendererInitFailedError.java71
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view/META-INF/MANIFEST.MF36
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/internal/provider/ViewProviderImpl.java183
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/internal/ui/Activator.java227
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/NoViewProviderError.java54
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewModelIsNullError.java55
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewProviderHelper.java174
-rw-r--r--bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewProviderInitFailedError.java71
-rw-r--r--bundles/org.eclipse.emf.ecp.view.context/META-INF/MANIFEST.MF7
-rw-r--r--bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/internal/context/Activator.java194
-rw-r--r--bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/internal/context/ViewModelContextImpl.java10
-rw-r--r--bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/internal/reporting/LogConsumer.java35
-rw-r--r--bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/internal/reporting/ReportServiceImpl.java89
-rw-r--r--bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/internal/reporting/ViewModelServiceNotAvailableError.java78
-rw-r--r--bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/spi/reporting/ReportEntity.java47
-rw-r--r--bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/spi/reporting/ReportService.java59
-rw-r--r--bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/spi/reporting/ReportServiceConsumer.java32
-rw-r--r--bundles/org.eclipse.emf.ecp.view.core.swt/META-INF/MANIFEST.MF14
-rw-r--r--bundles/org.eclipse.emf.ecp.view.custom.ui.swt/src/org/eclipse/emf/ecp/view/internal/custom/swt/Activator.java249
-rw-r--r--bundles/org.eclipse.emf.ecp.view.custom.ui.swt/src/org/eclipse/emf/ecp/view/spi/custom/swt/CustomControlSWTRenderer.java28
-rw-r--r--bundles/org.eclipse.emf.ecp.view.model.common/META-INF/MANIFEST.MF12
-rw-r--r--tests/org.eclipse.emf.ecp.view.context.test/META-INF/MANIFEST.MF12
-rw-r--r--tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/RendererErrorTest.java205
-rw-r--r--tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/SWTTestRendererFactoryImpl.java46
-rw-r--r--tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/TestSWTRendererFactory.java76
-rw-r--r--tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/MockViewSWTRenderer.java33
-rw-r--r--tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/ViewSWTRendererWithInvalidGridDescription.java25
-rw-r--r--tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/ViewSWTRendererWithNoPropertyDescriptorFoundException.java34
-rw-r--r--tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/ViewSWTRendererWithNoRendererFoundException.java32
-rw-r--r--tests/org.eclipse.emf.ecp.view.core.swt.tests/plugin.xml14
-rw-r--r--tests/org.eclipse.emf.ecp.view.test.common.swt/META-INF/MANIFEST.MF3
43 files changed, 2381 insertions, 588 deletions
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.emf.ecp.ui.view.swt/META-INF/MANIFEST.MF
index 8342c076dc..35dd112d76 100644
--- a/bundles/org.eclipse.emf.ecp.ui.view.swt/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.emf.ecp.ui.view.swt/META-INF/MANIFEST.MF
@@ -14,10 +14,11 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.emf.ecp.view.model.common;bundle-version="[1.4.0,2.0.0)";visibility:=reexport
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.emf.ecp.ui.view.swt;version="1.5.0",org.ec
- lipse.emf.ecp.view.internal.swt;version="1.5.0";x-friends:="org.eclip
- se.emf.ecp.view.table.ui.swt.test",org.eclipse.emf.ecp.view.spi.swt;v
- ersion="1.5.0",org.eclipse.emf.ecp.view.spi.swt.layout;version="1.5.0"
+Export-Package: org.eclipse.emf.ecp.ui.view.swt;version="1.5.0",
+ org.eclipse.emf.ecp.view.internal.swt;version="1.5.0";x-friends:="org.eclipse.emf.ecp.view.table.ui.swt.test,org.eclipse.emf.ecp.view.context.test",
+ org.eclipse.emf.ecp.view.spi.swt;version="1.5.0",
+ org.eclipse.emf.ecp.view.spi.swt.layout;version="1.5.0",
+ org.eclipse.emf.ecp.view.spi.swt.reporting;version="1.5.0"
Import-Package: org.eclipse.core.commands;version="0.0.0",
org.eclipse.jface;version="0.0.0",
org.eclipse.jface.action;version="0.0.0",
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/Activator.java b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/Activator.java
index 8578a2e963..8456ae903e 100644
--- a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/Activator.java
+++ b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/Activator.java
@@ -14,7 +14,9 @@ package org.eclipse.emf.ecp.view.internal.swt;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportService;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
/**
* The activator class controls the plug-in life cycle.
@@ -73,4 +75,17 @@ public class Activator extends Plugin {
new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e
.getMessage(), e));
}
+
+ /**
+ * Returns the {@link ReportService}.
+ *
+ * @return the {@link ReportService}
+ */
+ public ReportService getReportService() {
+ final BundleContext bundleContext = getBundle().getBundleContext();
+ final ServiceReference<ReportService> serviceReference =
+ bundleContext.getServiceReference(ReportService.class);
+ return bundleContext.getService(serviceReference);
+ }
+
}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/DebugViewModelService.java b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/DebugViewModelService.java
deleted file mode 100644
index f051e500fd..0000000000
--- a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/DebugViewModelService.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
- * Eugen - initial API and implementation
- ******************************************************************************/
-package org.eclipse.emf.ecp.view.internal.swt;
-
-import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
-import org.eclipse.emf.ecp.view.spi.context.ViewModelService;
-
-/**
- * @author Eugen
- *
- */
-public class DebugViewModelService implements ViewModelService {
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.ecp.view.spi.context.ViewModelService#instantiate(org.eclipse.emf.ecp.view.spi.context.ViewModelContext)
- */
- @Override
- public void instantiate(ViewModelContext context) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.ecp.view.spi.context.ViewModelService#dispose()
- */
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.ecp.view.spi.context.ViewModelService#getPriority()
- */
- @Override
- public int getPriority() {
- return 1000;
- }
-
-}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/ECPSWTViewRendererImpl.java b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/ECPSWTViewRendererImpl.java
index 31f7aed326..c01b920877 100644
--- a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/ECPSWTViewRendererImpl.java
+++ b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/ECPSWTViewRendererImpl.java
@@ -17,15 +17,20 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecp.ui.view.ECPRendererException;
import org.eclipse.emf.ecp.ui.view.swt.ECPSWTView;
import org.eclipse.emf.ecp.ui.view.swt.ECPSWTViewRenderer;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportService;
import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
import org.eclipse.emf.ecp.view.spi.context.ViewModelContextFactory;
import org.eclipse.emf.ecp.view.spi.model.VElement;
import org.eclipse.emf.ecp.view.spi.model.VView;
import org.eclipse.emf.ecp.view.spi.provider.ViewProviderHelper;
+import org.eclipse.emf.ecp.view.spi.renderer.NoPropertyDescriptorFoundExeption;
+import org.eclipse.emf.ecp.view.spi.renderer.NoRendererFoundException;
import org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer;
import org.eclipse.emf.ecp.view.spi.swt.SWTRendererFactory;
import org.eclipse.emf.ecp.view.spi.swt.layout.GridDescriptionFactory;
import org.eclipse.emf.ecp.view.spi.swt.layout.SWTGridDescription;
+import org.eclipse.emf.ecp.view.spi.swt.reporting.InvalidGridDescriptionError;
+import org.eclipse.emf.ecp.view.spi.swt.reporting.NoRenderingPossibleError;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
@@ -36,6 +41,15 @@ import org.eclipse.swt.widgets.Composite;
*/
public class ECPSWTViewRendererImpl implements ECPSWTViewRenderer {
+ private final SWTRendererFactory factory;
+
+ /**
+ * Constructor.
+ */
+ public ECPSWTViewRendererImpl() {
+ factory = createFactory();
+ }
+
/**
* {@inheritDoc}
*
@@ -68,24 +82,36 @@ public class ECPSWTViewRendererImpl implements ECPSWTViewRenderer {
*/
@Override
public ECPSWTView render(Composite parent, ViewModelContext viewModelContext) throws ECPRendererException {
- final SWTRendererFactory factory = new SWTRendererFactoryImpl();
final AbstractSWTRenderer<VElement> renderer = factory.getRenderer(
viewModelContext.getViewModel(),
viewModelContext);
+
+ final ReportService reportService = Activator.getDefault().getReportService();
+
final SWTGridDescription gridDescription = renderer.getGridDescription(GridDescriptionFactory.INSTANCE
.createEmptyGridDescription());
if (gridDescription.getGrid().size() != 1) {
+ reportService.report(
+ new InvalidGridDescriptionError("Invalid number of cells, expected exactly one cell!")); //$NON-NLS-1$
+ // TODO: RS
// do sth. if wrong number of controls
throw new IllegalStateException("Invalid number of cells, expected exactly one cell!"); //$NON-NLS-1$
}
- // a view returns always a composite and always only one row with one control
- final Composite composite = (Composite) renderer.render(gridDescription.getGrid().get(0), parent);
- renderer.finalizeRendering(parent);
- final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
- composite.setLayoutData(gridData);
+ // a view returns always a composite and always only one row with one control
+ ECPSWTView swtView = null;
+ try {
+ final Composite composite = (Composite) renderer.render(gridDescription.getGrid().get(0), parent);
+ renderer.finalizeRendering(parent);
+ final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ composite.setLayoutData(gridData);
+ swtView = new ECPSWTViewImpl(composite, viewModelContext);
+ } catch (final NoRendererFoundException e) {
+ reportService.report(new NoRenderingPossibleError<NoRendererFoundException>(e));
+ } catch (final NoPropertyDescriptorFoundExeption e) {
+ reportService.report(new NoRenderingPossibleError<NoPropertyDescriptorFoundExeption>(e));
+ }
- final ECPSWTView swtView = new ECPSWTViewImpl(composite, viewModelContext);
return swtView;
}
@@ -102,4 +128,13 @@ public class ECPSWTViewRendererImpl implements ECPSWTViewRenderer {
return render(parent, domainObject, view);
}
+ /**
+ * Returns the {@link SWTRendererFactory} used to obtain any SWT renderer.
+ * Clients may override.
+ *
+ * @return the {@link SWTRendererFactory}
+ */
+ protected SWTRendererFactory createFactory() {
+ return new SWTRendererFactoryImpl();
+ }
}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/EmptyVElementSWTRenderer.java b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/EmptyVElementSWTRenderer.java
new file mode 100644
index 0000000000..a2ff8ae82b
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/EmptyVElementSWTRenderer.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.internal.swt;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecp.view.spi.model.VElement;
+import org.eclipse.emf.ecp.view.spi.renderer.NoPropertyDescriptorFoundExeption;
+import org.eclipse.emf.ecp.view.spi.renderer.NoRendererFoundException;
+import org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer;
+import org.eclipse.emf.ecp.view.spi.swt.layout.GridDescriptionFactory;
+import org.eclipse.emf.ecp.view.spi.swt.layout.SWTGridCell;
+import org.eclipse.emf.ecp.view.spi.swt.layout.SWTGridDescription;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * An no-op renderer.
+ *
+ * @author emueller
+ * @since 1.3
+ *
+ */
+public final class EmptyVElementSWTRenderer extends AbstractSWTRenderer<VElement> {
+
+ private final SWTGridDescription gridDescription;
+
+ /**
+ * Default constructor.
+ */
+ public EmptyVElementSWTRenderer() {
+ super();
+ gridDescription = GridDescriptionFactory.INSTANCE.createEmptyGridDescription();
+ final SWTGridCell gc = new SWTGridCell(0, 0, this);
+ gc.setHorizontalFill(true);
+ gc.setHorizontalGrab(true);
+ gc.setVerticalFill(false);
+ gc.setVerticalGrab(false);
+ final List<SWTGridCell> grid = new ArrayList<SWTGridCell>();
+ grid.add(gc);
+ gridDescription.setGrid(grid);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer#getGridDescription(org.eclipse.emf.ecp.view.spi.swt.layout.SWTGridDescription)
+ */
+ @Override
+ public SWTGridDescription getGridDescription(SWTGridDescription gridDescription) {
+ return this.gridDescription;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer#renderControl(org.eclipse.emf.ecp.view.spi.swt.layout.SWTGridCell,
+ * org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control renderControl(SWTGridCell cell, Composite parent) throws NoRendererFoundException,
+ NoPropertyDescriptorFoundExeption {
+ return parent;
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/SWTRendererFactoryImpl.java b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/SWTRendererFactoryImpl.java
index a49aaea197..45791f4e27 100644
--- a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/SWTRendererFactoryImpl.java
+++ b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/internal/swt/SWTRendererFactoryImpl.java
@@ -23,6 +23,8 @@ import org.eclipse.core.runtime.InvalidRegistryObjectException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecp.view.model.common.ECPRendererTester;
import org.eclipse.emf.ecp.view.model.common.ECPStaticRendererTester;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportService;
import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
import org.eclipse.emf.ecp.view.spi.model.VElement;
import org.eclipse.emf.ecp.view.spi.swt.AbstractAdditionalSWTRenderer;
@@ -30,13 +32,17 @@ import org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer;
import org.eclipse.emf.ecp.view.spi.swt.ECPAdditionalRendererTester;
import org.eclipse.emf.ecp.view.spi.swt.SWTRendererFactory;
import org.eclipse.emf.ecp.view.spi.swt.UnknownVElementSWTRenderer;
+import org.eclipse.emf.ecp.view.spi.swt.reporting.AmbiguousRendererPriorityError;
+import org.eclipse.emf.ecp.view.spi.swt.reporting.ECPRendererDescriptionInitFailedError;
+import org.eclipse.emf.ecp.view.spi.swt.reporting.NoRendererFoundError;
+import org.eclipse.emf.ecp.view.spi.swt.reporting.RendererInitFailedError;
import org.osgi.framework.Bundle;
/**
* @author Eugen
*
*/
-public final class SWTRendererFactoryImpl implements SWTRendererFactory {
+public class SWTRendererFactoryImpl implements SWTRendererFactory {
private static final String TEST_DYNAMIC = "dynamicTest";//$NON-NLS-1$
private static final String TEST_STATIC = "staticTest";//$NON-NLS-1$
@@ -49,9 +55,22 @@ public final class SWTRendererFactoryImpl implements SWTRendererFactory {
// private final Map<Class<? extends VElement>, AbstractSWTRenderer<VElement>> rendererMapping = new
// LinkedHashMap<Class<? extends VElement>, AbstractSWTRenderer<VElement>>();
- private final Set<ECPRendererDescription> rendererDescriptors = new LinkedHashSet<ECPRendererDescription>();
- private final Set<ECPAdditionalRendererDescription> additionalRendererDescriptors = new LinkedHashSet<ECPAdditionalRendererDescription>();
- private boolean debugMode = false;
+ /**
+ * A description of all available renderers.
+ */
+ private final Set<ECPRendererDescription> rendererDescriptors =
+ new LinkedHashSet<ECPRendererDescription>();
+
+ /**
+ * A description of all additionally available renderers.
+ */
+ private final Set<ECPAdditionalRendererDescription> additionalRendererDescriptors =
+ new LinkedHashSet<ECPAdditionalRendererDescription>();
+
+ /**
+ * Whether EMF Forms is running in debug mode.
+ */
+ private boolean debugMode;
/**
* Default constructor for the renderer factory.
@@ -68,6 +87,24 @@ public final class SWTRendererFactoryImpl implements SWTRendererFactory {
readAdditionalRenderer();
}
+ /**
+ * Returns a set of descriptions of all additionally available renderers.
+ *
+ * @return a set of descriptions of all additionally available renderers.
+ */
+ protected Set<ECPAdditionalRendererDescription> getAdditionalRendererDescriptors() {
+ return additionalRendererDescriptors;
+ }
+
+ /**
+ * Returns a set of descriptions of all available renderers.
+ *
+ * @return a set of descriptions of all available renderers.
+ */
+ protected Set<ECPRendererDescription> getRendererDescriptors() {
+ return rendererDescriptors;
+ }
+
private void readRenderer() {
final IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
.getExtensionPoint(RENDER_EXTENSION);
@@ -101,11 +138,11 @@ public final class SWTRendererFactoryImpl implements SWTRendererFactory {
rendererDescriptors.add(new ECPRendererDescription(renderer, tester));
} catch (final CoreException ex) {
- ex.printStackTrace();
- } catch (final ClassNotFoundException e) {
- e.printStackTrace();
- } catch (final InvalidRegistryObjectException e) {
- e.printStackTrace();
+ report(new ECPRendererDescriptionInitFailedError<CoreException>(ex));
+ } catch (final ClassNotFoundException ex) {
+ report(new ECPRendererDescriptionInitFailedError<ClassNotFoundException>(ex));
+ } catch (final InvalidRegistryObjectException ex) {
+ report(new ECPRendererDescriptionInitFailedError<InvalidRegistryObjectException>(ex));
}
}
}
@@ -133,16 +170,20 @@ public final class SWTRendererFactoryImpl implements SWTRendererFactory {
additionalRendererDescriptors.add(new ECPAdditionalRendererDescription(renderer, tester));
} catch (final CoreException ex) {
- ex.printStackTrace();
+ report(new ECPRendererDescriptionInitFailedError<CoreException>(ex));
} catch (final ClassNotFoundException e) {
- e.printStackTrace();
+ report(new ECPRendererDescriptionInitFailedError<ClassNotFoundException>(e));
} catch (final InvalidRegistryObjectException e) {
- e.printStackTrace();
+ report(new ECPRendererDescriptionInitFailedError<InvalidRegistryObjectException>(e));
}
}
}
}
+ private void report(ReportEntity reportEntity) {
+ Activator.getDefault().getReportService().report(reportEntity);
+ }
+
@SuppressWarnings("unchecked")
private static <T> Class<T> loadClass(String bundleName, String clazz)
throws ClassNotFoundException {
@@ -183,8 +224,11 @@ public final class SWTRendererFactoryImpl implements SWTRendererFactory {
*/
@Override
public AbstractSWTRenderer<VElement> getRenderer(VElement vElement, ViewModelContext viewContext) {
+
int highestPriority = -1;
AbstractSWTRenderer<VElement> bestCandidate = null;
+ final ReportService reportService = Activator.getDefault().getReportService();
+
for (final ECPRendererDescription description : rendererDescriptors) {
int currentPriority = -1;
@@ -197,30 +241,42 @@ public final class SWTRendererFactoryImpl implements SWTRendererFactory {
}
+ if (currentPriority == highestPriority && highestPriority != -1) {
+ reportService.report(
+ new AmbiguousRendererPriorityError(
+ currentPriority,
+ description.getRenderer().getClass().getCanonicalName(),
+ bestCandidate.getClass().getCanonicalName()));
+ }
+
if (currentPriority > highestPriority) {
highestPriority = currentPriority;
try {
bestCandidate = description.getRenderer().newInstance();
} catch (final InstantiationException ex) {
- Activator.log(ex);
- return null;
+ reportService.report(new RendererInitFailedError<InstantiationException>(ex));
} catch (final IllegalAccessException ex) {
- Activator.log(ex);
- return null;
+ reportService.report(new RendererInitFailedError<IllegalAccessException>(ex));
}
}
}
- if (bestCandidate == null && showUnknownRenderer(viewContext)) {
- bestCandidate = new UnknownVElementSWTRenderer();
+ if (bestCandidate == null) {
+ reportService.report(new NoRendererFoundError(vElement));
+ if (showUnknownRenderer(viewContext)) {
+ bestCandidate = new UnknownVElementSWTRenderer();
+ } else {
+ bestCandidate = new EmptyVElementSWTRenderer();
+ }
}
+
bestCandidate.init(vElement, viewContext);
+
return bestCandidate;
}
private boolean showUnknownRenderer(ViewModelContext viewModelContext) {
-
- return debugMode || viewModelContext.hasService(DebugViewModelService.class);
+ return debugMode;
}
/**
@@ -233,7 +289,11 @@ public final class SWTRendererFactoryImpl implements SWTRendererFactory {
@Override
public Collection<AbstractAdditionalSWTRenderer<VElement>> getAdditionalRenderer(VElement vElement,
ViewModelContext viewModelContext) {
- final Set<AbstractAdditionalSWTRenderer<VElement>> renderers = new LinkedHashSet<AbstractAdditionalSWTRenderer<VElement>>();
+
+ final ReportService reportService = Activator.getDefault().getReportService();
+ final Set<AbstractAdditionalSWTRenderer<VElement>> renderers =
+ new LinkedHashSet<AbstractAdditionalSWTRenderer<VElement>>();
+
for (final ECPAdditionalRendererDescription description : additionalRendererDescriptors) {
final ECPAdditionalRendererTester tester = description.getTester();
if (tester.isApplicable(vElement, viewModelContext)) {
@@ -244,10 +304,10 @@ public final class SWTRendererFactoryImpl implements SWTRendererFactory {
renderers.add(renderer);
continue;
} catch (final InstantiationException ex) {
- Activator.log(ex);
+ reportService.report(new RendererInitFailedError<InstantiationException>(ex));
continue;
} catch (final IllegalAccessException ex) {
- Activator.log(ex);
+ reportService.report(new RendererInitFailedError<IllegalAccessException>(ex));
continue;
}
}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/AmbiguousRendererPriorityError.java b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/AmbiguousRendererPriorityError.java
new file mode 100644
index 0000000000..bdc4652444
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/AmbiguousRendererPriorityError.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.spi.swt.reporting;
+
+import java.text.MessageFormat;
+
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+
+/**
+ * An error that indicates that two renderers with the same priority have been found.
+ *
+ * @author emueller
+ *
+ */
+public class AmbiguousRendererPriorityError implements ReportEntity {
+
+ private final int priority;
+ private final String rendererName;
+ private final String otherRendererName;
+
+ /**
+ * Constructor.
+ *
+ * @param priority
+ * the ambiguous priority
+ * @param rendererName
+ * the name of the first renderer
+ * @param otherRendererName
+ * the name of the second renderer
+ */
+ public AmbiguousRendererPriorityError(int priority, String rendererName, String otherRendererName) {
+ this.priority = priority;
+ this.rendererName = rendererName;
+ this.otherRendererName = otherRendererName;
+ }
+
+ /**
+ * Returns the name of the first renderer.
+ *
+ * @return the name of the first renderer
+ */
+ public String getRendererName() {
+ return rendererName;
+ }
+
+ /**
+ * Returns the name of the second renderer.
+ *
+ * @return the name of the second renderer
+ */
+ public String getOtherRendererName() {
+ return otherRendererName;
+ }
+
+ /**
+ * Returns the priority.
+ *
+ * @return the priority
+ */
+ public int getPriority() {
+ return priority;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return MessageFormat.format("The {0} and the {1} renderers both have priority {2}.", //$NON-NLS-1$
+ rendererName, otherRendererName, priority);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#hasException()
+ */
+ @Override
+ public boolean hasException() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getException()
+ */
+ @Override
+ public <T extends Exception> T getException() {
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/CustomControlInitFailedError.java b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/CustomControlInitFailedError.java
new file mode 100644
index 0000000000..bc756f9f51
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/CustomControlInitFailedError.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.spi.swt.reporting;
+
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+
+/**
+ * Indicates that the initialization of a custom control failed.
+ *
+ * @author emueller
+ *
+ */
+public class CustomControlInitFailedError implements ReportEntity {
+
+ private final String bundleName;
+ private final String customControlClassName;
+
+ /**
+ * Constructor.
+ *
+ * @param bundleName
+ * the name of the bundle containing the custom control
+ * @param customControlClassName
+ * the name of the class for the custom control
+ */
+ public CustomControlInitFailedError(String bundleName, String customControlClassName) {
+ this.bundleName = bundleName;
+ this.customControlClassName = customControlClassName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return String.format("The %1$s/%2$s cannot be loaded!", //$NON-NLS-1$
+ bundleName, customControlClassName);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#hasException()
+ */
+ @Override
+ public boolean hasException() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getException()
+ */
+ @Override
+ public <T extends Exception> T getException() {
+ return null;
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/ECPRendererDescriptionInitFailedError.java b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/ECPRendererDescriptionInitFailedError.java
new file mode 100644
index 0000000000..05ce7fed71
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/ECPRendererDescriptionInitFailedError.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.spi.swt.reporting;
+
+import java.text.MessageFormat;
+
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+
+/**
+ * Indicates that an {@link org.eclipse.emf.ecp.view.internal.swt.ECPRendererDescription ECPRendererDescription} could
+ * not be initialized.
+ *
+ * @author emueller
+ *
+ * @param <E> the underlying exception type
+ */
+public class ECPRendererDescriptionInitFailedError<E extends Exception> implements ReportEntity {
+
+ private final E exception;
+
+ /**
+ * Constructor.
+ *
+ * @param exception
+ * the underlying exception
+ */
+ public ECPRendererDescriptionInitFailedError(E exception) {
+ this.exception = exception;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return MessageFormat.format("ECPRendererDescription initialization failed due to: {0}", //$NON-NLS-1$
+ exception.getMessage());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#hasException()
+ */
+ @Override
+ public boolean hasException() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getException()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public E getException() {
+ return exception;
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/InvalidGridDescriptionError.java b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/InvalidGridDescriptionError.java
new file mode 100644
index 0000000000..967bb1d032
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/InvalidGridDescriptionError.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.spi.swt.reporting;
+
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+
+/**
+ * Indicates that a renderer returned an invalid grid description.
+ *
+ * @author emueller
+ *
+ */
+public class InvalidGridDescriptionError implements ReportEntity {
+
+ private final String msg;
+
+ /**
+ * Constructor.
+ *
+ * @param msg
+ * an error message
+ */
+ public InvalidGridDescriptionError(String msg) {
+ this.msg = msg;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return msg;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#hasException()
+ */
+ @Override
+ public boolean hasException() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getException()
+ */
+ @Override
+ public <T extends Exception> T getException() {
+ return null;
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/NoRendererFoundError.java b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/NoRendererFoundError.java
new file mode 100644
index 0000000000..2184d43f10
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/NoRendererFoundError.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.spi.swt.reporting;
+
+import java.text.MessageFormat;
+
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+import org.eclipse.emf.ecp.view.spi.model.VElement;
+
+/**
+ * Indicates that no renderer has been found.
+ *
+ * @author emueller
+ *
+ */
+public class NoRendererFoundError implements ReportEntity {
+
+ private final VElement element;
+
+ /**
+ * Constructor.
+ *
+ * @param element
+ * the {@link VElement} for which no renderer could be found
+ */
+ public NoRendererFoundError(VElement element) {
+ this.element = element;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return MessageFormat.format("No renderer found for element {0}", //$NON-NLS-1$
+ element.getName());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#hasException()
+ */
+ @Override
+ public boolean hasException() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getException()
+ */
+ @Override
+ public <T extends Exception> T getException() {
+ return null;
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/NoRenderingPossibleError.java b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/NoRenderingPossibleError.java
new file mode 100644
index 0000000000..ef11d16be2
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/NoRenderingPossibleError.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.spi.swt.reporting;
+
+import java.text.MessageFormat;
+
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+
+/**
+ * Indicates that rendering is not possible due to an exception.
+ *
+ * @author emueller
+ *
+ * @param <E> the underlying exception type
+ */
+public class NoRenderingPossibleError<E extends Exception> implements ReportEntity {
+
+ private final E exception;
+
+ /**
+ * Constructor.
+ *
+ * @param exception
+ * the underlying exception
+ */
+ public NoRenderingPossibleError(E exception) {
+ this.exception = exception;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return MessageFormat.format("Rendering not possible due to: {0}.", //$NON-NLS-1$
+ exception.getMessage());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#hasException()
+ */
+ @Override
+ public boolean hasException() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getException()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public E getException() {
+ return exception;
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/RendererInitFailedError.java b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/RendererInitFailedError.java
new file mode 100644
index 0000000000..054d72ddde
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.ui.view.swt/src/org/eclipse/emf/ecp/view/spi/swt/reporting/RendererInitFailedError.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.spi.swt.reporting;
+
+import java.text.MessageFormat;
+
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+
+/**
+ * An error report that indicates that an renderer failed during its initialization.
+ *
+ * @author emueller
+ *
+ * @param <E> the underlying exception type
+ */
+public class RendererInitFailedError<E extends Exception> implements ReportEntity {
+
+ private final E exception;
+
+ /**
+ * Constructor.
+ *
+ * @param exception
+ * the underlying exception
+ */
+ public RendererInitFailedError(E exception) {
+ this.exception = exception;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return MessageFormat.format("Initialization of renderer failed due to: {0}", //$NON-NLS-1$
+ exception.getMessage());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#hasException()
+ */
+ @Override
+ public boolean hasException() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getException()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public E getException() {
+ return exception;
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view/META-INF/MANIFEST.MF b/bundles/org.eclipse.emf.ecp.ui.view/META-INF/MANIFEST.MF
index 0ec2f1130c..0afb429a45 100644
--- a/bundles/org.eclipse.emf.ecp.ui.view/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.emf.ecp.ui.view/META-INF/MANIFEST.MF
@@ -1,18 +1,18 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: MPI UI View
-Bundle-SymbolicName: org.eclipse.emf.ecp.ui.view;singleton:=true
-Bundle-Version: 1.5.0.qualifier
-Bundle-Activator: org.eclipse.emf.ecp.view.internal.ui.Activator
-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
- org.eclipse.emf.ecp.view.model;bundle-version="[1.4.0,2.0.0)";visibility:=reexport,
- org.eclipse.emf.ecp.view.context;bundle-version="[1.4.0,2.0.0)";visibility:=reexport,
- org.eclipse.emf.ecp.edit;bundle-version="[1.4.0,2.0.0)"
-Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Export-Package: org.eclipse.emf.ecp.ui.view;version="1.5.0",org.eclips
- e.emf.ecp.view.internal.provider;version="1.5.0";x-internal:=true,org
- .eclipse.emf.ecp.view.internal.ui;version="1.5.0";x-friends:="org.ecl
- ipse.emf.ecp.view.table.ui.swt",org.eclipse.emf.ecp.view.spi.provider
- ;version="1.5.0",org.eclipse.emf.ecp.view.spi.renderer;version="1.5.0"
-Bundle-Vendor: Eclipse Modeling Project
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: MPI UI View
+Bundle-SymbolicName: org.eclipse.emf.ecp.ui.view;singleton:=true
+Bundle-Version: 1.5.0.qualifier
+Bundle-Activator: org.eclipse.emf.ecp.view.internal.ui.Activator
+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.emf.ecp.view.model;bundle-version="[1.4.0,2.0.0)";visibility:=reexport,
+ org.eclipse.emf.ecp.view.context;bundle-version="[1.4.0,2.0.0)";visibility:=reexport,
+ org.eclipse.emf.ecp.edit;bundle-version="[1.4.0,2.0.0)"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.eclipse.emf.ecp.ui.view;version="1.5.0",
+ org.eclipse.emf.ecp.view.internal.provider;version="1.5.0";x-friends:="org.eclipse.emf.ecp.view.context.test",
+ org.eclipse.emf.ecp.view.internal.ui;version="1.5.0";x-friends:="org.eclipse.emf.ecp.view.table.ui.swt",
+ org.eclipse.emf.ecp.view.spi.provider;version="1.5.0",
+ org.eclipse.emf.ecp.view.spi.renderer;version="1.5.0"
+Bundle-Vendor: Eclipse Modeling Project
diff --git a/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/internal/provider/ViewProviderImpl.java b/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/internal/provider/ViewProviderImpl.java
new file mode 100644
index 0000000000..58fc3ff094
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/internal/provider/ViewProviderImpl.java
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Eugen Neufeld - initial API and implementation
+ * Edgar Mueller - refactorings
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.internal.provider;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecp.view.internal.ui.Activator;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+import org.eclipse.emf.ecp.view.spi.model.VView;
+import org.eclipse.emf.ecp.view.spi.provider.IViewProvider;
+import org.eclipse.emf.ecp.view.spi.provider.NoViewProviderError;
+import org.eclipse.emf.ecp.view.spi.provider.ViewModelIsNullError;
+import org.eclipse.emf.ecp.view.spi.provider.ViewProviderInitFailedError;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Eugen Neufeld
+ */
+public class ViewProviderImpl {
+
+ private static final String CLASS_CANNOT_BE_RESOLVED = "%1$s cannot be loaded because bundle %2$s cannot be resolved."; //$NON-NLS-1$
+ private static final String CLASS = "class"; //$NON-NLS-1$
+ private static final String EXTENSION_POINT_ID = "org.eclipse.emf.ecp.ui.view.viewModelProviders"; //$NON-NLS-1$
+ private final Set<IViewProvider> viewProviders = new LinkedHashSet<IViewProvider>();
+ private final boolean shouldReadExtensionPointPerRequest;
+
+ /**
+ * Default Constructor.
+ */
+ public ViewProviderImpl() {
+ this(true);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param shouldReadExtensionPointPerRequest
+ * whether the view providers extension should be read on each request
+ */
+ public ViewProviderImpl(boolean shouldReadExtensionPointPerRequest) {
+ this.shouldReadExtensionPointPerRequest = shouldReadExtensionPointPerRequest;
+ }
+
+ /**
+ * Clears all {@link IViewProvider}s.
+ */
+ public void clearProviders() {
+ viewProviders.clear();
+ }
+
+ /**
+ * Adds a {@link IViewProvider}.
+ *
+ * @param provider
+ * the {@link IViewProvider} to be added
+ */
+ public void addProvider(IViewProvider provider) {
+ viewProviders.add(provider);
+ }
+
+ private Set<IViewProvider> getViewProviders() {
+ if (viewProviders == null || viewProviders.isEmpty()) {
+ viewProviders.addAll(readViewProviders());
+ }
+ return viewProviders;
+ }
+
+ private static Set<IViewProvider> readViewProviders() {
+ final IConfigurationElement[] controls = Platform.getExtensionRegistry()
+ .getConfigurationElementsFor(
+ EXTENSION_POINT_ID);
+
+ final Set<IViewProvider> providers = new LinkedHashSet<IViewProvider>();
+
+ for (final IConfigurationElement e : controls) {
+ try {
+ final String clazz = e.getAttribute(CLASS);
+ final Class<? extends IViewProvider> resolvedClass = loadClass(e
+ .getContributor().getName(), clazz);
+ final Constructor<? extends IViewProvider> controlConstructor = resolvedClass
+ .getConstructor();
+ final IViewProvider viewProvider = controlConstructor.newInstance();
+ providers.add(viewProvider);
+ } catch (final ClassNotFoundException ex) {
+ report(new ViewProviderInitFailedError<ClassNotFoundException>(ex));
+ } catch (final NoSuchMethodException ex) {
+ report(new ViewProviderInitFailedError<NoSuchMethodException>(ex));
+ } catch (final SecurityException ex) {
+ report(new ViewProviderInitFailedError<SecurityException>(ex));
+ } catch (final InstantiationException ex) {
+ report(new ViewProviderInitFailedError<InstantiationException>(ex));
+ } catch (final IllegalAccessException ex) {
+ report(new ViewProviderInitFailedError<IllegalAccessException>(ex));
+ } catch (final IllegalArgumentException ex) {
+ report(new ViewProviderInitFailedError<IllegalArgumentException>(ex));
+ } catch (final InvocationTargetException ex) {
+ report(new ViewProviderInitFailedError<InvocationTargetException>(ex));
+ }
+ }
+
+ return providers;
+ }
+
+ private static void report(ReportEntity reportEntity) {
+ Activator.getDefault().getReportService().report(reportEntity);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T> Class<T> loadClass(String bundleName, String clazz)
+ throws ClassNotFoundException {
+ final Bundle bundle = Platform.getBundle(bundleName);
+ if (bundle == null) {
+ throw new ClassNotFoundException(String.format(
+ CLASS_CANNOT_BE_RESOLVED, clazz, bundleName));
+ }
+ return (Class<T>) bundle.loadClass(clazz);
+
+ }
+
+ /**
+ * This allows to retrieve a {@link VView} based on an {@link EObject}. This method reads all {@link IViewProvider
+ * IViewProviders} and searches for the best fitting. If none can be found, then null is returned.
+ *
+ * @param eObject the {@link EObject} to find a {@link VView} for
+ * @param context a key-value-map from String to Object
+ * @return a view model for the given {@link EObject} or null if no suited provider could be found
+ */
+ public VView getView(EObject eObject, Map<String, Object> context) {
+ int highestPrio = IViewProvider.NOT_APPLICABLE;
+ IViewProvider selectedProvider = null;
+ if (context == null) {
+ context = new LinkedHashMap<String, Object>();
+ }
+
+ Set<IViewProvider> providers;
+ if (shouldReadExtensionPointPerRequest) {
+ providers = getViewProviders();
+ } else {
+ providers = viewProviders;
+ }
+
+ if (providers.isEmpty()) {
+ report(new NoViewProviderError());
+ }
+
+ for (final IViewProvider viewProvider : providers) {
+ final int prio = viewProvider.canRender(eObject, context);
+ if (prio > highestPrio) {
+ highestPrio = prio;
+ selectedProvider = viewProvider;
+ }
+ }
+
+ if (selectedProvider != null) {
+ final VView view = selectedProvider.generate(eObject, context);
+ if (view == null) {
+ report(new ViewModelIsNullError());
+ }
+ return view;
+ }
+
+ return null;
+
+ }
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/internal/ui/Activator.java b/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/internal/ui/Activator.java
index d74112e5f4..fe4e339734 100644
--- a/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/internal/ui/Activator.java
+++ b/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/internal/ui/Activator.java
@@ -1,106 +1,121 @@
-/*******************************************************************************
- * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH 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:
- * EclipseSource Muenchen - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.emf.ecp.view.internal.ui;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.ecp.edit.spi.ECPControlFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-/**
- * The activator class controls the plug-in life cycle.
- */
-public class Activator extends Plugin {
-
- /** The plug-in ID. **/
- public static final String PLUGIN_ID = "org.eclipse.emf.ecp.ui.view"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor.
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- // this.context = context;
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance.
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- /**
- * Logs exception.
- *
- * @param e
- * the {@link Exception} to log
- */
- public static void log(Exception e) {
- getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e
- .getMessage(), e));
- }
-
- private ServiceReference<ECPControlFactory> controlFactoryReference;
-
- /**
- * Returns the {@link ECPControlFactory}.
- *
- * @return the {@link ECPControlFactory}
- */
- public ECPControlFactory getECPControlFactory() {
- if (controlFactoryReference == null) {
- controlFactoryReference = plugin.getBundle().getBundleContext()
- .getServiceReference(ECPControlFactory.class);
- }
- return plugin.getBundle().getBundleContext().getService(controlFactoryReference);
- }
-
- /**
- * Frees the {@link ECPControlFactory} from use, allowing the OSGi Bundle to be shutdown.
- */
- public void ungetECPControlFactory() {
- if (controlFactoryReference == null) {
- return;
- }
- plugin.getBundle().getBundleContext().ungetService(controlFactoryReference);
- controlFactoryReference = null;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH 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:
+ * EclipseSource Muenchen - initial API and implementation
+ *
+ *******************************************************************************/
+package org.eclipse.emf.ecp.view.internal.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecp.edit.spi.ECPControlFactory;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * The activator class controls the plug-in life cycle.
+ */
+public class Activator extends Plugin {
+
+ /** The plug-in ID. **/
+ public static final String PLUGIN_ID = "org.eclipse.emf.ecp.ui.view"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ private ServiceReference<ECPControlFactory> controlFactoryReference;
+ private ServiceReference<ReportService> reportServiceReference;
+
+ /**
+ * The constructor.
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ // this.context = context;
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Logs exception.
+ *
+ * @param e
+ * the {@link Exception} to log
+ */
+ public static void log(Exception e) {
+ getDefault().getLog().log(
+ new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e
+ .getMessage(), e));
+ }
+
+ /**
+ * Returns the {@link ECPControlFactory}.
+ *
+ * @return the {@link ECPControlFactory}
+ */
+ public ECPControlFactory getECPControlFactory() {
+ if (controlFactoryReference == null) {
+ controlFactoryReference = plugin.getBundle().getBundleContext()
+ .getServiceReference(ECPControlFactory.class);
+ }
+ return plugin.getBundle().getBundleContext().getService(controlFactoryReference);
+ }
+
+ /**
+ * Returns the {@link ReportService}.
+ *
+ * @return the {@link ReportService}
+ */
+ public ReportService getReportService() {
+ if (reportServiceReference == null) {
+ reportServiceReference = plugin.getBundle().getBundleContext()
+ .getServiceReference(ReportService.class);
+ }
+ return plugin.getBundle().getBundleContext().getService(reportServiceReference);
+ }
+
+ /**
+ * Frees the {@link ECPControlFactory} from use, allowing the OSGi Bundle to be shutdown.
+ */
+ public void ungetECPControlFactory() {
+ if (controlFactoryReference == null) {
+ return;
+ }
+ plugin.getBundle().getBundleContext().ungetService(controlFactoryReference);
+ controlFactoryReference = null;
+ }
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/NoViewProviderError.java b/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/NoViewProviderError.java
new file mode 100644
index 0000000000..a1470d2297
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/NoViewProviderError.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.spi.provider;
+
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+
+/**
+ * Indicates that no view provider could be obtained.
+ *
+ * @author emueller
+ *
+ */
+public class NoViewProviderError implements ReportEntity {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return "No view provider available."; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#hasException()
+ */
+ @Override
+ public boolean hasException() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getException()
+ */
+ @Override
+ public <T extends Exception> T getException() {
+ return null;
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewModelIsNullError.java b/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewModelIsNullError.java
new file mode 100644
index 0000000000..314103f4d3
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewModelIsNullError.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.spi.provider;
+
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+
+/**
+ * Indicates that a {@link IViewProvider} has returned {@code null} as
+ * the {@link org.eclipse.emf.ecp.view.spi.model.VView VView}.
+ *
+ * @author emueller
+ *
+ */
+public class ViewModelIsNullError implements ReportEntity {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return "ViewProvider has returned null as the view."; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#hasException()
+ */
+ @Override
+ public boolean hasException() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getException()
+ */
+ @Override
+ public <T extends Exception> T getException() {
+ return null;
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewProviderHelper.java b/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewProviderHelper.java
index e12cebba0e..e7b4b79878 100644
--- a/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewProviderHelper.java
+++ b/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewProviderHelper.java
@@ -1,127 +1,47 @@
-/*******************************************************************************
- * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH 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:
- * EclipseSource Muenchen - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.emf.ecp.view.spi.provider;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecp.view.internal.ui.Activator;
-import org.eclipse.emf.ecp.view.spi.model.VView;
-import org.osgi.framework.Bundle;
-
-/**
- * Util class for retrieving a {@link VView} based on an {@link EObject}.
- *
- * @author Eugen Neufeld
- * @since 1.2
- *
- */
-public final class ViewProviderHelper {
-
- private static final String CLASS_CANNOT_BE_RESOLVED = "%1$s cannot be loaded because bundle %2$s cannot be resolved."; //$NON-NLS-1$
- private static final String CLASS = "class"; //$NON-NLS-1$
- private static final String EXTENSION_POINT_ID = "org.eclipse.emf.ecp.ui.view.viewModelProviders"; //$NON-NLS-1$
-
- private ViewProviderHelper() {
-
- }
-
- private static Set<IViewProvider> viewProviders = new HashSet<IViewProvider>();
-
- private static Set<IViewProvider> getViewProviders() {
- if (viewProviders == null || viewProviders.isEmpty()) {
- readViewProviders();
- }
- return viewProviders;
- }
-
- private static void readViewProviders() {
- final IConfigurationElement[] controls = Platform.getExtensionRegistry()
- .getConfigurationElementsFor(
- EXTENSION_POINT_ID);
- for (final IConfigurationElement e : controls) {
- try {
- final String clazz = e.getAttribute(CLASS);
- final Class<? extends IViewProvider> resolvedClass = loadClass(e
- .getContributor().getName(), clazz);
- final Constructor<? extends IViewProvider> controlConstructor = resolvedClass
- .getConstructor();
- final IViewProvider viewProvider = controlConstructor.newInstance();
- viewProviders.add(viewProvider);
- } catch (final ClassNotFoundException ex) {
- Activator.log(ex);
- } catch (final NoSuchMethodException ex) {
- Activator.log(ex);
- } catch (final SecurityException ex) {
- Activator.log(ex);
- } catch (final InstantiationException ex) {
- Activator.log(ex);
- } catch (final IllegalAccessException ex) {
- Activator.log(ex);
- } catch (final IllegalArgumentException ex) {
- Activator.log(ex);
- } catch (final InvocationTargetException ex) {
- Activator.log(ex);
- }
-
- }
-
- }
-
- @SuppressWarnings("unchecked")
- private static <T> Class<T> loadClass(String bundleName, String clazz)
- throws ClassNotFoundException {
- final Bundle bundle = Platform.getBundle(bundleName);
- if (bundle == null) {
- throw new ClassNotFoundException(String.format(
- CLASS_CANNOT_BE_RESOLVED, clazz, bundleName));
- }
- return (Class<T>) bundle.loadClass(clazz);
-
- }
-
- /**
- * This allows to retrieve a {@link VView} based on an {@link EObject}. This method reads all {@link IViewProvider
- * IViewProviders} and searches for the best fitting. If none can be found, then null is returned.
- *
- * @param eObject the {@link EObject} to find a {@link VView} for
- * @param context a key-value-map from String to Object
- * @return a view model for the given {@link EObject} or null if no suited provider could be found
- */
- public static VView getView(EObject eObject, Map<String, Object> context) {
- int highestPrio = IViewProvider.NOT_APPLICABLE;
- IViewProvider selectedProvider = null;
- if (context == null) {
- context = new LinkedHashMap<String, Object>();
- }
- for (final IViewProvider viewProvider : ViewProviderHelper.getViewProviders()) {
- final int prio = viewProvider.canRender(eObject, context);
- if (prio > highestPrio) {
- highestPrio = prio;
- selectedProvider = viewProvider;
- }
- }
- if (selectedProvider != null) {
- return selectedProvider.generate(eObject, context);
- }
- return null;
-
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH 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:
+ * EclipseSource Muenchen - initial API and implementation
+ *
+ *******************************************************************************/
+package org.eclipse.emf.ecp.view.spi.provider;
+
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecp.view.internal.provider.ViewProviderImpl;
+import org.eclipse.emf.ecp.view.spi.model.VView;
+
+/**
+ * Util class for retrieving a {@link VView} based on an {@link EObject}.
+ *
+ * @author Eugen Neufeld
+ * @since 1.2
+ *
+ */
+public final class ViewProviderHelper {
+
+ private static ViewProviderImpl viewProvider = new ViewProviderImpl();
+
+ private ViewProviderHelper() {
+
+ }
+
+ /**
+ * This allows to retrieve a {@link VView} based on an {@link EObject}. This method reads all {@link IViewProvider
+ * IViewProviders} and searches for the best fitting. If none can be found, then null is returned.
+ *
+ * @param eObject the {@link EObject} to find a {@link VView} for
+ * @param context a key-value-map from String to Object
+ * @return a view model for the given {@link EObject} or null if no suited provider could be found
+ */
+ public static VView getView(EObject eObject, Map<String, Object> context) {
+ return viewProvider.getView(eObject, context);
+ }
+}
diff --git a/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewProviderInitFailedError.java b/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewProviderInitFailedError.java
new file mode 100644
index 0000000000..af2431446c
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.ui.view/src/org/eclipse/emf/ecp/view/spi/provider/ViewProviderInitFailedError.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.spi.provider;
+
+import java.text.MessageFormat;
+
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+
+/**
+ * Indicates that a ViewProvider could not be instantiated.
+ *
+ * @author emueller
+ *
+ * @param <E> the type f the exception due to initialization of the {@link IViewProvider} failed
+ */
+public class ViewProviderInitFailedError<E extends Exception> implements ReportEntity {
+
+ private final E exception;
+
+ /**
+ * Constructor.
+ *
+ * @param exception
+ * an exception
+ */
+ public ViewProviderInitFailedError(E exception) {
+ this.exception = exception;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return MessageFormat.format("ViewProvider could not be initialized due to {0}: ", //$NON-NLS-1$
+ exception.getMessage());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#hasException()
+ */
+ @Override
+ public boolean hasException() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getException()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends Exception> T getException() {
+ return (T) exception;
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.view.context/META-INF/MANIFEST.MF b/bundles/org.eclipse.emf.ecp.view.context/META-INF/MANIFEST.MF
index 6fe1896c85..1cddd1127d 100644
--- a/bundles/org.eclipse.emf.ecp.view.context/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.emf.ecp.view.context/META-INF/MANIFEST.MF
@@ -11,6 +11,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
org.eclipse.emf.ecp.common;bundle-version="[1.4.0,2.0.0)";visibility:=reexport
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.emf.ecp.view.internal.context;version="1.5
- .0";x-internal:=true,org.eclipse.emf.ecp.view.spi.context;version="1.
- 5.0"
+Export-Package: org.eclipse.emf.ecp.view.internal.context;version="1.5.0";x-internal:=true,
+ org.eclipse.emf.ecp.view.model.common.internal.reporting;version="1.5.0";x-internal:=true,
+ org.eclipse.emf.ecp.view.model.common.spi.reporting;version="1.5.0",
+ org.eclipse.emf.ecp.view.spi.context;version="1.5.0"
diff --git a/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/internal/context/Activator.java b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/internal/context/Activator.java
index 85d308cb04..327e0e960b 100644
--- a/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/internal/context/Activator.java
+++ b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/internal/context/Activator.java
@@ -1,80 +1,114 @@
-/*******************************************************************************
- * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH 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:
- * Eugen Neufeld - initial API and implementation
- ******************************************************************************/
-package org.eclipse.emf.ecp.view.internal.context;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.osgi.framework.BundleContext;
-
-/**
- * The Class Activator.
- */
-public class Activator extends Plugin {
-
- /**
- * The constant holding the id of this plugin.
- */
- public static final String PLUGIN_ID = "org.eclipse.emf.ecp.view.context"; //$NON-NLS-1$
-
- /** The instance. */
- private static Activator instance;
-
- /**
- * Default constructor.
- */
- public Activator() {
- }
-
- // BEGIN SUPRESS CATCH EXCEPTION
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext bundleContext) throws Exception {
- super.start(bundleContext);
- instance = this;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext bundleContext) throws Exception {
- instance = null;
- super.stop(bundleContext);
- }
-
- // END SUPRESS CATCH EXCEPTION
- /**
- * Returns the instance of this Activator.
- *
- * @return the saved instance
- */
- public static Activator getInstance() {
- return instance;
- }
-
- /**
- * Logs a {@link Throwable}.
- *
- * @param t the {@link Throwable} to log
- */
- public static void log(Throwable t) {
- getInstance().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, t.getMessage(), t));
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH 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:
+ * Eugen Neufeld - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.internal.context;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecp.view.model.common.internal.reporting.ReportServiceImpl;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * The Class Activator.
+ */
+public class Activator extends Plugin {
+
+ /**
+ * The constant holding the id of this plugin.
+ */
+ public static final String PLUGIN_ID = "org.eclipse.emf.ecp.view.context"; //$NON-NLS-1$
+
+ /** The instance. */
+ private static Activator instance;
+
+ private ServiceReference<ReportService> reportServiceReference;
+
+ /**
+ * Default constructor.
+ */
+ public Activator() {
+ }
+
+ // BEGIN SUPRESS CATCH EXCEPTION
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext bundleContext) throws Exception {
+ super.start(bundleContext);
+ bundleContext.registerService(ReportService.class, new ReportServiceImpl(), null);
+ instance = this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext bundleContext) throws Exception {
+ instance = null;
+ super.stop(bundleContext);
+ }
+
+ // END SUPRESS CATCH EXCEPTION
+ /**
+ * Returns the instance of this Activator.
+ *
+ * @return the saved instance
+ */
+ public static Activator getInstance() {
+ return instance;
+ }
+
+ /**
+ * Logs a {@link Throwable}.
+ *
+ * @param t the {@link Throwable} to log
+ */
+ public static void log(Throwable t) {
+ getInstance().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, t.getMessage(), t));
+ }
+
+ /**
+ * Logs a {@link ReportEntity}.
+ *
+ * @param report
+ * the {@link ReportEntity} to be logged
+ */
+ public static void log(ReportEntity report) {
+ getInstance().getLog().log(
+ new Status(IStatus.ERROR, // TODO RS: always ERROR?
+ PLUGIN_ID,
+ report.getMessage(),
+ report.getException()));
+ }
+
+ /**
+ * Returns the {@link ReportService}.
+ *
+ * @return the {@link ReportService}
+ */
+ public ReportService getReportService() {
+ if (reportServiceReference == null) {
+ reportServiceReference = instance.getBundle().getBundleContext()
+ .getServiceReference(ReportService.class);
+ }
+ return instance.getBundle().getBundleContext().getService(reportServiceReference);
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/internal/context/ViewModelContextImpl.java b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/internal/context/ViewModelContextImpl.java
index e9b6b9135f..c2bd1c9b73 100644
--- a/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/internal/context/ViewModelContextImpl.java
+++ b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/internal/context/ViewModelContextImpl.java
@@ -39,6 +39,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.eclipse.emf.ecp.common.UniqueSetting;
+import org.eclipse.emf.ecp.view.model.common.internal.reporting.ViewModelServiceNotAvailableError;
import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
import org.eclipse.emf.ecp.view.spi.context.ViewModelService;
import org.eclipse.emf.ecp.view.spi.model.DomainModelReferenceChangeListener;
@@ -59,8 +60,6 @@ import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
*/
public class ViewModelContextImpl implements ViewModelContext {
- private static final String NO_VIEW_SERVICE_OF_TYPE_FOUND = "No view service of type '%1$s' found."; //$NON-NLS-1$
-
private static final String MODEL_CHANGE_LISTENER_MUST_NOT_BE_NULL = "ModelChangeAddRemoveListener must not be null."; //$NON-NLS-1$
private static final String THE_VIEW_MODEL_CONTEXT_WAS_ALREADY_DISPOSED = "The ViewModelContext was already disposed."; //$NON-NLS-1$
@@ -484,8 +483,11 @@ public class ViewModelContextImpl implements ViewModelContext {
return (T) service;
}
}
- Activator.log(new IllegalArgumentException(String.format(NO_VIEW_SERVICE_OF_TYPE_FOUND,
- serviceType.getCanonicalName())));
+
+ Activator.getInstance()
+ .getReportService()
+ .report(new ViewModelServiceNotAvailableError<T>(serviceType));
+
return null;
}
diff --git a/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/internal/reporting/LogConsumer.java b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/internal/reporting/LogConsumer.java
new file mode 100644
index 0000000000..06ce658fe9
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/internal/reporting/LogConsumer.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.model.common.internal.reporting;
+
+import org.eclipse.emf.ecp.view.internal.context.Activator;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportServiceConsumer;
+
+/**
+ * A {@link ReportServiceConsumer} that logs all all received {@code ReportEntities}.
+ *
+ * @author emueller
+ */
+public class LogConsumer implements ReportServiceConsumer {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportServiceConsumer#reported(org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity)
+ */
+ @Override
+ public void reported(ReportEntity reportEntity) {
+ Activator.log(reportEntity);
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/internal/reporting/ReportServiceImpl.java b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/internal/reporting/ReportServiceImpl.java
new file mode 100644
index 0000000000..29a5711e1a
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/internal/reporting/ReportServiceImpl.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.model.common.internal.reporting;
+
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportService;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportServiceConsumer;
+
+/**
+ * Implementation of a {@link ReportService}.
+ *
+ * @author emueller
+ */
+public class ReportServiceImpl implements ReportService {
+
+ private final List<ReportEntity> reports;
+ private final Set<ReportServiceConsumer> consumers;
+
+ /**
+ * Constructor.
+ */
+ public ReportServiceImpl() {
+ reports = new ArrayList<ReportEntity>();
+ consumers = new LinkedHashSet<ReportServiceConsumer>();
+ }
+
+ /**
+ * Report an {@link ReportEntity} to the service.
+ *
+ * @param reportEntity
+ * the report entity
+ */
+ @Override
+ public void report(ReportEntity reportEntity) {
+ reports.add(reportEntity);
+ }
+
+ /**
+ * Returns all ReportEntities.
+ *
+ * @return all ReportEntities
+ */
+ @Override
+ public List<ReportEntity> getReports() {
+ return reports;
+ }
+
+ /**
+ * Discards all ReportEntities.
+ */
+ @Override
+ public void clearReports() {
+ reports.clear();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportService#addConsumer(org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportServiceConsumer)
+ */
+ @Override
+ public void addConsumer(ReportServiceConsumer consumer) {
+ consumers.add(consumer);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportService#removeConsumer(org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportServiceConsumer)
+ */
+ @Override
+ public void removeConsumer(ReportServiceConsumer consumer) {
+ consumers.remove(consumer);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/internal/reporting/ViewModelServiceNotAvailableError.java b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/internal/reporting/ViewModelServiceNotAvailableError.java
new file mode 100644
index 0000000000..907e270b36
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/internal/reporting/ViewModelServiceNotAvailableError.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.model.common.internal.reporting;
+
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity;
+
+/**
+ * Indicates that {@link org.eclipse.emf.ecp.view.spi.context.ViewModelService ViewModelService} is not available.
+ *
+ * @author emueller
+ *
+ * @param <T> The type of the unavailable service
+ */
+public class ViewModelServiceNotAvailableError<T> implements ReportEntity {
+
+ private static final String NO_VIEW_SERVICE_OF_TYPE_FOUND = "No view service of type '%1$s' found."; //$NON-NLS-1$
+ private final Class<T> serviceType;
+
+ /**
+ * Constructor.
+ *
+ * @param serviceType
+ * the type of the unavailable service
+ */
+ public ViewModelServiceNotAvailableError(Class<T> serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ /**
+ * Returns the type of the unavailable service.
+ *
+ * @return the type of the unavailable service
+ */
+ public Class<T> getServiceType() {
+ return serviceType;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return String.format(
+ NO_VIEW_SERVICE_OF_TYPE_FOUND, getServiceType().getCanonicalName());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#hasException()
+ */
+ @Override
+ public boolean hasException() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportEntity#getException()
+ */
+ @Override
+ public <E extends Exception> E getException() {
+ return null;
+ }
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/spi/reporting/ReportEntity.java b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/spi/reporting/ReportEntity.java
new file mode 100644
index 0000000000..178bebc0e9
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/spi/reporting/ReportEntity.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.model.common.spi.reporting;
+
+/**
+ * Common base type for reports that may be reported to the
+ * {@link org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportService ReportService}.
+ *
+ * @author emueller
+ *
+ */
+public interface ReportEntity {
+
+ /**
+ * Returns a message.
+ *
+ * @return the message
+ */
+ String getMessage();
+
+ /**
+ * Whether this report is based upon an exception.
+ *
+ * @return {@code true}, if this report is based upon an exception, {@code false} otherwise
+ */
+ boolean hasException();
+
+ /**
+ * Returns the exception this report is based on, if any.
+ *
+ * @return the exception this report is based on, if any, otherwise {@code null}
+ *
+ * @param <T> the type of the exception
+ *
+ * @see #hasException()
+ */
+ <T extends Exception> T getException();
+}
diff --git a/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/spi/reporting/ReportService.java b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/spi/reporting/ReportService.java
new file mode 100644
index 0000000000..6b493263bb
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/spi/reporting/ReportService.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.model.common.spi.reporting;
+
+import java.util.List;
+
+/**
+ * Service for reporting and aggregating errors.
+ *
+ * @author emueller
+ */
+public interface ReportService {
+
+ /**
+ * Report an {@link ReportEntity} to the service.
+ *
+ * @param reportEntity
+ * the report entity
+ */
+ void report(ReportEntity reportEntity);
+
+ /**
+ * Returns all ReportEntities.
+ *
+ * @return all ReportEntities
+ */
+ List<ReportEntity> getReports();
+
+ /**
+ * Discards all ReportEntities.
+ */
+ void clearReports();
+
+ /**
+ * Adds a {@link ReportServiceConsumer} that consumes {@code ReportEntities}.
+ *
+ * @param consumer
+ * a {@link ReportServiceConsumer}
+ */
+ void addConsumer(ReportServiceConsumer consumer);
+
+ /**
+ * Removes a {@link ReportServiceConsumer}.
+ *
+ * @param consumer
+ * the consumer to be removed
+ */
+ void removeConsumer(ReportServiceConsumer consumer);
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/spi/reporting/ReportServiceConsumer.java b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/spi/reporting/ReportServiceConsumer.java
new file mode 100644
index 0000000000..64f009ed9e
--- /dev/null
+++ b/bundles/org.eclipse.emf.ecp.view.context/src/org/eclipse/emf/ecp/view/model/common/spi/reporting/ReportServiceConsumer.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.model.common.spi.reporting;
+
+/**
+ * Common base types for any {@link ReportEntity} consumer that may
+ * be added to the {@link ReportService} in order to be notified.
+ *
+ * @author emueller
+ *
+ */
+public interface ReportServiceConsumer {
+
+ /**
+ * Called when a {@link ReportEntity} has been received
+ * by the {@link ReportService}.
+ *
+ * @param reportEntity
+ * the received {@link ReportEntity}
+ */
+ void reported(ReportEntity reportEntity);
+
+}
diff --git a/bundles/org.eclipse.emf.ecp.view.core.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.emf.ecp.view.core.swt/META-INF/MANIFEST.MF
index f8f32a8cc9..17add87c53 100644
--- a/bundles/org.eclipse.emf.ecp.view.core.swt/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.emf.ecp.view.core.swt/META-INF/MANIFEST.MF
@@ -26,10 +26,10 @@ Import-Package: org.eclipse.jface.databinding.swt;version="0.0.0",
org.eclipse.swt.graphics;version="0.0.0",
org.eclipse.swt.layout;version="0.0.0",
org.eclipse.swt.widgets;version="0.0.0"
-Export-Package: org.eclipse.emf.ecp.view.internal.core.swt;version="1.
- 5.0";x-internal:=true,org.eclipse.emf.ecp.view.internal.core.swt.rend
- erer;version="1.5.0";x-friends:="org.eclipse.emf.ecp.ui.view.editor.c
- ontrols",org.eclipse.emf.ecp.view.spi.core.swt;version="1.5.0"; uses:
- ="org.eclipse.emf.ecp.ui.view.swt.internal, org.eclipse.emf.ecp.view
- .spi.model, org.eclipse.swt.widgets, org.eclipse.emf.ecp.view.spi.c
- ontext"
+Export-Package: org.eclipse.emf.ecp.view.internal.core.swt;version="1.5.0";x-internal:=true,
+ org.eclipse.emf.ecp.view.internal.core.swt.renderer;version="1.5.0";x-friends:="org.eclipse.emf.ecp.ui.view.editor.controls,org.eclipse.emf.ecp.view.context.test",
+ org.eclipse.emf.ecp.view.spi.core.swt;version="1.5.0";
+ uses:="org.eclipse.emf.ecp.ui.view.swt.internal,
+ org.eclipse.emf.ecp.view.spi.model,
+ org.eclipse.swt.widgets,
+ org.eclipse.emf.ecp.view.spi.context"
diff --git a/bundles/org.eclipse.emf.ecp.view.custom.ui.swt/src/org/eclipse/emf/ecp/view/internal/custom/swt/Activator.java b/bundles/org.eclipse.emf.ecp.view.custom.ui.swt/src/org/eclipse/emf/ecp/view/internal/custom/swt/Activator.java
index b31bb31f45..9788061302 100644
--- a/bundles/org.eclipse.emf.ecp.view.custom.ui.swt/src/org/eclipse/emf/ecp/view/internal/custom/swt/Activator.java
+++ b/bundles/org.eclipse.emf.ecp.view.custom.ui.swt/src/org/eclipse/emf/ecp/view/internal/custom/swt/Activator.java
@@ -1,117 +1,132 @@
-/*******************************************************************************
- * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH 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:
- * Eugen Neufeld - initial API and implementation
- ******************************************************************************/
-package org.eclipse.emf.ecp.view.internal.custom.swt;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.ecp.edit.spi.ECPControlFactory;
-import org.eclipse.swt.graphics.Image;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-/**
- * The activator class controls the plug-in life cycle.
- */
-@SuppressWarnings("deprecation")
-public class Activator extends Plugin {
-
- /** The plug-in ID. */
- public static final String PLUGIN_ID = "org.eclipse.emf.ecp.ui.view.custom.swt"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor.
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance.
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- // Not API, delegating to reuse same images
- /**
- * Get an Image based on an path. This just delegates to
- * {@link org.eclipse.emf.ecp.edit.internal.swt.Activator#getImage(String)}.
- *
- * @param path the path of the image to load
- * @return the loaded image
- */
- @SuppressWarnings("restriction")
- public static Image getImage(String path) {
- return org.eclipse.emf.ecp.edit.internal.swt.Activator.getImage(path);
-
- }
-
- /**
- * Helper for logging {@link Throwable Throwables}.
- *
- * @param throwable the {@link Throwable} to log
- */
- public static void log(Throwable throwable) {
- plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, throwable.getMessage(), throwable));
- }
-
- private ServiceReference<ECPControlFactory> controlFactoryReference;
-
- /**
- * Returns the {@link ECPControlFactory}.
- *
- * @return the {@link ECPControlFactory}
- */
- public ECPControlFactory getECPControlFactory() {
- if (controlFactoryReference == null) {
- controlFactoryReference = plugin.getBundle().getBundleContext()
- .getServiceReference(ECPControlFactory.class);
- }
- return plugin.getBundle().getBundleContext().getService(controlFactoryReference);
- }
-
- /**
- * Frees the {@link ECPControlFactory} from use, allowing the OSGi Bundle to be shutdown.
- */
- public void ungetECPControlFactory() {
- if (controlFactoryReference == null) {
- return;
- }
- plugin.getBundle().getBundleContext().ungetService(controlFactoryReference);
- controlFactoryReference = null;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH 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:
+ * Eugen Neufeld - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.internal.custom.swt;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecp.edit.spi.ECPControlFactory;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportService;
+import org.eclipse.swt.graphics.Image;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * The activator class controls the plug-in life cycle.
+ */
+@SuppressWarnings("deprecation")
+public class Activator extends Plugin {
+
+ /** The plug-in ID. */
+ public static final String PLUGIN_ID = "org.eclipse.emf.ecp.ui.view.custom.swt"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor.
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ // Not API, delegating to reuse same images
+ /**
+ * Get an Image based on an path. This just delegates to
+ * {@link org.eclipse.emf.ecp.edit.internal.swt.Activator#getImage(String)}.
+ *
+ * @param path the path of the image to load
+ * @return the loaded image
+ */
+ @SuppressWarnings("restriction")
+ public static Image getImage(String path) {
+ return org.eclipse.emf.ecp.edit.internal.swt.Activator.getImage(path);
+
+ }
+
+ /**
+ * Helper for logging {@link Throwable Throwables}.
+ *
+ * @param throwable the {@link Throwable} to log
+ */
+ public static void log(Throwable throwable) {
+ plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, throwable.getMessage(), throwable));
+ }
+
+ private ServiceReference<ECPControlFactory> controlFactoryReference;
+ private ServiceReference<ReportService> reportServiceRef;
+
+ /**
+ * Returns the {@link ECPControlFactory}.
+ *
+ * @return the {@link ECPControlFactory}
+ */
+ public ECPControlFactory getECPControlFactory() {
+ if (controlFactoryReference == null) {
+ controlFactoryReference = plugin.getBundle().getBundleContext()
+ .getServiceReference(ECPControlFactory.class);
+ }
+ return plugin.getBundle().getBundleContext().getService(controlFactoryReference);
+ }
+
+ /**
+ * Returns the {@link ReportService}.
+ *
+ * @return the {@link ECPControlFactory}
+ */
+ public ReportService getReportService() {
+ if (reportServiceRef == null) {
+ reportServiceRef = plugin.getBundle().getBundleContext()
+ .getServiceReference(ReportService.class);
+ }
+ return plugin.getBundle().getBundleContext().getService(reportServiceRef);
+ }
+
+ /**
+ * Frees the {@link ECPControlFactory} from use, allowing the OSGi Bundle to be shutdown.
+ */
+ public void ungetECPControlFactory() {
+ if (controlFactoryReference == null) {
+ return;
+ }
+ plugin.getBundle().getBundleContext().ungetService(controlFactoryReference);
+ controlFactoryReference = null;
+ }
+}
diff --git a/bundles/org.eclipse.emf.ecp.view.custom.ui.swt/src/org/eclipse/emf/ecp/view/spi/custom/swt/CustomControlSWTRenderer.java b/bundles/org.eclipse.emf.ecp.view.custom.ui.swt/src/org/eclipse/emf/ecp/view/spi/custom/swt/CustomControlSWTRenderer.java
index 75eb341b21..16b70a13e7 100644
--- a/bundles/org.eclipse.emf.ecp.view.custom.ui.swt/src/org/eclipse/emf/ecp/view/spi/custom/swt/CustomControlSWTRenderer.java
+++ b/bundles/org.eclipse.emf.ecp.view.custom.ui.swt/src/org/eclipse/emf/ecp/view/spi/custom/swt/CustomControlSWTRenderer.java
@@ -1,11 +1,11 @@
/*******************************************************************************
* Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
* Eugen - initial API and implementation
******************************************************************************/
@@ -14,12 +14,15 @@ package org.eclipse.emf.ecp.view.spi.custom.swt;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecp.edit.internal.swt.util.SWTValidationHelper;
import org.eclipse.emf.ecp.internal.edit.EditMessages;
+import org.eclipse.emf.ecp.view.internal.custom.swt.Activator;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportService;
import org.eclipse.emf.ecp.view.spi.custom.model.VCustomControl;
import org.eclipse.emf.ecp.view.spi.renderer.NoPropertyDescriptorFoundExeption;
import org.eclipse.emf.ecp.view.spi.renderer.NoRendererFoundException;
import org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer;
import org.eclipse.emf.ecp.view.spi.swt.layout.SWTGridCell;
import org.eclipse.emf.ecp.view.spi.swt.layout.SWTGridDescription;
+import org.eclipse.emf.ecp.view.spi.swt.reporting.CustomControlInitFailedError;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
@@ -30,7 +33,7 @@ import org.osgi.framework.Bundle;
/**
* The renderer for custom control view models.
- *
+ *
* @author Eugen Neufeld
* @since 1.3
*/
@@ -41,7 +44,7 @@ public class CustomControlSWTRenderer extends AbstractSWTRenderer<VCustomControl
/**
* {@inheritDoc}
- *
+ *
* @see org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer#preInit()
*/
@Override
@@ -50,7 +53,10 @@ public class CustomControlSWTRenderer extends AbstractSWTRenderer<VCustomControl
final VCustomControl customControl = getVElement();
swtCustomControl = loadCustomControl(customControl);
if (swtCustomControl == null) {
- // TODO
+ final ReportService reportService = Activator.getDefault().getReportService();
+ reportService.report(new CustomControlInitFailedError(
+ customControl.getBundleName(), customControl.getClassName()));
+ // TODO: RS
throw new IllegalStateException(String.format("The %1$s/%2$s cannot be loaded!", //$NON-NLS-1$
customControl.getBundleName(), customControl.getClassName()));
}
@@ -59,7 +65,7 @@ public class CustomControlSWTRenderer extends AbstractSWTRenderer<VCustomControl
/**
* Loads and returns the {@link ECPAbstractCustomControlSWT} that is referenced by the {@link VCustomControl}.
- *
+ *
* @param customControl the custom control view model
* @return the swt renderer
* @since 1.4
@@ -105,7 +111,7 @@ public class CustomControlSWTRenderer extends AbstractSWTRenderer<VCustomControl
/**
* {@inheritDoc}
- *
+ *
* @see org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer#dispose()
*/
@Override
@@ -116,7 +122,7 @@ public class CustomControlSWTRenderer extends AbstractSWTRenderer<VCustomControl
/**
* {@inheritDoc}
- *
+ *
* @see org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer#getGridDescription(SWTGridDescription)
*/
@Override
@@ -129,15 +135,15 @@ public class CustomControlSWTRenderer extends AbstractSWTRenderer<VCustomControl
}
/**
- *
+ *
* {@inheritDoc}
- *
+ *
* @see org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer#renderControl(org.eclipse.emf.ecp.view.spi.swt.layout.SWTGridCell,
* org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control renderControl(SWTGridCell cell, Composite parent) throws NoRendererFoundException,
- NoPropertyDescriptorFoundExeption {
+ NoPropertyDescriptorFoundExeption {
return swtCustomControl.renderControl(cell, parent);
}
diff --git a/bundles/org.eclipse.emf.ecp.view.model.common/META-INF/MANIFEST.MF b/bundles/org.eclipse.emf.ecp.view.model.common/META-INF/MANIFEST.MF
index f22d0eca74..24a10fb6e3 100644
--- a/bundles/org.eclipse.emf.ecp.view.model.common/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.emf.ecp.view.model.common/META-INF/MANIFEST.MF
@@ -8,13 +8,11 @@ Bundle-Vendor: Eclipse Modeling Project
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.osgi.framework;version="1.3.0"
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.emf.ecp.view.internal.model.common;version
- ="1.5.0";x-internal:=true,org.eclipse.emf.ecp.view.model.common;versi
- on="1.5.0",org.eclipse.emf.ecp.view.model.common.edit.provider;versio
- n="1.5.0",org.eclipse.emf.ecp.view.model.common.internal.databinding;
- version="1.5.0";x-friends:="org.eclipse.emf.ecp.view.mappingdmr.datab
- inding",org.eclipse.emf.ecp.view.model.common.spi.databinding;version
- ="1.5.0"
+Export-Package: org.eclipse.emf.ecp.view.internal.model.common;version="1.5.0";x-internal:=true,
+ org.eclipse.emf.ecp.view.model.common;version="1.5.0",
+ org.eclipse.emf.ecp.view.model.common.edit.provider;version="1.5.0",
+ org.eclipse.emf.ecp.view.model.common.internal.databinding;version="1.5.0";x-friends:="org.eclipse.emf.ecp.view.mappingdmr.databinding",
+ org.eclipse.emf.ecp.view.model.common.spi.databinding;version="1.5.0"
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
org.eclipse.emf.ecp.view.context;bundle-version="[1.4.0,2.0.0)",
org.eclipse.emf.ecp.view.model;bundle-version="[1.4.0,2.0.0)",
diff --git a/tests/org.eclipse.emf.ecp.view.context.test/META-INF/MANIFEST.MF b/tests/org.eclipse.emf.ecp.view.context.test/META-INF/MANIFEST.MF
index 327310949f..4394709d86 100644
--- a/tests/org.eclipse.emf.ecp.view.context.test/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.emf.ecp.view.context.test/META-INF/MANIFEST.MF
@@ -8,6 +8,12 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: Eclipse Modeling Project
Require-Bundle: org.junit;bundle-version="[4.0.0,5.0.0)",
org.eclipse.emf.emfstore.examplemodel;bundle-version="[1.3.0,2.0.0)",
- org.eclipse.emf.ecp.view.table.model;bundle-version="[1.4.0,2.0.0)"
-Export-Package: org.eclipse.emf.ecp.view.context;version="1.5.0";x-int
- ernal:=true
+ org.eclipse.emf.ecp.view.table.model;bundle-version="[1.4.0,2.0.0)",
+ org.eclipse.emf.ecp.ui.view.swt;bundle-version="[1.5.0,2.0.0)",
+ org.eclipse.emf.ecp.view.test.common.swt;bundle-version="[1.5.0,2.0.0)",
+ org.eclipse.emf.ecp.view.core.swt;bundle-version="[1.5.0,2.0.0)",
+ org.hamcrest.library;bundle-version="[1.3.0,2.0.0)"
+Export-Package: org.eclipse.emf.ecp.view.context;version="1.5.0";x-internal:=true,
+ org.eclipse.emf.ecp.view.context.test;version="1.5.0",
+ org.eclipse.emf.ecp.view.context.test.mockup;version="1.5.0"
+Import-Package: org.eclipse.swt.widgets
diff --git a/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/RendererErrorTest.java b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/RendererErrorTest.java
new file mode 100644
index 0000000000..a4ee0ed2f4
--- /dev/null
+++ b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/RendererErrorTest.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.context.test;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecp.ui.view.ECPRendererException;
+import org.eclipse.emf.ecp.view.context.test.mockup.MockViewSWTRenderer;
+import org.eclipse.emf.ecp.view.internal.context.Activator;
+import org.eclipse.emf.ecp.view.internal.core.swt.renderer.ViewSWTRenderer;
+import org.eclipse.emf.ecp.view.internal.provider.ViewProviderImpl;
+import org.eclipse.emf.ecp.view.model.common.spi.reporting.ReportService;
+import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
+import org.eclipse.emf.ecp.view.spi.context.ViewModelContextFactory;
+import org.eclipse.emf.ecp.view.spi.model.VElement;
+import org.eclipse.emf.ecp.view.spi.model.VView;
+import org.eclipse.emf.ecp.view.spi.provider.IViewProvider;
+import org.eclipse.emf.ecp.view.spi.provider.NoViewProviderError;
+import org.eclipse.emf.ecp.view.spi.provider.ViewModelIsNullError;
+import org.eclipse.emf.ecp.view.spi.provider.ViewProviderHelper;
+import org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer;
+import org.eclipse.emf.ecp.view.spi.swt.reporting.AmbiguousRendererPriorityError;
+import org.eclipse.emf.ecp.view.spi.swt.reporting.InvalidGridDescriptionError;
+import org.eclipse.emf.ecp.view.spi.swt.reporting.NoRendererFoundError;
+import org.eclipse.emf.ecp.view.spi.swt.reporting.NoRenderingPossibleError;
+import org.eclipse.emf.ecp.view.spi.swt.reporting.RendererInitFailedError;
+import org.eclipse.emf.ecp.view.test.common.swt.DatabindingClassRunner;
+import org.eclipse.emf.ecp.view.test.common.swt.SWTViewTestHelper;
+import org.eclipse.emf.emfstore.bowling.BowlingFactory;
+import org.eclipse.emf.emfstore.bowling.League;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Unit test for renderer error aggregation service.
+ *
+ * @author emueller
+ */
+@RunWith(DatabindingClassRunner.class)
+public class RendererErrorTest {
+
+ private Shell shell;
+ private League league;
+ private VView view;
+ private ViewModelContext viewContext;
+ private ReportService reportService;
+ private TestSWTRendererFactory swtViewTestHelper;
+
+ @Before
+ public void before() {
+ shell = SWTViewTestHelper.createShell();
+ swtViewTestHelper = new TestSWTRendererFactory();
+ league = BowlingFactory.eINSTANCE.createLeague();
+ view = ViewProviderHelper.getView(league, null);
+ viewContext = ViewModelContextFactory.INSTANCE.createViewModelContext(view, league);
+ reportService = Activator.getInstance().getReportService();
+ }
+
+ @After
+ public void after() {
+ reportService.clearReports();
+ }
+
+ @Ignore
+ @Test
+ public void noErrors() throws ECPRendererException {
+ swtViewTestHelper.render(shell, viewContext);
+ assertEquals(0, reportService.getReports().size());
+ }
+
+ @Test
+ public void missingRenderer() throws ECPRendererException {
+ swtViewTestHelper.clearRenderers();
+ swtViewTestHelper.render(shell, viewContext);
+ assertThat(reportService.getReports(), hasSize(1));
+ assertThat(reportService.getReports().get(0), instanceOf(NoRendererFoundError.class));
+ }
+
+ @Test
+ public void rendererInit() throws ECPRendererException {
+ final ViewSWTRenderer failingInitRenderer = new ViewSWTRenderer() {
+ @Override
+ protected void postInit() {
+ throw new RuntimeException();
+ }
+ };
+
+ swtViewTestHelper.registerRenderer(3, cast(failingInitRenderer.getClass()), VView.class);
+
+ swtViewTestHelper.render(shell, viewContext);
+ assertThat(reportService.getReports(), hasSize(1));
+ assertThat(reportService.getReports().get(0), instanceOf(RendererInitFailedError.class));
+ }
+
+ @Test
+ public void samePriorityRenderers() throws ECPRendererException {
+ // modifiableSWTViewTestHelper.clearRenderers();
+
+ final ViewSWTRenderer viewRenderer = new ViewSWTRenderer();
+
+ swtViewTestHelper.registerRenderer(1, cast(viewRenderer.getClass()), VView.class);
+
+ swtViewTestHelper.render(shell, viewContext);
+ assertThat(reportService.getReports(), hasSize(1));
+ assertThat(reportService.getReports().get(0), instanceOf(AmbiguousRendererPriorityError.class));
+ }
+
+ @Test
+ public void invalidGridDescription() throws ECPRendererException {
+ swtViewTestHelper.replaceViewRenderer(1, cast(
+ MockViewSWTRenderer.withInvalidGridDescription().getClass()), VView.class);
+ swtViewTestHelper.render(shell, viewContext);
+ assertThat(reportService.getReports(), hasSize(1));
+ assertThat(reportService.getReports().get(0), instanceOf(InvalidGridDescriptionError.class));
+ }
+
+ @Test
+ public void noRendererFound() throws ECPRendererException {
+ swtViewTestHelper.replaceViewRenderer(1, cast(
+ MockViewSWTRenderer.withoutPropertyDescriptor().getClass()), VView.class);
+
+ swtViewTestHelper.render(shell, viewContext);
+ assertThat(reportService.getReports(), hasSize(1));
+ assertThat(reportService.getReports().get(0), instanceOf(NoRenderingPossibleError.class));
+ }
+
+ @Test
+ public void noPropertyDescriptorFound() throws ECPRendererException {
+ swtViewTestHelper.replaceViewRenderer(1, cast(
+ MockViewSWTRenderer.withoutPropertyDescriptor().getClass()), VView.class);
+
+ swtViewTestHelper.render(shell, viewContext);
+ assertThat(reportService.getReports(), hasSize(1));
+ assertThat(reportService.getReports().get(0), instanceOf(NoRenderingPossibleError.class));
+ }
+
+ @Test
+ public void viewProviderReturnsNullView() {
+ final ViewProviderImpl viewProvider = new ViewProviderImpl(false);
+ viewProvider.clearProviders();
+ viewProvider.addProvider(new IViewProvider() {
+ @Override
+ public VView generate(EObject eObject, Map<String, Object> context) {
+ return null;
+ }
+
+ @Override
+ public int canRender(EObject eObject, Map<String, Object> context) {
+ return 0;
+ }
+ });
+ viewProvider.getView(league, null);
+ assertThat(reportService.getReports(), hasSize(1));
+ assertThat(reportService.getReports().get(0), instanceOf(ViewModelIsNullError.class));
+ }
+
+ @Test
+ public void noViewProvider() {
+ final ViewProviderImpl viewProvider = new ViewProviderImpl(false);
+
+ viewProvider.clearProviders();
+ viewProvider.getView(league, null);
+ assertThat(reportService.getReports(), hasSize(1));
+ assertThat(reportService.getReports().get(0), instanceOf(NoViewProviderError.class));
+ }
+
+ @Test
+ public void noViewProviderInitFailed() {
+ final ViewProviderImpl viewProvider = new ViewProviderImpl(false);
+
+ viewProvider.clearProviders();
+ viewProvider.getView(league, null);
+ assertThat(reportService.getReports(), hasSize(1));
+ assertThat(reportService.getReports().get(0), instanceOf(NoViewProviderError.class));
+ }
+
+ // @Test
+ // public void initCustomControlFailed() {
+ //
+ // }
+
+ @SuppressWarnings({ "unchecked" })
+ private Class<AbstractSWTRenderer<VElement>> cast(Class<?> clazz) {
+ return (Class<AbstractSWTRenderer<VElement>>) clazz;
+ }
+}
diff --git a/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/SWTTestRendererFactoryImpl.java b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/SWTTestRendererFactoryImpl.java
new file mode 100644
index 0000000000..58c9c1bcbc
--- /dev/null
+++ b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/SWTTestRendererFactoryImpl.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.context.test;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecp.view.internal.core.swt.renderer.ViewSWTRenderer;
+import org.eclipse.emf.ecp.view.internal.swt.ECPRendererDescription;
+import org.eclipse.emf.ecp.view.internal.swt.SWTRendererFactoryImpl;
+
+class SWTTestRendererFactoryImpl extends SWTRendererFactoryImpl {
+
+ public void clearRenderers() {
+ getRendererDescriptors().clear();
+ }
+
+ public void registerRenderer(ECPRendererDescription descriptor) {
+ getRendererDescriptors().add(descriptor);
+ }
+
+ public void replaceViewRenderer(ECPRendererDescription newDescription) {
+
+ final Iterator<ECPRendererDescription> iterator = getRendererDescriptors().iterator();
+
+ ECPRendererDescription oldRenderer = null;
+ while (iterator.hasNext()) {
+ final ECPRendererDescription next = iterator.next();
+ if (next.getRenderer().equals(ViewSWTRenderer.class)) {
+ oldRenderer = next;
+ break;
+ }
+ }
+
+ getRendererDescriptors().remove(oldRenderer);
+ getRendererDescriptors().add(newDescription);
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/TestSWTRendererFactory.java b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/TestSWTRendererFactory.java
new file mode 100644
index 0000000000..d0162ee941
--- /dev/null
+++ b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/TestSWTRendererFactory.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.context.test;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.eclipse.emf.ecp.ui.view.ECPRendererException;
+import org.eclipse.emf.ecp.ui.view.swt.ECPSWTView;
+import org.eclipse.emf.ecp.view.internal.swt.ECPRendererDescription;
+import org.eclipse.emf.ecp.view.internal.swt.ECPSWTViewRendererImpl;
+import org.eclipse.emf.ecp.view.model.common.ECPRendererTester;
+import org.eclipse.emf.ecp.view.model.common.ECPStaticRendererTester;
+import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
+import org.eclipse.emf.ecp.view.spi.model.VElement;
+import org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer;
+import org.eclipse.emf.ecp.view.spi.swt.SWTRendererFactory;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * SWT Test renderer factory that allows to register and unregister renderers.
+ *
+ * @author emueller
+ *
+ */
+public class TestSWTRendererFactory {
+
+ private final SWTTestRendererFactoryImpl factory;
+
+ public TestSWTRendererFactory() {
+ factory = new SWTTestRendererFactoryImpl();
+ }
+
+ public void clearRenderers() {
+ factory.clearRenderers();
+ }
+
+ public ECPSWTView render(Composite parent, ViewModelContext viewModelContext) throws ECPRendererException {
+ final ECPSWTViewRendererImpl renderer = new ECPSWTViewRendererImpl() {
+ @Override
+ protected SWTRendererFactory createFactory() {
+ return factory;
+ }
+ };
+ return renderer.render(parent, viewModelContext);
+ }
+
+ public void registerRenderer(int priority,
+ Class<AbstractSWTRenderer<VElement>> class1,
+ Class<? extends VElement> supportedEObject) {
+
+ final Set<ECPRendererTester> tester = new LinkedHashSet<ECPRendererTester>();
+ tester.add(new ECPStaticRendererTester(priority, supportedEObject));
+ final ECPRendererDescription descriptor = new ECPRendererDescription(class1, tester);
+ factory.registerRenderer(descriptor);
+ }
+
+ public void replaceViewRenderer(int priority, Class<AbstractSWTRenderer<VElement>> class1,
+ Class<? extends VElement> supportedEObject) {
+
+ final Set<ECPRendererTester> tester = new LinkedHashSet<ECPRendererTester>();
+ tester.add(new ECPStaticRendererTester(priority, supportedEObject));
+ final ECPRendererDescription descriptor = new ECPRendererDescription(class1, tester);
+ factory.replaceViewRenderer(descriptor);
+ }
+
+}
diff --git a/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/MockViewSWTRenderer.java b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/MockViewSWTRenderer.java
new file mode 100644
index 0000000000..82ea51be1a
--- /dev/null
+++ b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/MockViewSWTRenderer.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.context.test.mockup;
+
+import org.eclipse.emf.ecp.view.internal.core.swt.renderer.ViewSWTRenderer;
+
+public final class MockViewSWTRenderer {
+
+ private MockViewSWTRenderer() {
+ }
+
+ public static ViewSWTRenderer withInvalidGridDescription() {
+ return new ViewSWTRendererWithInvalidGridDescription();
+ }
+
+ public static ViewSWTRenderer withoutPropertyDescriptor() {
+ return new ViewSWTRendererWithNoPropertyDescriptorFoundException();
+ }
+
+ public static ViewSWTRenderer withoutRenderer() {
+ return new ViewSWTRendererWithNoRendererFoundException();
+ }
+
+}
diff --git a/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/ViewSWTRendererWithInvalidGridDescription.java b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/ViewSWTRendererWithInvalidGridDescription.java
new file mode 100644
index 0000000000..2b4f869e63
--- /dev/null
+++ b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/ViewSWTRendererWithInvalidGridDescription.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.context.test.mockup;
+
+import org.eclipse.emf.ecp.view.internal.core.swt.renderer.ViewSWTRenderer;
+import org.eclipse.emf.ecp.view.spi.swt.layout.GridDescriptionFactory;
+import org.eclipse.emf.ecp.view.spi.swt.layout.SWTGridDescription;
+
+public class ViewSWTRendererWithInvalidGridDescription extends ViewSWTRenderer {
+
+ @Override
+ public SWTGridDescription getGridDescription(
+ SWTGridDescription gridDescription) {
+ return GridDescriptionFactory.INSTANCE.createSimpleGrid(2, 1, this);
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/ViewSWTRendererWithNoPropertyDescriptorFoundException.java b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/ViewSWTRendererWithNoPropertyDescriptorFoundException.java
new file mode 100644
index 0000000000..1fe014e79f
--- /dev/null
+++ b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/ViewSWTRendererWithNoPropertyDescriptorFoundException.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.context.test.mockup;
+
+import org.eclipse.emf.ecp.view.internal.core.swt.renderer.ViewSWTRenderer;
+import org.eclipse.emf.ecp.view.spi.renderer.NoPropertyDescriptorFoundExeption;
+import org.eclipse.emf.ecp.view.spi.renderer.NoRendererFoundException;
+import org.eclipse.emf.ecp.view.spi.swt.layout.SWTGridCell;
+import org.eclipse.emf.emfstore.bowling.BowlingPackage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+public class ViewSWTRendererWithNoPropertyDescriptorFoundException extends ViewSWTRenderer {
+
+ public ViewSWTRendererWithNoPropertyDescriptorFoundException() {
+
+ }
+
+ @Override
+ public Control render(SWTGridCell cell, Composite parent)
+ throws NoRendererFoundException, NoPropertyDescriptorFoundExeption {
+ throw new NoPropertyDescriptorFoundExeption(getViewModelContext().getDomainModel(),
+ BowlingPackage.eINSTANCE.getLeague_Name());
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/ViewSWTRendererWithNoRendererFoundException.java b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/ViewSWTRendererWithNoRendererFoundException.java
new file mode 100644
index 0000000000..1650063040
--- /dev/null
+++ b/tests/org.eclipse.emf.ecp.view.context.test/src/org/eclipse/emf/ecp/view/context/test/mockup/ViewSWTRendererWithNoRendererFoundException.java
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH 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:
+ * Edgar Mueller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.emf.ecp.view.context.test.mockup;
+
+import org.eclipse.emf.ecp.view.internal.core.swt.renderer.ViewSWTRenderer;
+import org.eclipse.emf.ecp.view.spi.renderer.NoPropertyDescriptorFoundExeption;
+import org.eclipse.emf.ecp.view.spi.renderer.NoRendererFoundException;
+import org.eclipse.emf.ecp.view.spi.swt.layout.SWTGridCell;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+public class ViewSWTRendererWithNoRendererFoundException extends ViewSWTRenderer {
+
+ public ViewSWTRendererWithNoRendererFoundException() {
+
+ }
+
+ @Override
+ public Control render(SWTGridCell cell, Composite parent)
+ throws NoRendererFoundException, NoPropertyDescriptorFoundExeption {
+ throw new NoRendererFoundException(getVElement());
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/plugin.xml b/tests/org.eclipse.emf.ecp.view.core.swt.tests/plugin.xml
deleted file mode 100644
index d6375a34fb..0000000000
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/plugin.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
-
-
- <extension point="org.eclipse.emf.ecore.generated_package">
- <!-- @generated test -->
- <package
- uri="http://eclipse.org/emf/ecp/core/test"
- class="org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage"
- genModel="model/test.genmodel"/>
- </extension>
-
-</plugin>
diff --git a/tests/org.eclipse.emf.ecp.view.test.common.swt/META-INF/MANIFEST.MF b/tests/org.eclipse.emf.ecp.view.test.common.swt/META-INF/MANIFEST.MF
index 60cb98ccfa..14e10997ac 100644
--- a/tests/org.eclipse.emf.ecp.view.test.common.swt/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.emf.ecp.view.test.common.swt/META-INF/MANIFEST.MF
@@ -15,5 +15,4 @@ Require-Bundle: org.eclipse.swt;bundle-version="[3.1.0,4.0.0)",
org.eclipse.emf.ecp.ui.view.swt;bundle-version="[1.4.0,2.0.0)",
org.eclipse.emf.ecp.edit;bundle-version="[1.4.0,2.0.0)",
org.eclipse.emf.ecp.ui.view.test;bundle-version="[1.4.0,2.0.0)"
-Export-Package: org.eclipse.emf.ecp.view.test.common.swt;version="1.5.
- 0";x-friends:="org.eclipse.emf.ecp.view.stack.ui.swt.test"
+Export-Package: org.eclipse.emf.ecp.view.test.common.swt;version="1.5.0";x-friends:="org.eclipse.emf.ecp.view.stack.ui.swt.test,org.eclipse.emf.ecp.view.context.test"

Back to the top