]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Fix SymbolLibraryComposite DnD to cope also with GroupProxySymbolItems 81/4481/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 28 Sep 2020 12:29:08 +0000 (15:29 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 29 Sep 2020 05:35:44 +0000 (05:35 +0000)
gitlab #613

Change-Id: Ia45674fb6fe99f4dc958096d35688441f363e80e
(cherry picked from commit 1b93154e988c98b4a2be6a1492b6eabc8b0f6471)

bundles/org.simantics.diagram/src/org/simantics/diagram/symbollibrary/ui/SymbolLibraryComposite.java

index af58be479ec1c7bf7ac4687d11ed478e26995155..31c091fd4eed1041e9b869639463f0ec5e4adfbb 100644 (file)
@@ -88,7 +88,6 @@ import org.simantics.diagram.internal.Activator;
 import org.simantics.diagram.symbolcontribution.CompositeSymbolGroup;
 import org.simantics.diagram.symbolcontribution.IIdentifiedObject;
 import org.simantics.diagram.symbolcontribution.ISymbolProvider;
-import org.simantics.diagram.symbolcontribution.IdentifiedObject;
 import org.simantics.diagram.symbolcontribution.SymbolProviderFactory;
 import org.simantics.diagram.symbollibrary.IModifiableSymbolGroup;
 import org.simantics.diagram.symbollibrary.ISymbolGroup;
@@ -1118,24 +1117,22 @@ public class SymbolLibraryComposite extends Composite {
             json.append(" \"res\" : [");
             int pos = 0;
             for(int i=0;i<res.length;i++) {
-               if(pos > 0) json.append(",");
-               Object r = res[i];
-               if(r instanceof IdentifiedObject) {
-                       Object id = ((IdentifiedObject) r).getId();
-                       if(id instanceof IAdaptable) {
-                               Object resource = ((IAdaptable) id).getAdapter(Resource.class);
-                               if(resource != null) {
-                                       long rid = ((Resource)resource).getResourceId();
-                               json.append(Long.toString(rid));
-                               pos++;
-                               }
-                       }
-               }
+                if(pos > 0) json.append(",");
+                Object r = res[i];
+                if(r instanceof IAdaptable) {
+                    Resource resource = ((IAdaptable) r).getAdapter(Resource.class);
+                    if(resource != null) {
+                        long rid = resource.getResourceId();
+                        json.append(Long.toString(rid));
+                        pos++;
+                    }
+                }
             }
             json.append("] }");
             
-            StringSelection text = new StringSelection(json.toString());
-            PlaintextTransfer plainText = new PlaintextTransfer(json.toString()); 
+            String jsonText = json.toString();
+            StringSelection text = new StringSelection(jsonText);
+            PlaintextTransfer plainText = new PlaintextTransfer(jsonText); 
             
             return new MultiTransferable(local, text, plainText);