From 58ddf4904032a5147bf4f53b5f86fe9aae9cb7a7 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Tue, 29 Mar 2011 15:24:48 +0000 Subject: [PATCH] - Add ProjectAssetManager accessor to abstract SceneExplorer actions - Use ProjectAssetManager in SkyBox wizard instead of "dirty" SceneApplication.getApplication().getAssetManager() git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7139 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../nodes/actions/AbstractNewControlAction.java | 3 +++ .../nodes/actions/AbstractNewControlWizardAction.java | 3 +++ .../nodes/actions/AbstractNewSpatialAction.java | 3 +++ .../nodes/actions/AbstractNewSpatialWizardAction.java | 5 ++++- .../com/jme3/gde/terraineditor/sky/AddSkyboxAction.java | 9 ++------- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewControlAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewControlAction.java index af5c5b247..79dcbee31 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewControlAction.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewControlAction.java @@ -31,6 +31,7 @@ */ package com.jme3.gde.core.sceneexplorer.nodes.actions; +import com.jme3.gde.core.assets.ProjectAssetManager; import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial; import com.jme3.gde.core.undoredo.AbstractUndoableSceneEdit; @@ -53,10 +54,12 @@ import org.openide.util.Lookup; public abstract class AbstractNewControlAction implements NewControlAction { protected String name = "*"; + protected ProjectAssetManager pm; protected abstract Control doCreateControl(Spatial spatial); protected Action makeAction(final JmeSpatial rootNode, final DataObject dataObject) { + pm = rootNode.getLookup().lookup(ProjectAssetManager.class); final Spatial spatial = rootNode.getLookup().lookup(Spatial.class); return new AbstractAction(name) { diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewControlWizardAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewControlWizardAction.java index 248ea0a51..70be67de2 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewControlWizardAction.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewControlWizardAction.java @@ -31,6 +31,7 @@ */ package com.jme3.gde.core.sceneexplorer.nodes.actions; +import com.jme3.gde.core.assets.ProjectAssetManager; import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial; import com.jme3.gde.core.undoredo.AbstractUndoableSceneEdit; @@ -53,12 +54,14 @@ import org.openide.util.Lookup; public abstract class AbstractNewControlWizardAction implements NewControlAction { protected String name = "*"; + protected ProjectAssetManager pm; protected abstract Object showWizard(Spatial spatial); protected abstract Control doCreateControl(Spatial spatial, Object configuration); protected Action makeAction(final JmeSpatial rootNode, final DataObject dataObject) { + pm = rootNode.getLookup().lookup(ProjectAssetManager.class); final Spatial spatial = rootNode.getLookup().lookup(Spatial.class); return new AbstractAction(name) { diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewSpatialAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewSpatialAction.java index 1bff08c67..019693925 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewSpatialAction.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewSpatialAction.java @@ -31,6 +31,7 @@ */ package com.jme3.gde.core.sceneexplorer.nodes.actions; +import com.jme3.gde.core.assets.ProjectAssetManager; import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.sceneexplorer.nodes.JmeNode; import com.jme3.gde.core.undoredo.AbstractUndoableSceneEdit; @@ -53,10 +54,12 @@ import org.openide.util.Lookup; public abstract class AbstractNewSpatialAction implements NewSpatialAction { protected String name = "*"; + protected ProjectAssetManager pm; protected abstract Spatial doCreateSpatial(Node parent); protected Action makeAction(final JmeNode rootNode, final DataObject dataObject) { + pm = rootNode.getLookup().lookup(ProjectAssetManager.class); final Node node = rootNode.getLookup().lookup(Node.class); return new AbstractAction(name) { diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewSpatialWizardAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewSpatialWizardAction.java index 6f6915dbd..cbba90d9b 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewSpatialWizardAction.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractNewSpatialWizardAction.java @@ -31,6 +31,7 @@ */ package com.jme3.gde.core.sceneexplorer.nodes.actions; +import com.jme3.gde.core.assets.ProjectAssetManager; import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.sceneexplorer.nodes.JmeNode; import com.jme3.gde.core.undoredo.AbstractUndoableSceneEdit; @@ -53,17 +54,19 @@ import org.openide.util.Lookup; public abstract class AbstractNewSpatialWizardAction implements NewSpatialAction { protected String name = "*"; + protected ProjectAssetManager pm; protected abstract Object showWizard(Spatial spatial); protected abstract Spatial doCreateSpatial(Node parent, Object configuration); protected Action makeAction(final JmeNode rootNode, final DataObject dataObject) { + pm = rootNode.getLookup().lookup(ProjectAssetManager.class); final Node node = rootNode.getLookup().lookup(Node.class); return new AbstractAction(name) { public void actionPerformed(ActionEvent e) { - final Object obj=showWizard(node); + final Object obj = showWizard(node); SceneApplication.getApplication().enqueue(new Callable() { public Void call() throws Exception { diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/sky/AddSkyboxAction.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/sky/AddSkyboxAction.java index 004b32104..e6c1b2120 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/sky/AddSkyboxAction.java +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/sky/AddSkyboxAction.java @@ -4,8 +4,6 @@ */ package com.jme3.gde.terraineditor.sky; -import com.jme3.asset.AssetManager; -import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractNewSpatialWizardAction; import com.jme3.gde.core.sceneexplorer.nodes.actions.NewSpatialAction; import com.jme3.math.Vector3f; @@ -15,12 +13,10 @@ import com.jme3.texture.Texture; import com.jme3.util.SkyFactory; import java.awt.Component; import java.awt.Dialog; -import java.lang.reflect.InvocationTargetException; import java.text.MessageFormat; import javax.swing.JComponent; import org.openide.DialogDisplayer; import org.openide.WizardDescriptor; -import org.openide.util.Exceptions; /** * @@ -59,7 +55,6 @@ public class AddSkyboxAction extends AbstractNewSpatialWizardAction { } public Spatial generateSkybox(WizardDescriptor wiz) { - AssetManager assetManager = SceneApplication.getApplication().getAssetManager(); if ((Boolean) wiz.getProperty("multipleTextures")) { Texture south = (Texture) wiz.getProperty("textureSouth"); Texture north = (Texture) wiz.getProperty("textureNorth"); @@ -68,12 +63,12 @@ public class AddSkyboxAction extends AbstractNewSpatialWizardAction { Texture top = (Texture) wiz.getProperty("textureTop"); Texture bottom = (Texture) wiz.getProperty("textureBottom"); Vector3f normalScale = (Vector3f) wiz.getProperty("normalScale"); - return SkyFactory.createSky(assetManager, west, east, north, south, top, bottom, normalScale); + return SkyFactory.createSky(pm, west, east, north, south, top, bottom, normalScale); } else { Texture textureSingle = (Texture) wiz.getProperty("textureSingle"); Vector3f normalScale = (Vector3f) wiz.getProperty("normalScale"); boolean useSpheremap = (Boolean) wiz.getProperty("useSpheremap"); - return SkyFactory.createSky(assetManager, textureSingle, normalScale, useSpheremap); + return SkyFactory.createSky(pm, textureSingle, normalScale, useSpheremap); } }