]> gerrit.simantics Code Review - simantics/platform.git/blob
b25e28129d8cb6fb9bf8cebc474c49b1f76dd3c3
[simantics/platform.git] /
1 package org.simantics.browsing.ui.nattable;
2
3 import org.eclipse.nebula.widgets.nattable.data.IColumnPropertyAccessor;
4 import org.simantics.browsing.ui.Column;
5 import org.simantics.browsing.ui.content.Labeler.Modifier;
6
7
8 public class GEColumnAccessor implements IColumnPropertyAccessor<TreeNode> {
9         NatTableGraphExplorer ge;
10         
11         public GEColumnAccessor(NatTableGraphExplorer ge) {
12                 this.ge = ge;
13         }
14         
15         @Override
16         public int getColumnCount() {
17                 return ge.getColumns().length;
18         }
19         
20         @Override
21         public Object getDataValue(TreeNode rowObject, int columnIndex) {
22                 
23                 if (columnIndex > 0)
24                         return rowObject.getValueString(columnIndex);
25                 else {
26                         String val = "";
27                         for (int i = 0 ; i <rowObject.getDepth(); i++)
28                                 val += "   ";
29                         return val + rowObject.getValueString(columnIndex);
30                 }
31                 
32                 
33         }
34         
35         
36         @Override
37         public void setDataValue(TreeNode rowObject, int columnIndex, Object newValue) {
38                 Modifier modifier = ge.getModifier(rowObject, columnIndex);
39                 if (modifier == null)
40                         throw new IllegalArgumentException("Items is not modifiable");
41                 modifier.modify(newValue.toString());
42         }
43         
44         
45         @Override
46         public String getColumnProperty(int columnIndex) {
47                 return ge.getColumns()[columnIndex].getKey();
48         }
49         
50         @Override
51         public int getColumnIndex(String propertyName) {
52                 Column columns[] = ge.getColumns();
53                 for (int i = 0; i < columns.length; i++) {
54                         if (columns[i].getKey().equals(propertyName))
55                                 return i;
56                 }
57                 return -1;
58         }
59         
60 }