From 2503bd150027d0b0bb9a702d6e3808448a0e9646 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Fri, 1 Jul 2011 23:49:52 +0000 Subject: [PATCH] - fix add to project git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7800 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/gde/assetpack/AssetPackLoader.java | 3 ++ .../assetpack/actions/AddToProjectAction.java | 33 +++++++++++-------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/AssetPackLoader.java b/sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/AssetPackLoader.java index e2e9ee09e..604623bd7 100644 --- a/sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/AssetPackLoader.java +++ b/sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/AssetPackLoader.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!"); diff --git a/sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/AddToProjectAction.java b/sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/AddToProjectAction.java index 375a458b9..dcd0f9ded 100644 --- a/sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/AddToProjectAction.java +++ b/sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/AddToProjectAction.java @@ -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; }