fixed some terrain editor texture table refresh bugs when terrain is added/deleted

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8274 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
bre..ns 13 years ago
parent a3a179d2ac
commit 0bcf848922
  1. 29
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorController.java
  2. 7
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java

@ -57,6 +57,7 @@ import com.jme3.texture.Texture;
import com.jme3.texture.Texture.WrapMode; import com.jme3.texture.Texture.WrapMode;
import com.jme3.util.SkyFactory; import com.jme3.util.SkyFactory;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -70,6 +71,10 @@ import jme3tools.converters.ImageToAwt;
import org.openide.cookies.SaveCookie; import org.openide.cookies.SaveCookie;
import org.openide.filesystems.FileObject; import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject; 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.Exceptions;
import org.openide.util.Lookup; import org.openide.util.Lookup;
@ -79,7 +84,7 @@ import org.openide.util.Lookup;
* @author normenhansen, bowens * @author normenhansen, bowens
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class TerrainEditorController { public class TerrainEditorController implements NodeListener {
private JmeSpatial jmeRootNode; private JmeSpatial jmeRootNode;
private Node terrainNode; private Node terrainNode;
private Node rootNode; private Node rootNode;
@ -122,6 +127,7 @@ public class TerrainEditorController {
terrainSaveCookie.rootNode = jmeRootNode; terrainSaveCookie.rootNode = jmeRootNode;
this.currentFileObject.setSaveCookie(terrainSaveCookie); this.currentFileObject.setSaveCookie(terrainSaveCookie);
this.topComponent = topComponent; this.topComponent = topComponent;
this.jmeRootNode.addNodeListener(this);
} }
public void setToolController(TerrainToolController toolController) { public void setToolController(TerrainToolController toolController) {
@ -1060,6 +1066,27 @@ public class TerrainEditorController {
setNeedsSave(true); 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. * Re-attach the camera to the LOD control.
* Called when the scene is opened and will only * Called when the scene is opened and will only

@ -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. * re-initialize the texture rows in the texture table to match the given terrain.
*/ */
private void reinitTextureTable() { protected void reinitTextureTable() {
TextureCellRendererEditor rendererTexturer = new TextureCellRendererEditor(); TextureCellRendererEditor rendererTexturer = new TextureCellRendererEditor();
textureTable.getColumnModel().getColumn(1).setCellRenderer(rendererTexturer); // diffuse 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); textureTable.getColumnModel().getColumn(2).setCellEditor(rendererNormal);
// empty out the table // empty out the table
for (int i = 0; i < textureTable.getModel().getRowCount(); i++) { while (textureTable.getModel().getRowCount() > 0)
((TextureTableModel) textureTable.getModel()).removeRow(i); ((TextureTableModel) textureTable.getModel()).removeRow(0);
}
if (editorController.getTerrain(null) == null) { if (editorController.getTerrain(null) == null) {
return; return;

Loading…
Cancel
Save