--- /dev/null
+package org.simantics.selectionview;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.simantics.browsing.ui.model.labels.LabelRule;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+\r
+public class VariablePropertyLabelRule implements LabelRule {\r
+ \r
+ @Override\r
+ public boolean isCompatible(Class<?> contentType) {\r
+ return contentType.equals(Variable.class);\r
+ }\r
+\r
+ @Override\r
+ public Map<String, String> getLabel(ReadGraph graph, Object content)\r
+ throws DatabaseException {\r
+ \r
+ Variable variable = (Variable)content;\r
+ \r
+ Map<String, String> result = new HashMap<String, String>();\r
+ \r
+ for(Variable property : variable.getProperties(graph)) {\r
+ String column = property.getPossiblePropertyValue(graph, Variables.DISPLAY_COLUMN);\r
+ if(column != null) {\r
+ String value = property.getValue(graph, Bindings.STRING);\r
+ if (value != null)\r
+ result.put(column, value);\r
+ }\r
+ }\r
+ \r
+ return result;\r
+ \r
+ }\r
+\r
+}\r