SymbolLibraryComposite does not handle GroupSymbolProxyItems properly
When symbol contributions contain ISymbolGroup instance with same name, the symbol library implementation will create CompositeSymbolGroup
instances to join those groups together. Internally CompositeSymbolGroup.getItems()
will create GroupProxySymbolItem
instances, which SymbolLibraryComposite
does not handle properly when it tries to generate JSON for DnD operations:
StringBuilder json = new StringBuilder();
json.append("{");
json.append(" \"type\" : \"Symbol\",");
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++;
}
}
}
}
json.append("] }");
Now, if r instanceof GroupProxySymbolItem
, this code will fail to produce any res
entries for the dragged symbol library element. This will cause diagram population to fail.
The code should resort to IAdaptable
and not test against IdentifiedObject
but IIdentifiedObject
instead.