- 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. 33
      sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/AddToProjectAction.java

@ -315,6 +315,7 @@ public class AssetPackLoader {
NodeList list = assetElement.getElementsByTagName("file");
ProjectAssetManager proman = null;
try {
//TODO:not good
proman = SceneApplication.getApplication().getCurrentSceneRequest().getManager();
if (proman == null) {
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");
ProjectAssetManager currentProjectAssetManager = null;
try {
//TODO:not good
currentProjectAssetManager = SceneApplication.getApplication().getCurrentSceneRequest().getManager();
if (currentProjectAssetManager == null) {
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) {
ProjectAssetManager currentProjectAssetManager = null;
try {
//TODO:not good
currentProjectAssetManager = SceneApplication.getApplication().getCurrentSceneRequest().getManager();
if (currentProjectAssetManager == null) {
Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!");

@ -4,10 +4,12 @@
*/
package com.jme3.gde.assetpack.actions;
import com.jme3.asset.AssetManager;
import com.jme3.export.binary.BinaryExporter;
import com.jme3.gde.assetpack.AssetConfiguration;
import com.jme3.gde.assetpack.AssetPackLoader;
import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.core.scene.SceneApplication;
import com.jme3.scene.Spatial;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeListener;
@ -43,19 +45,22 @@ public final class AddToProjectAction implements Action {
AssetConfiguration conf = new AssetConfiguration(assetElement);
Spatial model = AssetPackLoader.loadAssetPackModel(pm, conf);
if (model != null) {
FileObject modelFolder = pm.getAssetFolder().getFileObject("Models");
if (modelFolder == null) {
modelFolder = pm.getAssetFolder().createFolder("Models");
}
if (modelFolder.isFolder()) {
AssetPackLoader.addModelFiles(pm, conf);
SceneComposerTopComponent.findInstance().addModel(model);
OutputStream out = modelFolder.createAndOpen(conf.getAssetElement().getAttribute("name") + ".j3o");
BinaryExporter.getInstance().save(model, out);
out.close();
modelFolder.refresh();
} else {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot copy, file 'Models' exists");
ProjectAssetManager mgr = SceneApplication.getApplication().getCurrentSceneRequest().getManager();
if (mgr != null) {
FileObject modelFolder = mgr.getAssetFolder().getFileObject("Models");
if (modelFolder == null) {
modelFolder = mgr.getAssetFolder().createFolder("Models");
}
if (modelFolder.isFolder()) {
AssetPackLoader.addModelFiles(pm, conf);
SceneComposerTopComponent.findInstance().addModel(model);
OutputStream out = modelFolder.createAndOpen(conf.getAssetElement().getAttribute("name") + ".j3o");
BinaryExporter.getInstance().save(model, out);
out.close();
modelFolder.refresh();
} else {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot copy, file 'Models' exists");
}
}
} else {
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) {
if (key.equals(NAME)) {
return "Add to SceneComposer..";
return "Add to Project..";
}
return null;
}

Loading…
Cancel
Save