@ -13,6 +13,7 @@ import com.jme3.gde.core.scene.PreviewRequest;
import com.jme3.gde.core.scene.SceneApplication ;
import com.jme3.gde.core.scene.SceneApplication ;
import com.jme3.gde.core.scene.SceneListener ;
import com.jme3.gde.core.scene.SceneListener ;
import com.jme3.gde.core.scene.SceneRequest ;
import com.jme3.gde.core.scene.SceneRequest ;
import com.jme3.gde.core.sceneexplorer.SceneExplorerTopComponent ;
import com.jme3.gde.core.sceneexplorer.nodes.JmeNode ;
import com.jme3.gde.core.sceneexplorer.nodes.JmeNode ;
import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial ;
import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial ;
import com.jme3.gde.core.sceneexplorer.nodes.NodeUtility ;
import com.jme3.gde.core.sceneexplorer.nodes.NodeUtility ;
@ -28,8 +29,8 @@ import java.util.concurrent.Callable;
import java.util.logging.Logger ;
import java.util.logging.Logger ;
import javax.swing.ButtonGroup ;
import javax.swing.ButtonGroup ;
import javax.swing.border.TitledBorder ;
import javax.swing.border.TitledBorder ;
import org.openide.util.Lookup.Result ;
import org.netbeans.api.progress.ProgressHandle ;
import org.openide.util.LookupEvent ;
import org.netbeans.api.progress.ProgressHandleFactory ;
import org.openide.util.NbBundle ;
import org.openide.util.NbBundle ;
import org.openide.windows.TopComponent ;
import org.openide.windows.TopComponent ;
import org.openide.windows.WindowManager ;
import org.openide.windows.WindowManager ;
@ -45,6 +46,8 @@ import org.openide.awt.UndoRedo;
import org.openide.filesystems.FileObject ;
import org.openide.filesystems.FileObject ;
import org.openide.util.HelpCtx ;
import org.openide.util.HelpCtx ;
import org.openide.util.Lookup ;
import org.openide.util.Lookup ;
import org.openide.util.Lookup.Result ;
import org.openide.util.LookupEvent ;
import org.openide.util.LookupListener ;
import org.openide.util.LookupListener ;
import org.openide.util.Utilities ;
import org.openide.util.Utilities ;
@ -64,9 +67,9 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
ComposerCameraController camController ;
ComposerCameraController camController ;
SceneComposerToolController toolController ;
SceneComposerToolController toolController ;
SceneEditorController editorController ;
SceneEditorController editorController ;
// private SaveCookie saveCookie = new SaveCookieImpl();
private SceneRequest currentRequest ;
private SceneRequest currentRequest ;
private HelpCtx ctx = new HelpCtx ( "sdk.scene_composer" ) ;
private HelpCtx ctx = new HelpCtx ( "sdk.scene_composer" ) ;
// private ProjectAssetManager.ClassPathChangeListener listener;
public SceneComposerTopComponent ( ) {
public SceneComposerTopComponent ( ) {
initComponents ( ) ;
initComponents ( ) ;
@ -555,7 +558,6 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
private void jButton3ActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jButton3ActionPerformed
private void jButton3ActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jButton3ActionPerformed
SceneApplication . getApplication ( ) . setPhysicsEnabled ( false ) ;
SceneApplication . getApplication ( ) . setPhysicsEnabled ( false ) ;
} //GEN-LAST:event_jButton3ActionPerformed
} //GEN-LAST:event_jButton3ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax . swing . JButton camToCursorSelectionButton ;
private javax . swing . JButton camToCursorSelectionButton ;
private javax . swing . JButton createPhysicsMeshButton ;
private javax . swing . JButton createPhysicsMeshButton ;
@ -693,7 +695,7 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
protected void componentActivated ( ) {
protected void componentActivated ( ) {
SceneViewerTopComponent . findInstance ( ) . requestVisible ( ) ;
SceneViewerTopComponent . findInstance ( ) . requestVisible ( ) ;
}
}
void writeProperties ( java . util . Properties p ) {
void writeProperties ( java . util . Properties p ) {
// better to version settings since initial version as advocated at
// better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles
// http://wiki.apidesign.org/wiki/PropertyFiles
@ -724,7 +726,6 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
public void run ( ) {
public void run ( ) {
if ( text ! = null ) {
if ( text ! = null ) {
//XXX: wtf? why do i have to repaint?
( ( TitledBorder ) jPanel4 . getBorder ( ) ) . setTitle ( "Utilities - " + text ) ;
( ( TitledBorder ) jPanel4 . getBorder ( ) ) . setTitle ( "Utilities - " + text ) ;
} else {
} else {
( ( TitledBorder ) jPanel4 . getBorder ( ) ) . setTitle ( "Utilities - no spatial selected" ) ;
( ( TitledBorder ) jPanel4 . getBorder ( ) ) . setTitle ( "Utilities - no spatial selected" ) ;
@ -738,49 +739,43 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
* /
* /
private void setSceneInfo ( final JmeNode jmeNode , final FileObject file , final boolean active ) {
private void setSceneInfo ( final JmeNode jmeNode , final FileObject file , final boolean active ) {
final SceneComposerTopComponent inst = this ;
final SceneComposerTopComponent inst = this ;
java . awt . EventQueue . invokeLater ( new Runnable ( ) {
if ( jmeNode ! = null ) {
( ( TitledBorder ) sceneInfoPanel . getBorder ( ) ) . setTitle ( jmeNode . getName ( ) ) ;
public void run ( ) {
selectSpatial ( jmeNode ) ;
if ( jmeNode ! = null ) {
} else {
( ( TitledBorder ) sceneInfoPanel . getBorder ( ) ) . setTitle ( jmeNode . getName ( ) ) ;
( ( TitledBorder ) sceneInfoPanel . getBorder ( ) ) . setTitle ( "" ) ;
selectSpatial ( jmeNode ) ;
}
} else {
//XXX: wtf? why do i have to repaint?
( ( TitledBorder ) sceneInfoPanel . getBorder ( ) ) . setTitle ( "" ) ;
sceneInfoPanel . repaint ( ) ;
}
//XXX: wtf? why do i have to repaint?
if ( ! active ) {
sceneInfoPanel . repaint ( ) ;
result . removeLookupListener ( inst ) ;
showSelectionToggleButton . setSelected ( true ) ;
if ( ! active ) {
showGridToggleButton . setSelected ( false ) ;
result . removeLookupListener ( inst ) ;
sceneInfoLabel1 . setText ( "" ) ;
showSelectionToggleButton . setSelected ( true ) ;
sceneInfoLabel2 . setText ( "" ) ;
showGridToggleButton . setSelected ( false ) ;
sceneInfoLabel1 . setToolTipText ( "" ) ;
sceneInfoLabel1 . setText ( "" ) ;
sceneInfoLabel2 . setToolTipText ( "" ) ;
sceneInfoLabel2 . setText ( "" ) ;
close ( ) ;
sceneInfoLabel1 . setToolTipText ( "" ) ;
} else {
sceneInfoLabel2 . setToolTipText ( "" ) ;
showSelectionToggleButton . setSelected ( true ) ;
close ( ) ;
showGridToggleButton . setSelected ( false ) ;
} else {
//TODO: threading
showSelectionToggleButton . setSelected ( true ) ;
if ( file ! = null ) {
showGridToggleButton . setSelected ( false ) ;
sceneInfoLabel1 . setText ( "Name: " + file . getNameExt ( ) ) ;
//TODO: threading
sceneInfoLabel2 . setText ( "Size: " + file . getSize ( ) / 1024 + " kB" ) ;
if ( file ! = null ) {
sceneInfoLabel1 . setToolTipText ( "Name: " + file . getNameExt ( ) ) ;
sceneInfoLabel1 . setText ( "Name: " + file . getNameExt ( ) ) ;
sceneInfoLabel2 . setToolTipText ( "Size: " + file . getSize ( ) / 1024 + " kB" ) ;
sceneInfoLabel2 . setText ( "Size: " + file . getSize ( ) / 1024 + " kB" ) ;
sceneInfoLabel1 . setToolTipText ( "Name: " + file . getNameExt ( ) ) ;
sceneInfoLabel2 . setToolTipText ( "Size: " + file . getSize ( ) / 1024 + " kB" ) ;
}
open ( ) ;
requestActive ( ) ;
}
}
}
} ) ;
open ( ) ;
requestActive ( ) ;
}
}
}
public void openScene ( Spatial spat , AssetDataObject file , ProjectAssetManager manager ) {
public void openScene ( Spatial spat , AssetDataObject file , ProjectAssetManager manager ) {
cleanupControllers ( ) ;
cleanupControllers ( ) ;
SceneApplication . getApplication ( ) . addSceneListener ( this ) ;
SceneApplication . getApplication ( ) . addSceneListener ( this ) ;
result . addLookupListener ( this ) ;
result . addLookupListener ( this ) ;
//TODO: handle request change
Node node ;
Node node ;
if ( spat instanceof Node ) {
if ( spat instanceof Node ) {
node = ( Node ) spat ;
node = ( Node ) spat ;
@ -792,7 +787,6 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
SceneRequest request = new SceneRequest ( this , jmeNode , manager ) ;
SceneRequest request = new SceneRequest ( this , jmeNode , manager ) ;
request . setDataObject ( file ) ;
request . setDataObject ( file ) ;
request . setHelpCtx ( ctx ) ;
request . setHelpCtx ( ctx ) ;
// file.setSaveCookie(saveCookie);
if ( editorController ! = null ) {
if ( editorController ! = null ) {
editorController . cleanup ( ) ;
editorController . cleanup ( ) ;
}
}
@ -800,7 +794,7 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
this . currentRequest = request ;
this . currentRequest = request ;
request . setWindowTitle ( "SceneComposer - " + manager . getRelativeAssetPath ( file . getPrimaryFile ( ) . getPath ( ) ) ) ;
request . setWindowTitle ( "SceneComposer - " + manager . getRelativeAssetPath ( file . getPrimaryFile ( ) . getPath ( ) ) ) ;
request . setToolNode ( new Node ( "SceneComposerToolNode" ) ) ;
request . setToolNode ( new Node ( "SceneComposerToolNode" ) ) ;
SceneApplication . getApplication ( ) . request Scene( request ) ;
SceneApplication . getApplication ( ) . open Scene( request ) ;
}
}
public void addModel ( Spatial model ) {
public void addModel ( Spatial model ) {
@ -856,7 +850,6 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
if ( editorController ! = null ) {
if ( editorController ! = null ) {
editorController . setSelectedSpat ( spatial ) ;
editorController . setSelectedSpat ( spatial ) ;
}
}
setActivatedNodes ( new org . openide . nodes . Node [ ] { } ) ;
return ;
return ;
} else {
} else {
if ( toolController ! = null ) {
if ( toolController ! = null ) {
@ -874,39 +867,9 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
} else {
} else {
setSelectedObjectText ( null ) ;
setSelectedObjectText ( null ) ;
}
}
SceneApplication . getApplication ( ) . setCurrentFileNode ( spatial ) ;
SceneExplorerTopComponent . findInstance ( ) . setSelectedNode ( spatial ) ;
setActivatedNodes ( new org . openide . nodes . Node [ ] { spatial } ) ;
}
private boolean checkSaved ( ) {
if ( editorController ! = null & & editorController . isNeedSave ( ) ) {
Confirmation msg = new NotifyDescriptor . Confirmation (
"Your Scene is not saved, do you want to save?" ,
NotifyDescriptor . YES_NO_OPTION ,
NotifyDescriptor . WARNING_MESSAGE ) ;
Object result = DialogDisplayer . getDefault ( ) . notify ( msg ) ;
if ( NotifyDescriptor . CANCEL_OPTION . equals ( result ) ) {
return false ;
} else if ( NotifyDescriptor . YES_OPTION . equals ( result ) ) {
editorController . saveScene ( ) ;
return true ;
} else if ( NotifyDescriptor . NO_OPTION . equals ( result ) ) {
return true ;
}
}
return true ;
}
}
// public class SaveCookieImpl implements SaveCookie {
//
// public void save() throws IOException {
// editorController.saveScene();
// //TODO: update infos.. runs on callable..
//// if (currentRequest != null) {
//// setSceneInfo(currentRequest.getRootNode(), editorController.getCurrentFileObject(), true);
//// }
// }
// }
private void cleanupControllers ( ) {
private void cleanupControllers ( ) {
if ( camController ! = null ) {
if ( camController ! = null ) {
camController . disable ( ) ;
camController . disable ( ) ;
@ -920,14 +883,14 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
editorController . cleanup ( ) ;
editorController . cleanup ( ) ;
editorController = null ;
editorController = null ;
}
}
setActivatedNodes ( new org . openide . nodes . Node [ ] { } ) ;
}
}
/ *
/ *
* SceneListener
* SceneListener
* /
* /
public void sceneRequest ed ( SceneRequest request ) {
public void sceneOpen ed ( SceneRequest request ) {
if ( request . equals ( currentRequest ) ) {
if ( request . equals ( currentRequest ) ) {
setActivatedNodes ( new org . openide . nodes . Node [ ] { currentRequest . getDataObject ( ) . getNodeDelegate ( ) } ) ;
setSceneInfo ( currentRequest . getJmeNode ( ) , editorController . getCurrentFileObject ( ) , true ) ;
setSceneInfo ( currentRequest . getJmeNode ( ) , editorController . getCurrentFileObject ( ) , true ) ;
if ( camController ! = null ) {
if ( camController ! = null ) {
camController . disable ( ) ;
camController . disable ( ) ;
@ -947,44 +910,79 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
SelectTool tool = new SelectTool ( ) ;
SelectTool tool = new SelectTool ( ) ;
toolController . showEditTool ( tool ) ;
toolController . showEditTool ( tool ) ;
toolController . setShowSelection ( true ) ;
toolController . setShowSelection ( true ) ;
editorController . setToolController ( toolController ) ;
editorController . setToolController ( toolController ) ;
toolController . refreshNonSpatialMarkers ( ) ;
toolController . refreshNonSpatialMarkers ( ) ;
editorController . setTerrainLodCamera ( ) ;
editorController . setTerrainLodCamera ( ) ;
} / * else {
// final SpatialAssetDataObject dobj = ((SpatialAssetDataObject) currentRequest.getDataObject());
SceneApplication . getApplication ( ) . removeSceneListener ( this ) ;
// listener = new ProjectAssetManager.ClassPathChangeListener() {
currentRequest = null ;
//
setSceneInfo ( null , false ) ;
// public void classPathChanged(final ProjectAssetManager manager) {
cleanupControllers ( ) ;
// if (dobj.isModified()) {
} * /
// Confirmation msg = new NotifyDescriptor.Confirmation(
// "Classes have been changed, reload scene?",
// NotifyDescriptor.OK_CANCEL_OPTION,
// NotifyDescriptor.ERROR_MESSAGE);
// Object result = DialogDisplayer.getDefault().notify(msg);
// if (!NotifyDescriptor.OK_OPTION.equals(result)) {
// return;
// }
// }
// Runnable call = new Runnable() {
//
// public void run() {
// ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening in SceneComposer");
// progressHandle.start();
// try {
// manager.clearCache();
// final Spatial asset = dobj.loadAsset();
// if (asset != null) {
// java.awt.EventQueue.invokeLater(new Runnable() {
//
// public void run() {
// SceneComposerTopComponent composer = SceneComposerTopComponent.findInstance();
// composer.openScene(asset, dobj, manager);
// }
// });
// } else {
// Confirmation msg = new NotifyDescriptor.Confirmation(
// "Error opening " + dobj.getPrimaryFile().getNameExt(),
// NotifyDescriptor.OK_CANCEL_OPTION,
// NotifyDescriptor.ERROR_MESSAGE);
// DialogDisplayer.getDefault().notify(msg);
// }
// } finally {
// progressHandle.finish();
// }
// }
// };
// new Thread(call).start();
// }
// };
// currentRequest.getManager().addClassPathEventListener(listener);
}
}
}
public boolean sceneClose ( SceneRequest request ) {
public void sceneClosed ( SceneRequest request ) {
if ( request . equals ( currentRequest ) ) {
if ( request . equals ( currentRequest ) ) {
// if (checkSaved()) {
setActivatedNodes ( new org . openide . nodes . Node [ ] { } ) ;
// if (currentRequest != null) {
// currentRequest.getManager().removeClassPathEventListener(listener);
// listener = null;
// }
SceneApplication . getApplication ( ) . removeSceneListener ( this ) ;
SceneApplication . getApplication ( ) . removeSceneListener ( this ) ;
currentRequest = null ;
currentRequest = null ;
setSceneInfo ( null , null , false ) ;
setSceneInfo ( null , null , false ) ;
java . awt . EventQueue . invokeLater ( new Runnable ( ) {
cleanupControllers ( ) ;
public void run ( ) {
cleanupControllers ( ) ;
}
} ) ;
// } else {
// return false;
// }
}
}
return true ;
}
}
public void previewRequested ( PreviewRequest request ) {
public void previewCreated ( PreviewRequest request ) {
}
}
public void displayInfo ( String info ) {
public void displayInfo ( String info ) {
Message msg = new NotifyDescriptor . Message ( info ) ;
Message msg = new NotifyDescriptor . Message ( info ) ;
DialogDisplayer . getDefault ( ) . notifyLater ( msg ) ;
DialogDisplayer . getDefault ( ) . notifyLater ( msg ) ;
}
}
}
}