- Make scene sync listening generic
- Fix AppStateExplorer updates

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10116 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent 8fef000fe9
commit 12132aac65
  1. 5
      sdk/jme3-core/src/com/jme3/gde/core/appstates/AppStateExplorerTopComponent.java
  2. 15
      sdk/jme3-core/src/com/jme3/gde/core/appstates/AppStateNode.java
  3. 35
      sdk/jme3-core/src/com/jme3/gde/core/scene/NodeSyncAppState.java
  4. 7
      sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java
  5. 41
      sdk/jme3-core/src/com/jme3/gde/core/scene/SceneSyncListener.java
  6. 5
      sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/AbstractSceneExplorerNode.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());

@ -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;

@ -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<AbstractSceneExplorerNode> newNodes = Collections.synchronizedList(new LinkedList<AbstractSceneExplorerNode>());
private final List<AbstractSceneExplorerNode> oldNodes = Collections.synchronizedList(new LinkedList<AbstractSceneExplorerNode>());
private final Result<AbstractSceneExplorerNode> nodeSelectionResult;
private AbstractSceneExplorerNode node;
private final List<SceneSyncListener> newNodes = Collections.synchronizedList(new LinkedList<SceneSyncListener>());
private final List<SceneSyncListener> oldNodes = Collections.synchronizedList(new LinkedList<SceneSyncListener>());
private final Result<SceneSyncListener> 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<AbstractSceneExplorerNode> it = newNodes.iterator(); it.hasNext();) {
AbstractSceneExplorerNode abstractSceneExplorerNode = it.next();
abstractSceneExplorerNode.syncSceneData();
for (Iterator<SceneSyncListener> 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<AbstractSceneExplorerNode> it = oldNodes.iterator(); it.hasNext();) {
AbstractSceneExplorerNode abstractSceneExplorerNode = it.next();
abstractSceneExplorerNode.syncSceneData();
for (Iterator<SceneSyncListener> 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) {

@ -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());

@ -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);
}

@ -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()) {

Loading…
Cancel
Save