diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorController.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorController.java index 96158b5c2..9a3782183 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorController.java +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorController.java @@ -57,6 +57,7 @@ import com.jme3.texture.Texture; import com.jme3.texture.Texture.WrapMode; import com.jme3.util.SkyFactory; import java.awt.image.BufferedImage; +import java.beans.PropertyChangeEvent; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -70,6 +71,10 @@ import jme3tools.converters.ImageToAwt; import org.openide.cookies.SaveCookie; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; +import org.openide.nodes.NodeEvent; +import org.openide.nodes.NodeListener; +import org.openide.nodes.NodeMemberEvent; +import org.openide.nodes.NodeReorderEvent; import org.openide.util.Exceptions; import org.openide.util.Lookup; @@ -79,7 +84,7 @@ import org.openide.util.Lookup; * @author normenhansen, bowens */ @SuppressWarnings("unchecked") -public class TerrainEditorController { +public class TerrainEditorController implements NodeListener { private JmeSpatial jmeRootNode; private Node terrainNode; private Node rootNode; @@ -122,6 +127,7 @@ public class TerrainEditorController { terrainSaveCookie.rootNode = jmeRootNode; this.currentFileObject.setSaveCookie(terrainSaveCookie); this.topComponent = topComponent; + this.jmeRootNode.addNodeListener(this); } public void setToolController(TerrainToolController toolController) { @@ -1060,6 +1066,27 @@ public class TerrainEditorController { setNeedsSave(true); } + public void propertyChange(PropertyChangeEvent evt) { + } + + public void childrenAdded(NodeMemberEvent ev) { + topComponent.reinitTextureTable(); + } + + public void childrenRemoved(NodeMemberEvent ev) { + terrainNode = null; + Node t = getTerrain(rootNode); + if (t == null) + topComponent.reinitTextureTable(); + } + + public void childrenReordered(NodeReorderEvent ev) { + } + + public void nodeDestroyed(NodeEvent ev) { + + } + /** * Re-attach the camera to the LOD control. * Called when the scene is opened and will only diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java index 383af16cc..65019495b 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java @@ -1148,7 +1148,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce /** * re-initialize the texture rows in the texture table to match the given terrain. */ - private void reinitTextureTable() { + protected void reinitTextureTable() { TextureCellRendererEditor rendererTexturer = new TextureCellRendererEditor(); textureTable.getColumnModel().getColumn(1).setCellRenderer(rendererTexturer); // diffuse @@ -1159,9 +1159,8 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce textureTable.getColumnModel().getColumn(2).setCellEditor(rendererNormal); // empty out the table - for (int i = 0; i < textureTable.getModel().getRowCount(); i++) { - ((TextureTableModel) textureTable.getModel()).removeRow(i); - } + while (textureTable.getModel().getRowCount() > 0) + ((TextureTableModel) textureTable.getModel()).removeRow(0); if (editorController.getTerrain(null) == null) { return;