From 59d1b7c894891d83107ec82d4afe90bdb875eead Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Tue, 28 Jun 2011 16:44:23 +0000 Subject: [PATCH] SDK : used reflection to determine what attributes to use in the filter editor git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7762 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../gde/core/filters/AbstractFilterNode.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java b/sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java index 96a1c7457..fb6dbd6a4 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java @@ -36,6 +36,7 @@ import com.jme3.gde.core.sceneexplorer.nodes.properties.ScenePropertyChangeListe import com.jme3.post.Filter; import java.io.IOException; import java.lang.reflect.Field; +import java.lang.reflect.Method; import javax.swing.Action; import org.openide.actions.DeleteAction; import org.openide.loaders.DataObject; @@ -123,6 +124,7 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN return sheet; } + /** * @param saveCookie the saveCookie to set */ @@ -161,18 +163,24 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN } return prop; } - - protected void createFields(Class c, Sheet.Set set, Object obj) throws SecurityException { - for (Field field : c.getDeclaredFields()) { - Filter.FilterParameter param = field.getAnnotation(Filter.FilterParameter.class); - if (param != null) { - String name = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1); - String getter = "get"; - if (field.getType().equals(boolean.class)) { - getter = "is"; - } - set.put(makeProperty(obj, field.getType(), getter + name, "set" + name, param.name())); + + protected void createFields(Class c, Sheet.Set set, Object obj) throws SecurityException { + for (Field field : c.getDeclaredFields()) { + + String name = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1); + String getter = "get"; + if (field.getType().equals(boolean.class)) { + getter = "is"; } + try { + Method m=c.getMethod(getter + name, null); + m=c.getMethod("set" + name, field.getType()); + } catch (NoSuchMethodException e) { + continue; + } + + set.put(makeProperty(obj, field.getType(), getter + name, "set" + name, field.getName())); + } }