- public static Runnable addPlots(final Resource chart, final List<ChartItemDescriptor> references, final Set<Resource> movedPlots) {\r
- return new Runnable() {\r
- @Override\r
- public void run() {\r
- Simantics.getSession().asyncRequest(\r
- AddChartItem.addAndMoveChartItems(chart, references, movedPlots),\r
- new ProcedureAdapter<Collection<Resource>>() {\r
- @Override\r
- public void exception(Throwable e) {\r
+ private static List<VariableReference> toReferences(ReadGraph graph, Resource contextIndexRoot, List<Variable> variables) throws DatabaseException {\r
+ if (variables.isEmpty())\r
+ return Collections.emptyList();\r
+ return filterReferences( graph.syncRequest(VariableReferences.variablesToReferences(contextIndexRoot, variables)) );\r
+ }\r
+\r
+ private static List<VariableReference> toPropertyReferences(ReadGraph graph, Resource contextIndexRoot, List<PropertyVariables> variables) throws DatabaseException {\r
+ if (variables.isEmpty())\r
+ return Collections.emptyList();\r
+ return filterReferences( graph.syncRequest(VariableReferences.toReferences(contextIndexRoot, variables)) );\r
+ }\r
+\r
+ private static List<VariableReference> filterReferences(List<VariableReference> variables) throws DatabaseException {\r
+ return variables.stream()\r
+ .filter(ref -> ref.datatype instanceof BooleanType || ref.datatype instanceof NumberType)\r
+ .collect(Collectors.toList());\r
+ }\r
+\r
+ public static Runnable addPlots(Resource chart, List<ChartItemDescriptor> references, Set<Resource> movedPlots) {\r
+ return () -> {\r
+ Simantics.getSession().asyncRequest(\r
+ AddChartItem.addAndMoveChartItems(chart, references, movedPlots),\r
+ new ProcedureAdapter<Collection<Resource>>() {\r
+ @Override\r
+ public void exception(Throwable e) {\r
+ if (e != null)\r