--- /dev/null
+package org.simantics.diagram.profile.view;\r
+\r
+import java.util.Collections;\r
+import java.util.Map;\r
+\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.browsing.ui.model.labels.LabelRule;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public class ResourcePairLabelRule implements LabelRule {\r
+ \r
+ public static final ResourcePairLabelRule INSTANCE = new ResourcePairLabelRule();\r
+ \r
+ public ResourcePairLabelRule() {\r
+ }\r
+\r
+ @Override\r
+ public boolean isCompatible(Class<?> contentType) {\r
+ return contentType.equals(ResourcePair.class);\r
+ }\r
+\r
+ @Override\r
+ public Map<String,String> getLabel(ReadGraph graph, Object content) throws DatabaseException {\r
+ return Collections.singletonMap(ColumnKeys.SINGLE, \r
+ NameUtils.getSafeLabel(graph, ((ResourcePair)content).getSecond())\r
+ );\r
+ }\r
+}\r