- make "Add Asset" action of AssetPack browser more robust

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8383 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 14 years ago
parent 7e9f4b51b6
commit 82de99ca94
  1. 9
      sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/AddAssetAction.java

@ -8,6 +8,7 @@ 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.gde.core.scene.SceneApplication;
import com.jme3.gde.core.scene.SceneRequest;
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;
@ -30,7 +31,11 @@ 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(); SceneRequest req = SceneApplication.getApplication().getCurrentSceneRequest();
ProjectAssetManager scenePm = null;
if (req != null) {
scenePm = req.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;
@ -46,7 +51,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, scenePm,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");
} }

Loading…
Cancel
Save