1 package org.simantics.selectionview;
\r
3 import java.util.HashMap;
\r
4 import java.util.Map;
\r
6 import org.simantics.browsing.ui.model.labels.LabelRule;
\r
7 import org.simantics.databoard.Bindings;
\r
8 import org.simantics.db.ReadGraph;
\r
9 import org.simantics.db.exception.DatabaseException;
\r
10 import org.simantics.db.layer0.variable.Variable;
\r
11 import org.simantics.db.layer0.variable.Variables;
\r
13 public class VariablePropertyLabelRule implements LabelRule {
\r
16 public boolean isCompatible(Class<?> contentType) {
\r
17 return contentType.equals(Variable.class);
\r
21 public Map<String, String> getLabel(ReadGraph graph, Object content)
\r
22 throws DatabaseException {
\r
24 Variable variable = (Variable)content;
\r
26 Map<String, String> result = new HashMap<String, String>();
\r
28 for(Variable property : variable.getProperties(graph)) {
\r
29 String column = property.getPossiblePropertyValue(graph, Variables.DISPLAY_COLUMN);
\r
30 if(column != null) {
\r
31 String value = property.getPossibleValue(graph, Bindings.STRING);
\r
33 result.put(column, value);
\r