SDK: remove duplicate code in AbstractSceneExplorer's constructor

One constructor with the shared logic, other constructor are just sugar
experimental
David Bernard 11 years ago
parent 846960c28c
commit f26b53fcb7
  1. 22
      sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/AbstractSceneExplorerNode.java
  2. 1
      sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeBone.java
  3. 1
      sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeSpatial.java

@ -65,34 +65,22 @@ public abstract class AbstractSceneExplorerNode extends AbstractNode implements
private final List<Property<?>> sceneProperties = Collections.synchronizedList(new LinkedList<Property<?>>()); private final List<Property<?>> sceneProperties = Collections.synchronizedList(new LinkedList<Property<?>>());
public AbstractSceneExplorerNode() { public AbstractSceneExplorerNode() {
super(Children.LEAF, new DynamicLookup(new InstanceContent())); this(Children.LEAF, null);
lookupContents = ((DynamicLookup) getLookup()).getInstanceContent();
} }
public AbstractSceneExplorerNode(Children children, DataObject dataObject) { public AbstractSceneExplorerNode(Children children, DataObject dataObject) {
super(children, new ProxyLookup(dataObject.getLookup(), new DynamicLookup(new InstanceContent()))); super(children, new ProxyLookup(dataObject != null ? dataObject.getLookup() : Lookup.EMPTY, new DynamicLookup(new InstanceContent())));
this.dataObject = dataObject; this.dataObject = dataObject;
this.jmeChildren = children;
lookupContents = getLookup().lookup(DynamicLookup.class).getInstanceContent(); lookupContents = getLookup().lookup(DynamicLookup.class).getInstanceContent();
} }
public AbstractSceneExplorerNode(DataObject dataObject) { public AbstractSceneExplorerNode(DataObject dataObject) {
super(Children.LEAF, new ProxyLookup(dataObject != null ? dataObject.getLookup() : Lookup.EMPTY, new DynamicLookup(new InstanceContent()))); this(Children.LEAF, dataObject);
this.dataObject = dataObject;
lookupContents = getLookup().lookup(DynamicLookup.class).getInstanceContent();
} }
public AbstractSceneExplorerNode(Children children) { public AbstractSceneExplorerNode(Children children) {
//TODO: OMG! this(children, (children instanceof JmeSpatialChildren) ? ((JmeSpatialChildren) children).getDataObject() : null);
super(children, children instanceof JmeSpatialChildren
? (((JmeSpatialChildren) children).getDataObject() != null
? new ProxyLookup(((JmeSpatialChildren) children).getDataObject().getLookup(), new DynamicLookup(new InstanceContent()))
: new DynamicLookup(new InstanceContent()))
: new DynamicLookup(new InstanceContent()));
this.jmeChildren = children;
lookupContents = getLookup().lookup(DynamicLookup.class).getInstanceContent();
if (children instanceof JmeSpatialChildren) {
this.dataObject = ((JmeSpatialChildren) children).getDataObject();
}
} }
public InstanceContent getLookupContents() { public InstanceContent getLookupContents() {

@ -63,7 +63,6 @@ public class JmeBone extends AbstractSceneExplorerNode {
public JmeBone(JmeSkeletonControl jmeSkeletonControl, Bone bone, JmeBoneChildren children) { public JmeBone(JmeSkeletonControl jmeSkeletonControl, Bone bone, JmeBoneChildren children) {
super(children); super(children);
this.jmeChildren = children;
this.jmeSkeletonControl = jmeSkeletonControl; this.jmeSkeletonControl = jmeSkeletonControl;
getLookupContents().add(bone); getLookupContents().add(bone);
getLookupContents().add(this); getLookupContents().add(this);

@ -83,7 +83,6 @@ public class JmeSpatial extends AbstractSceneExplorerNode {
public JmeSpatial(Spatial spatial, JmeSpatialChildren factory) { public JmeSpatial(Spatial spatial, JmeSpatialChildren factory) {
super(factory); super(factory);
this.jmeChildren = factory;
this.spatial = spatial; this.spatial = spatial;
getLookupContents().add(spatial); getLookupContents().add(spatial);
getLookupContents().add(this); getLookupContents().add(this);

Loading…
Cancel
Save