[512443] EditModeDecorator should compute isBroken image first

The previous commit on EditModeDecorator optimized the decorator refresh
by removing duplicates in calls to permission authority and isBroken
checks (see shoulBeDecorated() and getDecorationImage()). 

The logic of the previous version of shouldBeDecorated was moved to
getDecorationImage but this changed the image priority: now the lock
status is displayed even if the edit part is broken whereas we want to
display only the red cross when the part is broken even if the lock
status could lead to a specific decoration.

This commit set back the previous getImage() computation priority.

Bug: 512443
Cherry-picked-from: 512292
Change-Id: Ib146180cf051f17095787563e5ec121406a5825c
Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/providers/decorators/EditModeDecorator.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/providers/decorators/EditModeDecorator.java
index 16e1943..7c6f450 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/providers/decorators/EditModeDecorator.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/providers/decorators/EditModeDecorator.java
@@ -100,9 +100,15 @@
         if (editPart instanceof IDiagramElementEditPart) {
             IDiagramElementEditPart part = (IDiagramElementEditPart) editPart;
 
-            // Case 1 : permission authority forbids the edition of the semantic
+            // Case 1 : edit part is broken
+            if (isBroken(editPart)) {
+                // If the edit part is broken, we return a "deleted" image (red cross)
+                decorationImage = DiagramUIPlugin.getPlugin().getImage(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.DELETE_FROM_DIAGRAM_ICON));
+            }
+
+            // Case 2 : permission authority forbids the edition of the semantic
             // element associated to this edit part
-            if (isDecorableEditPart(part)) {
+            if (decorationImage == null && isDecorableEditPart(part)) {
                 IPermissionAuthority auth = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(part.getEditingDomain().getResourceSet());
                 if (auth != null) {
                     EObject representedObject = part.resolveTargetSemanticElement();
@@ -112,11 +118,6 @@
                 }
             }
 
-            // Case 2 : edit part is broken
-            if (decorationImage == null && isBroken(editPart)) {
-                // If the edit part is broken, we return a "deleted" image (red cross)
-                decorationImage = DiagramUIPlugin.getPlugin().getImage(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.DELETE_FROM_DIAGRAM_ICON));
-            }
         }
         return decorationImage;
     }