1 package org.simantics.sysdyn.ui.browser.labelrules;
\r
3 import java.util.Collections;
\r
4 import java.util.Map;
\r
6 import org.simantics.browsing.ui.common.ColumnKeys;
\r
7 import org.simantics.browsing.ui.model.labels.LabelRule;
\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.exception.DatabaseException;
\r
12 import org.simantics.modeling.ModelingResources;
\r
14 public class ModuleTypeLabelRule implements LabelRule {
\r
15 public static final ModuleTypeLabelRule INSTANCE = new ModuleTypeLabelRule();
\r
18 public boolean isCompatible(Class<?> contentType) {
\r
19 return contentType.equals(Resource.class);
\r
23 public Map<String, String> getLabel(ReadGraph graph, Object content) throws DatabaseException {
\r
24 Resource symbol = (Resource)content;
\r
25 Resource component = graph.getSingleObject(symbol, ModelingResources.getInstance(graph).SymbolToComponentType);
\r
27 return Collections.singletonMap(ColumnKeys.SINGLE,
\r
28 NameUtils.getSafeName(graph, component)
\r