diff --git a/sdk/jme3-core/src/com/jme3/gde/core/appstates/AppStateExplorerTopComponent.java b/sdk/jme3-core/src/com/jme3/gde/core/appstates/AppStateExplorerTopComponent.java index 704cc5126..1c67b257b 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/appstates/AppStateExplorerTopComponent.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/appstates/AppStateExplorerTopComponent.java @@ -37,7 +37,6 @@ import com.jme3.gde.core.scene.PreviewRequest; import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.scene.SceneListener; import com.jme3.gde.core.scene.SceneRequest; -import com.jme3.scene.Spatial; import java.util.Iterator; import javax.swing.ActionMap; import org.netbeans.api.settings.ConvertAsProperties; @@ -80,10 +79,6 @@ public final class AppStateExplorerTopComponent extends TopComponent implements private SceneListener listener = new SceneListener() { public void sceneOpened(SceneRequest request) { currentRequest = request; - Spatial rootNode = request.getRootNode(); - if (!(rootNode instanceof com.jme3.scene.Node)) { - return; - } mgr = request.getManager(); FakeApplication app = request.getFakeApp(); final AppStateManagerNode nod = new AppStateManagerNode(app.getStateManager()); diff --git a/sdk/jme3-core/src/com/jme3/gde/core/appstates/AppStateNode.java b/sdk/jme3-core/src/com/jme3/gde/core/appstates/AppStateNode.java index bbcc37acf..ea6712b0e 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/appstates/AppStateNode.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/appstates/AppStateNode.java @@ -35,6 +35,7 @@ import com.jme3.app.state.AppState; import com.jme3.app.state.AppStateManager; import com.jme3.gde.core.properties.SceneExplorerProperty; import com.jme3.gde.core.properties.ScenePropertyChangeListener; +import com.jme3.gde.core.scene.SceneSyncListener; import com.jme3.gde.core.util.PropertyUtils; import java.beans.PropertyDescriptor; import java.io.IOException; @@ -52,7 +53,7 @@ import org.openide.util.Exceptions; * * @author normenhansen */ -public class AppStateNode extends AbstractNode implements ScenePropertyChangeListener { +public class AppStateNode extends AbstractNode implements ScenePropertyChangeListener, SceneSyncListener { protected AppState appState; protected AppStateManager parent; @@ -106,6 +107,18 @@ public class AppStateNode extends AbstractNode implements ScenePropertyChangeLis //// return Actions.alwaysEnabled(new EnableFiterAction(this), "Toggle enabled", "", false); // return null; // } + public void syncSceneData(float tpf) { + //TODO: precache structure to avoid locks? Do it backwards, sending the actual bean value? + for (PropertySet propertySet : getPropertySets()) { + for (Property property : propertySet.getProperties()) { + if (property instanceof SceneExplorerProperty) { + SceneExplorerProperty prop = (SceneExplorerProperty) property; + prop.syncValue(); + } + } + } + } + @Override public boolean canDestroy() { return true; diff --git a/sdk/jme3-core/src/com/jme3/gde/core/scene/NodeSyncAppState.java b/sdk/jme3-core/src/com/jme3/gde/core/scene/NodeSyncAppState.java index 8200409bf..9ce81dfa9 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/scene/NodeSyncAppState.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/scene/NodeSyncAppState.java @@ -34,7 +34,6 @@ package com.jme3.gde.core.scene; import com.jme3.app.Application; import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AppStateManager; -import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode; import java.util.Collection; import java.util.Collections; import java.util.Iterator; @@ -51,15 +50,15 @@ import org.openide.util.Utilities; */ public class NodeSyncAppState extends AbstractAppState implements LookupListener { - private final List newNodes = Collections.synchronizedList(new LinkedList()); - private final List oldNodes = Collections.synchronizedList(new LinkedList()); - private final Result nodeSelectionResult; - private AbstractSceneExplorerNode node; + private final List newNodes = Collections.synchronizedList(new LinkedList()); + private final List oldNodes = Collections.synchronizedList(new LinkedList()); + private final Result nodeSelectionResult; + private SceneSyncListener node; private float timeStep = 1; private float timer = 0; public NodeSyncAppState() { - nodeSelectionResult = Utilities.actionsGlobalContext().lookupResult(AbstractSceneExplorerNode.class); + nodeSelectionResult = Utilities.actionsGlobalContext().lookupResult(SceneSyncListener.class); } @Override @@ -72,24 +71,24 @@ public class NodeSyncAppState extends AbstractAppState implements LookupListener public void update(float tpf) { super.update(tpf); synchronized (newNodes) { - for (Iterator it = newNodes.iterator(); it.hasNext();) { - AbstractSceneExplorerNode abstractSceneExplorerNode = it.next(); - abstractSceneExplorerNode.syncSceneData(); + for (Iterator it = newNodes.iterator(); it.hasNext();) { + SceneSyncListener abstractSceneExplorerNode = it.next(); + abstractSceneExplorerNode.syncSceneData(0); it.remove(); } } timer += tpf; if (timer > timeStep) { timer = 0; - AbstractSceneExplorerNode node = this.node; + SceneSyncListener node = this.node; if (initialized && node != null) { - node.syncSceneData(); + node.syncSceneData(tpf); } } synchronized (oldNodes) { - for (Iterator it = oldNodes.iterator(); it.hasNext();) { - AbstractSceneExplorerNode abstractSceneExplorerNode = it.next(); - abstractSceneExplorerNode.syncSceneData(); + for (Iterator it = oldNodes.iterator(); it.hasNext();) { + SceneSyncListener abstractSceneExplorerNode = it.next(); + abstractSceneExplorerNode.syncSceneData(0); it.remove(); } } @@ -97,16 +96,16 @@ public class NodeSyncAppState extends AbstractAppState implements LookupListener public void resultChanged(LookupEvent ev) { Collection collection = nodeSelectionResult.allInstances(); - AbstractSceneExplorerNode newNode = null; + SceneSyncListener newNode = null; for (Iterator it = collection.iterator(); it.hasNext();) { Object object = it.next(); - if (object instanceof AbstractSceneExplorerNode) { + if (object instanceof SceneSyncListener) { if (object != null) { synchronized (newNodes) { - newNodes.add((AbstractSceneExplorerNode) object); + newNodes.add((SceneSyncListener) object); } } - newNode = (AbstractSceneExplorerNode) object; + newNode = (SceneSyncListener) object; } } if (node != null) { diff --git a/sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java b/sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java index 65bb4e6d8..823a17b24 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java @@ -389,7 +389,12 @@ public class SceneApplication extends Application implements LookupProvider { } //TODO: handle this differently (no opened file) if (request.getRootNode() == null && request.getJmeNode() == null) { - request.setJmeNode(NodeUtility.createNode(rootNode, false)); + DataObject dobj = request.getDataObject(); + if (dobj != null) { + request.setJmeNode(NodeUtility.createNode(rootNode, dobj)); + } else { + request.setJmeNode(NodeUtility.createNode(rootNode, false)); + } } setHelpContext(request.getHelpCtx()); setWindowTitle(request.getWindowTitle()); diff --git a/sdk/jme3-core/src/com/jme3/gde/core/scene/SceneSyncListener.java b/sdk/jme3-core/src/com/jme3/gde/core/scene/SceneSyncListener.java new file mode 100644 index 000000000..fb3093612 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/scene/SceneSyncListener.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2003-2012 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.gde.core.scene; + +/** + * + * @author normenhansen + */ +public interface SceneSyncListener { + public void syncSceneData(float tpf); + +} diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/AbstractSceneExplorerNode.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/AbstractSceneExplorerNode.java index 649b4f63c..b79e94674 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/AbstractSceneExplorerNode.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/AbstractSceneExplorerNode.java @@ -33,6 +33,7 @@ package com.jme3.gde.core.sceneexplorer.nodes; import com.jme3.gde.core.properties.SceneExplorerProperty; import com.jme3.gde.core.properties.ScenePropertyChangeListener; +import com.jme3.gde.core.scene.SceneSyncListener; import com.jme3.gde.core.util.DynamicLookup; import com.jme3.gde.core.util.PropertyUtils; import java.beans.PropertyDescriptor; @@ -55,7 +56,7 @@ import org.openide.util.lookup.ProxyLookup; * @author normenhansen */ @SuppressWarnings("unchecked") -public abstract class AbstractSceneExplorerNode extends AbstractNode implements SceneExplorerNode, ScenePropertyChangeListener { +public abstract class AbstractSceneExplorerNode extends AbstractNode implements SceneExplorerNode, ScenePropertyChangeListener, SceneSyncListener { protected Children jmeChildren; protected final InstanceContent lookupContents; @@ -200,7 +201,7 @@ public abstract class AbstractSceneExplorerNode extends AbstractNode implements return Sheet.createDefault(); } - public void syncSceneData() { + public void syncSceneData(float tpf) { //TODO: precache structure to avoid locks? Do it backwards, sending the actual bean value? for (PropertySet propertySet : getPropertySets()) { for (Property property : propertySet.getProperties()) {