1 package org.simantics.modeling.ui.diagram.monitor;
3 import org.simantics.databoard.Bindings;
4 import org.simantics.databoard.util.ObjectUtils;
5 import org.simantics.db.WriteGraph;
6 import org.simantics.db.common.CommentMetadata;
7 import org.simantics.db.common.request.WriteRequest;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.db.layer0.variable.Variable;
10 import org.simantics.db.layer0.variable.VariableWriteImplied;
11 import org.simantics.db.layer0.variable.Variables;
13 public class MonitorVariableWrite extends WriteRequest {
15 final private Variable variable;
16 final private String label;
18 public MonitorVariableWrite(Variable variable, String label) {
20 this.variable = variable;
25 public void perform(WriteGraph graph) throws DatabaseException {
27 Variable converted = variable.getPossibleProperty(graph, Variables.CONVERTED_VALUE);
28 if(converted != null) {
29 converted.setValue(graph, label, Bindings.STRING);
31 // Add a comment to metadata.
32 CommentMetadata cm = graph.getMetadata(CommentMetadata.class);
33 graph.addMetadata(cm.add("Set value " + ObjectUtils.toString(label)));
35 new VariableWriteImplied(variable, label).perform(graph);