diff options
author | aradermache | 2012-10-26 09:16:48 +0000 |
---|---|---|
committer | aradermache | 2012-10-26 09:16:48 +0000 |
commit | c558d503465e9140d2beeca55ed303baa030f6fc (patch) | |
tree | 4f1f3400c885729c18a388274463543979b3c312 | |
parent | 6b4ff21deeb133ee958e246d36bc88e1763201ee (diff) | |
download | org.eclipse.papyrus-c558d503465e9140d2beeca55ed303baa030f6fc.tar.gz org.eclipse.papyrus-c558d503465e9140d2beeca55ed303baa030f6fc.tar.xz org.eclipse.papyrus-c558d503465e9140d2beeca55ed303baa030f6fc.zip |
Introduction of priority, fix for bug 392724
6 files changed, 61 insertions, 6 deletions
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 d4bb0e21be2..1c9b7d79b8b 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 @@ -191,8 +191,9 @@ public class DecorationService extends Observable implements IDecorationService ImageDescriptor imageForGE = infoUtil.getImageDescriptorForGE(marker);
ImageDescriptor imageForME = infoUtil.getImageDescriptorForME(marker);
PreferedPosition position = infoUtil.getPreferedPosition(marker);
+ int priority = infoUtil.getPriority(marker);
IPapyrusDecoration decoration =
- addDecoration(marker.toString(), marker.getType(), element, imageForGE, imageForME, position, infoUtil.getMessage(marker));
+ addDecoration(marker.toString(), marker.getType(), element, imageForGE, imageForME, position, infoUtil.getMessage(marker), priority);
return decoration;
}
@@ -216,20 +217,23 @@ public class DecorationService extends Observable implements IDecorationService * the decoration
* @param message
* the message
+ * @param priority
+ * the priority
* @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 IPapyrusDecoration addDecoration(String id, String type, EObject element, ImageDescriptor decorationImageForGE, ImageDescriptor decorationImageForME, PreferedPosition position, String message, int priority) {
Decoration decoration = decorations.get(id);
if(decoration == null) {
- decoration = new Decoration(id, type, decorationImageForGE, decorationImageForME, message, element);
+ decoration = new Decoration(id, type, decorationImageForGE, decorationImageForME, message, element, priority);
decorations.put(id, decoration);
}
else {
decoration.setDecorationImageForGE(decorationImageForGE);
decoration.setDecorationImageForME(decorationImageForME);
decoration.setMessage(message);
+ decoration.setPriority(priority);
}
decoration.setPosition(position);
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 f86d5908696..98233257e1c 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 @@ -87,7 +87,7 @@ public interface IDecorationService extends IService { * the message
* @return the created (or existing) decoration
*/
- IPapyrusDecoration addDecoration(String id, String type, EObject element, ImageDescriptor decorationForGE, ImageDescriptor decorationForME, PreferedPosition position, String message);
+ IPapyrusDecoration addDecoration(String id, String type, EObject element, ImageDescriptor decorationForGE, ImageDescriptor decorationForME, PreferedPosition position, String message, int priority);
/**
* Removes the decoration.
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 index 509be113fb3..eae60345b8c 100644 --- 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 @@ -83,6 +83,12 @@ public interface IDecorationSpecificFunctions { public String getMessage(IMarker marker); /** + * return the priority of a decoration. This enables to select a marker with a high priority, if multiple markers for the + * same model element and the same position exist. See also bug 392724 + */ + public int getPriority(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 */ 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 209be15b925..8c55b7e092b 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 @@ -74,6 +74,8 @@ public class Decoration implements IPapyrusDecoration { /** The position. */
private PreferedPosition position;
+ /** The priority. */
+ private int priority;
/**
* Instantiates a new decoration.
@@ -86,8 +88,10 @@ public class Decoration implements IPapyrusDecoration { * the message
* @param element
* the element
+ * @param priority
+ * the priority
*/
- public Decoration(String id, String type, ImageDescriptor decorationImageForGE, ImageDescriptor decorationImageForME, String message, EObject element) {
+ public Decoration(String id, String type, ImageDescriptor decorationImageForGE, ImageDescriptor decorationImageForME, String message, EObject element, int priority) {
this.id = id;
this.decorationImageForGE = decorationImageForGE;
@@ -96,6 +100,7 @@ public class Decoration implements IPapyrusDecoration { this.element = element;
this.type = type;
this.position = PreferedPosition.SOUTH_EAST;
+ this.priority = priority;
}
@@ -264,4 +269,23 @@ public class Decoration implements IPapyrusDecoration { }
return message;
}
+
+ /**
+ * Gets the priority.
+ *
+ * @return the priority
+ */
+ public int getPriority() {
+ return priority;
+ }
+
+ /**
+ * Sets the priority.
+ *
+ * @param priority
+ * the new priority
+ */
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
}
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 index e2d114c131b..a1097b346f4 100644 --- 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 @@ -23,8 +23,25 @@ import org.eclipse.papyrus.infra.services.decoration.util.Decoration.PreferedPos * associated message.
* We explicitly prefix the interface with IPapyrus to avoid confusion with the IDecoration
* interface in JFace.
+ * A priority can be associated to a decoration. In the case where multiple decoration icons have the same positon,
+ * the priority allows to choose the which decoration icon will be shown.
*/
public interface IPapyrusDecoration {
+
+ /**
+ * Gets the priority.
+ *
+ * @return the priority
+ */
+ int getPriority();
+
+ /**
+ * Sets the priority.
+ *
+ * @param priority
+ * the new priority
+ */
+ void setPriority(int priority);
/**
* Sets the message.
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 index 478ddc370e5..20681d9187d 100644 --- 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 @@ -93,6 +93,10 @@ public class ValidationFunctions implements IDecorationSpecificFunctions { return marker.getAttribute(IMarker.MESSAGE, ""); } + public int getPriority(IMarker marker) { + return marker.getAttribute(IMarker.SEVERITY, -1); + } + public MarkChildren supportsMarkerPropagation() { return PreferencePage.getHierarchicalMarkers(); } @@ -129,7 +133,7 @@ public class ValidationFunctions implements IDecorationSpecificFunctions { } message += " marker(s) in one of the children"; IPapyrusDecoration deco = new Decoration(null, EValidator.MARKER, - getImageDescriptorForGE(childSeverity), getImageDescriptorForME(childSeverity), message, null); + getImageDescriptorForGE(childSeverity), getImageDescriptorForME(childSeverity), message, null, childSeverity); deco.setPosition(PreferedPosition.NORTH_WEST); return deco; } |