- more threading fixes in Scene(Composer)ToolController
- change order of calls in Application (first SceneApplication sets up your SceneRequest, then plugin sceneOpened is called, for sceneClosed the scene is destructed after the call)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8627 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent b90d093ef0
commit b43b9efe18
  1. 94
      sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java
  2. 9
      sdk/jme3-core/src/com/jme3/gde/core/scene/controller/SceneToolController.java
  3. 20
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerToolController.java
  4. 25
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java
  5. 4
      sdk/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorTopComponent.java

@ -209,7 +209,7 @@ public class SceneApplication extends Application implements LookupProvider {
guiViewPort.setClearFlags(false, false, false);
}
getProgressHandle().progress("Setup Camera Controller", 2);
//create camera controler
//create camera controller
camController = new SceneCameraController(cam, inputManager);
//create preview view
getProgressHandle().progress("Setup Preview Scene", 3);
@ -305,10 +305,10 @@ public class SceneApplication extends Application implements LookupProvider {
listeners.remove(listener);
}
private void notifyOpen() {
private void notifyOpen(final SceneRequest opened) {
for (Iterator<SceneListener> it = listeners.iterator(); it.hasNext();) {
SceneListener sceneViewerListener = it.next();
sceneViewerListener.sceneOpened(currentSceneRequest);
sceneViewerListener.sceneOpened(opened);
}
}
@ -337,13 +337,16 @@ public class SceneApplication extends Application implements LookupProvider {
/**
* method to display the node tree of a plugin (threadsafe)
* @param tree
* @param request
*/
public void openScene(final SceneRequest request) {
closeScene(currentSceneRequest);
closeScene(currentSceneRequest, request);
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
if (request == null) {
return;
}
currentSceneRequest = request;
if (request.getDataObject() != null) {
setCurrentFileNode(request.getDataObject().getNodeDelegate());
@ -352,7 +355,6 @@ public class SceneApplication extends Application implements LookupProvider {
}
setHelpContext(request.getHelpCtx());
setWindowTitle(request.getWindowTitle());
notifyOpen();
enqueue(new Callable() {
public Object call() throws Exception {
@ -373,62 +375,68 @@ public class SceneApplication extends Application implements LookupProvider {
if (request.getToolNode() != null) {
toolsNode.attachChild(request.getToolNode());
}
getCurrentSceneRequest().setDisplayed(true);
request.setDisplayed(true);
return null;
}
});
notifyOpen(request);
}
});
}
/**
* method to close a scene displayed by a scene request (threadsafe)
* @param tree
* @param request
*/
public void closeScene(final SceneRequest request) {
if (request != null) {
java.awt.EventQueue.invokeLater(new Runnable() {
closeScene(request, null);
}
public void run() {
checkSave();
setCurrentFileNode(null);
setWindowTitle("OpenGL Window");
setHelpContext(null);
private void closeScene(final SceneRequest oldRequest, final SceneRequest newRequest) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
if (oldRequest == null) {
return;
}
if (newRequest == null || newRequest.getRootNode() != oldRequest.getRootNode()) {
checkSave(oldRequest);
SceneUndoRedoManager manager = Lookup.getDefault().lookup(SceneUndoRedoManager.class);
if (manager != null) {
manager.discardAllEdits();
}
final SceneRequest currentRequest = currentSceneRequest;
currentSceneRequest = null;
notifyClose(request);
enqueue(new Callable() {
public Object call() throws Exception {
if (request.getRequester() instanceof SceneApplication) {
camController.disable();
}
if (physicsState != null) {
physicsState.getPhysicsSpace().removeAll(rootNode);
getStateManager().detach(physicsState);
physicsState = null;
}
toolsNode.detachAllChildren();
rootNode.detachAllChildren();
// resetCam();
lastError = "";
currentRequest.setDisplayed(false);
return null;
}
});
}
});
}
setCurrentFileNode(null);
setWindowTitle("OpenGL Window");
setHelpContext(null);
notifyClose(oldRequest);
enqueue(new Callable() {
public Object call() throws Exception {
if (oldRequest.getRequester() instanceof SceneApplication) {
camController.disable();
}
if (physicsState != null) {
physicsState.getPhysicsSpace().removeAll(rootNode);
getStateManager().detach(physicsState);
physicsState = null;
}
toolsNode.detachAllChildren();
rootNode.detachAllChildren();
// resetCam();
lastError = "";
oldRequest.setDisplayed(false);
return null;
}
});
}
});
}
private void checkSave() {
if ((currentSceneRequest != null)
&& currentSceneRequest.getDataObject().isModified()) {
final DataObject req = currentSceneRequest.getDataObject();
private void checkSave(SceneRequest request) {
if ((request != null)
&& request.getDataObject().isModified()) {
final DataObject req = request.getDataObject();
Confirmation mesg = new NotifyDescriptor.Confirmation("Scene has not been saved,\ndo you want to save it?",
"Not Saved",
NotifyDescriptor.YES_NO_OPTION);

@ -278,8 +278,15 @@ public class SceneToolController implements AppState {
protected void detachSelectionShape() {
if (selectionShape != null) {
selectionShape.removeFromParent();
final Spatial shape = selectionShape;
selectionShape = null;
SceneApplication.getApplication().enqueue(new Callable<Void>() {
public Void call() throws Exception {
shape.removeFromParent();
return null;
}
});
}
}

@ -66,18 +66,28 @@ public class SceneComposerToolController extends SceneToolController {
// a node in a viewport that will always render on top
onTopToolsNode = new Node("OverlayNode");
overlayView = SceneApplication.getApplication().getOverlayView();
// overlayView.setClearFlags(false, true, false);
overlayView.attachScene(onTopToolsNode);
SceneApplication.getApplication().enqueue(new Callable<Void>() {
public Void call() throws Exception {
overlayView.attachScene(onTopToolsNode);
return null;
}
});
}
@Override
public void cleanup() {
super.cleanup();
//SceneApplication.getApplication().getRenderManager().removeMainView(overlayView);
overlayView.detachScene(onTopToolsNode);
cameraController = null;
editorController = null;
onTopToolsNode.detachAllChildren();
SceneApplication.getApplication().enqueue(new Callable<Void>() {
public Void call() throws Exception {
overlayView.detachScene(onTopToolsNode);
onTopToolsNode.detachAllChildren();
return null;
}
});
}
@Override

@ -788,10 +788,6 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
SceneRequest request = new SceneRequest(this, jmeNode, manager);
request.setDataObject(file);
request.setHelpCtx(ctx);
if (editorController != null) {
editorController.cleanup();
}
editorController = new SceneEditorController(jmeNode, file);
this.sentRequest = request;
request.setWindowTitle("SceneComposer - " + manager.getRelativeAssetPath(file.getPrimaryFile().getPath()));
request.setToolNode(new Node("SceneComposerToolNode"));
@ -845,22 +841,17 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
}
private void selectSpatial(JmeSpatial spatial) {
if (editorController != null) {
editorController.setSelectedSpat(spatial);
}
if (spatial == null) {
setSelectedObjectText(null);
if (editorController != null) {
editorController.setSelectedSpat(spatial);
}
return;
} else {
if (toolController != null) {
toolController.updateSelection(spatial.getLookup().lookup(Spatial.class));
}
}
if (editorController == null) {
return;
}
editorController.setSelectedSpat(spatial);
if (spatial.getLookup().lookup(Node.class) != null) {
setSelectedObjectText(spatial.getLookup().lookup(Node.class).getName());
} else if (spatial.getLookup().lookup(Spatial.class) != null) {
@ -892,15 +883,19 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
public void sceneOpened(SceneRequest request) {
if (request.equals(sentRequest)) {
currentRequest = request;
setActivatedNodes(new org.openide.nodes.Node[]{currentRequest.getDataObject().getNodeDelegate()});
setSceneInfo(currentRequest.getJmeNode(), editorController.getCurrentFileObject(), true);
if (editorController != null) {
editorController.cleanup();
}
editorController = new SceneEditorController(request.getJmeNode(), request.getDataObject());
setActivatedNodes(new org.openide.nodes.Node[]{request.getDataObject().getNodeDelegate()});
setSceneInfo(request.getJmeNode(), editorController.getCurrentFileObject(), true);
if (camController != null) {
camController.disable();
}
if (toolController != null) {
toolController.cleanup();
}
toolController = new SceneComposerToolController(currentRequest.getToolNode(), currentRequest.getManager(), request.getJmeNode());
toolController = new SceneComposerToolController(request.getToolNode(), request.getManager(), request.getJmeNode());
camController = new ComposerCameraController(SceneApplication.getApplication().getCamera(), request.getJmeNode());
toolController.setEditorController(editorController);

@ -893,7 +893,7 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
public Void call() throws Exception {
controller.cleanupApplication();
// current.getRootNode().removeLight(dirLight);
current.getRootNode().getParent().removeLight(dirLight);
return null;
}
});
@ -910,7 +910,7 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
public Void call() throws Exception {
controller.prepareApplication();
// request.getRootNode().addLight(dirLight);
request.getRootNode().getParent().addLight(dirLight);
return null;
}
});

Loading…
Cancel
Save