Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraradermache2012-07-05 06:00:09 -0400
committeraradermache2012-07-05 06:00:09 -0400
commitbd09b1e21e2b341449222d48ef3a34564615ca56 (patch)
treeef5d5f7c1615b8057b54c80c04b8d60ceb34b690 /plugins/infra
parenta9eb08a01891e2852c74bb7b5d2df2f8628ed69f (diff)
downloadorg.eclipse.papyrus-bd09b1e21e2b341449222d48ef3a34564615ca56.tar.gz
org.eclipse.papyrus-bd09b1e21e2b341449222d48ef3a34564615ca56.tar.xz
org.eclipse.papyrus-bd09b1e21e2b341449222d48ef3a34564615ca56.zip
Larger re-factoring of the decoration and validation service. The decoration service is now independent of validation markers (bug 384164), supports multiple decorations on the same element (bug 384160) and decoration propagation.
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF1
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml13
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/markers/MarkerConstants.java16
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/plugin.xml2
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/Activator.java10
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/DecorationService.java68
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/IDecorationService.java78
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/IDecorationSpecificFunctions.java99
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/Decoration.java180
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationSpecificFunctions.java56
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationUtils.java141
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/IDecoration.java81
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/IPapyrusDecoration.java101
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/plugin.xml1
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/MarkersMonitorService.java46
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/util/MarkerListenerUtils.java5
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/META-INF/MANIFEST.MF6
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/plugin.xml10
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/ValidationFunctions.java111
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/ValidationTool.java152
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/preferences/PreferencePage.java38
22 files changed, 740 insertions, 478 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF
index 8fad07ecfd8..fd973f94880 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF
@@ -16,6 +16,7 @@ Export-Package: org.eclipse.papyrus.infra.core,
org.eclipse.papyrus.infra.core.extension.diagrameditor,
org.eclipse.papyrus.infra.core.lifecycleevents,
org.eclipse.papyrus.infra.core.listenerservice,
+ org.eclipse.papyrus.infra.core.markers,
org.eclipse.papyrus.infra.core.modelsetquery,
org.eclipse.papyrus.infra.core.modelsetquery.impl;x-friends:="org.eclipse.papyrus.uml.resourceloading.profile",
org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor,
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml
index a7947c9db5e..4bb9306c416 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml
@@ -298,6 +298,15 @@
type="notation">
</parser>
</extension>
-
-
+ <extension
+ id="org.eclipse.papyrus.modelmarker"
+ name="model marker"
+ point="org.eclipse.core.resources.markers">
+ <attribute
+ name="uri">
+ </attribute>
+ <persistent
+ value="true">
+ </persistent>
+ </extension>
</plugin>
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/markers/MarkerConstants.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/markers/MarkerConstants.java
new file mode 100644
index 00000000000..38b7bdd2dd9
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/markers/MarkerConstants.java
@@ -0,0 +1,16 @@
+package org.eclipse.papyrus.infra.core.markers;
+
+import org.eclipse.emf.ecore.EValidator;
+
+
+public class MarkerConstants {
+
+ public static final String modelrefMarkerID = "org.eclipse.papyrus.modelmarker";
+
+ /**
+ * Use the same name for the reference as in the "diagnostic" marker defined in org.eclipse.emf.ecore
+ * (we don't use the diagnostic marker, since it defines additional attributes that are not useful for
+ * trace point)
+ */
+ public static final String uri = EValidator.URI_ATTRIBUTE;
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/META-INF/MANIFEST.MF b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/META-INF/MANIFEST.MF
index 8776fe4e1e9..8a70d21bc66 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/META-INF/MANIFEST.MF
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/META-INF/MANIFEST.MF
@@ -11,7 +11,8 @@ Require-Bundle: org.eclipse.ui,
org.apache.commons.lang;bundle-version="2.4.0",
org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.2.0",
org.eclipse.emf.ecore;bundle-version="2.8.0",
- org.eclipse.papyrus.infra.core;bundle-version="0.9.0"
+ org.eclipse.papyrus.infra.core;bundle-version="0.9.0",
+ org.eclipse.core.resources;bundle-version="3.7.0"
Bundle-Vendor: %providerName
Bundle-Version: 0.9.0.qualifier
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/plugin.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/plugin.xml
index 568a0d2f0e1..5ba5b1c8ac7 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/plugin.xml
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/plugin.xml
@@ -10,5 +10,5 @@
startKind="lazy">
</service>
</extension>
-
+ <extension-point id="decorationSpecificFunctions" name="decorationSpecificFunctions" schema="schema/decorationSpecificFunctions.exsd"/>
</plugin>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/Activator.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/Activator.java
index cb9549e1a62..2e27ceac042 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/Activator.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/Activator.java
@@ -27,10 +27,6 @@ public class Activator extends AbstractUIPlugin {
/** The Constant PLUGIN_ID. */
public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.services.decoration"; //$NON-NLS-1$
- // The Hierarchical Markers ID
- /** The HIERARCHICA l_ markers. */
- public final String HIERARCHICAL_MARKERS = "org.eclipse.papyrus.validation.HierarchicalMarkers";
-
/** The shared instance (Singleton pattern). */
private static Activator plugin;
@@ -46,7 +42,7 @@ public class Activator extends AbstractUIPlugin {
/**
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- *
+ *
* @param context
* @throws Exception
*/
@@ -61,7 +57,7 @@ public class Activator extends AbstractUIPlugin {
/**
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- *
+ *
* @param context
* @throws Exception
*/
@@ -75,7 +71,7 @@ public class Activator extends AbstractUIPlugin {
/**
* Returns the shared instance.
- *
+ *
* @return the shared instance
*/
public static Activator getDefault() {
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/DecorationService.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/DecorationService.java
index 918ca2a7706..d4bb0e21be2 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/DecorationService.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/DecorationService.java
@@ -17,13 +17,18 @@ import java.util.Map;
import java.util.Observable;
import java.util.Observer;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.services.decoration.util.Decoration;
+import org.eclipse.papyrus.infra.services.decoration.util.Decoration.PreferedPosition;
+import org.eclipse.papyrus.infra.services.decoration.util.DecorationSpecificFunctions;
import org.eclipse.papyrus.infra.services.decoration.util.DecorationUtils;
-import org.eclipse.papyrus.infra.services.decoration.util.IDecoration;
+import org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration;
/**
* The Class DecorationService.
@@ -164,35 +169,47 @@ public class DecorationService extends Observable implements IDecorationService
}
/**
- * Adds the decoration.
+ * Adds the decoration from a marker
*
* @param id
* the id
* @param element
* the element
- * @param severity
- * the severity
+ * @param decoration
+ * the decoration
* @param message
* the message
- * @see org.eclipse.papyrus.infra.services.decoration.IDecorationService#addDecoration(java.lang.String, org.eclipse.emf.ecore.EObject, int, java.lang.String)
+ * @see org.eclipse.papyrus.infra.services.decoration.IDecorationService#addDecoration(java.lang.String, org.eclipse.emf.ecore.EObject,
+ * org.eclipse.jface.resource.ImageDescriptor, java.lang.String)
*/
-
- public void addDecoration(String id, EObject element, int severity, String message) {
-
- if(decorations.get(id) == null) {
- decorations.put(id, new Decoration(id, severity, message, element));
+ public IPapyrusDecoration addDecoration(IMarker marker, EObject element) {
+
+ try {
+ // obtain marker type specific function
+ IDecorationSpecificFunctions infoUtil = DecorationSpecificFunctions.getDecorationInterface(marker.getType());
+ if(infoUtil != null) {
+ ImageDescriptor imageForGE = infoUtil.getImageDescriptorForGE(marker);
+ ImageDescriptor imageForME = infoUtil.getImageDescriptorForME(marker);
+ PreferedPosition position = infoUtil.getPreferedPosition(marker);
+ IPapyrusDecoration decoration =
+ addDecoration(marker.toString(), marker.getType(), element, imageForGE, imageForME, position, infoUtil.getMessage(marker));
+
+ return decoration;
+ }
+ } catch (CoreException e) {
+ Activator.log.error(e.getMessage(), e);
}
- notifyListeners(this);
-
+ return null;
}
-
/**
* Adds the decoration.
*
* @param id
* the id
+ * @param type
+ * the decoration type, currently corresponding to the marker type
* @param element
* the element
* @param decoration
@@ -202,13 +219,22 @@ public class DecorationService extends Observable implements IDecorationService
* @see org.eclipse.papyrus.infra.services.decoration.IDecorationService#addDecoration(java.lang.String, org.eclipse.emf.ecore.EObject,
* org.eclipse.jface.resource.ImageDescriptor, java.lang.String)
*/
+ public IPapyrusDecoration addDecoration(String id, String type, EObject element, ImageDescriptor decorationImageForGE, ImageDescriptor decorationImageForME, PreferedPosition position, String message) {
- public void addDecoration(String id, EObject element, ImageDescriptor decoration, String message) {
-
- if(decorations.get(id) == null) {
- decorations.put(id, new Decoration(id, decoration, message, element));
+ Decoration decoration = decorations.get(id);
+ if(decoration == null) {
+ decoration = new Decoration(id, type, decorationImageForGE, decorationImageForME, message, element);
+ decorations.put(id, decoration);
+ }
+ else {
+ decoration.setDecorationImageForGE(decorationImageForGE);
+ decoration.setDecorationImageForME(decorationImageForME);
+ decoration.setMessage(message);
}
+ decoration.setPosition(position);
+
notifyListeners(this);
+ return decoration;
}
/**
@@ -221,11 +247,13 @@ public class DecorationService extends Observable implements IDecorationService
* @return the decoration
* @see org.eclipse.papyrus.infra.services.decoration.IDecorationService#getDecoration(java.lang.Object, boolean)
*/
-
- public IDecoration getDecoration(Object element, boolean navigateToParents) {
+ public EList<IPapyrusDecoration> getDecorations(Object element, boolean navigateToParents) {
DecorationUtils tool = new DecorationUtils(element);
tool.tryChildIfEmpty();
- return tool.getDecoration(this, navigateToParents);
+ if(tool.getEObject() != null) {
+ return tool.getDecorations(this, navigateToParents);
+ }
+ return null;
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/IDecorationService.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/IDecorationService.java
index 42144357580..f86d5908696 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/IDecorationService.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/IDecorationService.java
@@ -14,14 +14,15 @@ package org.eclipse.papyrus.infra.services.decoration;
import java.util.Observer;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.infra.core.services.IService;
import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.services.decoration.util.IDecoration;
+import org.eclipse.papyrus.infra.services.decoration.util.Decoration.PreferedPosition;
+import org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration;
-// TODO: Auto-generated Javadoc
/**
* The Interface IDecorationService.
*/
@@ -29,76 +30,81 @@ public interface IDecorationService extends IService {
/**
* @see org.eclipse.papyrus.infra.core.services.IService#startService()
- *
+ *
* @throws ServiceException
*/
-
+
void startService() throws ServiceException;
/**
* @see org.eclipse.papyrus.infra.core.services.IService#disposeService()
- *
+ *
* @throws ServiceException
*/
-
+
void disposeService() throws ServiceException;
/**
* Adds the listener.
- *
- * @param o the o
+ *
+ * @param o
+ * the o
*/
void addListener(Observer o);
/**
* Delete listener.
- *
- * @param o the o
+ *
+ * @param o
+ * the o
*/
void deleteListener(Observer o);
/**
* Notify listeners.
- *
- * @param decorationService the decoration service
+ *
+ * @param decorationService
+ * the decoration service
*/
void notifyListeners(DecorationService decorationService);
- /**
- * Adds the decoration.
- *
- * @param id the id
- * @param element the element
- * @param severity the severity
- * @param message the message
- */
- void addDecoration(String id, EObject element, int severity, String message);
/**
- * Adds the decoration.
- *
- * @param id the id
- * @param element the element
- * @param decoration the decoration
- * @param message the message
+ * Adds the decoration. If a decoration with the same ID already exists, do not add, but update
+ * the decoration.
+ *
+ * @param id
+ * the id
+ * @param type
+ * the decoration type, currently corresponding to the marker type
+ * @param element
+ * the element
+ * @param decorationForGE
+ * the decoration image for a graphical editor
+ * @param decorationForME
+ * the decoration image for the model explorer
+ * @param message
+ * the message
+ * @return the created (or existing) decoration
*/
- void addDecoration(String id, EObject element, ImageDescriptor decoration, String message);
+ IPapyrusDecoration addDecoration(String id, String type, EObject element, ImageDescriptor decorationForGE, ImageDescriptor decorationForME, PreferedPosition position, String message);
/**
* Removes the decoration.
- *
- * @param id the id
+ *
+ * @param id
+ * the id
*/
void removeDecoration(String id);
/**
* Gets the decoration.
- *
- * @param element the element
- * @param navigateToParents the navigate to parents
+ *
+ * @param element
+ * the element
+ * @param navigateToParents
+ * the navigate to parents
* @return the decoration
*/
- IDecoration getDecoration(Object element, boolean navigateToParents);
-
-
+ EList<IPapyrusDecoration> getDecorations(Object element, boolean navigateToParents);
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/IDecorationSpecificFunctions.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/IDecorationSpecificFunctions.java
new file mode 100644
index 00000000000..509be113fb3
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/IDecorationSpecificFunctions.java
@@ -0,0 +1,99 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Ansgar Radermacher (CEA LIST) - ansgar.radermacher@cea.fr
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.services.decoration;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.infra.services.decoration.util.Decoration.PreferedPosition;
+import org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration;
+
+/**
+ * This interface allows to access a set of functions that depend on the decorator type.
+ * The objective is that plug-ins for a specific decoration type can implement this interface (via an extension point)
+ * to provide the information that depends on the decoration type, notably the used icons, their possition, the way how
+ * messages are calculated and how decoration might propagate from children to parents.
+ *
+ * @author ansgar
+ */
+public interface IDecorationSpecificFunctions {
+
+ /**
+ * The Enum MarkChildren.
+ */
+
+ public enum MarkChildren {
+
+ /**
+ * Do not propagate markers from child to parent
+ */
+ NO,
+
+ /**
+ * Only propagate markers from direct child to parent
+ */
+ DIRECT,
+
+ /**
+ * Propagate markers from child (direct or nested) to parent
+ */
+ ALL
+ };
+
+ /**
+ * Get the image descriptor for a graphical editor
+ *
+ * @param marker
+ * @return the image descriptor
+ */
+ public ImageDescriptor getImageDescriptorForGE(IMarker marker);
+
+ /**
+ * Get the image descriptor for model explorer. May be identical to the image for a graphical editor
+ *
+ * @param marker
+ * @return the image descriptor
+ */
+ public ImageDescriptor getImageDescriptorForME(IMarker marker);
+
+ /**
+ * @return the preferred position for markers within the model explorer
+ *
+ */
+ public PreferedPosition getPreferedPosition(IMarker marker);
+
+ /**
+ * Return a textual information for the marker (used for fixed messages that do not need to
+ * be stored in each marker)
+ *
+ * @param marker
+ * @return
+ */
+ public String getMessage(IMarker marker);
+
+ /**
+ * does the decoration type support a propagation from child to parent, e.g. in case of a problem marker
+ * parents (package) might be marked as containing warnings or errors
+ */
+ public MarkChildren supportsMarkerPropagation();
+
+ /**
+ * calculate a propagated marker for the parent, given the set of child decorations
+ *
+ * @param childDecorations
+ * The set of decorations on children
+ * @return the calculated decoration for the parent
+ */
+ public IPapyrusDecoration markerPropagation(EList<IPapyrusDecoration> childDecorations);
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/Decoration.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/Decoration.java
index 4984af0fdcd..209be15b925 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/Decoration.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/Decoration.java
@@ -8,19 +8,23 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Amine EL KOUHEN (CEA LIST/LIFL) - Amine.Elkouhen@cea.fr
+ * Amine EL KOUHEN (CEA LIST/LIFL) - Amine.Elkouhen@cea.fr
+ * Ansgar Radermacher (CEA LIST) - ansgar.radermacher@cea.fr
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.services.decoration.util;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IDecoration;
// TODO: Auto-generated Javadoc
/**
* The Class Decoration.
*/
-public class Decoration implements IDecoration {
+public class Decoration implements IPapyrusDecoration {
/**
* The Enum PreferedPosition.
@@ -52,41 +56,24 @@ public class Decoration implements IDecoration {
/** The id. */
private final String id;
- /** The severity. */
- private int severity;
-
/** The message. */
private String message;
/** The element. */
private EObject element;
- /** The decoration image. */
- private ImageDescriptor decorationImage;
+ /** The decoration image for the graphical editor */
+ private ImageDescriptor decorationImageForGE;
+
+ /** The decoration image for the model explorer */
+ private ImageDescriptor decorationImageForME;
+
+ /** The decoration type, currently corresponding to marker name */
+ private String type;
/** The position. */
private PreferedPosition position;
- /**
- * Instantiates a new decoration.
- *
- * @param id
- * the id
- * @param severity
- * the severity
- * @param message
- * the message
- * @param element
- * the element
- */
- public Decoration(String id, int severity, String message, EObject element) {
- this.id = id;
- this.severity = severity;
- this.message = message;
- this.element = element;
- this.position = PreferedPosition.DEFAULT;
- }
-
/**
* Instantiates a new decoration.
@@ -100,13 +87,15 @@ public class Decoration implements IDecoration {
* @param element
* the element
*/
- public Decoration(String id, ImageDescriptor decorationImage, String message, EObject element) {
+ public Decoration(String id, String type, ImageDescriptor decorationImageForGE, ImageDescriptor decorationImageForME, String message, EObject element) {
this.id = id;
- this.severity = Integer.MAX_VALUE;
- this.decorationImage = decorationImage;
+ this.decorationImageForGE = decorationImageForGE;
+ this.decorationImageForME = decorationImageForME;
this.message = message;
this.element = element;
+ this.type = type;
+ this.position = PreferedPosition.SOUTH_EAST;
}
@@ -119,36 +108,18 @@ public class Decoration implements IDecoration {
return id;
}
-
/**
- * Gets the severity.
- *
- * @return the severity
- * @see org.eclipse.papyrus.infra.services.decoration.util.IDecoration#getSeverity()
+ * @return the type (corresponding to marker type)
*/
-
- public int getSeverity() {
- return severity;
+ public String getType() {
+ return type;
}
-
- /**
- * Sets the severity.
- *
- * @param severity the new severity
- * @see org.eclipse.papyrus.infra.services.decoration.util.IDecoration#setSeverity(int)
- */
-
- public void setSeverity(int severity) {
- this.severity = severity;
- }
-
-
/**
* Gets the message.
- *
+ *
* @return the message
- * @see org.eclipse.papyrus.infra.services.decoration.util.IDecoration#getMessage()
+ * @see org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration#getMessage()
*/
public String getMessage() {
@@ -158,9 +129,10 @@ public class Decoration implements IDecoration {
/**
* Sets the message.
- *
- * @param message the new message
- * @see org.eclipse.papyrus.infra.services.decoration.util.IDecoration#setMessage(java.lang.String)
+ *
+ * @param message
+ * the new message
+ * @see org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration#setMessage(java.lang.String)
*/
public void setMessage(String message) {
@@ -189,53 +161,107 @@ public class Decoration implements IDecoration {
}
/**
- * Gets the decoration image.
- *
+ * Gets the decoration image for a graphical editor.
+ *
* @return the decoration image
- * @see org.eclipse.papyrus.infra.services.decoration.util.IDecoration#getDecorationImage()
+ * @see org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration#getDecorationImage()
*/
-
- public ImageDescriptor getDecorationImage() {
- return decorationImage;
+ public ImageDescriptor getDecorationImageForGE() {
+ return decorationImageForGE;
}
/**
- * Sets the decoration image.
- *
- * @param decorationImage the new decoration image
- * @see org.eclipse.papyrus.infra.services.decoration.util.IDecoration#setDecorationImage(org.eclipse.jface.resource.ImageDescriptor)
+ * Sets the decoration image for a graphical editor.
+ *
+ * @param decorationImage
+ * the new decoration image
+ * @see org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration#setDecorationImageForGE(org.eclipse.jface.resource.ImageDescriptor)
*/
+ public void setDecorationImageForGE(ImageDescriptor decorationImageForGE) {
+ this.decorationImageForGE = decorationImageForGE;
+ }
- public void setDecorationImage(ImageDescriptor decorationImage) {
- this.decorationImage = decorationImage;
+ /**
+ * Gets the decoration image for the model explorer.
+ *
+ * @return the decoration image
+ * @see org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration#getDecorationImage()
+ */
+ public ImageDescriptor getDecorationImageForME() {
+ return decorationImageForME;
}
+ /**
+ * Sets the decoration image for the model explorer.
+ *
+ * @param decorationImage
+ * the new decoration image
+ * @see org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration#setDecorationImageForGE(org.eclipse.jface.resource.ImageDescriptor)
+ */
+ public void setDecorationImageForME(ImageDescriptor decorationImageForME) {
+ this.decorationImageForME = decorationImageForME;
+ }
/**
- * Gets the position.
- *
+ * Gets the position. Only used for display within model explorer
+ *
* @return the position
- * @see org.eclipse.papyrus.infra.services.decoration.util.IDecoration#getPosition()
+ * @see org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration#getPosition()
*/
-
public PreferedPosition getPosition() {
return position;
}
-
/**
* Sets the position.
- *
- * @param position the new position
- * @see org.eclipse.papyrus.infra.services.decoration.util.IDecoration#setPosition(org.eclipse.papyrus.infra.services.decoration.util.Decoration.PreferedPosition)
+ *
+ * @param position
+ * the new position
+ * @see org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration#setPosition(org.eclipse.papyrus.infra.services.decoration.util.Decoration.PreferedPosition)
*/
public void setPosition(PreferedPosition position) {
this.position = position;
}
+ /**
+ * @return the decoration position as enumerated by constants in IDecoration from JFace
+ * (TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, UNDERLAY
+ */
+ public int getPositionForJFace() {
+ switch(position) {
+ case NORTH_WEST:
+ case NORTH:
+ return IDecoration.TOP_LEFT;
+
+ case NORTH_EAST:
+ return IDecoration.TOP_RIGHT;
+ case WEST:
+ case SOUTH_WEST:
+ return IDecoration.BOTTOM_LEFT;
+ case EAST:
+ case SOUTH_EAST:
+ case DEFAULT:
+ default:
+ return IDecoration.BOTTOM_RIGHT;
+ case SOUTH:
+ case CENTER:
+ return IDecoration.UNDERLAY;
+ }
+ }
-
+ public static String getMessageFromDecorations(EList<IPapyrusDecoration> decorations) {
+ String message = "";
+ if(decorations != null) {
+ for(IPapyrusDecoration decoration : decorations) {
+ if(message.length() > 0) {
+ message += "\n";
+ }
+ message += decoration.getMessage();
+ }
+ }
+ return message;
+ }
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationSpecificFunctions.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationSpecificFunctions.java
new file mode 100644
index 00000000000..4a9d898b16a
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationSpecificFunctions.java
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Ansgar Radermacher (CEA LIST) - ansgar.radermacher@cea.fr
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.services.decoration.util;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.infra.services.decoration.Activator;
+import org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions;
+
+
+
+/**
+ * Return access to the extensions of interface IDecorationSpecificFunctions
+ *
+ * @author ansgar
+ *
+ */
+public class DecorationSpecificFunctions {
+
+ public static final String DECORATION_SPECIFIC_FUNCTIONS_ID = Activator.PLUGIN_ID + ".decorationSpecificFunctions";
+
+ public static final String DECORATION_TYPE_ID = "decorationType";
+
+ public static IDecorationSpecificFunctions getDecorationInterface(String decorationType) {
+ IExtensionRegistry reg = Platform.getExtensionRegistry();
+ IConfigurationElement[] configElements = reg.getConfigurationElementsFor(DECORATION_SPECIFIC_FUNCTIONS_ID);
+ for(IConfigurationElement configElement : configElements) {
+ try {
+ final String iConfiguratorIDext = configElement.getAttribute(DECORATION_TYPE_ID);
+ if((iConfiguratorIDext != null) && iConfiguratorIDext.equals(decorationType)) {
+ // TODO: cache returned instance (avoid creating a new instance each time => more efficient, no need for static attributes)
+ final Object obj = configElement.createExecutableExtension("class");
+ if(obj instanceof IDecorationSpecificFunctions) {
+ return (IDecorationSpecificFunctions)obj;
+ }
+ }
+ } catch (CoreException exception) {
+ exception.printStackTrace();
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationUtils.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationUtils.java
index c85e79b439e..80bcaac5e9b 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationUtils.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationUtils.java
@@ -8,21 +8,24 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Amine EL KOUHEN (CEA LIST/LIFL) - Amine.Elkouhen@cea.fr
+ * Amine EL KOUHEN (CEA LIST/LIFL) - Amine.Elkouhen@cea.fr
+ * Ansgar Radermacher (CEA LIST) - ansgar.radermacher@cea.fr
*****************************************************************************/
package org.eclipse.papyrus.infra.services.decoration.util;
-import java.util.Iterator;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.WordUtils;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.facet.infra.browser.uicore.internal.model.LinkItem;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.papyrus.infra.services.decoration.Activator;
import org.eclipse.papyrus.infra.services.decoration.DecorationService;
+import org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions;
+import org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions.MarkChildren;
// TODO: Auto-generated Javadoc
@@ -38,20 +41,6 @@ public class DecorationUtils {
private EObject eObject;
/**
- * The Enum MarkChildren.
- */
-
- public enum MarkChildren {
-
- /** The NO. */
- NO,
- /** The DIRECT. */
- DIRECT,
- /** The ALL. */
- ALL
- };
-
- /**
* Instantiates a new decoration utils.
*
* @param element
@@ -63,9 +52,6 @@ public class DecorationUtils {
}
EObject eObject = (EObject)Platform.getAdapterManager().getAdapter(element, EObject.class);
- if(eObject == null) {
- throw new IllegalArgumentException("The decorated element cannot be resolved to an EObject");
- }
this.element = element;
setEObject(eObject);
@@ -136,24 +122,8 @@ public class DecorationUtils {
}
/**
- * Gets the hierarchical markers.
- *
- * @return the hierarchical markers
- */
- public MarkChildren getHierarchicalMarkers() {
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- String choice = store.getString(Activator.getDefault().HIERARCHICAL_MARKERS);
- if(choice.equals("NO")) {
- return MarkChildren.NO;
- } else if(choice.equals("DIRECT")) {
- return MarkChildren.DIRECT;
- } else {
- return MarkChildren.ALL;
- }
- }
-
- /**
- * Gets the decoration severity.
+ * Returns a list of decorations for a given UML element. It's a list, since there might be
+ * more than one decoration (e.g. a validation marker and a tracepoint) for this element.
*
* @param decorationService
* the decoration service
@@ -161,41 +131,66 @@ public class DecorationUtils {
* the navigate to parents
* @return the decoration severity
*/
- public int getDecorationSeverity(DecorationService decorationService, boolean navigateToParents) {
+ public EList<IPapyrusDecoration> getDecorations(DecorationService decorationService, boolean navigateToParents) {
Map<String, Decoration> decorations = getDecorations(decorationService);
- MarkChildren markChildren = getHierarchicalMarkers();
- int severity = 0;
+ // child decorations are organized in a map indexed by the decoration type
+ EList<IPapyrusDecoration> foundDecorations = new BasicEList<IPapyrusDecoration>();
+ Map<String, EList<IPapyrusDecoration>> childDecorationMap = new HashMap<String, EList<IPapyrusDecoration>>();
if(decorations != null) {
- Iterator it = decorations.entrySet().iterator();
- while(it.hasNext()) {
- Map.Entry pairs = (Map.Entry)it.next();
- Decoration decoration = (Decoration)pairs.getValue();
+ for(Decoration decoration : decorations.values()) {
EObject eObjectOfDecorator = decoration.getElement();
- boolean first = true;
- while(eObjectOfDecorator != null) {
- if(eObjectOfDecorator == getEObject()) {
- int severityI = decoration.getSeverity();
- if(severityI > severity) {
- severity = severityI;
- }
- }
- if(!navigateToParents) {
- break;
+ if(eObjectOfDecorator == getEObject()) {
+ // decoration is for this element
+ if(decoration.getMessage() == null) {
+ decoration.setMessage("");
}
- // navigate to parents, since parent folder is contaminated as well
+ foundDecorations.add(decoration);
+ }
+ // check whether a decoration can be found in one the children
+ // (technically, we check the parents of a decoration)
+ IDecorationSpecificFunctions decoUtil = DecorationSpecificFunctions.getDecorationInterface(decoration.getType());
+
+ if(navigateToParents && (decoUtil != null) && decoUtil.supportsMarkerPropagation() != MarkChildren.NO) {
+ MarkChildren markChildren = decoUtil.supportsMarkerPropagation();
+ boolean first = true;
+
eObjectOfDecorator = eObjectOfDecorator.eContainer();
- if(markChildren != MarkChildren.ALL) {
- if((!first) || (markChildren == MarkChildren.NO)) {
- break;
+ while(eObjectOfDecorator != null) {
+ if(eObjectOfDecorator == getEObject()) {
+ String type = decoration.getType();
+ EList<IPapyrusDecoration> childDecorations = childDecorationMap.get(type);
+ if(childDecorations == null) {
+ // does not exist yet => create
+ childDecorations = new BasicEList<IPapyrusDecoration>();
+ childDecorationMap.put(type, childDecorations);
+ }
+ childDecorations.add(decoration);
+ }
+ // navigate to parents, since parent folder is concerned by error as well
+ eObjectOfDecorator = eObjectOfDecorator.eContainer();
+ if(markChildren != MarkChildren.ALL) {
+ if(!first) {
+ break;
+ }
}
+ first = false;
}
- first = false;
}
}
}
- return severity;
- }
+ // now process map of children
+ for(String type : childDecorationMap.keySet()) {
+ EList<IPapyrusDecoration> childDecorations = childDecorationMap.get(type);
+ if(childDecorations != null) {
+ IDecorationSpecificFunctions decoUtil = DecorationSpecificFunctions.getDecorationInterface(type);
+ IPapyrusDecoration propagatedDecoration = decoUtil.markerPropagation(childDecorations);
+ foundDecorations.add(propagatedDecoration);
+ }
+ }
+
+ return foundDecorations;
+ }
/**
* Gets the decoration message.
@@ -209,10 +204,7 @@ public class DecorationUtils {
Map<String, Decoration> decorations = getDecorations(decorationService);
if(decorations != null) {
String message = "";
- Iterator it = decorations.entrySet().iterator();
- while(it.hasNext()) {
- Map.Entry pairs = (Map.Entry)it.next();
- Decoration decoration = (Decoration)pairs.getValue();
+ for(Decoration decoration : decorations.values()) {
EObject eObjectOfDecorator = decoration.getElement();
if(eObjectOfDecorator == getEObject()) {
if(message.length() > 0) {
@@ -225,19 +217,4 @@ public class DecorationUtils {
}
return null;
}
-
-
- /**
- * Gets the decoration.
- *
- * @param decorationService
- * the decoration service
- * @param navigateToParents
- * the navigate to parents
- * @return the decoration
- */
- public Decoration getDecoration(DecorationService decorationService, boolean navigateToParents) {
- return new Decoration(getEObject().toString(), getDecorationSeverity(decorationService, navigateToParents), getDecorationMessage(decorationService), getEObject());
- }
-
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/IDecoration.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/IDecoration.java
deleted file mode 100644
index 48b69805e0c..00000000000
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/IDecoration.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Amine EL KOUHEN (CEA LIST/LIFL) - Amine.Elkouhen@cea.fr
- *****************************************************************************/
-package org.eclipse.papyrus.infra.services.decoration.util;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.papyrus.infra.services.decoration.util.Decoration.PreferedPosition;
-
-
-// TODO: Auto-generated Javadoc
-/**
- * The Interface IDecoration.
- */
-public interface IDecoration {
-
- /**
- * Sets the severity.
- *
- * @param severity the new severity
- */
- void setSeverity(int severity);
-
- /**
- * Gets the severity.
- *
- * @return the severity
- */
- int getSeverity();
-
- /**
- * Sets the message.
- *
- * @param message the new message
- */
- void setMessage(String message);
-
- /**
- * Gets the message.
- *
- * @return the message
- */
- String getMessage();
-
- /**
- * Sets the decoration image.
- *
- * @param imageDescriptor the new decoration image
- */
- void setDecorationImage(ImageDescriptor imageDescriptor);
-
- /**
- * Gets the decoration image.
- *
- * @return the decoration image
- */
- ImageDescriptor getDecorationImage();
-
- /**
- * Sets the position.
- *
- * @param position the new position
- */
- void setPosition(PreferedPosition position);
-
- /**
- * Gets the position.
- *
- * @return the position
- */
- PreferedPosition getPosition();
-
-}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/IPapyrusDecoration.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/IPapyrusDecoration.java
new file mode 100644
index 00000000000..e2d114c131b
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/IPapyrusDecoration.java
@@ -0,0 +1,101 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Amine EL KOUHEN (CEA LIST/LIFL) - Amine.Elkouhen@cea.fr
+ * Ansgar Radermacher (CEA LIST) - ansgar.radermacher@cea.fr
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.decoration.util;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.infra.services.decoration.util.Decoration.PreferedPosition;
+
+
+/**
+ * The Interface IPapyrusDecoration use to capture decoration icons (big/small), their position and the
+ * associated message.
+ * We explicitly prefix the interface with IPapyrus to avoid confusion with the IDecoration
+ * interface in JFace.
+ */
+public interface IPapyrusDecoration {
+
+ /**
+ * Sets the message.
+ *
+ * @param message
+ * the new message
+ */
+ void setMessage(String message);
+
+ /**
+ * Gets the message.
+ *
+ * @return the message
+ */
+ String getMessage();
+
+ /**
+ * @return the type (corresponding to marker type)
+ */
+ public String getType();
+
+ /**
+ * Sets the decoration image for a graphical editor.
+ *
+ * @param imageDescriptor
+ * the new decoration image
+ */
+ void setDecorationImageForGE(ImageDescriptor imageDescriptor);
+
+ /**
+ * Gets the decoration image for a graphical editor
+ *
+ * @return the decoration image
+ */
+ ImageDescriptor getDecorationImageForGE();
+
+ /**
+ * Sets the decoration image for the model explorer.
+ *
+ * @param imageDescriptor
+ * the new decoration image
+ */
+ void setDecorationImageForME(ImageDescriptor imageDescriptor);
+
+ /**
+ * Gets the decoration image for the model explorer
+ *
+ * @return the decoration image
+ */
+ ImageDescriptor getDecorationImageForME();
+
+
+ /**
+ * Sets the position.
+ *
+ * @param position
+ * the new position
+ */
+ void setPosition(PreferedPosition position);
+
+ /**
+ * Gets the position.
+ *
+ * @return the position
+ */
+ PreferedPosition getPosition();
+
+ /**
+ * @return the decoration position as enumerated by constants in IDecoration from JFace
+ * (TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, UNDERLAY
+ */
+ int getPositionForJFace();
+
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/plugin.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/plugin.xml
index 31f7212df65..bf323a48eba 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/plugin.xml
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/plugin.xml
@@ -9,5 +9,4 @@
startKind="startup">
</service>
</extension>
-
</plugin>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/MarkersMonitorService.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/MarkersMonitorService.java
index 2c76c15c1c1..bb0aeb6e24e 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/MarkersMonitorService.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/MarkersMonitorService.java
@@ -10,6 +10,7 @@
* Contributors:
* Amine EL KOUHEN (CEA LIST/LIFL) - Amine.Elkouhen@cea.fr
*****************************************************************************/
+
package org.eclipse.papyrus.infra.services.markerlistener;
import java.util.Map;
@@ -19,8 +20,10 @@ import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.ui.resources.FileChangeManager;
import org.eclipse.gmf.runtime.common.ui.resources.IFileObserver;
@@ -121,23 +124,22 @@ public class MarkersMonitorService implements IService {
IMarker[] markers = null;
try {
- URI uri = ServiceUtils.getInstance().getModelSet(servicesRegistry).getResources().get(0).getURI();
- String platformResourceString = uri.toPlatformString(true);
- IFile file = (platformResourceString != null ? ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformResourceString)) : null);
- if(file != null) {
- try {
- markers = file.findMarkers(IMarker.PROBLEM, true, 0);
- } catch (CoreException e) {
- Activator.log.error(e.getMessage(), e);
- }
- }
-
- for(int i = 0; i < markers.length; i++) {
- EObject eObjectFromMarker = MarkerListenerUtils.eObjectFromMarkerOrMap(markers[i], null, ServiceUtils.getInstance().getModelSet(servicesRegistry).getTransactionalEditingDomain());
- int severity = markers[i].getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
- if(eObjectFromMarker != null && severity > IMarker.SEVERITY_INFO) {
+ EList<Resource> resources = ServiceUtils.getInstance().getModelSet(servicesRegistry).getResources();
+ // loop over all resources (e.g. error markers are on notation, breakpoints on UML model)
+ for(Resource resource : resources) {
+ URI uri = resource.getURI();
+ String platformResourceString = uri.toPlatformString(true);
+ IFile file = (platformResourceString != null ? ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformResourceString)) : null);
+ if(file != null) {
try {
- decorationService.addDecoration(markers[i].toString(), eObjectFromMarker, severity, (String)markers[i].getAttribute(IMarker.MESSAGE));
+ markers = file.findMarkers(null /* all markers */, true, 0);
+
+ for(int i = 0; i < markers.length; i++) {
+ EObject eObjectFromMarker = MarkerListenerUtils.eObjectFromMarkerOrMap(markers[i], null, ServiceUtils.getInstance().getModelSet(servicesRegistry).getTransactionalEditingDomain());
+ if(eObjectFromMarker != null) {
+ decorationService.addDecoration(markers[i], eObjectFromMarker);
+ }
+ }
} catch (CoreException e) {
Activator.log.error(e.getMessage(), e);
}
@@ -236,8 +238,7 @@ public class MarkersMonitorService implements IService {
*/
public void handleMarkerDeleted(IMarker marker, @SuppressWarnings("rawtypes") Map attributes) {
EObject eObjectFromMarker = MarkerListenerUtils.eObjectFromMarkerOrMap(null, attributes, domain);
- int severity = marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
- if(eObjectFromMarker != null && severity == IMarker.SEVERITY_INFO) {
+ if(eObjectFromMarker != null) {
decorationService.removeDecoration(marker.toString());
}
}
@@ -250,13 +251,8 @@ public class MarkersMonitorService implements IService {
*/
public void handleMarkerChanged(IMarker marker) {
EObject eObjectFromMarker = MarkerListenerUtils.eObjectFromMarkerOrMap(marker, null, domain);
- int severity = marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
- if(eObjectFromMarker != null && severity > IMarker.SEVERITY_INFO) {
- try {
- decorationService.addDecoration(marker.toString(), eObjectFromMarker, severity, (String)marker.getAttribute(IMarker.MESSAGE));
- } catch (CoreException e) {
- Activator.log.error(e.getMessage(), e);
- }
+ if(eObjectFromMarker != null) {
+ decorationService.addDecoration(marker, eObjectFromMarker);
}
}
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/util/MarkerListenerUtils.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/util/MarkerListenerUtils.java
index ed45b959cdb..44ee72b6c8a 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/util/MarkerListenerUtils.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/util/MarkerListenerUtils.java
@@ -10,6 +10,7 @@
* Contributors:
* Amine EL KOUHEN (CEA LIST/LIFL) - Amine.Elkouhen@cea.fr
*****************************************************************************/
+
package org.eclipse.papyrus.infra.services.markerlistener.util;
import java.util.Map;
@@ -24,7 +25,6 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.domain.EditingDomain;
-// TODO: Auto-generated Javadoc
/**
* The Class MarkerListenerUtils.
*/
@@ -80,6 +80,9 @@ public class MarkerListenerUtils {
public static EObject eObjectOfFragment(URI uri, EditingDomain domain) {
try {
for(Resource resource : domain.getResourceSet().getResources()) {
+ if(uri.fragment() == null) {
+ continue;
+ }
EObject eObjectOfMarker = resource.getEObject(uri.fragment());
if(eObjectOfMarker != null) {
return eObjectOfMarker;
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/META-INF/MANIFEST.MF b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/META-INF/MANIFEST.MF
index dce28d1054e..8d2d2427aef 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/META-INF/MANIFEST.MF
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/META-INF/MANIFEST.MF
@@ -8,8 +8,10 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.emf.edit.ui;bundle-version="2.6.0",
org.eclipse.gmf.runtime.emf.commands.core;bundle-version="1.0.100",
org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.1.0",
- org.eclipse.papyrus.infra.core;bundle-version="0.9.0"
-Export-Package: org.eclipse.papyrus.infra.services.validation
+ org.eclipse.papyrus.infra.core;bundle-version="0.9.0",
+ org.eclipse.papyrus.infra.services.decoration;bundle-version="0.9.0"
+Export-Package: org.eclipse.papyrus.infra.services.validation,
+ org.eclipse.papyrus.infra.services.validation.preferences
Bundle-Vendor: %pluginProvider
Bundle-ActivationPolicy: lazy
Bundle-Version: 0.9.0.qualifier
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/plugin.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/plugin.xml
index 2d6a15dc8e5..2f0a6dcdb60 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/plugin.xml
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/plugin.xml
@@ -125,4 +125,14 @@
name="ValidateDelMarkersFromSubtree">
</command>
</extension>
+ <extension
+ point="org.eclipse.ui.decorators">
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.services.decoration.decorationSpecificFunctions">
+ <client
+ class="org.eclipse.papyrus.infra.services.validation.ValidationFunctions"
+ decorationType="org.eclipse.emf.ecore.diagnostic">
+ </client>
+ </extension>
</plugin>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/ValidationFunctions.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/ValidationFunctions.java
new file mode 100644
index 00000000000..ebb67b59765
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/ValidationFunctions.java
@@ -0,0 +1,111 @@
+package org.eclipse.papyrus.infra.services.validation;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions;
+import org.eclipse.papyrus.infra.services.decoration.util.Decoration;
+import org.eclipse.papyrus.infra.services.decoration.util.Decoration.PreferedPosition;
+import org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration;
+import org.eclipse.papyrus.infra.services.validation.preferences.PreferencePage;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+
+public class ValidationFunctions implements IDecorationSpecificFunctions {
+
+ /**
+ * Return the image descriptor associated with an validation marker
+ */
+ public ImageDescriptor getImageDescriptorForGE(IMarker marker) {
+ int severity = marker.getAttribute(IMarker.SEVERITY, -1);
+ return getImageDescriptorForGE(severity);
+ }
+
+ public ImageDescriptor getImageDescriptorForGE(int severity) {
+ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
+ ImageDescriptor overlay = null;
+ switch(severity) {
+ case IMarker.SEVERITY_ERROR:
+ overlay = sharedImages.getImageDescriptor(ISharedImages.IMG_OBJS_ERROR_TSK);
+ break;
+ case IMarker.SEVERITY_WARNING:
+ overlay = sharedImages.getImageDescriptor(ISharedImages.IMG_OBJS_WARN_TSK);
+ break;
+ case IMarker.SEVERITY_INFO:
+ overlay = sharedImages.getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK);
+ break;
+ }
+
+ return overlay;
+ }
+
+ /**
+ * Return the image descriptor associated with an validation marker
+ */
+ public ImageDescriptor getImageDescriptorForME(IMarker marker) {
+ int severity = marker.getAttribute(IMarker.SEVERITY, -1);
+ return getImageDescriptorForME(severity);
+ }
+
+ public ImageDescriptor getImageDescriptorForME(int severity) {
+ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
+ ImageDescriptor overlay = null;
+
+ switch(severity) {
+ case IMarker.SEVERITY_ERROR:
+ overlay = sharedImages.getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR);
+ break;
+ case IMarker.SEVERITY_WARNING:
+ overlay = sharedImages.getImageDescriptor(ISharedImages.IMG_DEC_FIELD_WARNING);
+ break;
+ case IMarker.SEVERITY_INFO:
+ overlay = sharedImages.getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK); // TODO: Image too big (unclear, if "info" is useful)
+ break;
+ }
+
+ return overlay;
+ }
+
+ public PreferedPosition getPreferedPosition(IMarker marker) {
+ return PreferedPosition.SOUTH_WEST;
+ }
+
+ public String getMessage(IMarker marker) {
+ // message is stored within marker
+ return marker.getAttribute(IMarker.MESSAGE, "");
+ }
+
+ public MarkChildren supportsMarkerPropagation() {
+ return PreferencePage.getHierarchicalMarkers();
+ }
+
+ /**
+ * Set of child decorations. use severity information?
+ */
+ public IPapyrusDecoration markerPropagation(EList<IPapyrusDecoration> childDecorations) {
+ int childSeverity = 0;
+ // loop over children. Use the "highest" level for parent decoration
+ for(IPapyrusDecoration childDecoration : childDecorations) {
+ if(childDecoration.getDecorationImageForME() == getImageDescriptorForME(IMarker.SEVERITY_WARNING)) {
+ childSeverity = IMarker.SEVERITY_WARNING;
+ }
+ else if(childDecoration.getDecorationImageForME() == getImageDescriptorForME(IMarker.SEVERITY_WARNING)) {
+ childSeverity = IMarker.SEVERITY_ERROR;
+ break; // no need to check further
+ }
+ }
+ if(childSeverity != 0) {
+ String message = (childSeverity == IMarker.SEVERITY_ERROR) ? "Error" : "Warning";
+ message += " marker in one of the children (packaged elements)";
+ IPapyrusDecoration deco = new Decoration(null, EValidator.MARKER,
+ getImageDescriptorForGE(childSeverity), getImageDescriptorForME(childSeverity), message, null);
+ deco.setPosition(PreferedPosition.NORTH_WEST);
+ return deco;
+ }
+ else {
+ return null;
+ }
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/ValidationTool.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/ValidationTool.java
index f57b0e091f5..ea00a999789 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/ValidationTool.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/ValidationTool.java
@@ -16,7 +16,6 @@ package org.eclipse.papyrus.infra.services.validation;
import java.util.List;
-import org.apache.commons.lang.WordUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -29,10 +28,8 @@ import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.facet.infra.browser.uicore.internal.model.LinkItem;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.papyrus.infra.services.validation.preferences.PreferencePage;
-import org.eclipse.papyrus.infra.services.validation.preferences.PreferencePage.MarkChildren;
+@SuppressWarnings("restriction")
public class ValidationTool {
/** Current element */
@@ -48,13 +45,14 @@ public class ValidationTool {
/**
* Constructor:
* create a new instance of the validation tool for a specific model element
- *
- * @param element a model element
+ *
+ * @param element
+ * a model element
*/
- public ValidationTool (Object element) {
+ public ValidationTool(Object element) {
this.element = element;
setEObject((EObject)Platform.getAdapterManager().getAdapter(element, EObject.class));
- }
+ }
/**
* Constructor:
@@ -63,16 +61,16 @@ public class ValidationTool {
* @param eObject
* a model element
*/
- public ValidationTool (EObject eObject) {
+ public ValidationTool(EObject eObject) {
setEObject(eObject);
- }
+ }
public void tryChildIfEmpty() {
// element has no eObject. try parent
if(getEObject() == null) {
// TODO: is it possible to access the children in another way (without internal access?)
- if (element instanceof LinkItem) {
+ if(element instanceof LinkItem) {
List<?> items = ((LinkItem)element).getChildrenElements();
if(items.size() > 0 && items.get(0) instanceof EObject) {
// element = items[0];
@@ -90,7 +88,7 @@ public class ValidationTool {
public EObject getEObject() {
return eObject;
}
-
+
/**
* sets the current EObject
@@ -101,156 +99,68 @@ public class ValidationTool {
this.eObject = eObject;
}
- public IMarker [] getMarkers () {
+ public IMarker[] getMarkers() {
if(getEObject() != null) {
if(getEObject().eResource() != null) {
URI uri = getEObject().eResource().getURI();
String platformResourceString = uri.toPlatformString(true);
IFile file = (platformResourceString != null ?
- ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformResourceString)) : null);
- if (file != null) {
+ ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformResourceString)) : null);
+ if(file != null) {
try {
// TODO: quite inefficient, since requested for each element (could cache markers, already done
// by findMarkers operation?)
return file.findMarkers(IMarker.PROBLEM, true, 0);
- }
- catch (CoreException e) {
+ } catch (CoreException e) {
}
}
}
}
return null;
}
-
+
/**
*
* @param marker
* @return
*/
- public EObject eObjectOfMarker (IMarker marker) {
+ public EObject eObjectOfMarker(IMarker marker) {
if(getEObject() != null) {
domain = AdapterFactoryEditingDomain.getEditingDomainFor(getEObject());
try {
- if (marker.isSubtypeOf((EValidator.MARKER))) {
- return ValidationUtils.eObjectFromMarkerOrMap (marker, null, domain);
+ if(marker.isSubtypeOf((EValidator.MARKER)) /* || marker.isSubtypeOf(MarkerConstants.modelrefMarkerID) */) {
+ return ValidationUtils.eObjectFromMarkerOrMap(marker, null, domain);
}
- }
- catch (CoreException e) {
+ } catch (CoreException e) {
// only reason: marker does not exist
}
}
return null;
}
-
+
/**
* Delete all markers that refer to eObjects owned by the passed parentEObj
*/
public void deleteSubMarkers() {
- for (IMarker marker : getMarkers ()) {
- EObject eObjOfMarker = eObjectOfMarker (marker);
+ for(IMarker marker : getMarkers()) {
+ EObject eObjOfMarker = eObjectOfMarker(marker);
if(isContainedBy(eObjOfMarker, getEObject())) {
try {
- marker.delete ();
- }
- catch (CoreException e) {
+ marker.delete();
+ } catch (CoreException e) {
}
}
}
}
-
- /**
- * @return the maximum severity of markers associated with the model element
- * (constructor parameter of validation tool)
- */
- public int getSeverity() {
- IMarker markers[] = getMarkers();
- MarkChildren markChildren = PreferencePage.getHierarchicalMarkers();
- int severity = 0;
- if (markers != null) {
- for (IMarker marker : markers) {
- EObject eObjectOfMarker = eObjectOfMarker(marker);
- boolean first = true;
- while (eObjectOfMarker != null) {
- if (eObjectOfMarker == getEObject()) {
- try {
- Integer severityI = (Integer) marker.getAttribute(IMarker.SEVERITY);
- if (severityI.intValue () > severity) {
- severity = severityI.intValue();
- }
- }
- catch (CoreException e) {
- }
- }
- // navigate to parents, since parent folder is contaminated as well
- eObjectOfMarker = eObjectOfMarker.eContainer();
- if (markChildren != MarkChildren.ALL) {
- if ((!first) || (markChildren == MarkChildren.NO)) {
- break;
- }
- }
- first = false;
- }
- }
- }
- return severity;
- }
-
- /**
- * @return A set of messages associated with the markers for the model element
- * (constructor parameter of validation tool)
- */
- public String getMarkerMessages() {
- IMarker markers[] = getMarkers();
- MarkChildren markChildren = PreferencePage.getHierarchicalMarkers();
- if (markers != null) {
- boolean examineChilds = (markChildren != MarkChildren.NO);
- String message = "";
- for (IMarker marker : markers) {
- EObject eObjectOfMarker = eObjectOfMarker(marker);
- if (eObjectOfMarker == getEObject()) {
- if (message.length() > 0) {
- message += "\n";
- }
- // vt.getWrappedMessage (marker);
- try {
- message += "- " + WordUtils.wrap ((String) marker.getAttribute(IMarker.MESSAGE), 100, "\n ", true);
- }
- catch (CoreException e) {
- }
- }
- if (examineChilds && (eObjectOfMarker != null)) {
- eObjectOfMarker = eObjectOfMarker.eContainer();
- boolean first = true;
- while (eObjectOfMarker != null) {
- if (eObjectOfMarker == getEObject ()) {
- if (message.length() > 0) {
- message += "\n";
- }
- message += "- Problem marker in (at least) one of the children";
- examineChilds = false;
- break;
- }
- // navigate to parents, since parent folder is contaminated as well
- eObjectOfMarker = eObjectOfMarker.eContainer();
- if ((!first) && (markChildren == MarkChildren.DIRECT)) {
- break;
- }
- first = false;
- }
- }
- }
- return (message.length() > 0) ? message : null;
- }
- return null;
- }
-
- private boolean isContainedBy (EObject subEObj, EObject eObj) {
- if (eObj == subEObj) return true;
- else if (subEObj != null) {
- return isContainedBy (subEObj.eContainer(), eObj);
+
+ private boolean isContainedBy(EObject subEObj, EObject eObj) {
+ if(eObj == subEObj)
+ return true;
+ else if(subEObj != null) {
+ return isContainedBy(subEObj.eContainer(), eObj);
}
// reached, if subEObj == null
return false;
}
-
+
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/preferences/PreferencePage.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/preferences/PreferencePage.java
index 1fd77f5e2e1..f5b601443f1 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/preferences/PreferencePage.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/preferences/PreferencePage.java
@@ -10,6 +10,7 @@ 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.EditorUtils;
+import org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions.MarkChildren;
import org.eclipse.papyrus.infra.services.validation.Activator;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -18,15 +19,11 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
public class PreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
public final static String HIERARCHICAL_MARKERS = "org.eclipse.papyrus.infra.services.validation.HierarchicalMarkers";
-
+
public PreferencePage() {
super(GRID);
}
- public enum MarkChildren {
- NO, DIRECT, ALL
- };
-
public void createFieldEditors() {
String selection[][] = new String[][]{ { "&No", "NO" }, { "&Direct parent", "DIRECT" }, { "&All parents", "ALL" } };
@@ -40,11 +37,11 @@ public class PreferencePage extends FieldEditorPreferencePage implements IWorkbe
public static MarkChildren getHierarchicalMarkers() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- String choice = store.getString(HIERARCHICAL_MARKERS);
- if (choice.equals("NO")) {
+ String choice = store.getString(HIERARCHICAL_MARKERS);
+ if(choice.equals("NO")) {
return MarkChildren.NO;
}
- else if (choice.equals("DIRECT")) {
+ else if(choice.equals("DIRECT")) {
return MarkChildren.DIRECT;
}
else {
@@ -64,13 +61,13 @@ public class PreferencePage extends FieldEditorPreferencePage implements IWorkbe
triggerRedraw();
return retCode;
}
-
+
@Override
protected void performApply() {
super.performApply();
triggerRedraw();
}
-
+
/**
* trigger a redraw of the model explorer by sending a notify signal (otherwise markers
* would remain (or not been drawn) on parent elements that are concerned by a change
@@ -78,17 +75,16 @@ public class PreferencePage extends FieldEditorPreferencePage implements IWorkbe
*/
protected void triggerRedraw() {
// get references to all Papyrus editors, send the notification to each
- IMultiDiagramEditor papyrusEditors[] = EditorUtils.getMultiDiagramEditors();
- for (IMultiDiagramEditor papyrusEditor : papyrusEditors) {
- ServicesRegistry serviceRegistry = papyrusEditor.getServicesRegistry();
- if (serviceRegistry != null) {
- try {
- ModelSet modelSet = serviceRegistry.getService(ModelSet.class);
- modelSet.eNotify(new NotificationImpl(Notification.SET, new Object(), null));
- }
- catch (ServiceException e) {
- }
- }
+ IMultiDiagramEditor papyrusEditors[] = EditorUtils.getMultiDiagramEditors();
+ for(IMultiDiagramEditor papyrusEditor : papyrusEditors) {
+ ServicesRegistry serviceRegistry = papyrusEditor.getServicesRegistry();
+ if(serviceRegistry != null) {
+ try {
+ ModelSet modelSet = serviceRegistry.getService(ModelSet.class);
+ modelSet.eNotify(new NotificationImpl(Notification.SET, new Object(), null));
+ } catch (ServiceException e) {
+ }
+ }
}
}

Back to the top