Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2013-03-06 04:57:09 -0500
committercletavernie2013-03-06 04:57:09 -0500
commitae6e412bc4fdea543cffbbdc2964335f5a2efa57 (patch)
treef95cd9b57c4b2501fa0a7b17dd99539953ad3d39
parent8be32fb7c45059308df91e8fbeebdd85d6e937f5 (diff)
downloadorg.eclipse.papyrus-ae6e412bc4fdea543cffbbdc2964335f5a2efa57.tar.gz
org.eclipse.papyrus-ae6e412bc4fdea543cffbbdc2964335f5a2efa57.tar.xz
org.eclipse.papyrus-ae6e412bc4fdea543cffbbdc2964335f5a2efa57.zip
290952: [CDO] Support for CDO model repository
https://bugs.eclipse.org/bugs/show_bug.cgi?id=290952 Merged the cdo_kepler branch to the trunk (r9967 -> r10361). views.validation
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/.classpath7
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/.project28
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/META-INF/MANIFEST.MF23
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/about.html28
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/build.properties9
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/icons/full/elcl16/goto_marker.gifbin0 -> 372 bytes
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/icons/full/view16/model_validation.gifbin0 -> 104 bytes
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/plugin.properties13
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/plugin.xml60
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/Activator.java71
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/IValidationMarkerListener.java26
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ModelValidationPage.java330
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ModelValidationView.java160
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ValidationMarkersService.java118
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ViewSettings.java154
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/AbstractMarkerAction.java64
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/CopyMarkerAction.java112
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/DeleteMarkerAction.java53
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/GotoMarkerAction.java66
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/SelectAllAction.java49
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/DescriptionLabelProvider.java36
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ElementLabelProvider.java76
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/InvertedViewerComparator.java73
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/LabelProviderSorter.java43
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/PathLabelProvider.java65
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemCellLabelProvider.java41
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemLabelProvider.java36
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemsContentProvider.java167
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/SeverityLabelProvider.java80
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/TypeLabelProvider.java44
31 files changed, 2039 insertions, 0 deletions
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/.classpath b/plugins/views/validation/org.eclipse.papyrus.views.validation/.classpath
new file mode 100644
index 00000000000..64c5e31b7a2
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/.project b/plugins/views/validation/org.eclipse.papyrus.views.validation/.project
new file mode 100644
index 00000000000..902318fcefa
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.views.validation</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/.settings/org.eclipse.jdt.core.prefs b/plugins/views/validation/org.eclipse.papyrus.views.validation/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..af0f20f97a5
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/META-INF/MANIFEST.MF b/plugins/views/validation/org.eclipse.papyrus.views.validation/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..23f81c0425f
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
+Bundle-SymbolicName: org.eclipse.papyrus.views.validation;singleton:=true
+Bundle-Version: 0.10.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.views.validation.internal.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.ui,
+ org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.services.markerlistener;bundle-version="0.10.0",
+ org.eclipse.emf.ecore;bundle-version="2.8.0",
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
+ org.eclipse.emf.edit.ui;bundle-version="2.8.0",
+ org.eclipse.emf.transaction;bundle-version="1.4.0",
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.widgets;bundle-version="0.10.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Export-Package: org.eclipse.papyrus.views.validation.internal
+Import-Package: com.google.common.base;version="10.0.1",
+ com.google.common.collect;version="10.0.1"
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/about.html b/plugins/views/validation/org.eclipse.papyrus.views.validation/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>November 14, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/build.properties b/plugins/views/validation/org.eclipse.papyrus.views.validation/build.properties
new file mode 100644
index 00000000000..9f45063bc21
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/build.properties
@@ -0,0 +1,9 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ icons/,\
+ plugin.properties,\
+ plugin.xml
+src.includes = about.html
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/icons/full/elcl16/goto_marker.gif b/plugins/views/validation/org.eclipse.papyrus.views.validation/icons/full/elcl16/goto_marker.gif
new file mode 100644
index 00000000000..cf62b63ae3e
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/icons/full/elcl16/goto_marker.gif
Binary files differ
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/icons/full/view16/model_validation.gif b/plugins/views/validation/org.eclipse.papyrus.views.validation/icons/full/view16/model_validation.gif
new file mode 100644
index 00000000000..a7753cd9c01
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/icons/full/view16/model_validation.gif
Binary files differ
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/plugin.properties b/plugins/views/validation/org.eclipse.papyrus.views.validation/plugin.properties
new file mode 100644
index 00000000000..9843eca5367
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/plugin.properties
@@ -0,0 +1,13 @@
+# Copyright (c) 2013 CEA LIST.
+#
+# 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:
+# CEA LIST - Initial API and implementation
+#
+
+pluginName = Papyrus Model Validation View (Incubation)
+providerName = Eclipse Modeling Project
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/plugin.xml b/plugins/views/validation/org.eclipse.papyrus.views.validation/plugin.xml
new file mode 100644
index 00000000000..328fd311091
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/plugin.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+
+<!--
+ Copyright (c) 2013 CEA LIST.
+
+ 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:
+ CEA LIST - Initial API and implementation
+
+-->
+
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ category="org.eclipse.papyrus.views.category"
+ class="org.eclipse.papyrus.views.validation.internal.ModelValidationView"
+ icon="icons/full/view16/model_validation.gif"
+ id="org.eclipse.papyrus.views.validation.ModelValidationView"
+ name="Model Validation"
+ restorable="true">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.eclipse.papyrus.infra.core.perspective">
+ <viewShortcut
+ id="org.eclipse.papyrus.views.validation.ModelValidationView">
+ </viewShortcut>
+ <view
+ id="org.eclipse.papyrus.views.validation.ModelValidationView"
+ minimized="false"
+ relationship="stack"
+ relative="org.eclipse.ui.views.ProblemView">
+ </view>
+ </perspectiveExtension>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.core.service">
+ <service
+ classname="org.eclipse.papyrus.views.validation.internal.ValidationMarkersService"
+ description="Validation markers tracking service for the Model Validation View."
+ id="org.eclipse.papyrus.views.validation.internal.ValidationMarkersService"
+ priority="1"
+ startKind="startup">
+ </service>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.services.markerlistener.markereventlistener">
+ <listener
+ class="org.eclipse.papyrus.views.validation.internal.ValidationMarkersService">
+ </listener>
+ </extension>
+</plugin>
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/Activator.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/Activator.java
new file mode 100644
index 00000000000..00d95978fd0
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/Activator.java
@@ -0,0 +1,71 @@
+package org.eclipse.papyrus.views.validation.internal;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator
+ extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.views.validation"; //$NON-NLS-1$
+
+ public static final String ICON_GOTO_MARKER = "goto_marker"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /** Logging helper */
+ public static LogHelper log = new LogHelper();
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ super();
+ }
+
+ public void start(BundleContext context)
+ throws Exception {
+
+ super.start(context);
+ plugin = this;
+
+ // register the log helper
+ log.setPlugin(plugin);
+ }
+
+ public void stop(BundleContext context)
+ throws Exception {
+
+ plugin = null;
+ log = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ @Override
+ protected void initializeImageRegistry(ImageRegistry reg) {
+ super.initializeImageRegistry(reg);
+
+ reg.put(ICON_GOTO_MARKER,
+ getImageDescriptor("full/elcl16/goto_marker.gif")); //$NON-NLS-1$
+ }
+
+ protected ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, "$nl$/icons/" + path); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/IValidationMarkerListener.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/IValidationMarkerListener.java
new file mode 100644
index 00000000000..0d50ae8c575
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/IValidationMarkerListener.java
@@ -0,0 +1,26 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal;
+
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+
+/**
+ * This is the IValidationMarkerListener type. Enjoy.
+ */
+public interface IValidationMarkerListener {
+
+ void notifyMarkerChange(IPapyrusMarker marker, MarkerChangeKind kind);
+
+ enum MarkerChangeKind {
+ ADDED, REMOVED;
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ModelValidationPage.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ModelValidationPage.java
new file mode 100644
index 00000000000..fe4c777e15f
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ModelValidationPage.java
@@ -0,0 +1,330 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal;
+
+import static org.eclipse.papyrus.views.validation.internal.providers.InvertedViewerComparator.direction;
+import static org.eclipse.papyrus.views.validation.internal.providers.InvertedViewerComparator.invert;
+
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.views.validation.internal.actions.CopyMarkerAction;
+import org.eclipse.papyrus.views.validation.internal.actions.DeleteMarkerAction;
+import org.eclipse.papyrus.views.validation.internal.actions.GotoMarkerAction;
+import org.eclipse.papyrus.views.validation.internal.actions.SelectAllAction;
+import org.eclipse.papyrus.views.validation.internal.providers.DescriptionLabelProvider;
+import org.eclipse.papyrus.views.validation.internal.providers.ElementLabelProvider;
+import org.eclipse.papyrus.views.validation.internal.providers.InvertedViewerComparator;
+import org.eclipse.papyrus.views.validation.internal.providers.PathLabelProvider;
+import org.eclipse.papyrus.views.validation.internal.providers.ProblemLabelProvider;
+import org.eclipse.papyrus.views.validation.internal.providers.ProblemsContentProvider;
+import org.eclipse.papyrus.views.validation.internal.providers.SeverityLabelProvider;
+import org.eclipse.papyrus.views.validation.internal.providers.TypeLabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.part.Page;
+
+/**
+ * This is the ModelValidationPage type. Enjoy.
+ */
+public class ModelValidationPage
+ extends Page {
+
+ private final ViewSettings settings;
+
+ private ValidationMarkersService markers;
+
+ private LabelProviderService labelProviders;
+
+ private ModelSet modelSet;
+
+ private Control control;
+
+ private TableViewer table;
+
+ private GotoMarkerAction gotoMarkerAction;
+
+ private CopyMarkerAction copyMarkerAction;
+
+ private DeleteMarkerAction deleteMarkerAction;
+
+ private SelectAllAction selectAllAction;
+
+ private boolean ready;
+
+ public ModelValidationPage(ServicesRegistry services, ViewSettings settings)
+ throws ServiceException {
+
+ super();
+
+ this.settings = settings;
+
+ this.markers = ServiceUtils.getInstance().getService(
+ ValidationMarkersService.class, services);
+ this.labelProviders = ServiceUtils.getInstance().getService(
+ LabelProviderService.class, services);
+ this.modelSet = ServiceUtils.getInstance().getModelSet(services);
+ }
+
+ @Override
+ public void dispose() {
+ markers = null;
+ modelSet = null;
+
+ super.dispose();
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite tableParent = new Composite(parent, SWT.NONE);
+ control = tableParent;
+ TableColumnLayout layout = new TableColumnLayout();
+ tableParent.setLayout(layout);
+
+ table = new TableViewer(tableParent, SWT.BORDER | SWT.V_SCROLL
+ | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
+ table.getTable().setHeaderVisible(true);
+ table.getTable().setLinesVisible(true);
+ table.setUseHashlookup(true);
+
+ // the severity column has fixed width
+ TableViewerColumn severity = new TableViewerColumn(table, SWT.NONE);
+ layout.setColumnData(severity.getColumn(), new ColumnPixelData(24,
+ false));
+ severity.getColumn().setResizable(false);
+ labels(severity, new SeverityLabelProvider());
+
+ // the other columns are user-resizable
+ labels(column(table, "Description"), new DescriptionLabelProvider());
+ labels(column(table, "Element"), new ElementLabelProvider(modelSet));
+ labels(column(table, "Path"), new PathLabelProvider(labelProviders));
+ labels(column(table, "Type"), new TypeLabelProvider());
+
+ ColumnViewerToolTipSupport.enableFor(table);
+
+ table.setContentProvider(new ProblemsContentProvider());
+ table.setInput(markers);
+
+ table.addDoubleClickListener(new IDoubleClickListener() {
+
+ public void doubleClick(DoubleClickEvent event) {
+ if (gotoMarkerAction.isEnabled()) {
+ gotoMarkerAction.run();
+ }
+ }
+ });
+
+ getSite().setSelectionProvider(table);
+
+ createActions();
+ createContextMenu();
+
+ table.getControl().getDisplay().asyncExec(new Runnable() {
+
+ public void run() {
+ updateColumnWidth(-1);
+ }
+ });
+ }
+
+ private TableViewerColumn column(TableViewer table, String title) {
+ TableViewerColumn result = new TableViewerColumn(table, SWT.NONE);
+ result.getColumn().setText(title);
+
+ TableColumnLayout layout = (TableColumnLayout) table.getControl()
+ .getParent().getLayout();
+
+ final int columnIndex = table.getTable().indexOf(result.getColumn());
+
+ int width = settings.getColumnWidth(columnIndex);
+ ColumnLayoutData layoutData;
+ if (width < 0) {
+ // it's a relative weight
+ layoutData = new ColumnWeightData(-width, true);
+ } else {
+ layoutData = new ColumnPixelData(width, true);
+ }
+ layout.setColumnData(result.getColumn(), layoutData);
+
+ result.getColumn().addListener(SWT.Resize, new Listener() {
+
+ public void handleEvent(Event event) {
+ updateColumnWidth(columnIndex);
+ }
+ });
+
+ return result;
+ }
+
+ private TableViewerColumn labels(final TableViewerColumn col,
+ ProblemLabelProvider labelProvider) {
+
+ final TableViewer viewer = (TableViewer) col.getViewer();
+ final ViewerComparator sorter = labelProvider.createSorter();
+ final int columnIndex = viewer.getTable().indexOf(col.getColumn());
+
+ col.setLabelProvider(labelProvider.createCellLabelProvider());
+ col.getColumn().addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ ViewerComparator current = viewer.getComparator();
+
+ if (InvertedViewerComparator.unwrap(current) == sorter) {
+ // toggle the sort direction
+ ViewerComparator newSorter = invert(current);
+ viewer.setComparator(newSorter);
+
+ int direction = direction(newSorter);
+ viewer.getTable().setSortDirection(direction);
+ settings.setSortDirection(direction);
+ } else {
+ viewer.setComparator(sorter);
+ viewer.getTable().setSortColumn(col.getColumn());
+ viewer.getTable().setSortDirection(SWT.UP);
+
+ settings.setSortColumn(columnIndex);
+ settings.setSortDirection(SWT.UP);
+ }
+ }
+ });
+
+ if (settings.getSortColumn() == columnIndex) {
+ int direction = settings.getSortDirection();
+ viewer.setComparator(direction == SWT.UP
+ ? sorter
+ : invert(sorter));
+ viewer.getTable().setSortColumn(col.getColumn());
+ viewer.getTable().setSortDirection(direction);
+ }
+
+ return col;
+ }
+
+ private void createContextMenu() {
+ MenuManager contextMenu = new MenuManager();
+ contextMenu.setRemoveAllWhenShown(true);
+ contextMenu.addMenuListener(new IMenuListener() {
+
+ public void menuAboutToShow(IMenuManager manager) {
+ fillContextMenu(manager);
+ }
+ });
+
+ Menu menu = contextMenu.createContextMenu(table.getControl());
+ table.getControl().setMenu(menu);
+
+ getSite().registerContextMenu(ModelValidationView.VIEW_ID, contextMenu,
+ table);
+ }
+
+ protected void createActions() {
+ final ISelectionProvider selectionProvider = getSite()
+ .getSelectionProvider();
+
+ gotoMarkerAction = new GotoMarkerAction(getSite());
+ selectionProvider.addSelectionChangedListener(gotoMarkerAction);
+ copyMarkerAction = new CopyMarkerAction(getSite());
+ selectionProvider.addSelectionChangedListener(copyMarkerAction);
+ deleteMarkerAction = new DeleteMarkerAction(getSite());
+ selectionProvider.addSelectionChangedListener(deleteMarkerAction);
+ selectAllAction = new SelectAllAction(getSite());
+
+ final IActionBars actionBars = getSite().getActionBars();
+ actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(),
+ copyMarkerAction);
+ actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(),
+ deleteMarkerAction);
+ actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(),
+ selectAllAction);
+ }
+
+ protected void fillContextMenu(IMenuManager menu) {
+ menu.add(gotoMarkerAction);
+ menu.add(copyMarkerAction);
+ menu.add(deleteMarkerAction);
+ menu.add(selectAllAction);
+
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ @Override
+ public Control getControl() {
+ return control;
+ }
+
+ @Override
+ public void setFocus() {
+ // pass
+ }
+
+ private void updateColumnWidth(int index) {
+ if ((index >= 0) != ready) {
+ return;
+ }
+
+ if (index < 0) {
+ // initialization step: normalize all of the layout data to pixels
+ ready = true;
+
+ final int startIndex = 1; // the severity column is not resizable
+ TableColumn[] columns = table.getTable().getColumns();
+ Composite parent = table.getTable().getParent();
+ TableColumnLayout layout = (TableColumnLayout) parent.getLayout();
+
+ // store the widths
+ for (int i = startIndex; i < columns.length; i++) {
+ settings.setColumnWidth(i, columns[i].getWidth());
+ }
+
+ // apply to the columns
+ for (int i = startIndex; i < columns.length; i++) {
+ layout.setColumnData(columns[i],
+ new ColumnPixelData(settings.getColumnWidth(i)));
+ }
+
+ // discover the new layout data
+ parent.layout();
+ } else {
+ // update the settings for next time
+ settings.setColumnWidth(index, table.getTable().getColumn(index)
+ .getWidth());
+ }
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ModelValidationView.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ModelValidationView.java
new file mode 100644
index 00000000000..f1e255045e0
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ModelValidationView.java
@@ -0,0 +1,160 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal;
+
+import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.IPage;
+import org.eclipse.ui.part.IPageBookViewPage;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.part.PageBookView;
+
+/**
+ * This is the ModelValidationView type. Enjoy.
+ */
+public class ModelValidationView
+ extends PageBookView {
+
+ public static final String VIEW_ID = "org.eclipse.papyrus.views.validation.ModelValidationView";
+
+ private ViewSettings settings;
+
+ public ModelValidationView() {
+ super();
+ }
+
+ @Override
+ public void init(IViewSite site, IMemento memento)
+ throws PartInitException {
+
+ super.init(site, memento);
+
+ this.settings = new ViewSettings(memento);
+ }
+
+ @Override
+ public void saveState(IMemento memento) {
+ super.saveState(memento);
+
+ settings.save(memento);
+ }
+
+ @Override
+ protected IPage createDefaultPage(PageBook book) {
+ IPageBookViewPage result = new MessagePage(
+ "No model editor is currently active.");
+
+ initPage(result);
+ result.createControl(book);
+
+ return result;
+ }
+
+ @Override
+ protected PageRec doCreatePage(IWorkbenchPart part) {
+ ServicesRegistry services = getServicesRegistry(part);
+
+ IPageBookViewPage result;
+ try {
+ result = (services == null)
+ ? new MessagePage("Invalid model editor selected.")
+ : new ModelValidationPage(services, settings);
+ } catch (ServiceException e) {
+ String message = "Failed to obtain services required for Model Validation View.";
+ Activator.log.error(message, e);
+ result = new MessagePage(message);
+ }
+
+ initPage(result);
+ result.createControl(getPageBook());
+
+ return new PageRec(part, result);
+ }
+
+ private ServicesRegistry getServicesRegistry(IWorkbenchPart part) {
+ ServicesRegistry result = null;
+
+ if (part instanceof IMultiDiagramEditor) {
+ IMultiDiagramEditor editor = (IMultiDiagramEditor) part;
+ result = editor.getServicesRegistry();
+ }
+
+ return result;
+ }
+
+ @Override
+ protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) {
+ pageRecord.page.dispose();
+ }
+
+ @Override
+ protected IWorkbenchPart getBootstrapPart() {
+ IWorkbenchPart result = null;
+
+ IEditorPart editor = getSite().getPage().getActiveEditor();
+ if ((editor != null) && isImportant(editor)) {
+ result = editor;
+ }
+
+ return result;
+ }
+
+ @Override
+ protected boolean isImportant(IWorkbenchPart part) {
+ return part instanceof IMultiDiagramEditor;
+ }
+
+ //
+ // Nested types
+ //
+
+ private static class MessagePage
+ extends Page {
+
+ private String message;
+
+ private Label label;
+
+ MessagePage(String message) {
+ super();
+
+ this.message = message;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ label = new Label(parent, SWT.CENTER);
+ label.setText(message);
+ }
+
+ @Override
+ public Control getControl() {
+ return label;
+ }
+
+ @Override
+ public void setFocus() {
+ // pass
+ }
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ValidationMarkersService.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ValidationMarkersService.java
new file mode 100644
index 00000000000..95b1016f784
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ValidationMarkersService.java
@@ -0,0 +1,118 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal;
+
+import java.util.Collection;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.services.markerlistener.IMarkerEventListener;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.eclipse.papyrus.views.validation.internal.IValidationMarkerListener.MarkerChangeKind;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+
+/**
+ * This is the ValidationMarkersService type. Enjoy.
+ */
+public class ValidationMarkersService
+ implements IMarkerEventListener {
+
+ private ModelSet modelSet;
+
+ private final Multimap<EObject, IPapyrusMarker> markers = HashMultimap
+ .create();
+
+ private final CopyOnWriteArrayList<IValidationMarkerListener> listeners = new CopyOnWriteArrayList<IValidationMarkerListener>();
+
+ public ValidationMarkersService() {
+ super();
+ }
+
+ public void init(ServicesRegistry services)
+ throws ServiceException {
+
+ modelSet = ServiceUtils.getInstance().getModelSet(services);
+ }
+
+ public void startService()
+ throws ServiceException {
+
+ // pass
+ }
+
+ public void disposeService()
+ throws ServiceException {
+
+ markers.clear();
+ modelSet = null;
+ }
+
+ public boolean isNotifiedOnInitialMarkerCheck() {
+ return true;
+ }
+
+ public void notifyMarkerChange(EObject eObjectOfMarker,
+ IPapyrusMarker marker, int addedOrRemoved) {
+
+ MarkerChangeKind kind = (addedOrRemoved == MARKER_ADDED)
+ ? MarkerChangeKind.ADDED
+ : MarkerChangeKind.REMOVED;
+
+ switch (kind) {
+ case ADDED :
+ markers.put(eObjectOfMarker, marker);
+ break;
+ case REMOVED :
+ // workspace markers don't know their EObjects, so we can't look
+ // up the mapping to remove by key
+ markers.values().remove(marker);
+ break;
+ }
+
+ for (IValidationMarkerListener next : listeners) {
+ try {
+ next.notifyMarkerChange(marker, kind);
+ } catch (Exception e) {
+ Activator.log.error(
+ "Uncaught exception in validation marker listener.", e);
+ }
+ }
+ }
+
+ public ModelSet getModelSet() {
+ return modelSet;
+ }
+
+ public Collection<IPapyrusMarker> getMarkers() {
+ return markers.values();
+ }
+
+ public Collection<IPapyrusMarker> getMarkers(EObject object) {
+ return markers.get(object);
+ }
+
+ public void addValidationMarkerListener(IValidationMarkerListener listener) {
+ listeners.addIfAbsent(listener);
+ }
+
+ public void removeValidationMarkerListener(
+ IValidationMarkerListener listener) {
+
+ listeners.remove(listener);
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ViewSettings.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ViewSettings.java
new file mode 100644
index 00000000000..b66fb7e0909
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/ViewSettings.java
@@ -0,0 +1,154 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.IMemento;
+
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * This is the ViewSettings type. Enjoy.
+ */
+class ViewSettings {
+
+ // the Element column is 2
+ private static int DEFAULT_SORT_COLUMN = 2;
+
+ private static int DEFAULT_SORT_DIRECTION = SWT.UP;
+
+ // negative values indicate relative weights
+ private static Integer[] DEFAULT_COLUMN_WIDTHS = {0, -30, -25, -30, -15};
+
+ private static int DEFAULT_COLUMN_WIDTH = 30;
+
+ private List<Integer> columnWidths;
+
+ private int sortColumn;
+
+ private int sortDirection;
+
+ public ViewSettings(IMemento memento) {
+ if (memento != null) {
+ load(memento);
+ } else {
+ initDefaults();
+ }
+ }
+
+ public int getSortColumn() {
+ return sortColumn;
+ }
+
+ public void setSortColumn(int index) {
+ sortColumn = index;
+ }
+
+ public int getSortDirection() {
+ return sortDirection;
+ }
+
+ public void setSortDirection(int direction) {
+ sortDirection = (direction == SWT.DOWN)
+ ? SWT.DOWN
+ : SWT.UP;
+ }
+
+ public int getColumnWidth(int index) {
+ int result = DEFAULT_COLUMN_WIDTH;
+
+ if ((index >= 0) && (index < columnWidths.size())) {
+ result = columnWidths.get(index);
+ }
+
+ return result;
+ }
+
+ public void setColumnWidth(int index, int weight) {
+ if (index >= 0) {
+ if (index < columnWidths.size()) {
+ columnWidths.set(index, weight);
+ } else {
+ if (index > columnWidths.size()) {
+ // pad
+ columnWidths.addAll(Collections.nCopies(index
+ - columnWidths.size(), DEFAULT_COLUMN_WIDTH));
+ }
+ columnWidths.add(weight);
+ }
+ }
+ }
+
+ public void save(IMemento memento) {
+ setIntegerList(memento, "columnWidths", columnWidths);
+ memento.putInteger("sortColumn", sortColumn);
+ memento.putInteger("sortDirection", sortDirection);
+ }
+
+ private void load(IMemento memento) {
+ columnWidths = getIntegerList(memento, "columnWidths",
+ DEFAULT_COLUMN_WIDTHS);
+ sortColumn = getInt(memento, "sortColumn", DEFAULT_SORT_COLUMN);
+ sortDirection = getInt(memento, "sortDirection", DEFAULT_SORT_DIRECTION);
+ }
+
+ private void initDefaults() {
+ columnWidths = Lists.newArrayList(DEFAULT_COLUMN_WIDTHS);
+ sortColumn = DEFAULT_SORT_COLUMN;
+ sortDirection = DEFAULT_SORT_DIRECTION;
+ }
+
+ private int getInt(IMemento memento, String key, int defaultValue) {
+ Integer value = memento.getInteger(key);
+
+ return (value == null)
+ ? defaultValue
+ : value.intValue();
+ }
+
+ private List<Integer> getIntegerList(IMemento memento, String key,
+ Integer[] defaultValue) {
+
+ List<Integer> result;
+
+ String stringValue = memento.getString(key);
+ if (stringValue == null) {
+ result = Lists.newArrayList(defaultValue);
+ } else {
+ result = Lists.newArrayList(Iterables.transform(Splitter.on(',')
+ .trimResults().split(stringValue),
+ new Function<String, Integer>() {
+
+ public Integer apply(String input) {
+ return "".equals(input)
+ ? DEFAULT_COLUMN_WIDTH
+ : Integer.valueOf(input);
+ }
+ }));
+ }
+
+ return result;
+ }
+
+ private void setIntegerList(IMemento memento, String key,
+ Iterable<Integer> values) {
+
+ memento.putString(key, Joiner.on(',').join(values));
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/AbstractMarkerAction.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/AbstractMarkerAction.java
new file mode 100644
index 00000000000..c2b82a989d6
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/AbstractMarkerAction.java
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.actions;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * This is the AbstractMarkerAction type. Enjoy.
+ */
+public class AbstractMarkerAction
+ extends BaseSelectionListenerAction {
+
+ private IWorkbenchSite site;
+
+ private Collection<IPapyrusMarker> markers;
+
+ public AbstractMarkerAction(IWorkbenchSite site, String label) {
+ super(label);
+
+ this.site = site;
+
+ setEnabled(false);
+ }
+
+ protected IWorkbenchSite getSite() {
+ return site;
+ }
+
+ protected IPapyrusMarker getMarker() {
+ return Iterables.getFirst(markers, null);
+ }
+
+ protected Collection<IPapyrusMarker> getMarkers() {
+ return markers;
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ markers = selection.isEmpty()
+ ? Collections.<IPapyrusMarker> emptyList()
+ : Lists.newArrayList(Iterables.filter(selection.toList(),
+ IPapyrusMarker.class));
+
+ return !markers.isEmpty() && super.updateSelection(selection);
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/CopyMarkerAction.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/CopyMarkerAction.java
new file mode 100644
index 00000000000..f554a9991f0
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/CopyMarkerAction.java
@@ -0,0 +1,112 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.actions;
+
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+
+/**
+ * This is the CopyMarkerAction type. Enjoy.
+ */
+public class CopyMarkerAction
+ extends AbstractMarkerAction {
+
+ public CopyMarkerAction(IWorkbenchSite site) {
+ super(site, "Copy");
+
+ setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+ setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
+ setActionDefinitionId(ActionFactory.COPY.getCommandId());
+ }
+
+ @Override
+ public void run() {
+ ISelectionProvider selectionProvider = getSite().getSelectionProvider();
+ if (selectionProvider instanceof TableViewer) {
+ TableViewer viewer = (TableViewer) selectionProvider;
+ String text = copy(viewer);
+
+ Clipboard clipboard = new Clipboard(viewer.getControl()
+ .getDisplay());
+ try {
+ clipboard.setContents(new Object[]{text},
+ new Transfer[]{TextTransfer.getInstance()});
+ } finally {
+ clipboard.dispose();
+ }
+ }
+ }
+
+ private String copy(TableViewer viewer) {
+ final String recordSep = System.getProperty("line.separator");
+ final String fieldSep = "\t";
+ StringBuilder result = new StringBuilder();
+
+ // header record
+ result.append("Severity").append(fieldSep);
+ result.append("Description").append(fieldSep);
+ result.append("Element").append(fieldSep);
+ result.append("Parent").append(fieldSep);
+ result.append("Type").append(recordSep);
+
+ final int startIndex = 1; // the Severity column has no label
+ final int columnCount = viewer.getTable().getColumnCount();
+ CellLabelProvider[] labelProviders = new CellLabelProvider[columnCount
+ - startIndex];
+ for (int i = startIndex; i < columnCount; i++) {
+ labelProviders[i - startIndex] = viewer.getLabelProvider(i);
+ }
+
+ for (IPapyrusMarker next : getMarkers()) {
+ result.append(getSeverity(next));
+
+ for (int i = 0; i < labelProviders.length; i++) {
+ result.append(fieldSep);
+ result.append(labelProviders[i].getToolTipText(next));
+ }
+
+ result.append(recordSep);
+ }
+
+ return result.toString();
+ }
+
+ private static String getSeverity(IPapyrusMarker marker) {
+ String result;
+
+ switch (marker.getAttribute(IPapyrusMarker.SEVERITY,
+ IPapyrusMarker.SEVERITY_ERROR)) {
+
+ case IPapyrusMarker.SEVERITY_INFO :
+ result = "Info";
+ break;
+ case IPapyrusMarker.SEVERITY_WARNING :
+ result = "Warning";
+ break;
+ default :
+ result = "Error";
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/DeleteMarkerAction.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/DeleteMarkerAction.java
new file mode 100644
index 00000000000..3b762fa8414
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/DeleteMarkerAction.java
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.statushandlers.IStatusAdapterConstants;
+import org.eclipse.ui.statushandlers.StatusAdapter;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+/**
+ * This is the DeleteMarkerAction type. Enjoy.
+ */
+public class DeleteMarkerAction
+ extends AbstractMarkerAction {
+
+ public DeleteMarkerAction(IWorkbenchSite site) {
+ super(site, "Delete");
+
+ setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+ setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
+ setActionDefinitionId(ActionFactory.DELETE.getCommandId());
+ }
+
+ @Override
+ public void run() {
+ for (IPapyrusMarker next : getMarkers()) {
+ try {
+ next.delete();
+ } catch (CoreException e) {
+ StatusAdapter adapter = new StatusAdapter(e.getStatus());
+ adapter.setProperty(IStatusAdapterConstants.TITLE_PROPERTY,
+ "Delete Validation Problem");
+ StatusManager.getManager().handle(adapter, StatusManager.SHOW);
+ }
+ }
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/GotoMarkerAction.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/GotoMarkerAction.java
new file mode 100644
index 00000000000..daf1119b2ca
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/GotoMarkerAction.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.actions;
+
+import java.util.Collections;
+
+import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement;
+import org.eclipse.papyrus.views.validation.internal.Activator;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbenchSite;
+
+/**
+ * This is the GotoMarkerAction type. Enjoy.
+ */
+public class GotoMarkerAction
+ extends AbstractMarkerAction {
+
+ public GotoMarkerAction(IWorkbenchSite site) {
+ super(site, "Go To");
+
+ setImageDescriptor(Activator.getDefault().getImageRegistry()
+ .getDescriptor(Activator.ICON_GOTO_MARKER));
+ }
+
+ @Override
+ public void run() {
+ if (getMarker() != null) {
+ gotoMarker();
+ }
+ }
+
+ private void gotoMarker() {
+ IRevealSemanticElement revealer = null;
+
+ if (getMarker().getEObject() != null) {
+ for (IViewReference next : getSite().getPage().getViewReferences()) {
+ IViewPart part = next.getView(false);
+ if (part instanceof IRevealSemanticElement) {
+ revealer = (IRevealSemanticElement) part;
+ break;
+ } else if (part != null) {
+ revealer = (IRevealSemanticElement) part
+ .getAdapter(IRevealSemanticElement.class);
+ if (revealer != null) {
+ break;
+ }
+ }
+ }
+
+ if (revealer != null) {
+ revealer.revealSemanticElement(Collections
+ .singletonList(getMarker().getEObject()));
+ }
+ }
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/SelectAllAction.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/SelectAllAction.java
new file mode 100644
index 00000000000..b64f1f942fe
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/actions/SelectAllAction.java
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.actions.ActionFactory;
+
+/**
+ * This is the SelectAllAction type. Enjoy.
+ */
+public class SelectAllAction
+ extends Action {
+
+ private IWorkbenchSite site;
+
+ public SelectAllAction(IWorkbenchSite site) {
+ super("Select All");
+
+ this.site = site;
+
+ setActionDefinitionId(ActionFactory.SELECT_ALL.getCommandId());
+ }
+
+ @Override
+ public void run() {
+ ISelectionProvider selectionProvider = site.getSelectionProvider();
+ if (selectionProvider instanceof StructuredViewer) {
+ StructuredViewer viewer = (StructuredViewer) selectionProvider;
+ IStructuredContentProvider content = (IStructuredContentProvider) viewer
+ .getContentProvider();
+ viewer.setSelection(new StructuredSelection(content
+ .getElements(viewer.getInput())));
+ }
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/DescriptionLabelProvider.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/DescriptionLabelProvider.java
new file mode 100644
index 00000000000..cbd73b5e940
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/DescriptionLabelProvider.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.providers;
+
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+
+/**
+ * This is the DescriptionLabelProvider type. Enjoy.
+ */
+public class DescriptionLabelProvider
+ extends ProblemLabelProvider {
+
+ public DescriptionLabelProvider() {
+ super();
+ }
+
+ public String getText(Object element) {
+ String result = null;
+
+ if (element instanceof IPapyrusMarker) {
+ IPapyrusMarker marker = (IPapyrusMarker) element;
+ return marker.getAttribute(IPapyrusMarker.MESSAGE, "");
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ElementLabelProvider.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ElementLabelProvider.java
new file mode 100644
index 00000000000..3502b390f1f
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ElementLabelProvider.java
@@ -0,0 +1,76 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.providers;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This is the ElementLabelProvider type. Enjoy.
+ */
+public class ElementLabelProvider
+ extends ProblemLabelProvider {
+
+ private AdapterFactory factory;
+
+ private ExtendedImageRegistry images = ExtendedImageRegistry.getInstance();
+
+ public ElementLabelProvider(ModelSet modelSet) {
+ super();
+
+ this.factory = ((AdapterFactoryEditingDomain) modelSet
+ .getTransactionalEditingDomain()).getAdapterFactory();
+ }
+
+ public String getText(Object element) {
+ String result = null;
+
+ if (element instanceof IPapyrusMarker) {
+ IPapyrusMarker marker = (IPapyrusMarker) element;
+ EObject object = marker.getEObject();
+ if (object != null) {
+ IItemLabelProvider provider = (IItemLabelProvider) factory
+ .adapt(object, IItemLabelProvider.class);
+ if (provider != null) {
+ result = provider.getText(object);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ Image result = null;
+
+ if (element instanceof IPapyrusMarker) {
+ IPapyrusMarker marker = (IPapyrusMarker) element;
+ EObject object = marker.getEObject();
+ if (object != null) {
+ IItemLabelProvider provider = (IItemLabelProvider) factory
+ .adapt(object, IItemLabelProvider.class);
+ if (provider != null) {
+ result = images.getImage(provider.getImage(object));
+ }
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/InvertedViewerComparator.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/InvertedViewerComparator.java
new file mode 100644
index 00000000000..e9a8fe65c06
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/InvertedViewerComparator.java
@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.providers;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.SWT;
+
+/**
+ * This is the InvertedViewerComparator type. Enjoy.
+ */
+public class InvertedViewerComparator
+ extends ViewerComparator {
+
+ private final ViewerComparator comparator;
+
+ private InvertedViewerComparator(ViewerComparator comparator) {
+ this.comparator = comparator;
+ }
+
+ public static ViewerComparator invert(ViewerComparator comparator) {
+ return (comparator instanceof InvertedViewerComparator)
+ ? ((InvertedViewerComparator) comparator).comparator
+ : new InvertedViewerComparator(comparator);
+ }
+
+ public static ViewerComparator unwrap(ViewerComparator comparator) {
+ return (comparator instanceof InvertedViewerComparator)
+ ? ((InvertedViewerComparator) comparator).comparator
+ : comparator;
+ }
+
+ public static int direction(ViewerComparator comparator) {
+ return (comparator instanceof InvertedViewerComparator)
+ ? SWT.DOWN
+ : SWT.UP;
+ }
+
+ @Override
+ public boolean isSorterProperty(Object element, String property) {
+ return comparator.isSorterProperty(element, property);
+ }
+
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ return -comparator.compare(viewer, e1, e2);
+ }
+
+ @Override
+ public int category(Object element) {
+ return comparator.category(element);
+ }
+
+ @Override
+ public int hashCode() {
+ return -comparator.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return (obj instanceof InvertedViewerComparator)
+ && ((InvertedViewerComparator) obj).comparator.equals(comparator);
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/LabelProviderSorter.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/LabelProviderSorter.java
new file mode 100644
index 00000000000..a10be21dcbd
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/LabelProviderSorter.java
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.providers;
+
+import static com.google.common.base.Strings.nullToEmpty;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+
+/**
+ * This is the LabelProviderSorter type. Enjoy.
+ */
+public class LabelProviderSorter
+ extends ViewerComparator {
+
+ private final ILabelProvider labelProvider;
+
+ public LabelProviderSorter(ILabelProvider labelProvider) {
+ super();
+
+ this.labelProvider = labelProvider;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ String label1 = nullToEmpty(labelProvider.getText(e1));
+ String label2 = nullToEmpty(labelProvider.getText(e2));
+
+ return getComparator().compare(label1, label2);
+ }
+
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/PathLabelProvider.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/PathLabelProvider.java
new file mode 100644
index 00000000000..f4bc406e68d
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/PathLabelProvider.java
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.providers;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.papyrus.infra.services.labelprovider.service.IQualifierLabelProvider;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This is the PathLabelProvider type. Enjoy.
+ */
+public class PathLabelProvider
+ extends ProblemLabelProvider {
+
+ private LabelProviderService service;
+
+ public PathLabelProvider(LabelProviderService service) {
+ super();
+
+ this.service = service;
+ }
+
+ @Override
+ public String getText(Object element) {
+ String result = null;
+
+ if (element instanceof IPapyrusMarker) {
+ element = ((IPapyrusMarker) element).getEObject();
+ ILabelProvider provider = service.getLabelProvider(element);
+ if (provider instanceof IQualifierLabelProvider) {
+ result = ((IQualifierLabelProvider) provider)
+ .getQualifierText(element);
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ Image result = null;
+
+ if (element instanceof IPapyrusMarker) {
+ element = ((IPapyrusMarker) element).getEObject();
+ ILabelProvider provider = service.getLabelProvider(element);
+ if (provider instanceof IQualifierLabelProvider) {
+ result = ((IQualifierLabelProvider) provider)
+ .getQualifierImage(element);
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemCellLabelProvider.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemCellLabelProvider.java
new file mode 100644
index 00000000000..d0d2f21d211
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemCellLabelProvider.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.providers;
+
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.ViewerCell;
+
+/**
+ * This is the ProblemCellLabelProvider type. Enjoy.
+ */
+public class ProblemCellLabelProvider
+ extends CellLabelProvider {
+
+ private final ProblemLabelProvider labelProvider;
+
+ public ProblemCellLabelProvider(ProblemLabelProvider labelProvider) {
+ super();
+
+ this.labelProvider = labelProvider;
+ }
+
+ @Override
+ public void update(ViewerCell cell) {
+ cell.setText(labelProvider.getText(cell.getElement()));
+ cell.setImage(labelProvider.getImage(cell.getElement()));
+ }
+
+ @Override
+ public String getToolTipText(Object element) {
+ return labelProvider.getText(element);
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemLabelProvider.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemLabelProvider.java
new file mode 100644
index 00000000000..ad549abafc7
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemLabelProvider.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.providers;
+
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ViewerComparator;
+
+/**
+ * This is the ProblemLabelProvider type. Enjoy.
+ */
+public abstract class ProblemLabelProvider
+ extends LabelProvider {
+
+ public ProblemLabelProvider() {
+ super();
+ }
+
+ public CellLabelProvider createCellLabelProvider() {
+ return new ProblemCellLabelProvider(this);
+ }
+
+ public ViewerComparator createSorter() {
+ return new LabelProviderSorter(this);
+ }
+
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemsContentProvider.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemsContentProvider.java
new file mode 100644
index 00000000000..23b5f5c347c
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemsContentProvider.java
@@ -0,0 +1,167 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.providers;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.transaction.DemultiplexingListener;
+import org.eclipse.emf.transaction.ResourceSetListener;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.viewers.AbstractTableViewer;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.eclipse.papyrus.views.validation.internal.IValidationMarkerListener;
+import org.eclipse.papyrus.views.validation.internal.ValidationMarkersService;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * This is the ProblemsContentProvider type. Enjoy.
+ */
+public class ProblemsContentProvider
+ implements IStructuredContentProvider {
+
+ private static final Object[] NONE = {};
+
+ private AbstractTableViewer viewer;
+
+ private ValidationMarkersService service;
+
+ private IValidationMarkerListener listener;
+
+ private ResourceSetListener resourceSetListener;
+
+ public ProblemsContentProvider() {
+ super();
+ }
+
+ public void dispose() {
+ viewer = null;
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ this.viewer = (AbstractTableViewer) viewer;
+
+ if (oldInput instanceof ValidationMarkersService) {
+ ValidationMarkersService service = (ValidationMarkersService) oldInput;
+ unhookMarkers(service);
+ unhookResourceSet(service.getModelSet()
+ .getTransactionalEditingDomain());
+ this.service = null;
+ }
+
+ if (newInput instanceof ValidationMarkersService) {
+ ValidationMarkersService service = (ValidationMarkersService) newInput;
+ this.service = service;
+ hookMarkers(service);
+ hookResourceSet(service.getModelSet()
+ .getTransactionalEditingDomain());
+ }
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return (inputElement instanceof ValidationMarkersService)
+ ? Iterables.toArray(
+ ((ValidationMarkersService) inputElement).getMarkers(),
+ IPapyrusMarker.class)
+ : NONE;
+ }
+
+ protected void hookMarkers(ValidationMarkersService service) {
+ service.addValidationMarkerListener(getValidationMarkerListener());
+ }
+
+ protected void unhookMarkers(ValidationMarkersService service) {
+ service.removeValidationMarkerListener(getValidationMarkerListener());
+ }
+
+ private IValidationMarkerListener getValidationMarkerListener() {
+ if (listener == null) {
+ listener = new IValidationMarkerListener() {
+
+ public void notifyMarkerChange(IPapyrusMarker marker,
+ MarkerChangeKind kind) {
+ if (viewer != null) {
+ switch (kind) {
+ case ADDED :
+ viewer.add(marker);
+ break;
+ case REMOVED :
+ viewer.remove(marker);
+ break;
+ }
+ }
+ }
+ };
+ }
+
+ return listener;
+ }
+
+ protected void hookResourceSet(TransactionalEditingDomain domain) {
+ domain.addResourceSetListener(getResourceSetListener());
+ }
+
+ protected void unhookResourceSet(TransactionalEditingDomain domain) {
+ domain.removeResourceSetListener(getResourceSetListener());
+ }
+
+ private ResourceSetListener getResourceSetListener() {
+ if (resourceSetListener == null) {
+ resourceSetListener = new DemultiplexingListener() {
+
+ @Override
+ protected void handleNotification(
+ TransactionalEditingDomain domain,
+ Notification notification) {
+
+ // handle containment changes of problem elements to update
+ // labels
+ Object feature = notification.getFeature();
+ if ((feature instanceof EReference)
+ && ((EReference) feature).isContainment()) {
+
+ switch (notification.getEventType()) {
+ case Notification.ADD :
+ handleContainment((EObject) notification
+ .getNewValue());
+ break;
+ case Notification.ADD_MANY :
+ for (Object next : (Collection<?>) notification
+ .getNewValue()) {
+ handleContainment((EObject) next);
+ }
+ break;
+ case Notification.SET :
+ handleContainment((EObject) notification
+ .getNewValue());
+ break;
+ }
+ }
+ }
+
+ private void handleContainment(EObject object) {
+ Object[] markers = service.getMarkers(object).toArray();
+ if (markers.length > 0) {
+ viewer.update(markers, null);
+ }
+ }
+ };
+ }
+
+ return resourceSetListener;
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/SeverityLabelProvider.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/SeverityLabelProvider.java
new file mode 100644
index 00000000000..903d36cfd23
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/SeverityLabelProvider.java
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.providers;
+
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * This is the SeverityLabelProvider type. Enjoy.
+ */
+public class SeverityLabelProvider
+ extends ProblemLabelProvider {
+
+ private ISharedImages images;
+
+ public SeverityLabelProvider() {
+ super();
+
+ this.images = PlatformUI.getWorkbench().getSharedImages();
+ }
+
+ @Override
+ public String getText(Object element) {
+ return null;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ Image result = null;
+
+ if (element instanceof IPapyrusMarker) {
+ IPapyrusMarker marker = (IPapyrusMarker) element;
+ switch (marker.getAttribute(IPapyrusMarker.SEVERITY,
+ IPapyrusMarker.SEVERITY_ERROR)) {
+ case IPapyrusMarker.SEVERITY_INFO :
+ result = images.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
+ break;
+ case IPapyrusMarker.SEVERITY_WARNING :
+ result = images.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+ break;
+ default :
+ result = images.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public ViewerComparator createSorter() {
+ return new ViewerComparator() {
+
+ @Override
+ public int category(Object element) {
+ int result = -1;
+
+ if (element instanceof IPapyrusMarker) {
+ IPapyrusMarker marker = (IPapyrusMarker) element;
+ result = IPapyrusMarker.SEVERITY_ERROR
+ - marker.getAttribute(IPapyrusMarker.SEVERITY, -1);
+ }
+
+ return result;
+ }
+ };
+ }
+}
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/TypeLabelProvider.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/TypeLabelProvider.java
new file mode 100644
index 00000000000..1c68dfada78
--- /dev/null
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/TypeLabelProvider.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.validation.internal.providers;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.eclipse.papyrus.views.validation.internal.Activator;
+
+/**
+ * This is the TypeLabelProvider type. Enjoy.
+ */
+public class TypeLabelProvider
+ extends ProblemLabelProvider {
+
+ public TypeLabelProvider() {
+ super();
+ }
+
+ @Override
+ public String getText(Object element) {
+ String result = null;
+
+ if (element instanceof IPapyrusMarker) {
+ IPapyrusMarker marker = (IPapyrusMarker) element;
+
+ try {
+ result = marker.getTypeLabel();
+ } catch (CoreException e) {
+ Activator.getDefault().getLog().log(e.getStatus());
+ }
+ }
+
+ return result;
+ }
+}

Back to the top