From: Tuukka Lehtonen Date: Mon, 28 Sep 2020 12:29:08 +0000 (+0300) Subject: Fix SymbolLibraryComposite DnD to cope also with GroupProxySymbolItems X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=86617be247efb3b904b3180d0569049aff232d75;p=simantics%2Fplatform.git Fix SymbolLibraryComposite DnD to cope also with GroupProxySymbolItems gitlab #613 Change-Id: Ia45674fb6fe99f4dc958096d35688441f363e80e (cherry picked from commit 1b93154e988c98b4a2be6a1492b6eabc8b0f6471) --- diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/symbollibrary/ui/SymbolLibraryComposite.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/symbollibrary/ui/SymbolLibraryComposite.java index af58be479..31c091fd4 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/symbollibrary/ui/SymbolLibraryComposite.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/symbollibrary/ui/SymbolLibraryComposite.java @@ -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 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);