X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.linking.ui%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Flinking%2Freport%2Fevaluator%2FVariable.java;h=fdf92297e40532478aa717e28425e94b7a7bc445;hb=HEAD;hp=e19b3528107ea233b95197c5eca630107bf7ab06;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/report/evaluator/Variable.java b/bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/report/evaluator/Variable.java index e19b35281..fdf92297e 100644 --- a/bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/report/evaluator/Variable.java +++ b/bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/report/evaluator/Variable.java @@ -1,91 +1,91 @@ -package org.simantics.document.linking.report.evaluator; - -import java.util.Map; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.document.linking.Activator; -import org.simantics.document.linking.ontology.DocumentLink; -import org.simantics.document.linking.utils.SourceLinkUtil; -import org.simantics.objmap.graph.annotations.GraphType; -import org.simantics.objmap.graph.annotations.RelatedGetValue; -import org.simantics.objmap.graph.annotations.RelatedSetValue; - - -@GraphType(DocumentLink.URIs.EvaluatorTree_Variable) -public class Variable extends EvaluatorLeaf implements StringEditableNode{ - - String variableRef = "#HasName"; - - public Variable() { - - } - - public Variable(String variableRef) { - this.variableRef = variableRef; - } - - public void setVariableRef(String variableRef) { - this.variableRef = variableRef; - } - - public String getVariableRef() { - return variableRef; - } - - @Override - public String getValue(ReadGraph graph, org.simantics.db.layer0.variable.Variable variable, Map context) throws DatabaseException { - if (context.containsKey(variableRef)) - return SourceLinkUtil.getValueString(context.get(variableRef)); - try { - org.simantics.db.layer0.variable.Variable propertyVar = PredefinedVariables.getInstance().getVariable(graph, variableRef, null, variable); - if (propertyVar.getRepresents(graph) == null) - return null; - return SourceLinkUtil.getValueString(propertyVar.getValue(graph)); - } catch (Exception e) { - return null; - } - } - - - - - @Override - public String toString() { - return variableRef; - } - - @RelatedGetValue(DocumentLink.URIs.EvaluatorTree_HasValue) - @Override - public String getValue() { - return variableRef; - } - - - @Override - public String setValue(String value) { - if (value.length() == 0) - return "Variable reference cannot be empty"; - variableRef = value; - return null; - } - - @RelatedSetValue(DocumentLink.URIs.EvaluatorTree_HasValue) - public void _setValue(String value) { - variableRef = value; - } - - - @Override - public EvaluatorItem copy() { - return new Variable(variableRef); - } - - @Override - public ImageDescriptor getImage() { - return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/database_go.png"); - } - - -} +package org.simantics.document.linking.report.evaluator; + +import java.util.Map; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.document.linking.Activator; +import org.simantics.document.linking.ontology.DocumentLink; +import org.simantics.document.linking.utils.SourceLinkUtil; +import org.simantics.objmap.graph.annotations.GraphType; +import org.simantics.objmap.graph.annotations.RelatedGetValue; +import org.simantics.objmap.graph.annotations.RelatedSetValue; + + +@GraphType(DocumentLink.URIs.EvaluatorTree_Variable) +public class Variable extends EvaluatorLeaf implements StringEditableNode{ + + String variableRef = "#HasName"; //$NON-NLS-1$ + + public Variable() { + + } + + public Variable(String variableRef) { + this.variableRef = variableRef; + } + + public void setVariableRef(String variableRef) { + this.variableRef = variableRef; + } + + public String getVariableRef() { + return variableRef; + } + + @Override + public String getValue(ReadGraph graph, org.simantics.db.layer0.variable.Variable variable, Map context) throws DatabaseException { + if (context.containsKey(variableRef)) + return SourceLinkUtil.getValueString(context.get(variableRef)); + try { + org.simantics.db.layer0.variable.Variable propertyVar = PredefinedVariables.getInstance().getVariable(graph, variableRef, null, variable); + if (propertyVar.getRepresents(graph) == null) + return null; + return SourceLinkUtil.getValueString(propertyVar.getValue(graph)); + } catch (Exception e) { + return null; + } + } + + + + + @Override + public String toString() { + return variableRef; + } + + @RelatedGetValue(DocumentLink.URIs.EvaluatorTree_HasValue) + @Override + public String getValue() { + return variableRef; + } + + + @Override + public String setValue(String value) { + if (value.length() == 0) + return "Variable reference cannot be empty"; //$NON-NLS-1$ + variableRef = value; + return null; + } + + @RelatedSetValue(DocumentLink.URIs.EvaluatorTree_HasValue) + public void _setValue(String value) { + variableRef = value; + } + + + @Override + public EvaluatorItem copy() { + return new Variable(variableRef); + } + + @Override + public ImageDescriptor getImage() { + return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/database_go.png"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + +}