[571537] Fix ClassCastException issue with NoteAttachement from edge.

Bug: 571537
Change-Id: I1a88108c0400af97932f808b30beb9924a632c7b
Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/MappingBasedSiriusFormatManagerFactory.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/MappingBasedSiriusFormatManagerFactory.java
index d3e1bad..719533e 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/MappingBasedSiriusFormatManagerFactory.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/format/MappingBasedSiriusFormatManagerFactory.java
@@ -637,10 +637,10 @@
         // Duplicate note attachments if possible
         Collection<Edge> notesAttachments = GMFNotationHelper.getNotesAttachments(sourceGMFDiagram);
         notesAttachments.forEach(attach -> {
-            Node nodeAttachment = (Node) attach.getSource();
+            View nodeAttachment = attach.getSource();
             Boolean noteIsSource = true;
-            if (!GMFNotationHelper.isNote(nodeAttachment) && !GMFNotationHelper.isTextNote(nodeAttachment)) {
-                nodeAttachment = (Node) attach.getTarget();
+            if (!isNoteOrText(nodeAttachment)) {
+                nodeAttachment = attach.getTarget();
                 noteIsSource = false;
             }
             MappingBasedSiriusFormatManagerFactoryHelper.duplicateNoteAttachment(attach, sourceToTargetNoteMap.get(nodeAttachment), targetSession, noteIsSource, diagramContentDuplicationSwitch,
@@ -648,6 +648,10 @@
         });
     }
 
+    private boolean isNoteOrText(View nodeAttachment) {
+        return nodeAttachment instanceof Node && (GMFNotationHelper.isNote((Node) nodeAttachment) || GMFNotationHelper.isTextNote((Node) nodeAttachment));
+    }
+
     /**
      * Search in <code>nodes</code> a Node (Text or Note) with the same label (<code>searchedLabel</code>) and the same
      * attachments than the <code>sourceNode</code>.