X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fselection%2FWorkbenchSelectionUtils.java;h=e3e6eeafe9270432ab1a1a1dd984d8f8ea3d2306;hb=HEAD;hp=47e866d0f61a651d7df83d53c93e6041740cdd09;hpb=f94662db8f48e79c706844ace3692734dd6c2f48;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/selection/WorkbenchSelectionUtils.java b/bundles/org.simantics.ui/src/org/simantics/ui/selection/WorkbenchSelectionUtils.java index 47e866d0f..e3e6eeafe 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/selection/WorkbenchSelectionUtils.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/selection/WorkbenchSelectionUtils.java @@ -11,6 +11,7 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.handlers.HandlerUtil; import org.simantics.Simantics; +import org.simantics.databoard.type.Datatype; import org.simantics.db.ReadGraph; import org.simantics.db.RequestProcessor; import org.simantics.db.Resource; @@ -18,7 +19,9 @@ import org.simantics.db.common.primitiverequest.IsInstanceOf; import org.simantics.db.common.primitiverequest.Supertypes; import org.simantics.db.common.primitiverequest.Types; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.request.PossibleGUID; import org.simantics.db.layer0.request.PossibleURI; +import org.simantics.db.layer0.request.PossibleVariableGUID; import org.simantics.db.layer0.request.PossibleVariableRepresents; import org.simantics.db.layer0.request.VariableRead; import org.simantics.db.layer0.request.VariableURI; @@ -105,16 +108,40 @@ public class WorkbenchSelectionUtils { String typesStr = getTypeResourceString(processor, res, var); if(var != null) { String uri = processor.syncRequest(new VariableURI(var)); + String guid = processor.syncRequest(new PossibleVariableGUID(var)); + + Set classifications = processor.syncRequest(new VariableRead>(var) { + @Override + public Set perform(ReadGraph graph) throws DatabaseException { + return var.getClassifications(graph); + } + }); + String classificationsStr = toJSONStringArray(new ArrayList<>(classifications)); + + Datatype datatype = processor.syncRequest(new VariableRead(var) { + @Override + public Datatype perform(ReadGraph graph) throws DatabaseException { + return var.getPossibleDatatype(graph); + } + }); + return toJSONObjectString( "type", "\"Variable\"", "uri", safeQuotedString(uri), - "typeResources", typesStr); + "guid", safeQuotedString(guid), + "resourceId", res == null ? "" : Long.toString(res.getResourceId()), + "typeResources", typesStr, + "classifications", classificationsStr, + "datatype", safeQuotedString(datatype != null ? datatype.getClass().getName() : null)); } if(res != null) { - String uri = processor.syncRequest(new PossibleURI(res)); + String uri = processor.syncRequest(new PossibleURI(res)); + String guid = processor.syncRequest(new PossibleGUID(res)); return toJSONObjectString( "type", "\"Resource\"", "uri", safeQuotedString(uri), + "guid", safeQuotedString(guid), + "resourceId", Long.toString(res.getResourceId()), "typeResources", typesStr); } return "{ \"type\": \"Unknown\" }";