import org.simantics.ui.SimanticsUI;
import org.simantics.ui.selection.AnyResource;
import org.simantics.ui.selection.AnyVariable;
+import org.simantics.ui.selection.ParentVariable;
import org.simantics.ui.selection.WorkbenchSelectionContentType;
import org.simantics.utils.DataContainer;
import org.simantics.utils.threads.IThreadWorkQueue;
} catch (DatabaseException e) {
Logger.defaultLogError(e);
}
+ }
+ else if(contentType instanceof ParentVariable) {
+ ParentVariable type = (ParentVariable)contentType;
+ try {
+ return (T) type.processor.sync(new ResourceRead2<Variable>(runtime, element) {
+ @Override
+ public Variable perform(ReadGraph graph) throws DatabaseException {
+
+ DiagramResource DIA = DiagramResource.getInstance(graph);
+ ModelingResources MOD = ModelingResources.getInstance(graph);
+ Layer0 L0 = Layer0.getInstance(graph);
+
+ String uri = graph.getPossibleRelatedValue(resource, DIA.RuntimeDiagram_HasVariable);
+ if (uri == null)
+ return null;
+
+ Variable var = Variables.getPossibleVariable(graph, uri);
+ if (var == null)
+ return null;
+
+ return var;
+ }
+ });
+ } catch (DatabaseException e) {
+ Logger.defaultLogError(e);
+ }
}
+
return null;
}
}
@Override
- final public void contribute(ReadGraph graph, final Object selection, Collection<ComparableTabContributor> result) throws DatabaseException {
+ public void contribute(ReadGraph graph, final Object selection, Collection<ComparableTabContributor> result) throws DatabaseException {
Variable variable = getPossibleVariable(graph, selection);
if(variable == null) return;
--- /dev/null
+package org.simantics.ui.selection;
+
+import org.simantics.db.RequestProcessor;
+import org.simantics.db.layer0.variable.Variable;
+
+public class ParentVariable implements WorkbenchSelectionContentType<Variable> {
+
+ public RequestProcessor processor;
+
+ public ParentVariable(RequestProcessor processor) {
+ this.processor = processor;
+ }
+
+}