1 package org.simantics.sysdyn.ui.properties.widgets.arrays;
\r
3 import java.util.HashMap;
\r
4 import java.util.ListIterator;
\r
5 import java.util.Map;
\r
7 import org.simantics.browsing.ui.graph.impl.contributor.labeler.ColumnLabelerContributorImpl;
\r
8 import org.simantics.db.ReadGraph;
\r
9 import org.simantics.db.Resource;
\r
10 import org.simantics.db.common.utils.NameUtils;
\r
11 import org.simantics.db.common.utils.OrderedSetUtils;
\r
12 import org.simantics.db.exception.DatabaseException;
\r
13 import org.simantics.sysdyn.SysdynResource;
\r
14 import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys;
\r
16 public class EnumerationLabeler extends ColumnLabelerContributorImpl<EnumerationNode>{
\r
19 public Map<String, String> getLabel(ReadGraph graph, EnumerationNode input)
\r
20 throws DatabaseException {
\r
22 String name = NameUtils.getSafeName(graph, input.data);
\r
23 HashMap<String, String> map = new HashMap<String, String>();
\r
24 map.put(ColumnKeys.ENUMERATION, name);
\r
26 SysdynResource sr = SysdynResource.getInstance(graph);
\r
28 Resource enumerationIndexes = graph.getPossibleObject(input.data, sr.HasEnumerationIndexes);
\r
29 ListIterator<Resource> indexes = OrderedSetUtils.iterator(graph, enumerationIndexes);
\r
30 StringBuilder sb = new StringBuilder();
\r
32 while(indexes.hasNext()) {
\r
33 Resource i = indexes.next();
\r
34 sb.append(NameUtils.getSafeName(graph, i));
\r
35 if(indexes.hasNext())
\r
40 Boolean relaceable = graph.getPossibleRelatedValue(input.data, sr.IsReplaceable);
\r
41 if(Boolean.TRUE.equals(relaceable)) {
\r
42 sb.append(" Replaceable");
\r
45 map.put(ColumnKeys.INDEXES, sb.toString());
\r