]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.selectionview/src/org/simantics/selectionview/CategoryNodeLabelRule.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.selectionview / src / org / simantics / selectionview / CategoryNodeLabelRule.java
diff --git a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/CategoryNodeLabelRule.java b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/CategoryNodeLabelRule.java
new file mode 100644 (file)
index 0000000..5654c01
--- /dev/null
@@ -0,0 +1,29 @@
+package org.simantics.selectionview;\r
+\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.exception.DatabaseException;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+public class CategoryNodeLabelRule implements LabelRule {\r
+\r
+       private static final String[] COLS = new String[] { ColumnKeys.DISPLAY_PROPERTY };\r
+       \r
+    @Override\r
+    public boolean isCompatible(Class<?> contentType) {\r
+        return contentType.equals(CategoryNode.class);\r
+    }\r
+\r
+    @Override\r
+    public Map<String, String> getLabel(ReadGraph graph, Object content)\r
+            throws DatabaseException {\r
+       \r
+               String[] result = new String[] { ((CategoryNode)content).getName() };\r
+               return new ArrayMap<String, String>(COLS, result);\r
+               \r
+    }\r
+\r
+}\r