|
|
|
@ -37,6 +37,7 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc |
|
|
|
|
/** path to the icon used by the component and its open action */ |
|
|
|
|
static final String ICON_PATH = "com/jme3/gde/vehiclecreator/objects_039.gif"; |
|
|
|
|
private static final String PREFERRED_ID = "VehicleCreatorTopComponent"; |
|
|
|
|
private VehicleEditorController newEditorController; |
|
|
|
|
private VehicleEditorController editorController; |
|
|
|
|
private SceneRequest currentRequest; |
|
|
|
|
private SceneRequest sentRequest; |
|
|
|
@ -806,7 +807,7 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc |
|
|
|
|
protected void componentActivated() { |
|
|
|
|
SceneViewerTopComponent.findInstance().requestVisible(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void writeProperties(java.util.Properties p) { |
|
|
|
|
// better to version settings since initial version as advocated at
|
|
|
|
|
// http://wiki.apidesign.org/wiki/PropertyFiles
|
|
|
|
@ -837,7 +838,6 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc |
|
|
|
|
return ctx; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SuspensionSettings getSuspensionSettings() { |
|
|
|
|
SuspensionSettings settings = new SuspensionSettings(); |
|
|
|
|
settings.setFriction((Float) frictionSpinner.getValue()); |
|
|
|
@ -869,12 +869,12 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc |
|
|
|
|
|
|
|
|
|
public void openFile(BinaryModelDataObject file, Node spatial) { |
|
|
|
|
JmeNode node = NodeUtility.createNode(spatial, false); |
|
|
|
|
editorController = new VehicleEditorController(node, file); |
|
|
|
|
newEditorController = new VehicleEditorController(node, file); |
|
|
|
|
SceneApplication.getApplication().addSceneListener(this); |
|
|
|
|
sentRequest = new SceneRequest(this, node, file.getLookup().lookup(ProjectAssetManager.class)); |
|
|
|
|
sentRequest.setWindowTitle("Vehicle Creator"); |
|
|
|
|
sentRequest.setDataObject(file); |
|
|
|
|
sentRequest.setToolNode(editorController.getToolsNode()); |
|
|
|
|
sentRequest.setToolNode(newEditorController.getToolsNode()); |
|
|
|
|
sentRequest.setHelpCtx(ctx); |
|
|
|
|
SceneApplication.getApplication().openScene(sentRequest); |
|
|
|
|
} |
|
|
|
@ -883,53 +883,55 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void sceneClosed(SceneRequest request) { |
|
|
|
|
if (request == sentRequest) { |
|
|
|
|
currentRequest = request; |
|
|
|
|
if (request == currentRequest) { |
|
|
|
|
SceneApplication.getApplication().removeSceneListener(this); |
|
|
|
|
editorController.cleanupApplication(); |
|
|
|
|
setLoadedScene(null, false); |
|
|
|
|
final SceneRequest current= currentRequest; |
|
|
|
|
final SceneRequest current = currentRequest; |
|
|
|
|
currentRequest = null; |
|
|
|
|
final VehicleEditorController controller = editorController; |
|
|
|
|
setLoadedScene(null, false); |
|
|
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() { |
|
|
|
|
|
|
|
|
|
public Void call() throws Exception { |
|
|
|
|
current.getRootNode().getParent().removeLight(dirLight); |
|
|
|
|
SceneApplication.getApplication().getStateManager().detach(editorController.getBulletState()); |
|
|
|
|
controller.cleanupApplication(); |
|
|
|
|
// current.getRootNode().removeLight(dirLight);
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void sceneOpened(SceneRequest request) { |
|
|
|
|
if (request == currentRequest) { |
|
|
|
|
editorController.prepareApplication(); |
|
|
|
|
SceneApplication.getApplication().getStateManager().attach(editorController.getBulletState()); |
|
|
|
|
setLoadedScene(currentRequest.getJmeNode(), true); |
|
|
|
|
currentRequest.getRootNode().getParent().addLight(dirLight); |
|
|
|
|
public void sceneOpened(final SceneRequest request) { |
|
|
|
|
if (request == sentRequest) { |
|
|
|
|
currentRequest = request; |
|
|
|
|
editorController = newEditorController; |
|
|
|
|
setLoadedScene(currentRequest.getDataObject().getNodeDelegate(), true); |
|
|
|
|
final VehicleEditorController controller = editorController; |
|
|
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() { |
|
|
|
|
|
|
|
|
|
public Void call() throws Exception { |
|
|
|
|
controller.prepareApplication(); |
|
|
|
|
// request.getRootNode().addLight(dirLight);
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setLoadedScene(final org.openide.nodes.Node jmeNode, final boolean active) { |
|
|
|
|
java.awt.EventQueue.invokeLater(new Runnable() { |
|
|
|
|
|
|
|
|
|
public void run() { |
|
|
|
|
if (!active) { |
|
|
|
|
close(); |
|
|
|
|
setActivatedNodes(new org.openide.nodes.Node[]{}); |
|
|
|
|
if (editorController != null) { |
|
|
|
|
editorController.cleanup(); |
|
|
|
|
editorController = null; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (!isOpened()) { |
|
|
|
|
open(); |
|
|
|
|
} |
|
|
|
|
requestActive(); |
|
|
|
|
// setActivatedNodes(new org.openide.nodes.Node[]{jmeNode});
|
|
|
|
|
editorController.checkVehicle(); |
|
|
|
|
} |
|
|
|
|
if (!active) { |
|
|
|
|
close(); |
|
|
|
|
setActivatedNodes(new org.openide.nodes.Node[]{}); |
|
|
|
|
if (editorController != null) { |
|
|
|
|
editorController.cleanup(); |
|
|
|
|
editorController = null; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
if (!isOpened()) { |
|
|
|
|
open(); |
|
|
|
|
} |
|
|
|
|
requestActive(); |
|
|
|
|
setActivatedNodes(new org.openide.nodes.Node[]{jmeNode}); |
|
|
|
|
editorController.checkVehicle(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|