- Warn user when no Node is selected when trying to add something to the SceneComposer

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8380 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 14 years ago
parent ca27cb1b1a
commit d174cb28cd
  1. 11
      sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/AddAssetAction.java
  2. 13
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java
  3. 203
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java

@ -17,8 +17,8 @@ import javax.swing.Action;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import com.jme3.gde.scenecomposer.SceneComposerTopComponent; import com.jme3.gde.scenecomposer.SceneComposerTopComponent;
import java.util.ArrayList; import org.openide.DialogDisplayer;
import java.util.List; import org.openide.NotifyDescriptor;
public final class AddAssetAction implements Action { public final class AddAssetAction implements Action {
@ -30,10 +30,15 @@ public final class AddAssetAction implements Action {
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
ProjectAssetManager pm = context.getLookup().lookup(ProjectAssetManager.class); ProjectAssetManager pm = context.getLookup().lookup(ProjectAssetManager.class);
ProjectAssetManager scenePm = SceneApplication.getApplication().getCurrentSceneRequest().getManager();
if (pm == null) { if (pm == null) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "AssetManager not found!"); Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "AssetManager not found!");
return; return;
} }
if (scenePm == null) {
DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message("No scene opened!"));
return;
}
Element assetElement = context.getLookup().lookup(Element.class); Element assetElement = context.getLookup().lookup(Element.class);
String type = assetElement.getAttribute("type"); String type = assetElement.getAttribute("type");
if ("model".equals(type) || "scene".equals(type)) { if ("model".equals(type) || "scene".equals(type)) {
@ -41,7 +46,7 @@ public final class AddAssetAction implements Action {
Spatial model = AssetPackLoader.loadAssetPackModel(pm, conf); Spatial model = AssetPackLoader.loadAssetPackModel(pm, conf);
if (model != null) { if (model != null) {
SceneComposerTopComponent.findInstance().addModel(model); SceneComposerTopComponent.findInstance().addModel(model);
AssetPackLoader.addModelFiles(pm, SceneApplication.getApplication().getCurrentSceneRequest().getManager(),conf); AssetPackLoader.addModelFiles(pm, scenePm,conf);
} else { } else {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Error loading model"); Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Error loading model");
} }

@ -38,6 +38,7 @@ import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.DialogDisplayer; import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor; import org.openide.NotifyDescriptor;
import org.openide.NotifyDescriptor.Confirmation; import org.openide.NotifyDescriptor.Confirmation;
import org.openide.NotifyDescriptor.Message;
import org.openide.awt.Toolbar; import org.openide.awt.Toolbar;
import org.openide.awt.ToolbarPool; import org.openide.awt.ToolbarPool;
import org.openide.awt.UndoRedo; import org.openide.awt.UndoRedo;
@ -761,24 +762,32 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
public void addModel(Spatial model) { public void addModel(Spatial model) {
if (editorController != null) { if (editorController != null) {
editorController.addModel(model, toolController.getCursorLocation()); editorController.addModel(model, toolController.getCursorLocation());
} else {
displayInfo("No scene opened!");
} }
} }
public void addModel(SpatialAssetDataObject model) { public void addModel(SpatialAssetDataObject model) {
if (editorController != null) { if (editorController != null) {
editorController.addModel(model, toolController.getCursorLocation()); editorController.addModel(model, toolController.getCursorLocation());
} else {
displayInfo("No scene opened!");
} }
} }
public void linkModel(AssetManager manager, String assetName) { public void linkModel(AssetManager manager, String assetName) {
if (editorController != null) { if (editorController != null) {
editorController.linkModel(manager, assetName, toolController.getCursorLocation()); editorController.linkModel(manager, assetName, toolController.getCursorLocation());
} else {
displayInfo("No scene opened!");
} }
} }
public void doMoveCursor(Vector3f vector) { public void doMoveCursor(Vector3f vector) {
if (toolController != null) { if (toolController != null) {
toolController.doSetCursorLocation(vector); toolController.doSetCursorLocation(vector);
} else {
displayInfo("No scene opened!");
} }
} }
@ -929,5 +938,9 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
public void previewRequested(PreviewRequest request) { public void previewRequested(PreviewRequest request) {
} }
public void displayInfo(String info) {
Message msg = new NotifyDescriptor.Message(info);
DialogDisplayer.getDefault().notifyLater(msg);
}
} }

@ -42,6 +42,7 @@ import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.DialogDisplayer; import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor; import org.openide.NotifyDescriptor;
import org.openide.NotifyDescriptor.Confirmation; import org.openide.NotifyDescriptor.Confirmation;
import org.openide.NotifyDescriptor.Message;
import org.openide.cookies.SaveCookie; import org.openide.cookies.SaveCookie;
import org.openide.filesystems.FileObject; import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject; import org.openide.loaders.DataObject;
@ -58,30 +59,30 @@ import org.openide.util.Lookup;
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class SceneEditorController implements PropertyChangeListener, NodeListener { public class SceneEditorController implements PropertyChangeListener, NodeListener {
private JmeSpatial jmeRootNode; private JmeSpatial jmeRootNode;
private JmeSpatial selectedSpat; private JmeSpatial selectedSpat;
private DataObject currentFileObject; private DataObject currentFileObject;
// private boolean needSave = false; // private boolean needSave = false;
private SceneComposerToolController toolController; private SceneComposerToolController toolController;
public SceneEditorController(JmeSpatial jmeRootNode, DataObject currentFileObject) { public SceneEditorController(JmeSpatial jmeRootNode, DataObject currentFileObject) {
this.jmeRootNode = jmeRootNode; this.jmeRootNode = jmeRootNode;
this.currentFileObject = currentFileObject; this.currentFileObject = currentFileObject;
} }
public void setToolController(SceneComposerToolController toolController) { public void setToolController(SceneComposerToolController toolController) {
this.toolController = toolController; this.toolController = toolController;
} }
public JmeSpatial getJmeRootNode() { public JmeSpatial getJmeRootNode() {
return jmeRootNode; return jmeRootNode;
} }
public JmeSpatial getSelectedSpat() { public JmeSpatial getSelectedSpat() {
return selectedSpat; return selectedSpat;
} }
public void setSelectedSpat(JmeSpatial selectedSpat) { public void setSelectedSpat(JmeSpatial selectedSpat) {
if (this.selectedSpat == selectedSpat) { if (this.selectedSpat == selectedSpat) {
return; return;
@ -96,39 +97,39 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
selectedSpat.addNodeListener(this);//WeakListeners.propertyChange(this, selectedSpat)); selectedSpat.addNodeListener(this);//WeakListeners.propertyChange(this, selectedSpat));
} }
} }
public FileObject getCurrentFileObject() { public FileObject getCurrentFileObject() {
return currentFileObject.getPrimaryFile(); return currentFileObject.getPrimaryFile();
} }
public DataObject getCurrentDataObject() { public DataObject getCurrentDataObject() {
return currentFileObject; return currentFileObject;
} }
private void addSpatialUndo(final Node undoParent, final Spatial undoSpatial, final Light undoLight, final AbstractSceneExplorerNode parentNode) { private void addSpatialUndo(final Node undoParent, final Spatial undoSpatial, final Light undoLight, final AbstractSceneExplorerNode parentNode) {
//add undo //add undo
if (undoParent != null && undoSpatial != null) { if (undoParent != null && undoSpatial != null) {
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() { Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
@Override @Override
public void sceneUndo() throws CannotUndoException { public void sceneUndo() throws CannotUndoException {
//undo stuff here //undo stuff here
undoSpatial.removeFromParent(); undoSpatial.removeFromParent();
} }
@Override @Override
public void sceneRedo() throws CannotRedoException { public void sceneRedo() throws CannotRedoException {
//redo stuff here //redo stuff here
undoParent.attachChild(undoSpatial); undoParent.attachChild(undoSpatial);
} }
@Override @Override
public void awtRedo() { public void awtRedo() {
if (parentNode != null) { if (parentNode != null) {
parentNode.refresh(true); parentNode.refresh(true);
} }
} }
@Override @Override
public void awtUndo() { public void awtUndo() {
if (parentNode != null) { if (parentNode != null) {
@ -139,28 +140,28 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
} }
if (undoParent != null && undoLight != null) { if (undoParent != null && undoLight != null) {
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() { Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
@Override @Override
public void sceneUndo() throws CannotUndoException { public void sceneUndo() throws CannotUndoException {
//undo stuff here //undo stuff here
undoParent.removeLight(undoLight); undoParent.removeLight(undoLight);
toolController.removeLightMarker(undoLight); toolController.removeLightMarker(undoLight);
} }
@Override @Override
public void sceneRedo() throws CannotRedoException { public void sceneRedo() throws CannotRedoException {
//redo stuff here //redo stuff here
undoParent.addLight(undoLight); undoParent.addLight(undoLight);
toolController.addLightMarker(undoLight); toolController.addLightMarker(undoLight);
} }
@Override @Override
public void awtRedo() { public void awtRedo() {
if (parentNode != null) { if (parentNode != null) {
parentNode.refresh(true); parentNode.refresh(true);
} }
} }
@Override @Override
public void awtUndo() { public void awtUndo() {
if (parentNode != null) { if (parentNode != null) {
@ -170,7 +171,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
}); });
} }
} }
public void moveSelectedSpatial(final Vector3f point) { public void moveSelectedSpatial(final Vector3f point) {
if (selectedSpat == null) { if (selectedSpat == null) {
return; return;
@ -180,11 +181,11 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
if (node != null) { if (node != null) {
setNeedsSave(true); setNeedsSave(true);
SceneApplication.getApplication().enqueue(new Callable() { SceneApplication.getApplication().enqueue(new Callable() {
public Object call() throws Exception { public Object call() throws Exception {
doMoveSpatial(node, point); doMoveSpatial(node, point);
return null; return null;
} }
}).get(); }).get();
} }
@ -194,7 +195,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
} }
} }
public void doMoveSpatial(Spatial selected, Vector3f translation) { public void doMoveSpatial(Spatial selected, Vector3f translation) {
Vector3f localTranslation = selected.getLocalTranslation(); Vector3f localTranslation = selected.getLocalTranslation();
Vector3f before = new Vector3f(localTranslation); Vector3f before = new Vector3f(localTranslation);
@ -212,17 +213,17 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
AbstractSceneExplorerNode selectedSpat = this.selectedSpat; AbstractSceneExplorerNode selectedSpat = this.selectedSpat;
moveUndo(selected, before, after, selectedSpat); moveUndo(selected, before, after, selectedSpat);
} }
private void moveUndo(final Spatial spatial, final Vector3f before, final Vector3f after, final AbstractSceneExplorerNode parentNode) { private void moveUndo(final Spatial spatial, final Vector3f before, final Vector3f after, final AbstractSceneExplorerNode parentNode) {
if (spatial != null && before != null) { if (spatial != null && before != null) {
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() { Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
@Override @Override
public void sceneUndo() throws CannotUndoException { public void sceneUndo() throws CannotUndoException {
//undo stuff here //undo stuff here
spatial.setLocalTranslation(before); spatial.setLocalTranslation(before);
} }
@Override @Override
public void sceneRedo() throws CannotRedoException { public void sceneRedo() throws CannotRedoException {
//redo stuff here //redo stuff here
@ -231,7 +232,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
}); });
} }
} }
public void nudgeSelectedSpatial(final Vector3f amount) { public void nudgeSelectedSpatial(final Vector3f amount) {
if (selectedSpat == null) { if (selectedSpat == null) {
return; return;
@ -241,11 +242,11 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
if (node != null) { if (node != null) {
setNeedsSave(true); setNeedsSave(true);
SceneApplication.getApplication().enqueue(new Callable() { SceneApplication.getApplication().enqueue(new Callable() {
public Object call() throws Exception { public Object call() throws Exception {
doNudgeSpatial(node, amount); doNudgeSpatial(node, amount);
return null; return null;
} }
}).get(); }).get();
} }
@ -255,24 +256,24 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
} }
} }
public void doNudgeSpatial(Spatial selected, Vector3f translation) { public void doNudgeSpatial(Spatial selected, Vector3f translation) {
Vector3f before = new Vector3f(selected.getLocalTranslation()); Vector3f before = new Vector3f(selected.getLocalTranslation());
selected.setLocalTranslation(before.add(translation)); selected.setLocalTranslation(before.add(translation));
Vector3f after = new Vector3f(selected.getLocalTranslation()); Vector3f after = new Vector3f(selected.getLocalTranslation());
nudgeUndo(selected, before, after, selectedSpat); nudgeUndo(selected, before, after, selectedSpat);
} }
private void nudgeUndo(final Spatial spatial, final Vector3f before, final Vector3f after, final AbstractSceneExplorerNode parentNode) { private void nudgeUndo(final Spatial spatial, final Vector3f before, final Vector3f after, final AbstractSceneExplorerNode parentNode) {
if (spatial != null && before != null) { if (spatial != null && before != null) {
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() { Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
@Override @Override
public void sceneUndo() throws CannotUndoException { public void sceneUndo() throws CannotUndoException {
//undo stuff here //undo stuff here
spatial.setLocalTranslation(before); spatial.setLocalTranslation(before);
} }
@Override @Override
public void sceneRedo() throws CannotRedoException { public void sceneRedo() throws CannotRedoException {
//redo stuff here //redo stuff here
@ -281,7 +282,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
}); });
} }
} }
public void rotateSelectedSpatial(final Quaternion amount) { public void rotateSelectedSpatial(final Quaternion amount) {
if (selectedSpat == null) { if (selectedSpat == null) {
return; return;
@ -291,11 +292,11 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
if (node != null) { if (node != null) {
setNeedsSave(true); setNeedsSave(true);
SceneApplication.getApplication().enqueue(new Callable() { SceneApplication.getApplication().enqueue(new Callable() {
public Object call() throws Exception { public Object call() throws Exception {
doRotateSpatial(node, amount); doRotateSpatial(node, amount);
return null; return null;
} }
}).get(); }).get();
} }
@ -305,24 +306,24 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
} }
} }
public void doRotateSpatial(Spatial selected, Quaternion rotation) { public void doRotateSpatial(Spatial selected, Quaternion rotation) {
Quaternion before = new Quaternion(selected.getLocalRotation()); Quaternion before = new Quaternion(selected.getLocalRotation());
selected.rotate(rotation); selected.rotate(rotation);
Quaternion after = new Quaternion(selected.getLocalRotation()); Quaternion after = new Quaternion(selected.getLocalRotation());
rotateUndo(selected, before, after, selectedSpat); rotateUndo(selected, before, after, selectedSpat);
} }
private void rotateUndo(final Spatial spatial, final Quaternion before, final Quaternion after, final AbstractSceneExplorerNode parentNode) { private void rotateUndo(final Spatial spatial, final Quaternion before, final Quaternion after, final AbstractSceneExplorerNode parentNode) {
if (spatial != null && before != null) { if (spatial != null && before != null) {
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() { Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
@Override @Override
public void sceneUndo() throws CannotUndoException { public void sceneUndo() throws CannotUndoException {
//undo stuff here //undo stuff here
spatial.setLocalRotation(before); spatial.setLocalRotation(before);
} }
@Override @Override
public void sceneRedo() throws CannotRedoException { public void sceneRedo() throws CannotRedoException {
//redo stuff here //redo stuff here
@ -331,7 +332,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
}); });
} }
} }
public void createTangentsForSelectedSpatial() { public void createTangentsForSelectedSpatial() {
if (selectedSpat == null) { if (selectedSpat == null) {
return; return;
@ -341,11 +342,11 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
if (node != null) { if (node != null) {
setNeedsSave(true); setNeedsSave(true);
SceneApplication.getApplication().enqueue(new Callable() { SceneApplication.getApplication().enqueue(new Callable() {
public Object call() throws Exception { public Object call() throws Exception {
doCreateTangents(node); doCreateTangents(node);
return null; return null;
} }
}).get(); }).get();
} }
@ -355,7 +356,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
} }
} }
public void doCreateTangents(Spatial selected) { public void doCreateTangents(Spatial selected) {
if (selected instanceof Geometry) { if (selected instanceof Geometry) {
Geometry geom = (Geometry) selected; Geometry geom = (Geometry) selected;
@ -366,16 +367,16 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
} }
} }
} }
private void createTrangentsUndo(final Mesh mesh) { private void createTrangentsUndo(final Mesh mesh) {
if (mesh != null) { if (mesh != null) {
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() { Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
@Override @Override
public void sceneUndo() throws CannotUndoException { public void sceneUndo() throws CannotUndoException {
mesh.clearBuffer(Type.Tangent); mesh.clearBuffer(Type.Tangent);
} }
@Override @Override
public void sceneRedo() throws CannotRedoException { public void sceneRedo() throws CannotRedoException {
TangentBinormalGenerator.generate(mesh); TangentBinormalGenerator.generate(mesh);
@ -383,7 +384,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
}); });
} }
} }
public void createPhysicsMeshForSelectedSpatial() { public void createPhysicsMeshForSelectedSpatial() {
if (selectedSpat == null) { if (selectedSpat == null) {
return; return;
@ -393,11 +394,11 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
setNeedsSave(true); setNeedsSave(true);
if (node != null) { if (node != null) {
SceneApplication.getApplication().enqueue(new Callable() { SceneApplication.getApplication().enqueue(new Callable() {
public Object call() throws Exception { public Object call() throws Exception {
doCreatePhysicsMesh(node); doCreatePhysicsMesh(node);
return null; return null;
} }
}).get(); }).get();
} }
@ -407,7 +408,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
} }
} }
public void doCreatePhysicsMesh(Spatial selected) { public void doCreatePhysicsMesh(Spatial selected) {
RigidBodyControl control = selected.getControl(RigidBodyControl.class); RigidBodyControl control = selected.getControl(RigidBodyControl.class);
if (control != null) { if (control != null) {
@ -424,7 +425,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
AbstractSceneExplorerNode selectedSpat = this.selectedSpat; AbstractSceneExplorerNode selectedSpat = this.selectedSpat;
addControlUndo(parent, control, selectedSpat); addControlUndo(parent, control, selectedSpat);
} }
public void createDynamicPhysicsMeshForSelectedSpatial(final float weight) { public void createDynamicPhysicsMeshForSelectedSpatial(final float weight) {
if (selectedSpat == null) { if (selectedSpat == null) {
return; return;
@ -434,11 +435,11 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
setNeedsSave(true); setNeedsSave(true);
if (node != null) { if (node != null) {
SceneApplication.getApplication().enqueue(new Callable() { SceneApplication.getApplication().enqueue(new Callable() {
public Object call() throws Exception { public Object call() throws Exception {
doCreateDynamicPhysicsMesh(node, weight); doCreateDynamicPhysicsMesh(node, weight);
return null; return null;
} }
}).get(); }).get();
} }
@ -448,7 +449,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
} }
} }
public void doCreateDynamicPhysicsMesh(Spatial selected, float weight) { public void doCreateDynamicPhysicsMesh(Spatial selected, float weight) {
RigidBodyControl control = selected.getControl(RigidBodyControl.class); RigidBodyControl control = selected.getControl(RigidBodyControl.class);
if (control != null) { if (control != null) {
@ -465,7 +466,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
AbstractSceneExplorerNode selectedSpat = this.selectedSpat; AbstractSceneExplorerNode selectedSpat = this.selectedSpat;
addControlUndo(parent, control, selectedSpat); addControlUndo(parent, control, selectedSpat);
} }
public void createCharacterControlForSelectedSpatial(final boolean auto, final float radius, final float height) { public void createCharacterControlForSelectedSpatial(final boolean auto, final float radius, final float height) {
if (selectedSpat == null) { if (selectedSpat == null) {
return; return;
@ -475,11 +476,11 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
setNeedsSave(true); setNeedsSave(true);
if (node != null) { if (node != null) {
SceneApplication.getApplication().enqueue(new Callable() { SceneApplication.getApplication().enqueue(new Callable() {
public Object call() throws Exception { public Object call() throws Exception {
doCreateCharacterControl(node, auto, radius, height); doCreateCharacterControl(node, auto, radius, height);
return null; return null;
} }
}).get(); }).get();
} }
@ -489,7 +490,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
} }
} }
public void doCreateCharacterControl(Spatial selected, boolean auto, float radius, float height) { public void doCreateCharacterControl(Spatial selected, boolean auto, float radius, float height) {
CharacterControl control = selected.getControl(CharacterControl.class); CharacterControl control = selected.getControl(CharacterControl.class);
if (control != null) { if (control != null) {
@ -511,30 +512,30 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
AbstractSceneExplorerNode selectedSpat = this.selectedSpat; AbstractSceneExplorerNode selectedSpat = this.selectedSpat;
addControlUndo(parent, control, selectedSpat); addControlUndo(parent, control, selectedSpat);
} }
private void addControlUndo(final Node undoParent, final Control undoControl, final AbstractSceneExplorerNode parentNode) { private void addControlUndo(final Node undoParent, final Control undoControl, final AbstractSceneExplorerNode parentNode) {
if (undoParent != null && undoControl != null) { if (undoParent != null && undoControl != null) {
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() { Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
@Override @Override
public void sceneUndo() throws CannotUndoException { public void sceneUndo() throws CannotUndoException {
//undo stuff here //undo stuff here
undoParent.removeControl(undoControl); undoParent.removeControl(undoControl);
} }
@Override @Override
public void sceneRedo() throws CannotRedoException { public void sceneRedo() throws CannotRedoException {
//redo stuff here //redo stuff here
undoParent.addControl(undoControl); undoParent.addControl(undoControl);
} }
@Override @Override
public void awtRedo() { public void awtRedo() {
if (parentNode != null) { if (parentNode != null) {
parentNode.refresh(true); parentNode.refresh(true);
} }
} }
@Override @Override
public void awtUndo() { public void awtUndo() {
if (parentNode != null) { if (parentNode != null) {
@ -544,7 +545,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
}); });
} }
} }
public void addModel(final SpatialAssetDataObject file, final Vector3f location) { public void addModel(final SpatialAssetDataObject file, final Vector3f location) {
if (selectedSpat == null) { if (selectedSpat == null) {
return; return;
@ -557,15 +558,17 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
if (selected != null) { if (selected != null) {
setNeedsSave(true); setNeedsSave(true);
SceneApplication.getApplication().enqueue(new Callable<Object>() { SceneApplication.getApplication().enqueue(new Callable<Object>() {
public Object call() throws Exception { public Object call() throws Exception {
doAddModel(file, selected, location); doAddModel(file, selected, location);
return null; return null;
} }
}); });
} else {
displayInfo("Please select a Node to attach to\nin the SceneExplorer.");
} }
} }
public void doAddModel(SpatialAssetDataObject file, Node selected, Vector3f location) { public void doAddModel(SpatialAssetDataObject file, Node selected, Vector3f location) {
ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Adding Model.."); ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Adding Model..");
progressHandle.start(); progressHandle.start();
@ -589,9 +592,9 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
DialogDisplayer.getDefault().notifyLater(msg); DialogDisplayer.getDefault().notifyLater(msg);
} }
progressHandle.finish(); progressHandle.finish();
} }
public void linkModel(final AssetManager manager, final String assetName, final Vector3f location) { public void linkModel(final AssetManager manager, final String assetName, final Vector3f location) {
if (selectedSpat == null) { if (selectedSpat == null) {
return; return;
@ -600,15 +603,17 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
if (selected != null) { if (selected != null) {
setNeedsSave(true); setNeedsSave(true);
SceneApplication.getApplication().enqueue(new Callable<Object>() { SceneApplication.getApplication().enqueue(new Callable<Object>() {
public Object call() throws Exception { public Object call() throws Exception {
doLinkModel(manager, assetName, selected, location); doLinkModel(manager, assetName, selected, location);
return null; return null;
} }
}); });
} else {
displayInfo("Please select a Node to attach to\nin the SceneExplorer.");
} }
} }
public void doLinkModel(AssetManager manager, String assetName, Node selected, Vector3f location) { public void doLinkModel(AssetManager manager, String assetName, Node selected, Vector3f location) {
ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Adding Model.."); ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Adding Model..");
progressHandle.start(); progressHandle.start();
@ -638,13 +643,13 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
DialogDisplayer.getDefault().notifyLater(msg); DialogDisplayer.getDefault().notifyLater(msg);
} }
progressHandle.finish(); progressHandle.finish();
} }
public void addModel(final Spatial file) { public void addModel(final Spatial file) {
addModel(file, null); addModel(file, null);
} }
public void addModel(final Spatial file, final Vector3f location) { public void addModel(final Spatial file, final Vector3f location) {
if (selectedSpat == null) { if (selectedSpat == null) {
return; return;
@ -653,15 +658,17 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
if (selected != null) { if (selected != null) {
setNeedsSave(true); setNeedsSave(true);
SceneApplication.getApplication().enqueue(new Callable<Object>() { SceneApplication.getApplication().enqueue(new Callable<Object>() {
public Object call() throws Exception { public Object call() throws Exception {
doAddModel(file, selected, location); doAddModel(file, selected, location);
return null; return null;
} }
}); });
} else {
displayInfo("Please select a Node to attach to\nin the SceneExplorer.");
} }
} }
public void doAddModel(Spatial file, Node selected, Vector3f location) { public void doAddModel(Spatial file, Node selected, Vector3f location) {
ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Adding Model.."); ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Adding Model..");
progressHandle.start(); progressHandle.start();
@ -684,43 +691,43 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
DialogDisplayer.getDefault().notifyLater(msg); DialogDisplayer.getDefault().notifyLater(msg);
} }
progressHandle.finish(); progressHandle.finish();
} }
public void setNeedsSave(boolean state) { public void setNeedsSave(boolean state) {
currentFileObject.setModified(state); currentFileObject.setModified(state);
} }
public boolean isNeedSave() { public boolean isNeedSave() {
return currentFileObject.isModified(); return currentFileObject.isModified();
} }
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
// if ((evt.getOldValue() == null && !(evt.getNewValue() == null)) || ((evt.getOldValue() != null) && !evt.getOldValue().equals(evt.getNewValue()))) { // if ((evt.getOldValue() == null && !(evt.getNewValue() == null)) || ((evt.getOldValue() != null) && !evt.getOldValue().equals(evt.getNewValue()))) {
// setNeedsSave(true); // setNeedsSave(true);
// } // }
} }
public void childrenAdded(NodeMemberEvent ev) { public void childrenAdded(NodeMemberEvent ev) {
// setNeedsSave(true); // setNeedsSave(true);
toolController.refreshNonSpatialMarkers(); toolController.refreshNonSpatialMarkers();
} }
public void childrenRemoved(NodeMemberEvent ev) { public void childrenRemoved(NodeMemberEvent ev) {
// setNeedsSave(true); // setNeedsSave(true);
toolController.refreshNonSpatialMarkers(); toolController.refreshNonSpatialMarkers();
} }
public void childrenReordered(NodeReorderEvent ev) { public void childrenReordered(NodeReorderEvent ev) {
// setNeedsSave(true); // setNeedsSave(true);
toolController.refreshNonSpatialMarkers(); toolController.refreshNonSpatialMarkers();
} }
public void nodeDestroyed(NodeEvent ev) { public void nodeDestroyed(NodeEvent ev) {
// setNeedsSave(true); // setNeedsSave(true);
toolController.refreshNonSpatialMarkers(); toolController.refreshNonSpatialMarkers();
} }
public void saveScene() { public void saveScene() {
try { try {
currentFileObject.getLookup().lookup(SaveCookie.class).save(); currentFileObject.getLookup().lookup(SaveCookie.class).save();
@ -728,55 +735,55 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
} }
} }
private void refreshSelected(final JmeSpatial spat) { private void refreshSelected(final JmeSpatial spat) {
java.awt.EventQueue.invokeLater(new Runnable() { java.awt.EventQueue.invokeLater(new Runnable() {
public void run() { public void run() {
if (spat != null) { if (spat != null) {
spat.refresh(false); spat.refresh(false);
} }
} }
}); });
} }
private void refreshSelected() { private void refreshSelected() {
java.awt.EventQueue.invokeLater(new Runnable() { java.awt.EventQueue.invokeLater(new Runnable() {
public void run() { public void run() {
if (getSelectedSpat() != null) { if (getSelectedSpat() != null) {
getSelectedSpat().refresh(false); getSelectedSpat().refresh(false);
} }
} }
}); });
} }
private void refreshSelectedParent() { private void refreshSelectedParent() {
java.awt.EventQueue.invokeLater(new Runnable() { java.awt.EventQueue.invokeLater(new Runnable() {
public void run() { public void run() {
if (getSelectedSpat() != null) { if (getSelectedSpat() != null) {
((JmeSpatial) getSelectedSpat().getParentNode()).refresh(false); ((JmeSpatial) getSelectedSpat().getParentNode()).refresh(false);
} }
} }
}); });
} }
private void refreshRoot() { private void refreshRoot() {
java.awt.EventQueue.invokeLater(new Runnable() { java.awt.EventQueue.invokeLater(new Runnable() {
public void run() { public void run() {
if (getJmeRootNode() != null) { if (getJmeRootNode() != null) {
getJmeRootNode().refresh(true); getJmeRootNode().refresh(true);
} }
} }
}); });
} }
public void cleanup() { public void cleanup() {
final Node node = jmeRootNode.getLookup().lookup(Node.class); final Node node = jmeRootNode.getLookup().lookup(Node.class);
if (selectedSpat != null) { if (selectedSpat != null) {
@ -793,4 +800,8 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
TerrainUtils.enableLodControl(camera, root); TerrainUtils.enableLodControl(camera, root);
} }
public void displayInfo(String info) {
Message msg = new NotifyDescriptor.Message(info);
DialogDisplayer.getDefault().notifyLater(msg);
}
} }

Loading…
Cancel
Save