]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java
Use generics type variable for mapping db object.
[simantics/3d.git] / org.simantics.g3d / src / org / simantics / g3d / property / AnnotatedPropertyTabContributorFactory.java
index c3d7376fd87af9af1fef64c6066b893d48671fdb..f0fe47ece8be37c8f0403842bb1423abfde4f2f9 100644 (file)
@@ -131,85 +131,85 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri
        
        
        private static void collectItems(Class<?> clazz, Map<String, IPropertyItem> items) throws InstantiationException, IllegalAccessException {
-                Class<?> superclass = clazz.getSuperclass();
-                if(superclass != null)
-                        collectItems(superclass, items);
-                
-                for (Method m : clazz.getDeclaredMethods()) {
-                        m.setAccessible(true);
-               for (Annotation annotation : m.getAnnotations()) {
-                       if (annotation.annotationType().equals(GetPropertyValue.class)) {
-                               GetPropertyValue get = (GetPropertyValue)annotation;
-                               PropertyItem item = (PropertyItem)items.get(get.value());
-                               if (item == null) {
-                                       item = new PropertyItem(get.value());
-                                       items.put(item.id, item);
-                               }
+               Class<?> superclass = clazz.getSuperclass();
+               if(superclass != null)
+                       collectItems(superclass, items);
+               
+               for (Method m : clazz.getDeclaredMethods()) {
+                       m.setAccessible(true);
+                       for (Annotation annotation : m.getAnnotations()) {
+                               if (annotation.annotationType().equals(GetPropertyValue.class)) {
+                                       GetPropertyValue get = (GetPropertyValue)annotation;
+                                       PropertyItem item = (PropertyItem)items.get(get.value());
+                                       if (item == null) {
+                                               item = new PropertyItem(get.value());
+                                               items.put(item.id, item);
+                                       }
 
-                               item.getter = m;
-                               item.manipulatorClass = get.manipulator().newInstance().get(m,null);
+                                       item.getter = m;
+                                       item.manipulatorClass = get.manipulator().newInstance().get(m,null);
 
-                               item.tabId = get.tabId();
+                                       item.tabId = get.tabId();
 
-                               item.name = get.name();
-                               
-                               
-                       } else if (annotation.annotationType().equals(SetPropertyValue.class)) {
-                               SetPropertyValue set = (SetPropertyValue)annotation;
-                               PropertyItem item = (PropertyItem)items.get(set.value());
-                               if (item == null) {
-                                       item = new PropertyItem(set.value());
-                                       items.put(item.id, item);
-                               }
-                               
-                               item.setter = m;
-                       } else if (annotation.annotationType().equals(CompoundGetPropertyValue.class)) {
-                               CompoundGetPropertyValue get = (CompoundGetPropertyValue)annotation;
-                               CompoundPropertyItem item = (CompoundPropertyItem)items.get(get.value());
-                               if (item == null) {
-                                       item = new CompoundPropertyItem(get.value());
-                                       items.put(item.id, item);
-                               }
+                                       item.name = get.name();
+                                       
+                                       
+                               } else if (annotation.annotationType().equals(SetPropertyValue.class)) {
+                                       SetPropertyValue set = (SetPropertyValue)annotation;
+                                       PropertyItem item = (PropertyItem)items.get(set.value());
+                                       if (item == null) {
+                                               item = new PropertyItem(set.value());
+                                               items.put(item.id, item);
+                                       }
+                                       
+                                       item.setter = m;
+                               } else if (annotation.annotationType().equals(CompoundGetPropertyValue.class)) {
+                                       CompoundGetPropertyValue get = (CompoundGetPropertyValue)annotation;
+                                       CompoundPropertyItem item = (CompoundPropertyItem)items.get(get.value());
+                                       if (item == null) {
+                                               item = new CompoundPropertyItem(get.value());
+                                               items.put(item.id, item);
+                                       }
 
-                               item.getter = m;
-                               item.manipulatorFactory = get.manipulator().newInstance();
+                                       item.getter = m;
+                                       item.manipulatorFactory = get.manipulator().newInstance();
 
-                               item.tabId = get.tabId();
+                                       item.tabId = get.tabId();
 
-                               item.name = get.name();
-                       } else if (annotation.annotationType().equals(CompoundSetPropertyValue.class)) {
-                               CompoundSetPropertyValue set = (CompoundSetPropertyValue)annotation;
-                               CompoundPropertyItem item = (CompoundPropertyItem)items.get(set.value());
-                               if (item == null) {
-                                       item = new CompoundPropertyItem(set.value());
-                                       items.put(item.id, item);
-                               }
-                               
-                               item.setter = m;
-                       }
-               }
-                }
+                                       item.name = get.name();
+                               } else if (annotation.annotationType().equals(CompoundSetPropertyValue.class)) {
+                                       CompoundSetPropertyValue set = (CompoundSetPropertyValue)annotation;
+                                       CompoundPropertyItem item = (CompoundPropertyItem)items.get(set.value());
+                                       if (item == null) {
+                                               item = new CompoundPropertyItem(set.value());
+                                               items.put(item.id, item);
+                                       }
+                                       
+                                       item.setter = m;
+                               }
+                       }
+               }
                
                
        }
        
        private static void collectBlacklist(Class<?> clazz, List<String> blacklist) throws InstantiationException, IllegalAccessException {
-                Class<?> superclass = clazz.getSuperclass();
-                if(superclass != null)
-                        collectBlacklist(superclass, blacklist);
-                
-                PropertyTabBlacklist ann = clazz.getAnnotation(PropertyTabBlacklist.class);
-                if (ann == null)
-                        return;
-                String s = ann.value();
-                if (s == null)
-                        return;
-                if (s.length() == 0)
-                        return;
-                for (String item : s.split(";")) {
-                        blacklist.add(item);
-                }
-                
+               Class<?> superclass = clazz.getSuperclass();
+               if(superclass != null)
+                       collectBlacklist(superclass, blacklist);
+               
+               PropertyTabBlacklist ann = clazz.getAnnotation(PropertyTabBlacklist.class);
+               if (ann == null)
+                       return;
+               String s = ann.value();
+               if (s == null)
+                       return;
+               if (s.length() == 0)
+                       return;
+               for (String item : s.split(";")) {
+                       blacklist.add(item);
+               }
+               
                
        }
        
@@ -339,7 +339,7 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri
                private TableViewer viewer;
                
                private IG3DNode node;
-               private NodeMap<?,?> nodeMap;
+               private NodeMap<?,?,?> nodeMap;
                
                private List<TableViewerColumn> valueColumns = new ArrayList<TableViewerColumn>();
                
@@ -578,8 +578,8 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri
                                        nodeMap = null;
                                        break;
                                }
-                               if (n instanceof NodeMapProvider<?,?>) {
-                                       nodeMap = ((NodeMapProvider<?,?>) n).getNodeMap();
+                               if (n instanceof NodeMapProvider<?,?,?>) {
+                                       nodeMap = ((NodeMapProvider<?,?,?>) n).getNodeMap();
                                        if (nodeMap != null)
                                                break;
                                }
@@ -733,11 +733,11 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri
        private static class PropertyEditingSupport extends EditingSupport {
                AnnotatedPropertyTab tab;
                int index;
-               NodeMap<?,?> nodeMap;
+               NodeMap<?,?,?> nodeMap;
                TableViewer viewer;
                CellEditor editor;
 
-               public PropertyEditingSupport(AnnotatedPropertyTab tab, TableViewer viewer, int index, NodeMap<?,?> nodeMap) {
+               public PropertyEditingSupport(AnnotatedPropertyTab tab, TableViewer viewer, int index, NodeMap<?,?,?> nodeMap) {
                        super(viewer);
                        this.tab = tab;
                        this.index = index;
@@ -799,7 +799,7 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri
                        if (DEBUG)System.err.println("CELL SET VALUE: " + element + " " + value);
                        manipulator.setValue((String)value,index);
                        viewer.refresh(item);
-                       nodeMap.commit();
+                       nodeMap.commit("Set " + item.id + " value to " + value);
                        
                }