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
3.0
rem..om 14 years ago
parent cc7110d4f5
commit 59d1b7c894
  1. 30
      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()));
}
}

Loading…
Cancel
Save