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
15 public class EnumerationLabeler extends ColumnLabelerContributorImpl<EnumerationNode>{
\r
18 public Map<String, String> getLabel(ReadGraph graph, EnumerationNode input)
\r
19 throws DatabaseException {
\r
21 String name = NameUtils.getSafeName(graph, input.data);
\r
22 HashMap<String, String> map = new HashMap<String, String>();
\r
23 map.put(Keys.ENUMERATION, name);
\r
25 SysdynResource sr = SysdynResource.getInstance(graph);
\r
26 Resource enumerationIndexes = graph.getPossibleObject(input.data, sr.HasEnumerationIndexes);
\r
27 ListIterator<Resource> indexes = OrderedSetUtils.iterator(graph, enumerationIndexes);
\r
28 StringBuilder sb = new StringBuilder();
\r
30 while(indexes.hasNext()) {
\r
31 Resource i = indexes.next();
\r
32 sb.append(NameUtils.getSafeName(graph, i));
\r
33 if(indexes.hasNext())
\r
37 map.put(Keys.INDEXES, sb.toString());
\r