X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.selectionview%2Fsrc%2Forg%2Fsimantics%2Fselectionview%2FVariablePropertyLabelRule.java;fp=bundles%2Forg.simantics.selectionview%2Fsrc%2Forg%2Fsimantics%2Fselectionview%2FVariablePropertyLabelRule.java;h=f99f679efe4859813bdd8186605afeacb08c22af;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/VariablePropertyLabelRule.java b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/VariablePropertyLabelRule.java new file mode 100644 index 000000000..f99f679ef --- /dev/null +++ b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/VariablePropertyLabelRule.java @@ -0,0 +1,41 @@ +package org.simantics.selectionview; + +import java.util.HashMap; +import java.util.Map; + +import org.simantics.browsing.ui.model.labels.LabelRule; +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.db.layer0.variable.Variables; + +public class VariablePropertyLabelRule implements LabelRule { + + @Override + public boolean isCompatible(Class contentType) { + return contentType.equals(Variable.class); + } + + @Override + public Map getLabel(ReadGraph graph, Object content) + throws DatabaseException { + + Variable variable = (Variable)content; + + Map result = new HashMap(); + + for(Variable property : variable.getProperties(graph)) { + String column = property.getPossiblePropertyValue(graph, Variables.DISPLAY_COLUMN); + if(column != null) { + String value = property.getValue(graph, Bindings.STRING); + if (value != null) + result.put(column, value); + } + } + + return result; + + } + +}