- 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
This commit is contained in:
parent
ca27cb1b1a
commit
d174cb28cd
@ -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;
|
||||||
@ -563,6 +564,8 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
displayInfo("Please select a Node to attach to\nin the SceneExplorer.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,6 +609,8 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
displayInfo("Please select a Node to attach to\nin the SceneExplorer.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,6 +664,8 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
displayInfo("Please select a Node to attach to\nin the SceneExplorer.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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…
x
Reference in New Issue
Block a user