]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/GEColumnAccessor.java
Sync git svn branch with SVN repository r33144.
[simantics/platform.git] / bundles / org.simantics.browsing.ui.nattable / src / org / simantics / browsing / ui / nattable / GEColumnAccessor.java
diff --git a/bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/GEColumnAccessor.java b/bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/GEColumnAccessor.java
new file mode 100644 (file)
index 0000000..4ccc2a7
--- /dev/null
@@ -0,0 +1,60 @@
+package org.simantics.browsing.ui.nattable;\r
+\r
+import org.eclipse.nebula.widgets.nattable.data.IColumnPropertyAccessor;\r
+import org.simantics.browsing.ui.Column;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+\r
+\r
+public class GEColumnAccessor implements IColumnPropertyAccessor<TreeNode> {\r
+       NatTableGraphExplorer ge;\r
+       \r
+       public GEColumnAccessor(NatTableGraphExplorer ge) {\r
+               this.ge = ge;\r
+       }\r
+       \r
+       @Override\r
+       public int getColumnCount() {\r
+               return ge.getColumns().length;\r
+       }\r
+       \r
+       @Override\r
+       public Object getDataValue(TreeNode rowObject, int columnIndex) {\r
+               \r
+               if (columnIndex > 0)\r
+                       return rowObject.getValueString(columnIndex);\r
+               else {\r
+                       String val = "";\r
+                       for (int i = 0 ; i <rowObject.getDepth(); i++)\r
+                               val += "   ";\r
+                       return val + rowObject.getValueString(columnIndex);\r
+               }\r
+               \r
+               \r
+       }\r
+       \r
+       \r
+       @Override\r
+       public void setDataValue(TreeNode rowObject, int columnIndex, Object newValue) {\r
+               Modifier modifier = ge.getModifier(rowObject, columnIndex);\r
+               if (modifier == null)\r
+                       throw new IllegalArgumentException("Items is not modifiable");\r
+               modifier.modify(newValue.toString());\r
+       }\r
+       \r
+       \r
+       @Override\r
+       public String getColumnProperty(int columnIndex) {\r
+               return ge.getColumns()[columnIndex].getKey();\r
+       }\r
+       \r
+       @Override\r
+       public int getColumnIndex(String propertyName) {\r
+               Column columns[] = ge.getColumns();\r
+               for (int i = 0; i < columns.length; i++) {\r
+                       if (columns[i].getKey().equals(propertyName))\r
+                               return i;\r
+               }\r
+               return -1;\r
+       }\r
+       \r
+}
\ No newline at end of file