X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fproperty%2FAnnotatedPropertyTabContributorFactory.java;h=f0fe47ece8be37c8f0403842bb1423abfde4f2f9;hb=9070983be64f9f107e0a6388549aad475fcd9d76;hp=21e773c1c82c2fdf4dbda2e91a3e59afdeb272ee;hpb=9c5be9fa9ff5fece5710b9f21bcafca58388899d;p=simantics%2F3d.git diff --git a/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java b/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java index 21e773c1..f0fe47ec 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java +++ b/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java @@ -131,85 +131,85 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri private static void collectItems(Class clazz, Map 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 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 valueColumns = new ArrayList(); @@ -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; } @@ -673,6 +673,8 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri // } // } if (Thread.currentThread() == Display.getDefault().getThread()) { + if (viewer.getTable().isDisposed()) + return; if (DEBUG)System.out.println("Viewer refresh " + id); for (PropertyItem item : resolvedItems) if (!item.equals(selectedItem)) @@ -731,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; @@ -748,7 +750,11 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri PropertyItem item = (PropertyItem)element; if (tab.getManipulator(item).getValueCount() <= index) return false; - return (item.setter != null); + if (item.setter == null) + return false; + if (getValue(element) == null) + return false; + return true; } @Override @@ -793,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); }