@ -66,6 +66,7 @@ import java.text.NumberFormat;
import java.util.Collection ;
import java.util.Collection ;
import java.util.HashMap ;
import java.util.HashMap ;
import java.util.Map ;
import java.util.Map ;
import java.util.logging.Level ;
import java.util.logging.Logger ;
import java.util.logging.Logger ;
import javax.swing.* ;
import javax.swing.* ;
import javax.swing.event.ListSelectionEvent ;
import javax.swing.event.ListSelectionEvent ;
@ -91,6 +92,8 @@ import org.openide.nodes.NodeMemberEvent;
import org.openide.nodes.NodeReorderEvent ;
import org.openide.nodes.NodeReorderEvent ;
import org.openide.util.Lookup.Result ;
import org.openide.util.Lookup.Result ;
import org.openide.util.* ;
import org.openide.util.* ;
import org.openide.util.lookup.AbstractLookup ;
import org.openide.util.lookup.InstanceContent ;
import org.openide.windows.TopComponent ;
import org.openide.windows.TopComponent ;
import org.openide.windows.WindowManager ;
import org.openide.windows.WindowManager ;
@ -122,11 +125,22 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
private Map < String , JButton > buttons = new HashMap < String , JButton > ( ) ;
private Map < String , JButton > buttons = new HashMap < String , JButton > ( ) ;
private JPanel insideToolSettings ;
private JPanel insideToolSettings ;
//private InstanceContent content;
public TerrainEditorTopComponent ( ) {
public TerrainEditorTopComponent ( ) {
initComponents ( ) ;
initComponents ( ) ;
setName ( NbBundle . getMessage ( TerrainEditorTopComponent . class , "CTL_TerrainEditorTopComponent" ) ) ;
setName ( NbBundle . getMessage ( TerrainEditorTopComponent . class , "CTL_TerrainEditorTopComponent" ) ) ;
setToolTipText ( NbBundle . getMessage ( TerrainEditorTopComponent . class , "HINT_TerrainEditorTopComponent" ) ) ;
setToolTipText ( NbBundle . getMessage ( TerrainEditorTopComponent . class , "HINT_TerrainEditorTopComponent" ) ) ;
associateLookup ( ExplorerUtils . createLookup ( new ExplorerManager ( ) , getActionMap ( ) ) ) ;
//content = new InstanceContent();
/ * ActionMap actionMap = getActionMap ( ) ;
for ( Object key : actionMap . allKeys ( ) ) {
System . out . println ( "key: " + key + actionMap . get ( key ) ) ;
Action value = actionMap . get ( key ) ;
} * /
//actionMap.put(, terrainWizard);
Lookup lookup = ExplorerUtils . createLookup ( new ExplorerManager ( ) , getActionMap ( ) ) ;
associateLookup ( lookup ) ;
setIcon ( ImageUtilities . loadImage ( ICON_PATH , true ) ) ;
setIcon ( ImageUtilities . loadImage ( ICON_PATH , true ) ) ;
result = Utilities . actionsGlobalContext ( ) . lookupResult ( JmeSpatial . class ) ;
result = Utilities . actionsGlobalContext ( ) . lookupResult ( JmeSpatial . class ) ;
}
}
@ -745,7 +759,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
private void paintButtonActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_paintButtonActionPerformed
private void paintButtonActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_paintButtonActionPerformed
if ( paintButton . isSelected ( ) ) {
if ( paintButton . isSelected ( ) ) {
PaintTerrainTool tool = new PaintTerrainTool ( ) ;
PaintTerrainTool tool = new PaintTerrainTool ( editorController ) ;
toolController . setTerrainEditButtonState ( tool ) ;
toolController . setTerrainEditButtonState ( tool ) ;
setHintText ( tool ) ;
setHintText ( tool ) ;
} else {
} else {
@ -802,7 +816,8 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
Float f = new Float ( shininessField . getText ( ) ) ;
Float f = new Float ( shininessField . getText ( ) ) ;
editorController . setShininess ( Math . max ( 0 , f ) ) ;
editorController . setShininess ( Math . max ( 0 , f ) ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
return ;
Logger . getLogger ( TerrainEditorTopComponent . class . getName ( ) ) . log ( Level . WARNING ,
"Error accessing shininess field in terrain material." , e ) ;
}
}
} //GEN-LAST:event_shininessFieldActionPerformed
} //GEN-LAST:event_shininessFieldActionPerformed
@ -1283,12 +1298,17 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
//SceneUndoRedoManager m = Lookup.getDefault().lookup(SceneUndoRedoManager.class);//TODO remove this line
//SceneUndoRedoManager m = Lookup.getDefault().lookup(SceneUndoRedoManager.class);//TODO remove this line
Logger . getLogger ( TerrainEditorTopComponent . class . getName ( ) ) . finer ( "Terrain openScene " + file . getName ( ) ) ;
Logger . getLogger ( TerrainEditorTopComponent . class . getName ( ) ) . log ( Level . FINER , "Terrain openScene {0}" , file . getName ( ) ) ;
if ( editorController ! = null ) {
if ( editorController ! = null ) {
editorController . cleanup ( ) ;
editorController . cleanup ( ) ;
}
}
//this.associateLookup( new AbstractLookup(content) ); // for saving alpha images
editorController = new TerrainEditorController ( jmeNode , file , this ) ;
editorController = new TerrainEditorController ( jmeNode , file , this ) ;
this . sentRequest = request ;
this . sentRequest = request ;
request . setWindowTitle ( "TerrainEditor - " + manager . getRelativeAssetPath ( file . getPrimaryFile ( ) . getPath ( ) ) ) ;
request . setWindowTitle ( "TerrainEditor - " + manager . getRelativeAssetPath ( file . getPrimaryFile ( ) . getPath ( ) ) ) ;
request . setToolNode ( new Node ( "TerrainEditorToolNode" ) ) ;
request . setToolNode ( new Node ( "TerrainEditorToolNode" ) ) ;
@ -1339,7 +1359,6 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
toolController . setEditorController ( editorController ) ;
toolController . setEditorController ( editorController ) ;
toolController . setCameraController ( camController ) ;
toolController . setCameraController ( camController ) ;
toolController . setTopComponent ( this ) ;
toolController . setTopComponent ( this ) ;
editorController . setToolController ( toolController ) ;
toolController . setHeightToolRadius ( ( float ) radiusSlider . getValue ( ) / ( float ) radiusSlider . getMaximum ( ) ) ;
toolController . setHeightToolRadius ( ( float ) radiusSlider . getValue ( ) / ( float ) radiusSlider . getMaximum ( ) ) ;
toolController . setHeightToolHeight ( ( float ) heightSlider . getValue ( ) / ( float ) heightSlider . getMaximum ( ) ) ;
toolController . setHeightToolHeight ( ( float ) heightSlider . getValue ( ) / ( float ) heightSlider . getMaximum ( ) ) ;
@ -1449,10 +1468,6 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
while ( textureTable . getModel ( ) . getRowCount ( ) > 0 ) {
while ( textureTable . getModel ( ) . getRowCount ( ) > 0 ) {
( ( TextureTableModel ) textureTable . getModel ( ) ) . removeRow ( 0 ) ;
( ( TextureTableModel ) textureTable . getModel ( ) ) . removeRow ( 0 ) ;
}
}
if ( editorController . getTerrain ( null ) = = null ) {
return ;
}
}
}
/ * *
/ * *
@ -1513,7 +1528,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
Float scale = editorController . getTextureScale ( i ) ;
Float scale = editorController . getTextureScale ( i ) ;
if ( scale = = null ) {
if ( scale = = null ) {
scale = editorController . DEFAULT_TEXTURE_SCALE ;
scale = T errainE ditorController. DEFAULT_TEXTURE_SCALE ;
}
}
addRow ( new Object [ ] { "" , i , i , scale } ) ;
addRow ( new Object [ ] { "" , i , i , scale } ) ;
}
}
@ -1540,7 +1555,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
}
}
protected void addNewTexture ( int newIndex ) {
protected void addNewTexture ( int newIndex ) {
float scale = editorController . DEFAULT_TEXTURE_SCALE ;
float scale = T errainE ditorController. DEFAULT_TEXTURE_SCALE ;
// add it to the table model
// add it to the table model
addRow ( new Object [ ] { "" , newIndex , null , scale } ) ; // add to the table model
addRow ( new Object [ ] { "" , newIndex , null , scale } ) ; // add to the table model