Selaa lähdekoodia

SDK:
- changes in Scene opening (all callbacks are coming on the EDT now)
- optimize selection callbacks
- optimize/simplify threading
- recognize changes in classpath and recreate ClassPath for AssetManager based on that

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8621 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

nor..67 14 vuotta sitten
vanhempi
commit
35f8c8f754
21 muutettua tiedostoa jossa 516 lisäystä ja 476 poistoa
  1. 1 1
      jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/PreviewAssetAction.java
  2. 12 12
      jme3-core/src/com/jme3/gde/core/assets/AssetDataObject.java
  3. 105 14
      jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java
  4. 3 3
      jme3-core/src/com/jme3/gde/core/assets/SpatialAssetDataObject.java
  5. 1 1
      jme3-core/src/com/jme3/gde/core/assets/actions/OpenModel.java
  6. 9 15
      jme3-core/src/com/jme3/gde/core/properties/preview/DDSPreview.java
  7. 114 162
      jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java
  8. 3 3
      jme3-core/src/com/jme3/gde/core/scene/SceneListener.java
  9. 13 13
      jme3-core/src/com/jme3/gde/core/scene/ScenePreviewProcessor.java
  10. 45 33
      jme3-core/src/com/jme3/gde/core/sceneexplorer/SceneExplorerTopComponent.java
  11. 1 1
      jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/MaterialPreviewWidget.form
  12. 3 4
      jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/MaterialPreviewWidget.java
  13. 1 1
      jme3-ogrexml/src/com/jme3/gde/ogrexml/OgreSceneDataObject.java
  14. 3 3
      jme3-ogrexml/src/com/jme3/gde/ogrexml/OgreXMLDataObject.java
  15. 1 4
      jme3-scenecomposer/src/com/jme3/gde/scenecomposer/OpenSceneComposer.java
  16. 98 100
      jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java
  17. 2 2
      jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/SelectTool.java
  18. 33 43
      jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java
  19. 1 1
      jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorTopComponent.form
  20. 14 7
      jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorTopComponent.java
  21. 53 53
      jme3-welcome-screen/src/com/jme3/gde/welcome/WelcomeScreen.java

+ 1 - 1
jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/PreviewAssetAction.java

@@ -52,7 +52,7 @@ public final class PreviewAssetAction implements Action {
             Exceptions.printStackTrace(ex);
         }
         request.setWindowTitle("AssetPack - PreView Model");
-        app.requestScene(request);
+        app.openScene(request);
 
     }
 

+ 12 - 12
jme3-core/src/com/jme3/gde/core/assets/AssetDataObject.java

@@ -140,7 +140,7 @@ public class AssetDataObject extends MultiDataObject {
     }
 
     @Override
-    public void setModified(boolean modif) {
+    public synchronized void setModified(boolean modif) {
         super.setModified(modif);
         if (modif && saveCookie != null) {
             getCookieSet().assign(SaveCookie.class, saveCookie);
@@ -158,13 +158,13 @@ public class AssetDataObject extends MultiDataObject {
         return lookupContents;
     }
 
-    public void setSaveCookie(SaveCookie cookie) {
+    public synchronized void setSaveCookie(SaveCookie cookie) {
         this.saveCookie = cookie;
         getCookieSet().assign(SaveCookie.class, saveCookie);
         setModified(false);
     }
 
-    public Savable loadAsset() {
+    public synchronized Savable loadAsset() {
         if (isModified() && savable != null) {
             return savable;
         }
@@ -191,7 +191,7 @@ public class AssetDataObject extends MultiDataObject {
         return savable;
     }
 
-    public void saveAsset() throws IOException {
+    public synchronized void saveAsset() throws IOException {
         if (savable == null) {
             Logger.getLogger(AssetDataObject.class.getName()).log(Level.WARNING, "Trying to save asset that has not been loaded before or does not support saving!");
             return;
@@ -227,7 +227,7 @@ public class AssetDataObject extends MultiDataObject {
         setModified(false);
     }
 
-    public AssetKey<?> getAssetKey() {
+    public synchronized AssetKey<?> getAssetKey() {
         if (assetKey == null) {
             ProjectAssetManager mgr = getLookup().lookup(ProjectAssetManager.class);
             if (mgr == null) {
@@ -239,7 +239,7 @@ public class AssetDataObject extends MultiDataObject {
         return assetKey;
     }
 
-    public void setAssetKeyData(AssetKey key) {
+    public synchronized void setAssetKeyData(AssetKey key) {
         try {
             BeanUtils.copyProperties(getAssetKey(), key);
         } catch (IllegalAccessException ex) {
@@ -249,16 +249,16 @@ public class AssetDataObject extends MultiDataObject {
         }
     }
 
-    public List<FileObject> getAssetList() {
-        return assetList;
+    public synchronized List<FileObject> getAssetList() {
+        return new LinkedList<FileObject>(assetList);
     }
 
-    public List<AssetKey> getAssetKeyList() {
-        return assetKeyList;
+    public synchronized List<AssetKey> getAssetKeyList() {
+        return new LinkedList<AssetKey>(assetKeyList);
     }
 
-    public List<AssetKey> getFailedList() {
-        return failedList;
+    public synchronized List<AssetKey> getFailedList() {
+        return new LinkedList<AssetKey>(failedList);
     }
 
     protected static class AssetListListener implements AssetEventListener {

+ 105 - 14
jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java

@@ -38,6 +38,7 @@ import com.jme3.asset.DesktopAssetManager;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -50,7 +51,11 @@ import org.netbeans.api.project.Project;
 import org.netbeans.api.project.ProjectManager;
 import org.netbeans.api.project.SourceGroup;
 import org.netbeans.api.project.Sources;
+import org.openide.filesystems.FileAttributeEvent;
+import org.openide.filesystems.FileChangeListener;
+import org.openide.filesystems.FileEvent;
 import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileRenameEvent;
 import org.openide.filesystems.FileStateInvalidException;
 import org.openide.filesystems.XMLFileSystem;
 import org.openide.util.Exceptions;
@@ -66,9 +71,11 @@ public class ProjectAssetManager extends DesktopAssetManager {
 
     private Project project;
     private List<String> folderNames = new LinkedList<String>();
-    private List<AssetEventListener> assetEventListeners = new LinkedList<AssetEventListener>();
+    private List<AssetEventListener> assetEventListeners = Collections.synchronizedList(new LinkedList<AssetEventListener>());
+    private List<ClassPathChangeListener> classPathListeners = Collections.synchronizedList(new LinkedList<ClassPathChangeListener>());
     private URLClassLoader loader;
-    private LinkedList<FileObject> classPathItems = new LinkedList<FileObject>();
+    private LinkedList<FileObject> jarItems = new LinkedList<FileObject>();
+    private LinkedList<ClassPathItem> classPathItems = new LinkedList<ClassPathItem>();
 
     public ProjectAssetManager(Project prj, String folderName) {
         super(true);
@@ -106,15 +113,20 @@ public class ProjectAssetManager extends DesktopAssetManager {
         this(null);
     }
 
-    public void updateClassLoader() {
-        for (FileObject fileObject : classPathItems) {
+    private synchronized void updateClassLoader() {
+        for (FileObject fileObject : jarItems) {
             try {
+                Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Remove classpath locator:{0}", fileObject.getURL());
                 unregisterLocator(fileObject.getURL().toExternalForm(),
                         com.jme3.asset.plugins.UrlLocator.class);
             } catch (FileStateInvalidException ex) {
                 Exceptions.printStackTrace(ex);
             }
         }
+        jarItems.clear();
+        for (ClassPathItem fileObject : classPathItems) {
+            fileObject.object.removeRecursiveListener(fileObject.listener);
+        }
         classPathItems.clear();
         Sources sources = project.getLookup().lookup(Sources.class);
         if (sources != null) {
@@ -129,10 +141,41 @@ public class ProjectAssetManager extends DesktopAssetManager {
                     try {
                         FileObject[] roots = path.getRoots();
                         for (FileObject fileObject : roots) {
+                            FileChangeListener listener = new FileChangeListener() {
+
+                                public void fileFolderCreated(FileEvent fe) {
+//                                    notifyClassPathListeners();
+                                }
+
+                                public void fileDataCreated(FileEvent fe) {
+//                                    notifyClassPathListeners();
+                                }
+
+                                public void fileChanged(FileEvent fe) {
+                                    System.out.println(fe);
+                                    if (!fe.isExpected()) {
+                                        notifyClassPathListeners();
+                                    }
+                                }
+
+                                public void fileDeleted(FileEvent fe) {
+//                                    notifyClassPathListeners();
+                                }
+
+                                public void fileRenamed(FileRenameEvent fre) {
+//                                    notifyClassPathListeners();
+                                }
+
+                                public void fileAttributeChanged(FileAttributeEvent fae) {
+//                                    notifyClassPathListeners();
+                                }
+                            };
+                            fileObject.addRecursiveListener(listener);
+                            classPathItems.add(new ClassPathItem(fileObject, listener));
                             urls.add(fileObject.getURL());
-                            if(fileObject.getURL().toExternalForm().startsWith("jar")){
+                            if (fileObject.getURL().toExternalForm().startsWith("jar")) {
                                 Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Add classpath locator:{0}", fileObject.getURL());
-                                classPathItems.add(fileObject);
+                                jarItems.add(fileObject);
                                 registerLocator(fileObject.getURL().toExternalForm(),
                                         "com.jme3.asset.plugins.UrlLocator");
                             }
@@ -151,25 +194,31 @@ public class ProjectAssetManager extends DesktopAssetManager {
     public void setAssetEventListener(AssetEventListener listener) {
         throw new UnsupportedOperationException("Setting the asset event listener is not allowed for ProjectAssetManager, use addAssetEventListener instead");
     }
-    
+
     private void prepAssetEventListeners() {
         super.setAssetEventListener(new AssetEventListener() {
 
             public void assetLoaded(AssetKey ak) {
-                for (AssetEventListener assetEventListener : assetEventListeners) {
-                    assetEventListener.assetLoaded(ak);
+                synchronized (assetEventListeners) {
+                    for (AssetEventListener assetEventListener : assetEventListeners) {
+                        assetEventListener.assetLoaded(ak);
+                    }
                 }
             }
 
             public void assetRequested(AssetKey ak) {
-                for (AssetEventListener assetEventListener : assetEventListeners) {
-                    assetEventListener.assetRequested(ak);
+                synchronized (assetEventListeners) {
+                    for (AssetEventListener assetEventListener : assetEventListeners) {
+                        assetEventListener.assetRequested(ak);
+                    }
                 }
             }
 
             public void assetDependencyNotFound(AssetKey ak, AssetKey ak1) {
-                for (AssetEventListener assetEventListener : assetEventListeners) {
-                    assetEventListener.assetDependencyNotFound(ak, ak1);
+                synchronized (assetEventListeners) {
+                    for (AssetEventListener assetEventListener : assetEventListeners) {
+                        assetEventListener.assetDependencyNotFound(ak, ak1);
+                    }
                 }
             }
         });
@@ -336,10 +385,33 @@ public class ProjectAssetManager extends DesktopAssetManager {
         assetEventListeners.remove(listener);
     }
 
+    public void addClassPathEventListener(ClassPathChangeListener listener) {
+        classPathListeners.add(listener);
+    }
+
+    public void removeClassPathEventListener(ClassPathChangeListener listener) {
+        classPathListeners.remove(listener);
+    }
+
+    private void notifyClassPathListeners() {
+        updateClassLoader();
+        final ProjectAssetManager pm = this;
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                synchronized (classPathListeners) {
+                    for (ClassPathChangeListener classPathChangeListener : classPathListeners) {
+                        classPathChangeListener.classPathChanged(pm);
+                    }
+                }
+            }
+        });
+    }
+
     /**
      * For situations with no Project
      */
-    private class DummyProject implements Project {
+    private static class DummyProject implements Project {
 
         ProjectAssetManager pm;
         FileObject folder;
@@ -365,4 +437,23 @@ public class ProjectAssetManager extends DesktopAssetManager {
             return fileSystem.getRoot();
         }
     }
+
+    private static class ClassPathItem {
+
+        FileObject object;
+        FileChangeListener listener;
+
+        public ClassPathItem() {
+        }
+
+        public ClassPathItem(FileObject object, FileChangeListener listener) {
+            this.object = object;
+            this.listener = listener;
+        }
+    }
+
+    public static interface ClassPathChangeListener {
+
+        public void classPathChanged(ProjectAssetManager manager);
+    }
 }

+ 3 - 3
jme3-core/src/com/jme3/gde/core/assets/SpatialAssetDataObject.java

@@ -58,7 +58,7 @@ public class SpatialAssetDataObject extends AssetDataObject {
     }
 
     @Override
-    public ModelKey getAssetKey() {
+    public synchronized ModelKey getAssetKey() {
         AssetKey superKey = super.getAssetKey();
         if (superKey instanceof ModelKey) {
             return (ModelKey)superKey;
@@ -73,7 +73,7 @@ public class SpatialAssetDataObject extends AssetDataObject {
     }
 
     @Override
-    public Spatial loadAsset() {
+    public synchronized Spatial loadAsset() {
         if (isModified() && savable != null) {
             return (Spatial) savable;
         }
@@ -102,7 +102,7 @@ public class SpatialAssetDataObject extends AssetDataObject {
         return null;
     }
 
-    public void saveAsset() throws IOException {
+    public synchronized void saveAsset() throws IOException {
         super.saveAsset();
         ProjectAssetManager mgr = getLookup().lookup(ProjectAssetManager.class);
         if (mgr == null) {

+ 1 - 1
jme3-core/src/com/jme3/gde/core/assets/actions/OpenModel.java

@@ -84,7 +84,7 @@ public final class OpenModel implements ActionListener {
                         SceneRequest request = new SceneRequest(app, jmeNode, manager);
                         request.setDataObject(context);
                         request.setWindowTitle("OpenGL Window - View Model");
-                        app.requestScene(request);
+                        app.openScene(request);
                     } else {
                         Confirmation msg = new NotifyDescriptor.Confirmation(
                                 "Error opening " + context.getPrimaryFile().getNameExt(),

+ 9 - 15
jme3-core/src/com/jme3/gde/core/properties/preview/DDSPreview.java

@@ -120,27 +120,21 @@ public class DDSPreview implements SceneListener {
         SceneApplication.getApplication().removeSceneListener(this);
     }
 
-    public void sceneRequested(SceneRequest request) {
+    public void sceneOpened(SceneRequest request) {
     }
 
-    public boolean sceneClose(SceneRequest request) {
-        return true;
+    public void sceneClosed(SceneRequest request) {
     }
 
-    public void previewRequested(PreviewRequest request) {
+    public void previewCreated(PreviewRequest request) {
         if (request.getRequester() == this) {
             final ImageIcon icon = new ImageIcon(request.getImage());
-            java.awt.EventQueue.invokeLater(new Runnable() {
-
-                public void run() {
-                    if (picPreview instanceof JLabel) {
-                        ((JLabel) picPreview).setIcon(icon);
-                    }
-                    if (picPreview instanceof JButton) {
-                        ((JButton) picPreview).setIcon(icon);
-                    }
-                }
-            });
+            if (picPreview instanceof JLabel) {
+                ((JLabel) picPreview).setIcon(icon);
+            }
+            if (picPreview instanceof JButton) {
+                ((JButton) picPreview).setIcon(icon);
+            }
         }
     }
 }

+ 114 - 162
jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java

@@ -32,7 +32,6 @@ import com.jme3.font.BitmapText;
 import com.jme3.gde.core.Installer;
 import com.jme3.gde.core.assets.AssetData;
 import com.jme3.gde.core.scene.controller.AbstractCameraController;
-import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial;
 import com.jme3.gde.core.scene.processors.WireProcessor;
 import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
 import com.jme3.gde.core.undoredo.SceneUndoRedoManager;
@@ -56,7 +55,6 @@ import com.jme3.system.awt.AwtPanelsContext;
 import com.jme3.system.awt.PaintMode;
 import java.awt.Component;
 import java.io.IOException;
-import java.util.Collection;
 import java.util.Iterator;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentLinkedQueue;
@@ -69,13 +67,11 @@ import org.openide.NotifyDescriptor;
 import org.openide.NotifyDescriptor.Confirmation;
 import org.openide.NotifyDescriptor.Message;
 import org.openide.awt.StatusDisplayer;
+import org.openide.loaders.DataObject;
 import org.openide.util.Exceptions;
 import org.openide.util.HelpCtx;
 import org.openide.util.Lookup;
-import org.openide.util.LookupEvent;
-import org.openide.util.LookupListener;
 import org.openide.util.NbPreferences;
-import org.openide.util.Utilities;
 import org.openide.util.lookup.Lookups;
 
 /**
@@ -84,7 +80,7 @@ import org.openide.util.lookup.Lookups;
  * @author normenhansen
  */
 @SuppressWarnings("unchecked")
-public class SceneApplication extends Application implements LookupProvider, LookupListener {
+public class SceneApplication extends Application implements LookupProvider {
 
     private PointLight camLight;
     private static SceneApplication application;
@@ -110,7 +106,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo
     private SceneRequest currentSceneRequest;
     private ConcurrentLinkedQueue<SceneListener> listeners = new ConcurrentLinkedQueue<SceneListener>();
     private ScenePreviewProcessor previewProcessor;
-    private Lookup.Result nodeSelectionResult;
     private ApplicationLogHandler logHandler = new ApplicationLogHandler();
     private WireProcessor wireProcessor;
     private ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening SceneViewer..");
@@ -139,9 +134,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo
 
             setPauseOnLostFocus(false);
 
-            //add listener for project selection
-            nodeSelectionResult = Utilities.actionsGlobalContext().lookupResult(JmeSpatial.class);
-            nodeSelectionResult.addLookupListener(this);
             if (useCanvas) {
                 createCanvas();
                 startCanvas(true);
@@ -303,20 +295,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo
         return Lookups.fixed(getApplication());
     }
 
-    /**
-     * updates node selection
-     * @param ev
-     */
-    public void resultChanged(LookupEvent ev) {
-        Collection collection = nodeSelectionResult.allInstances();
-        for (Iterator it = collection.iterator(); it.hasNext();) {
-            Object object = it.next();
-            if (object instanceof JmeSpatial) {
-                return;
-            }
-        }
-    }
-
     //TODO: replace with Lookup functionality
     public void addSceneListener(SceneListener listener) {
         listeners.add(listener);
@@ -326,28 +304,30 @@ public class SceneApplication extends Application implements LookupProvider, Loo
         listeners.remove(listener);
     }
 
-    private void notifySceneListeners() {
+    private void notifyOpen() {
         for (Iterator<SceneListener> it = listeners.iterator(); it.hasNext();) {
             SceneListener sceneViewerListener = it.next();
-            sceneViewerListener.sceneRequested(currentSceneRequest);
+            sceneViewerListener.sceneOpened(currentSceneRequest);
         }
     }
 
-    private boolean notifySceneListeners(SceneRequest closed) {
+    private void notifyClose(final SceneRequest closed) {
         for (Iterator<SceneListener> it = listeners.iterator(); it.hasNext();) {
             SceneListener sceneViewerListener = it.next();
-            if (!sceneViewerListener.sceneClose(closed)) {
-                return false;
-            }
+            sceneViewerListener.sceneClosed(closed);
         }
-        return true;
     }
 
-    public void notifySceneListeners(PreviewRequest request) {
-        for (Iterator<SceneListener> it = listeners.iterator(); it.hasNext();) {
-            SceneListener sceneViewerListener = it.next();
-            sceneViewerListener.previewRequested(request);
-        }
+    public void notifyPreview(final PreviewRequest request) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                for (Iterator<SceneListener> it = listeners.iterator(); it.hasNext();) {
+                    SceneListener sceneViewerListener = it.next();
+                    sceneViewerListener.previewCreated(request);
+                }
+            }
+        });
     }
 
     public void createPreview(final PreviewRequest request) {
@@ -358,21 +338,11 @@ public class SceneApplication extends Application implements LookupProvider, Loo
      * method to display the node tree of a plugin (threadsafe)
      * @param tree
      */
-    public void requestScene(final SceneRequest request) {
-        enqueue(new Callable() {
+    public void openScene(final SceneRequest request) {
+        closeScene(currentSceneRequest);
+        java.awt.EventQueue.invokeLater(new Runnable() {
 
-            public Object call() throws Exception {
-                if (!closeCurrentScene()) {
-                    return null;
-                }
-                if (request.getManager() != null) {
-                    assetManager = request.getManager();
-                }
-                if (request.getRequester() instanceof SceneApplication) {
-                    camController.enable();
-                } else {
-                    camController.disable();
-                }
+            public void run() {
                 currentSceneRequest = request;
                 if (request.getDataObject() != null) {
                     setCurrentFileNode(request.getDataObject().getNodeDelegate());
@@ -380,48 +350,34 @@ public class SceneApplication extends Application implements LookupProvider, Loo
                     setCurrentFileNode(null);
                 }
                 setHelpContext(request.getHelpCtx());
-                getCurrentSceneRequest().setDisplayed(true);
-                Spatial model = request.getRootNode();
-                if (model == null) {
-                    StatusDisplayer.getDefault().setStatusText("could not load Spatial from request: " + getCurrentSceneRequest().getWindowTitle());
-                    return null;
-                }
-                rootNode.attachChild(model);
-                if (request.getToolNode() != null) {
-                    toolsNode.attachChild(request.getToolNode());
-                }
-                notifySceneListeners();
                 setWindowTitle(request.getWindowTitle());
-                return null;
-            }
-        });
-    }
+                notifyOpen();
+                enqueue(new Callable() {
 
-    private void checkSave() {
-        if ((currentSceneRequest != null)
-                && currentSceneRequest.getDataObject().isModified()) {
-            final SceneRequest req = currentSceneRequest;
-            java.awt.EventQueue.invokeLater(new Runnable() {
-
-                public void run() {
-                    Confirmation mesg = new NotifyDescriptor.Confirmation("Scene has not been saved,\ndo you want to save it?",
-                            "Not Saved",
-                            NotifyDescriptor.YES_NO_OPTION);
-                    DialogDisplayer.getDefault().notify(mesg);
-                    if (mesg.getValue() == Confirmation.YES_OPTION) {
-                        try {
-                            req.getDataObject().getLookup().lookup(AssetData.class).saveAsset();
-                        } catch (IOException ex) {
-                            Exceptions.printStackTrace(ex);
+                    public Object call() throws Exception {
+                        if (request.getManager() != null) {
+                            assetManager = request.getManager();
                         }
-                    } else if (mesg.getValue() == Confirmation.CANCEL_OPTION) {
-                        return;
-                    } else if (mesg.getValue() == Confirmation.NO_OPTION) {
-                        req.getDataObject().setModified(false);
+                        if (request.getRequester() instanceof SceneApplication) {
+                            camController.enable();
+                        } else {
+                            camController.disable();
+                        }
+                        Spatial model = request.getRootNode();
+                        if (model == null) {
+                            StatusDisplayer.getDefault().setStatusText("could not load Spatial from request: " + getCurrentSceneRequest().getWindowTitle());
+                            return null;
+                        }
+                        rootNode.attachChild(model);
+                        if (request.getToolNode() != null) {
+                            toolsNode.attachChild(request.getToolNode());
+                        }
+                        getCurrentSceneRequest().setDisplayed(true);
+                        return null;
                     }
-                }
-            });
-        }
+                });
+            }
+        });
     }
 
     /**
@@ -429,59 +385,70 @@ public class SceneApplication extends Application implements LookupProvider, Loo
      * @param tree
      */
     public void closeScene(final SceneRequest request) {
-        enqueue(new Callable() {
+        if (request != null) {
+            java.awt.EventQueue.invokeLater(new Runnable() {
 
-            public Object call() throws Exception {
-                if (request == currentSceneRequest) {
-                    if (closeCurrentScene()) {
-                        if (request.getRequester() instanceof SceneApplication) {
-                            camController.disable();
-                        }
-                        currentSceneRequest = null;
+                public void run() {
+
+                    if (request == currentSceneRequest) {
+                        checkSave();
                         setCurrentFileNode(null);
                         setWindowTitle("OpenGL Window");
+                        setHelpContext(null);
+                        SceneUndoRedoManager manager = Lookup.getDefault().lookup(SceneUndoRedoManager.class);
+                        if (manager != null) {
+                            manager.discardAllEdits();
+                        }
+                        final SceneRequest currentRequest = currentSceneRequest;
+                        currentSceneRequest = null;
+                        notifyClose(request);
+                        enqueue(new Callable() {
+
+                            public Object call() throws Exception {
+                                if (request.getRequester() instanceof SceneApplication) {
+                                    camController.disable();
+                                }
+                                notifyClose(currentRequest);
+                                if (physicsState != null) {
+                                    physicsState.getPhysicsSpace().removeAll(rootNode);
+                                    getStateManager().detach(physicsState);
+                                    physicsState = null;
+                                }
+                                currentRequest.setDisplayed(false);
+                                toolsNode.detachAllChildren();
+                                rootNode.detachAllChildren();
+                                // resetCam();
+                                lastError = "";
+                                return null;
+                            }
+                        });
                     }
-                }
-                return null;
-            }
-        });
-    }
 
-    private boolean closeCurrentScene() {
-        return closeCurrentScene(false);
-    }
-
-    private boolean closeCurrentScene(boolean force) {
-        if (currentSceneRequest != null) {
-            if (!notifySceneListeners(currentSceneRequest)) {
-                if (!force) {
-                    return false;
                 }
-            }
-            checkSave();
-            if (physicsState != null) {
-                physicsState.getPhysicsSpace().removeAll(rootNode);
-                getStateManager().detach(physicsState);
-                physicsState = null;
-            }
-            currentSceneRequest.setDisplayed(false);
+            });
         }
-        toolsNode.detachAllChildren();
-        rootNode.detachAllChildren();
-        setHelpContext(null);
-        // resetCam();
-        currentSceneRequest = null;
-        lastError = "";
-        java.awt.EventQueue.invokeLater(new Runnable() {
+    }
 
-            public void run() {
-                SceneUndoRedoManager manager = Lookup.getDefault().lookup(SceneUndoRedoManager.class);
-                if (manager != null) {
-                    manager.discardAllEdits();
+    private void checkSave() {
+        if ((currentSceneRequest != null)
+                && currentSceneRequest.getDataObject().isModified()) {
+            final DataObject req = currentSceneRequest.getDataObject();
+            Confirmation mesg = new NotifyDescriptor.Confirmation("Scene has not been saved,\ndo you want to save it?",
+                    "Not Saved",
+                    NotifyDescriptor.YES_NO_OPTION);
+            DialogDisplayer.getDefault().notify(mesg);
+            if (mesg.getValue() == Confirmation.YES_OPTION) {
+                try {
+                    req.getLookup().lookup(AssetData.class).saveAsset();
+                } catch (IOException ex) {
+                    Exceptions.printStackTrace(ex);
                 }
+            } else if (mesg.getValue() == Confirmation.CANCEL_OPTION) {
+                return;
+            } else if (mesg.getValue() == Confirmation.NO_OPTION) {
+                req.setModified(false);
             }
-        });
-        return true;
+        }
     }
 
     private void resetCam() {
@@ -490,41 +457,26 @@ public class SceneApplication extends Application implements LookupProvider, Loo
     }
 
     private void setWindowTitle(final String string) {
-        java.awt.EventQueue.invokeLater(new Runnable() {
-
-            public void run() {
-                SceneViewerTopComponent.findInstance().setDisplayName(string);
-            }
-        });
+        SceneViewerTopComponent.findInstance().setDisplayName(string);
     }
 
-    public void setCurrentFileNode(final org.openide.nodes.Node node) {
-        java.awt.EventQueue.invokeLater(new Runnable() {
-
-            public void run() {
-                if (node == null) {
-                    SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{});
-                    SceneViewerTopComponent.findInstance().close();
-                } else {
-                    SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{node});
-                    SceneViewerTopComponent.findInstance().open();
-                    SceneViewerTopComponent.findInstance().requestVisible();
-                }
-            }
-        });
+    private void setCurrentFileNode(final org.openide.nodes.Node node) {
+        if (node == null) {
+            SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{});
+            SceneViewerTopComponent.findInstance().close();
+        } else {
+            SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{node});
+            SceneViewerTopComponent.findInstance().open();
+            SceneViewerTopComponent.findInstance().requestVisible();
+        }
     }
 
-    public void setHelpContext(final HelpCtx helpContext) {
-        java.awt.EventQueue.invokeLater(new Runnable() {
-
-            public void run() {
-                if (helpContext == null) {
-                    SceneViewerTopComponent.findInstance().setHelpContext(new HelpCtx("com.jme3.gde.core.sceneviewer"));
-                } else {
-                    SceneViewerTopComponent.findInstance().setHelpContext(helpContext);
-                }
-            }
-        });
+    private void setHelpContext(final HelpCtx helpContext) {
+        if (helpContext == null) {
+            SceneViewerTopComponent.findInstance().setHelpContext(new HelpCtx("com.jme3.gde.core.sceneviewer"));
+        } else {
+            SceneViewerTopComponent.findInstance().setHelpContext(helpContext);
+        }
     }
 
     public void enableCamLight(final boolean enabled) {

+ 3 - 3
jme3-core/src/com/jme3/gde/core/scene/SceneListener.java

@@ -37,10 +37,10 @@ package com.jme3.gde.core.scene;
  */
 public interface SceneListener {
 
-    public void sceneRequested(SceneRequest request);
+    public void sceneOpened(SceneRequest request);
 
-    public boolean sceneClose(SceneRequest request);
+    public void sceneClosed(SceneRequest request);
 
-    public void previewRequested(PreviewRequest request);
+    public void previewCreated(PreviewRequest request);
 
 }

+ 13 - 13
jme3-core/src/com/jme3/gde/core/scene/ScenePreviewProcessor.java

@@ -71,18 +71,6 @@ public class ScenePreviewProcessor implements SceneProcessor {
 
     public void addRequest(PreviewRequest request) {
         previewQueue.add(request);
-        boolean reInit = false;
-        if (request.getCameraRequest().getWidth() != width) {
-            reInit = true;
-            width = request.getCameraRequest().getWidth();
-        }
-        if (request.getCameraRequest().getHeight() != height) {
-            reInit = true;
-            height = request.getCameraRequest().getHeight();
-        }
-        if (reInit) {
-            setupPreviewView();
-        }
     }
 
     private void update(float tpf) {
@@ -148,6 +136,18 @@ public class ScenePreviewProcessor implements SceneProcessor {
     public void preFrame(float f) {
         currentPreviewRequest = previewQueue.poll();
         if (currentPreviewRequest != null) {
+            boolean reInit = false;
+            if (currentPreviewRequest.getCameraRequest().getWidth() != width) {
+                reInit = true;
+                width = currentPreviewRequest.getCameraRequest().getWidth();
+            }
+            if (currentPreviewRequest.getCameraRequest().getHeight() != height) {
+                reInit = true;
+                height = currentPreviewRequest.getCameraRequest().getHeight();
+            }
+            if (reInit) {
+                setupPreviewView();
+            }
             previewNode.attachChild(currentPreviewRequest.getSpatial());
             if (currentPreviewRequest.getCameraRequest().location != null) {
                 offCamera.setLocation(currentPreviewRequest.getCameraRequest().location);
@@ -197,7 +197,7 @@ public class ScenePreviewProcessor implements SceneProcessor {
 
             currentPreviewRequest.setImage(image);
             previewNode.detachAllChildren();
-            SceneApplication.getApplication().notifySceneListeners(currentPreviewRequest);
+            SceneApplication.getApplication().notifyPreview(currentPreviewRequest);
             currentPreviewRequest = null;
         }
     }

+ 45 - 33
jme3-core/src/com/jme3/gde/core/sceneexplorer/SceneExplorerTopComponent.java

@@ -39,15 +39,15 @@ import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode;
 import com.jme3.gde.core.sceneexplorer.nodes.JmeNode;
 import com.jme3.gde.core.util.TerrainUtils;
 import com.jme3.renderer.Camera;
+import java.beans.PropertyVetoException;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import org.openide.util.Lookup.Result;
+import org.openide.util.Exceptions;
 import org.openide.util.NbBundle;
 import org.openide.windows.TopComponent;
 import org.openide.windows.WindowManager;
@@ -64,9 +64,6 @@ import org.openide.explorer.view.BeanTreeView;
 import org.openide.nodes.Node;
 import org.openide.util.HelpCtx;
 import org.openide.util.Lookup;
-import org.openide.util.LookupEvent;
-import org.openide.util.LookupListener;
-import org.openide.util.Utilities;
 import org.openide.util.actions.SystemAction;
 
 /**
@@ -74,14 +71,14 @@ import org.openide.util.actions.SystemAction;
  */
 @ConvertAsProperties(dtd = "-//com.jme3.gde.core.sceneexplorer//SceneExplorer//EN",
 autostore = false)
-public final class SceneExplorerTopComponent extends TopComponent implements ExplorerManager.Provider, SceneListener, LookupListener {
+public final class SceneExplorerTopComponent extends TopComponent implements ExplorerManager.Provider, SceneListener/*, LookupListener */ {
 
     private static SceneExplorerTopComponent instance;
     /** path to the icon used by the component and its open action */
     static final String ICON_PATH = "com/jme3/gde/core/sceneexplorer/jme-logo.png";
     private static final String PREFERRED_ID = "SceneExplorerTopComponent";
     private SceneRequest request;
-    private final Result<AbstractSceneExplorerNode> nodeSelectionResult;
+//    private final Result<AbstractSceneExplorerNode> nodeSelectionResult;
     private AbstractSceneExplorerNode selectedSpatial;
     private AbstractSceneExplorerNode lastSelected;
     private Map<String, MaterialChangeProvider> materialChangeProviders = new HashMap<String, MaterialChangeProvider>();
@@ -94,8 +91,8 @@ public final class SceneExplorerTopComponent extends TopComponent implements Exp
         setToolTipText(NbBundle.getMessage(SceneExplorerTopComponent.class, "HINT_SceneExplorerTopComponent"));
         setIcon(ImageUtilities.loadImage(ICON_PATH, true));
         associateLookup(ExplorerUtils.createLookup(explorerManager, getActionMap()));
-        nodeSelectionResult = Utilities.actionsGlobalContext().lookupResult(AbstractSceneExplorerNode.class);
-        nodeSelectionResult.addLookupListener(this);
+//        nodeSelectionResult = Utilities.actionsGlobalContext().lookupResult(AbstractSceneExplorerNode.class);
+//        nodeSelectionResult.addLookupListener(this);
     }
 
     private void initActions() {
@@ -253,20 +250,35 @@ public final class SceneExplorerTopComponent extends TopComponent implements Exp
         return explorerManager;
     }
 
-    public void resultChanged(LookupEvent ev) {
-        Collection collection = nodeSelectionResult.allInstances();
-        for (Iterator it = collection.iterator(); it.hasNext();) {
-            Object object = it.next();
-            if (object instanceof AbstractSceneExplorerNode) {
-                selectedSpatial = (AbstractSceneExplorerNode) object;
-                lastSelected = (AbstractSceneExplorerNode) object;
-                return;
+    public void setSelectedNode(AbstractSceneExplorerNode node) {
+        selectedSpatial = node;
+        if (node != null) {
+            lastSelected = node;
+        }
+        try {
+            if (node != null) {
+                explorerManager.setSelectedNodes(new Node[]{node});
+//                setActivatedNodes(new Node[]{node});
+            } else {
+                explorerManager.setSelectedNodes(new Node[]{});
+//                setActivatedNodes(new Node[]{});
             }
+        } catch (Exception ex) {
+            Exceptions.printStackTrace(ex);
         }
-        selectedSpatial = null;
     }
 
-    public void sceneRequested(SceneRequest request) {
+//    public void resultChanged(LookupEvent ev) {
+//        Collection collection = nodeSelectionResult.allInstances();
+//        for (Iterator it = collection.iterator(); it.hasNext();) {
+//            Object object = it.next();
+//            if (object instanceof AbstractSceneExplorerNode) {
+//                return;
+//            }
+//        }
+//        selectedSpatial = null;
+//    }
+    public void sceneOpened(SceneRequest request) {
         this.request = request;
         final JmeNode node = request.getJmeNode();
         for (Iterator it = materialChangeProviders.values().iterator(); it.hasNext();) {
@@ -274,25 +286,25 @@ public final class SceneExplorerTopComponent extends TopComponent implements Exp
             provider.clearMaterialChangeListeners();
         }
         if (node != null) {
-            java.awt.EventQueue.invokeLater(new Runnable() {
-
-                public void run() {
-                    explorerManager.setRootContext(node);
-                    explorerManager.getRootContext().setDisplayName(node.getName());
-                    requestVisible();
-                }
-            });
+                explorerManager.setRootContext(node);
+                explorerManager.getRootContext().setDisplayName(node.getName());
+                setActivatedNodes(new Node[]{node});
+                requestVisible();
+            try {
+                explorerManager.setSelectedNodes(new Node[]{node});
+            } catch (PropertyVetoException ex) {
+                Exceptions.printStackTrace(ex);
+            }
         }
         setTerrainLodCamera(node);
     }
 
-    public boolean sceneClose(SceneRequest request) {
+    public void sceneClosed(SceneRequest request) {
         this.request = null;
         explorerManager.setRootContext(Node.EMPTY);
-        return true;
     }
 
-    public void previewRequested(PreviewRequest request) {
+    public void previewCreated(PreviewRequest request) {
     }
 
     /**
@@ -321,7 +333,7 @@ public final class SceneExplorerTopComponent extends TopComponent implements Exp
     public void addMaterialChangeListener(MaterialChangeListener listener) {
 
         if (listener.getKey() != null) {
-             Logger.getLogger(SceneExplorerTopComponent.class.getName()).log(Level.INFO, "New material listener for : {0}", listener.getKey());
+            Logger.getLogger(SceneExplorerTopComponent.class.getName()).log(Level.INFO, "New material listener for : {0}", listener.getKey());
             List<MaterialChangeListener> listeners = materialChangeListeners.get(listener.getKey());
             if (listeners == null) {
                 listeners = new ArrayList<MaterialChangeListener>();
@@ -366,7 +378,7 @@ public final class SceneExplorerTopComponent extends TopComponent implements Exp
 
         if (newKey != null) {
             //  assert newKey.equals(listener.getKey());
-             List<MaterialChangeListener> listeners = materialChangeListeners.get(newKey);
+            List<MaterialChangeListener> listeners = materialChangeListeners.get(newKey);
             if (listeners == null) {
                 listeners = new ArrayList<MaterialChangeListener>();
                 materialChangeListeners.put(newKey, listeners);
@@ -379,7 +391,7 @@ public final class SceneExplorerTopComponent extends TopComponent implements Exp
             }
         }
     }
-    
+
     /**
      * Terrain has a LOD control that requires the camera to function.
      */

+ 1 - 1
jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/MaterialPreviewWidget.form

@@ -1,6 +1,6 @@
 <?xml version="1.1" encoding="UTF-8" ?>
 
-<Form version="1.5" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
   <NonVisualComponents>
     <Component class="javax.swing.ButtonGroup" name="toggleButtonGroup">
     </Component>

+ 3 - 4
jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/MaterialPreviewWidget.java

@@ -103,18 +103,17 @@ public class MaterialPreviewWidget extends javax.swing.JPanel implements SceneLi
         previewLabel.setIcon(null);
     }
 
-    public void sceneRequested(SceneRequest request) {
+    public void sceneOpened(SceneRequest request) {
     }
 
-    public boolean sceneClose(SceneRequest request) {
-        return true;
+    public void sceneClosed(SceneRequest request) {
     }
 
     public void cleanUp(){
          SceneApplication.getApplication().removeSceneListener(this);
     }
     
-    public void previewRequested(PreviewRequest request) {        
+    public void previewCreated(PreviewRequest request) {        
         if (request.getRequester() == this) {
             final ImageIcon icon = new ImageIcon(request.getImage());
             java.awt.EventQueue.invokeLater(new Runnable() {

+ 1 - 1
jme3-ogrexml/src/com/jme3/gde/ogrexml/OgreSceneDataObject.java

@@ -51,7 +51,7 @@ public class OgreSceneDataObject extends SpatialAssetDataObject {
     }
 
     @Override
-    public Spatial loadAsset() {
+    public synchronized Spatial loadAsset() {
         if (isModified() && savable != null) {
             return (Spatial) savable;
         }

+ 3 - 3
jme3-ogrexml/src/com/jme3/gde/ogrexml/OgreXMLDataObject.java

@@ -62,7 +62,7 @@ public class OgreXMLDataObject extends SpatialAssetDataObject {
     }
 
     @Override
-    public ModelKey getAssetKey() {
+    public synchronized ModelKey getAssetKey() {
         if(super.getAssetKey() instanceof OgreMeshKey){
             return (OgreMeshKey)assetKey;
         }
@@ -71,7 +71,7 @@ public class OgreXMLDataObject extends SpatialAssetDataObject {
     }
     
     @Override
-    public Spatial loadAsset() {
+    public synchronized Spatial loadAsset() {
         if (isModified() && savable != null) {
             return (Spatial) savable;
         }
@@ -125,7 +125,7 @@ public class OgreXMLDataObject extends SpatialAssetDataObject {
         return null;
     }
 
-    public void saveAsset() throws IOException {
+    public synchronized void saveAsset() throws IOException {
         ProjectAssetManager mgr = getLookup().lookup(ProjectAssetManager.class);
         if (mgr == null) {
             return;

+ 1 - 4
jme3-scenecomposer/src/com/jme3/gde/scenecomposer/OpenSceneComposer.java

@@ -34,15 +34,12 @@ public final class OpenSceneComposer implements ActionListener {
                 ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening in SceneComposer");
                 progressHandle.start();
                 try {
-
+                    manager.clearCache();
                     final Spatial asset = context.loadAsset();
-
                     if (asset != null) {
                         java.awt.EventQueue.invokeLater(new Runnable() {
 
                             public void run() {
-                                manager.updateClassLoader();
-                                manager.clearCache();
                                 SceneComposerTopComponent composer = SceneComposerTopComponent.findInstance();
                                 composer.openScene(asset, context, manager);
                             }

+ 98 - 100
jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java

@@ -13,6 +13,7 @@ import com.jme3.gde.core.scene.PreviewRequest;
 import com.jme3.gde.core.scene.SceneApplication;
 import com.jme3.gde.core.scene.SceneListener;
 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.JmeSpatial;
 import com.jme3.gde.core.sceneexplorer.nodes.NodeUtility;
@@ -28,8 +29,8 @@ import java.util.concurrent.Callable;
 import java.util.logging.Logger;
 import javax.swing.ButtonGroup;
 import javax.swing.border.TitledBorder;
-import org.openide.util.Lookup.Result;
-import org.openide.util.LookupEvent;
+import org.netbeans.api.progress.ProgressHandle;
+import org.netbeans.api.progress.ProgressHandleFactory;
 import org.openide.util.NbBundle;
 import org.openide.windows.TopComponent;
 import org.openide.windows.WindowManager;
@@ -45,6 +46,8 @@ import org.openide.awt.UndoRedo;
 import org.openide.filesystems.FileObject;
 import org.openide.util.HelpCtx;
 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.Utilities;
 
@@ -64,9 +67,9 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
     ComposerCameraController camController;
     SceneComposerToolController toolController;
     SceneEditorController editorController;
-//    private SaveCookie saveCookie = new SaveCookieImpl();
     private SceneRequest currentRequest;
     private HelpCtx ctx = new HelpCtx("sdk.scene_composer");
+//    private ProjectAssetManager.ClassPathChangeListener listener;
 
     public SceneComposerTopComponent() {
         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
         SceneApplication.getApplication().setPhysicsEnabled(false);
     }//GEN-LAST:event_jButton3ActionPerformed
-
     // Variables declaration - do not modify//GEN-BEGIN:variables
     private javax.swing.JButton camToCursorSelectionButton;
     private javax.swing.JButton createPhysicsMeshButton;
@@ -693,7 +695,7 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
     protected void componentActivated() {
         SceneViewerTopComponent.findInstance().requestVisible();
     }
-    
+
     void writeProperties(java.util.Properties p) {
         // better to version settings since initial version as advocated at
         // http://wiki.apidesign.org/wiki/PropertyFiles
@@ -724,7 +726,6 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
 
             public void run() {
                 if (text != null) {
-                    //XXX: wtf? why do i have to repaint?
                     ((TitledBorder) jPanel4.getBorder()).setTitle("Utilities - " + text);
                 } else {
                     ((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) {
         final SceneComposerTopComponent inst = this;
-        java.awt.EventQueue.invokeLater(new Runnable() {
-
-            public void run() {
-                if (jmeNode != null) {
-                    ((TitledBorder) sceneInfoPanel.getBorder()).setTitle(jmeNode.getName());
-                    selectSpatial(jmeNode);
-                } else {
-                    ((TitledBorder) sceneInfoPanel.getBorder()).setTitle("");
-                }
-                //XXX: wtf? why do i have to repaint?
-                sceneInfoPanel.repaint();
-
-                if (!active) {
-                    result.removeLookupListener(inst);
-                    showSelectionToggleButton.setSelected(true);
-                    showGridToggleButton.setSelected(false);
-                    sceneInfoLabel1.setText("");
-                    sceneInfoLabel2.setText("");
-                    sceneInfoLabel1.setToolTipText("");
-                    sceneInfoLabel2.setToolTipText("");
-                    close();
-                } else {
-                    showSelectionToggleButton.setSelected(true);
-                    showGridToggleButton.setSelected(false);
-                    //TODO: threading
-                    if (file != null) {
-                        sceneInfoLabel1.setText("Name: " + file.getNameExt());
-                        sceneInfoLabel2.setText("Size: " + file.getSize() / 1024 + " kB");
-                        sceneInfoLabel1.setToolTipText("Name: " + file.getNameExt());
-                        sceneInfoLabel2.setToolTipText("Size: " + file.getSize() / 1024 + " kB");
-                    }
-                    open();
-                    requestActive();
-                }
+        if (jmeNode != null) {
+            ((TitledBorder) sceneInfoPanel.getBorder()).setTitle(jmeNode.getName());
+            selectSpatial(jmeNode);
+        } else {
+            ((TitledBorder) sceneInfoPanel.getBorder()).setTitle("");
+        }
+        //XXX: wtf? why do i have to repaint?
+        sceneInfoPanel.repaint();
+
+        if (!active) {
+            result.removeLookupListener(inst);
+            showSelectionToggleButton.setSelected(true);
+            showGridToggleButton.setSelected(false);
+            sceneInfoLabel1.setText("");
+            sceneInfoLabel2.setText("");
+            sceneInfoLabel1.setToolTipText("");
+            sceneInfoLabel2.setToolTipText("");
+            close();
+        } else {
+            showSelectionToggleButton.setSelected(true);
+            showGridToggleButton.setSelected(false);
+            //TODO: threading
+            if (file != null) {
+                sceneInfoLabel1.setText("Name: " + file.getNameExt());
+                sceneInfoLabel2.setText("Size: " + file.getSize() / 1024 + " kB");
+                sceneInfoLabel1.setToolTipText("Name: " + file.getNameExt());
+                sceneInfoLabel2.setToolTipText("Size: " + file.getSize() / 1024 + " kB");
             }
-        });
+            open();
+            requestActive();
+        }
     }
 
     public void openScene(Spatial spat, AssetDataObject file, ProjectAssetManager manager) {
         cleanupControllers();
         SceneApplication.getApplication().addSceneListener(this);
         result.addLookupListener(this);
-        //TODO: handle request change
         Node node;
         if (spat instanceof Node) {
             node = (Node) spat;
@@ -792,7 +787,6 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
         SceneRequest request = new SceneRequest(this, jmeNode, manager);
         request.setDataObject(file);
         request.setHelpCtx(ctx);
-//        file.setSaveCookie(saveCookie);
         if (editorController != null) {
             editorController.cleanup();
         }
@@ -800,7 +794,7 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
         this.currentRequest = request;
         request.setWindowTitle("SceneComposer - " + manager.getRelativeAssetPath(file.getPrimaryFile().getPath()));
         request.setToolNode(new Node("SceneComposerToolNode"));
-        SceneApplication.getApplication().requestScene(request);
+        SceneApplication.getApplication().openScene(request);
     }
 
     public void addModel(Spatial model) {
@@ -856,7 +850,6 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
             if (editorController != null) {
                 editorController.setSelectedSpat(spatial);
             }
-            setActivatedNodes(new org.openide.nodes.Node[]{});
             return;
         } else {
             if (toolController != null) {
@@ -874,39 +867,9 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
         } else {
             setSelectedObjectText(null);
         }
-        SceneApplication.getApplication().setCurrentFileNode(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;
+        SceneExplorerTopComponent.findInstance().setSelectedNode(spatial);
     }
 
-//    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() {
         if (camController != null) {
             camController.disable();
@@ -920,14 +883,14 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
             editorController.cleanup();
             editorController = null;
         }
-        setActivatedNodes(new org.openide.nodes.Node[]{});
     }
 
     /*
      * SceneListener
      */
-    public void sceneRequested(SceneRequest request) {
+    public void sceneOpened(SceneRequest request) {
         if (request.equals(currentRequest)) {
+            setActivatedNodes(new org.openide.nodes.Node[]{currentRequest.getDataObject().getNodeDelegate()});
             setSceneInfo(currentRequest.getJmeNode(), editorController.getCurrentFileObject(), true);
             if (camController != null) {
                 camController.disable();
@@ -947,44 +910,79 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
             SelectTool tool = new SelectTool();
             toolController.showEditTool(tool);
             toolController.setShowSelection(true);
-            
+
             editorController.setToolController(toolController);
             toolController.refreshNonSpatialMarkers();
-            
+
             editorController.setTerrainLodCamera();
-        }/* else {
-         SceneApplication.getApplication().removeSceneListener(this);
-         currentRequest = null;
-         setSceneInfo(null, false);
-         cleanupControllers();
-         }*/
+//            final SpatialAssetDataObject dobj = ((SpatialAssetDataObject) currentRequest.getDataObject());
+//            listener = new ProjectAssetManager.ClassPathChangeListener() {
+//
+//                public void classPathChanged(final ProjectAssetManager manager) {
+//                    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 (checkSaved()) {
+            setActivatedNodes(new org.openide.nodes.Node[]{});
+//            if (currentRequest != null) {
+//                currentRequest.getManager().removeClassPathEventListener(listener);
+//                listener = null;
+//            }
             SceneApplication.getApplication().removeSceneListener(this);
             currentRequest = null;
             setSceneInfo(null, null, false);
-            java.awt.EventQueue.invokeLater(new Runnable() {
-
-                public void run() {
-                    cleanupControllers();
-                }
-            });
-//            } else {
-//                return false;
-//            }
+            cleanupControllers();
         }
-        return true;
     }
 
-    public void previewRequested(PreviewRequest request) {
+    public void previewCreated(PreviewRequest request) {
     }
 
     public void displayInfo(String info) {
         Message msg = new NotifyDescriptor.Message(info);
         DialogDisplayer.getDefault().notifyLater(msg);
     }
-    
 }

+ 2 - 2
jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/SelectTool.java

@@ -34,11 +34,11 @@ public class SelectTool extends SceneEditTool {
                     if (result != null) {
 //                        System.out.println(rootNode.getChild(result).getName());
 //                        SceneExplorerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{rootNode.getChild(result)});
-                        SceneApplication.getApplication().setCurrentFileNode(rootNode.getChild(result));
+                        SceneExplorerTopComponent.findInstance().setSelectedNode(rootNode.getChild(result));
 
                     } else {
                        // SceneExplorerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{rootNode});
-                        SceneApplication.getApplication().setCurrentFileNode(rootNode);
+                        SceneExplorerTopComponent.findInstance().setSelectedNode(rootNode);
                     }
                 }
             });

+ 33 - 43
jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java

@@ -871,8 +871,8 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
         selectedSpat = spatial;
         editorController.setSelectedSpat(spatial);
         /*if (selectedSpat instanceof JmeTerrainQuad) { //TODO shouldn't be terrainQuad, should be a generic JmeTerrain
-            selectedSpat.removeNodeListener(terrainDeletedNodeListener); // remove it if it exists, no way to check if it is there already
-            selectedSpat.addNodeListener(terrainDeletedNodeListener); // add it back
+        selectedSpat.removeNodeListener(terrainDeletedNodeListener); // remove it if it exists, no way to check if it is there already
+        selectedSpat.addNodeListener(terrainDeletedNodeListener); // add it back
         }*/
     }
 
@@ -948,7 +948,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
     protected void componentActivated() {
         SceneViewerTopComponent.findInstance().requestVisible();
     }
-    
+
     void writeProperties(java.util.Properties p) {
         // better to version settings since initial version as advocated at
         // http://wiki.apidesign.org/wiki/PropertyFiles
@@ -1009,15 +1009,15 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
         this.currentRequest = request;
         request.setWindowTitle("TerrainEditor - " + manager.getRelativeAssetPath(file.getPrimaryFile().getPath()));
         request.setToolNode(new Node("TerrainEditorToolNode"));
-        SceneApplication.getApplication().requestScene(request);
+        SceneApplication.getApplication().openScene(request);
 
         terrainDeletedNodeListener = new TerrainNodeListener();
         editorController.enableTextureButtons();
 
     }
 
-    // run on GL thread
-    public void sceneRequested(SceneRequest request) {
+    // runs on AWT thread now
+    public void sceneOpened(SceneRequest request) {
 
         if (request.equals(currentRequest)) {
             Logger.getLogger(TerrainEditorTopComponent.class.getName()).finer("Terrain sceneRequested " + request.getWindowTitle());
@@ -1064,16 +1064,11 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
             toolController.setHeightToolHeight((float) heightSlider.getValue() / (float) heightSlider.getMaximum());
 
             editorController.setTerrainLodCamera();
-            
-            java.awt.EventQueue.invokeLater(new Runnable() {
 
-                public void run() {
-                    reinitTextureTable(); // update the UI
-                    if (editorController.getTerrain(null) != null) {
-                        //createTerrainButton.setEnabled(false); // only let the user add one terrain
-                    }
-                }
-            });
+            reinitTextureTable(); // update the UI
+            if (editorController.getTerrain(null) != null) {
+                //createTerrainButton.setEnabled(false); // only let the user add one terrain
+            }
         }
     }
 
@@ -1110,24 +1105,18 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
         });
     }
 
-    public boolean sceneClose(SceneRequest request) {
+    public void sceneClosed(SceneRequest request) {
         if (request.equals(currentRequest)) {
 //            if (checkSaved()) {
             SceneApplication.getApplication().removeSceneListener(this);
             setSceneInfo(null, false);
             currentRequest = null;
-            java.awt.EventQueue.invokeLater(new Runnable() {
-
-                public void run() {
-                    cleanupControllers();
-                }
-            });
+            cleanupControllers();
 //            }
         }
-        return true;
     }
 
-    public void previewRequested(PreviewRequest request) {
+    public void previewCreated(PreviewRequest request) {
     }
 
     private void cleanupControllers() {
@@ -1175,14 +1164,15 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
         textureTable.getColumnModel().getColumn(2).setCellEditor(rendererNormal);
 
         // empty out the table
-        while (textureTable.getModel().getRowCount() > 0)
-             ((TextureTableModel) textureTable.getModel()).removeRow(0);
+        while (textureTable.getModel().getRowCount() > 0) {
+            ((TextureTableModel) textureTable.getModel()).removeRow(0);
+        }
 
         if (editorController.getTerrain(null) == null) {
             return;
         }
     }
-    
+
     /**
      * Adds another texture layer to the material, sets a default texture for it.
      * Assumes that the new index is in the range of the amount of available textures
@@ -1596,22 +1586,22 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
             throw new UnsupportedOperationException("Unable to create directory");
         }
         /*
-         @Override
-         public File[] getRoots()
-         {
-         return rootDirectories;
-         }
-
-         @Override
-         public boolean isRoot(File file)
-         {
-         for (File root : rootDirectories) {
-         if (root.equals(file)) {
-         return true;
-         }
-         }
-         return false;
-         }*/
+        @Override
+        public File[] getRoots()
+        {
+        return rootDirectories;
+        }
+        
+        @Override
+        public boolean isRoot(File file)
+        {
+        for (File root : rootDirectories) {
+        if (root.equals(file)) {
+        return true;
+        }
+        }
+        return false;
+        }*/
     }
 
     public class Utils {

+ 1 - 1
jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorTopComponent.form

@@ -753,7 +753,7 @@
                   <Layout>
                     <DimensionLayout dim="0">
                       <Group type="103" groupAlignment="0" attributes="0">
-                          <EmptySpace min="0" pref="56" max="32767" attributes="0"/>
+                          <EmptySpace min="0" pref="59" max="32767" attributes="0"/>
                       </Group>
                     </DimensionLayout>
                     <DimensionLayout dim="1">

+ 14 - 7
jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorTopComponent.java

@@ -17,6 +17,7 @@ import com.jme3.light.DirectionalLight;
 import com.jme3.math.FastMath;
 import com.jme3.math.Vector3f;
 import com.jme3.scene.Node;
+import java.util.concurrent.Callable;
 import java.util.logging.Logger;
 import org.openide.util.NbBundle;
 import org.openide.windows.TopComponent;
@@ -874,25 +875,31 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
         currentRequest.setDataObject(file);
         currentRequest.setToolNode(editorController.getToolsNode());
         currentRequest.setHelpCtx(ctx);
-        SceneApplication.getApplication().requestScene(currentRequest);
+        SceneApplication.getApplication().openScene(currentRequest);
     }
 
-    public void previewRequested(PreviewRequest request) {
+    public void previewCreated(PreviewRequest request) {
     }
 
-    public boolean sceneClose(SceneRequest request) {
+    public void sceneClosed(SceneRequest request) {
         if (request == currentRequest) {
             SceneApplication.getApplication().removeSceneListener(this);
-            currentRequest.getRootNode().getParent().removeLight(dirLight);
             editorController.cleanupApplication();
-            SceneApplication.getApplication().getStateManager().detach(editorController.getBulletState());
             setLoadedScene(null, false);
+            final SceneRequest current= currentRequest;
             currentRequest = null;
+            SceneApplication.getApplication().enqueue(new Callable<Void>() {
+
+                public Void call() throws Exception {
+                    current.getRootNode().getParent().removeLight(dirLight);
+                    SceneApplication.getApplication().getStateManager().detach(editorController.getBulletState());
+                    return null;
+                }
+            });
         }
-        return true;
     }
 
-    public void sceneRequested(SceneRequest request) {
+    public void sceneOpened(SceneRequest request) {
         if (request == currentRequest) {
             editorController.prepareApplication();
             SceneApplication.getApplication().getStateManager().attach(editorController.getBulletState());

+ 53 - 53
jme3-welcome-screen/src/com/jme3/gde/welcome/WelcomeScreen.java

@@ -61,60 +61,60 @@ public class WelcomeScreen implements ScreenController {
         final DirectionalLight dirLight = new DirectionalLight();
         dirLight.setDirection(new Vector3f(.1f, 1, .1f).normalizeLocal());
         dirLight.setColor(ColorRGBA.Gray);
-        SceneApplication.getApplication().addSceneListener(new SceneListener() {
-
-            @Override
-            public void sceneRequested(SceneRequest request) {
-                if (request.getRequester() == WelcomeScreen.this) {
-                    //FIXME: planet location dont work?
-                    if (SceneApplication.getApplication().getRenderer().getCaps().contains(Caps.OpenGL21)) {
-//                        planetView = new PlanetRendererState(new Planet(100f, new Vector3f(0, 0, 0)), dirLight);
-//                        SceneApplication.getApplication().getStateManager().attach(planetView);
-                    }
-                    SceneApplication.getApplication().getViewPort().getScenes().get(0).addLight(dirLight);
-                    SceneApplication.getApplication().getCamera().setLocation(new Vector3f(0, 0, 400));
-                    setupSkyBox();
-                    niftyDisplay = new NiftyJmeDisplay(SceneApplication.getApplication().getAssetManager(),
-                            SceneApplication.getApplication().getInputManager(),
-                            SceneApplication.getApplication().getAudioRenderer(),
-                            SceneApplication.getApplication().getGuiViewPort());
-                    nifty = niftyDisplay.getNifty();
-                    try {
-                        nifty.fromXml("Interface/WelcomeScreen.xml", new URL("nbres:/Interface/WelcomeScreen.xml").openStream(), "start", welcomeScreen);
-                    } catch (Exception ex) {
-                        Exceptions.printStackTrace(ex);
-                    }
-
-                    // attach the nifty display to the gui view port as a processor
-                    SceneApplication.getApplication().getGuiViewPort().addProcessor(niftyDisplay);
-                }
-            }
-
-            @Override
-            public boolean sceneClose(SceneRequest request) {
-                SceneApplication.getApplication().getViewPort().getScenes().get(0).removeLight(dirLight);
-                skyBox.removeFromParent();
-                SceneApplication.getApplication().getGuiViewPort().removeProcessor(niftyDisplay);
-                nifty.exit();
-//                if (planetView != null) {
-//                    SceneApplication.getApplication().getStateManager().detach(planetView);
+//        SceneApplication.getApplication().addSceneListener(new SceneListener() {
+//
+//            @Override
+//            public void sceneRequested(SceneRequest request) {
+//                if (request.getRequester() == WelcomeScreen.this) {
+//                    //FIXME: planet location dont work?
+//                    if (SceneApplication.getApplication().getRenderer().getCaps().contains(Caps.OpenGL21)) {
+////                        planetView = new PlanetRendererState(new Planet(100f, new Vector3f(0, 0, 0)), dirLight);
+////                        SceneApplication.getApplication().getStateManager().attach(planetView);
+//                    }
+//                    SceneApplication.getApplication().getViewPort().getScenes().get(0).addLight(dirLight);
+//                    SceneApplication.getApplication().getCamera().setLocation(new Vector3f(0, 0, 400));
+//                    setupSkyBox();
+//                    niftyDisplay = new NiftyJmeDisplay(SceneApplication.getApplication().getAssetManager(),
+//                            SceneApplication.getApplication().getInputManager(),
+//                            SceneApplication.getApplication().getAudioRenderer(),
+//                            SceneApplication.getApplication().getGuiViewPort());
+//                    nifty = niftyDisplay.getNifty();
+//                    try {
+//                        nifty.fromXml("Interface/WelcomeScreen.xml", new URL("nbres:/Interface/WelcomeScreen.xml").openStream(), "start", welcomeScreen);
+//                    } catch (Exception ex) {
+//                        Exceptions.printStackTrace(ex);
+//                    }
+//
+//                    // attach the nifty display to the gui view port as a processor
+//                    SceneApplication.getApplication().getGuiViewPort().addProcessor(niftyDisplay);
 //                }
-                SceneApplication.getApplication().removeSceneListener(this);
-                return true;
-            }
-
-            @Override
-            public void previewRequested(PreviewRequest request) {
-            }
-        });
-        SceneApplication.getApplication().enqueue(new Callable<Object>() {
-
-            @Override
-            public Object call() throws Exception {
-                SceneApplication.getApplication().requestScene(request);
-                return null;
-            }
-        });
+//            }
+//
+//            @Override
+//            public boolean sceneClose(SceneRequest request) {
+//                SceneApplication.getApplication().getViewPort().getScenes().get(0).removeLight(dirLight);
+//                skyBox.removeFromParent();
+//                SceneApplication.getApplication().getGuiViewPort().removeProcessor(niftyDisplay);
+//                nifty.exit();
+////                if (planetView != null) {
+////                    SceneApplication.getApplication().getStateManager().detach(planetView);
+////                }
+//                SceneApplication.getApplication().removeSceneListener(this);
+//                return true;
+//            }
+//
+//            @Override
+//            public void previewRequested(PreviewRequest request) {
+//            }
+//        });
+//        SceneApplication.getApplication().enqueue(new Callable<Object>() {
+//
+//            @Override
+//            public Object call() throws Exception {
+//                SceneApplication.getApplication().requestScene(request);
+//                return null;
+//            }
+//        });
     }
 
     private void setupSkyBox() {