- fix add to project

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7800 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 14 years ago
parent 2bcc98512e
commit 2503bd1500
  1. 3
      sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/AssetPackLoader.java
  2. 11
      sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/AddToProjectAction.java

@ -315,6 +315,7 @@ public class AssetPackLoader {
NodeList list = assetElement.getElementsByTagName("file"); NodeList list = assetElement.getElementsByTagName("file");
ProjectAssetManager proman = null; ProjectAssetManager proman = null;
try { try {
//TODO:not good
proman = SceneApplication.getApplication().getCurrentSceneRequest().getManager(); proman = SceneApplication.getApplication().getCurrentSceneRequest().getManager();
if (proman == null) { if (proman == null) {
Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!"); Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!");
@ -350,6 +351,7 @@ public class AssetPackLoader {
NodeList fileNodeList = assetElement.getElementsByTagName("file"); NodeList fileNodeList = assetElement.getElementsByTagName("file");
ProjectAssetManager currentProjectAssetManager = null; ProjectAssetManager currentProjectAssetManager = null;
try { try {
//TODO:not good
currentProjectAssetManager = SceneApplication.getApplication().getCurrentSceneRequest().getManager(); currentProjectAssetManager = SceneApplication.getApplication().getCurrentSceneRequest().getManager();
if (currentProjectAssetManager == null) { if (currentProjectAssetManager == null) {
Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!"); Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!");
@ -392,6 +394,7 @@ public class AssetPackLoader {
private static void addVariationFiles(NodeList fileNodeList, ProjectAssetManager pm) { private static void addVariationFiles(NodeList fileNodeList, ProjectAssetManager pm) {
ProjectAssetManager currentProjectAssetManager = null; ProjectAssetManager currentProjectAssetManager = null;
try { try {
//TODO:not good
currentProjectAssetManager = SceneApplication.getApplication().getCurrentSceneRequest().getManager(); currentProjectAssetManager = SceneApplication.getApplication().getCurrentSceneRequest().getManager();
if (currentProjectAssetManager == null) { if (currentProjectAssetManager == null) {
Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!"); Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!");

@ -4,10 +4,12 @@
*/ */
package com.jme3.gde.assetpack.actions; package com.jme3.gde.assetpack.actions;
import com.jme3.asset.AssetManager;
import com.jme3.export.binary.BinaryExporter; import com.jme3.export.binary.BinaryExporter;
import com.jme3.gde.assetpack.AssetConfiguration; import com.jme3.gde.assetpack.AssetConfiguration;
import com.jme3.gde.assetpack.AssetPackLoader; import com.jme3.gde.assetpack.AssetPackLoader;
import com.jme3.gde.core.assets.ProjectAssetManager; import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.core.scene.SceneApplication;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
@ -43,9 +45,11 @@ public final class AddToProjectAction implements Action {
AssetConfiguration conf = new AssetConfiguration(assetElement); AssetConfiguration conf = new AssetConfiguration(assetElement);
Spatial model = AssetPackLoader.loadAssetPackModel(pm, conf); Spatial model = AssetPackLoader.loadAssetPackModel(pm, conf);
if (model != null) { if (model != null) {
FileObject modelFolder = pm.getAssetFolder().getFileObject("Models"); ProjectAssetManager mgr = SceneApplication.getApplication().getCurrentSceneRequest().getManager();
if (mgr != null) {
FileObject modelFolder = mgr.getAssetFolder().getFileObject("Models");
if (modelFolder == null) { if (modelFolder == null) {
modelFolder = pm.getAssetFolder().createFolder("Models"); modelFolder = mgr.getAssetFolder().createFolder("Models");
} }
if (modelFolder.isFolder()) { if (modelFolder.isFolder()) {
AssetPackLoader.addModelFiles(pm, conf); AssetPackLoader.addModelFiles(pm, conf);
@ -57,6 +61,7 @@ public final class AddToProjectAction implements Action {
} else { } else {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot copy, file 'Models' exists"); Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot copy, file 'Models' exists");
} }
}
} else { } else {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Error loading model"); Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Error loading model");
} }
@ -71,7 +76,7 @@ public final class AddToProjectAction implements Action {
public Object getValue(String key) { public Object getValue(String key) {
if (key.equals(NAME)) { if (key.equals(NAME)) {
return "Add to SceneComposer.."; return "Add to Project..";
} }
return null; return null;
} }

Loading…
Cancel
Save