From beeb32c9d44830623e81bea539681588a5436759 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Wed, 23 Mar 2011 10:21:11 +0000 Subject: [PATCH] - commit closeable sceneviewer git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7084 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/gde/core/scene/SceneApplication.java | 63 ++----------------- .../sceneviewer/SceneViewerTopComponent.java | 16 +++-- .../ComposerCameraController.java | 4 +- .../SceneComposerTopComponent.java | 2 +- 4 files changed, 18 insertions(+), 67 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java b/sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java index 65bae7921..457baee47 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java @@ -58,9 +58,6 @@ import java.util.Collection; import java.util.Iterator; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; import java.util.logging.Logger; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandleFactory; @@ -110,7 +107,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo private ApplicationLogHandler logHandler = new ApplicationLogHandler(); private WireProcessor wireProcessor; private ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening SceneViewer.."); - private boolean sceneActive = true; private String lastError = ""; private boolean started = false; @@ -246,42 +242,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo } } - @Override - public Future enqueue(Callable callable) { - if (sceneActive) { - return super.enqueue(callable); - } else { - try { - final V value = callable.call(); - return new Future() { - - public boolean cancel(boolean mayInterruptIfRunning) { - return true; - } - - public boolean isCancelled() { - return false; - } - - public boolean isDone() { - return true; - } - - public V get() throws InterruptedException, ExecutionException { - return value; - } - - public V get(long timeout, TimeUnit unit) { - return value; - } - }; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - } - //TODO: Lookup for Application public Lookup createAdditionalLookup(Lookup baseContext) { return Lookups.fixed(getApplication()); @@ -359,7 +319,7 @@ public class SceneApplication extends Application implements LookupProvider, Loo } currentSceneRequest = request; if (request.getDataObject() != null) { - setSelectedNode(request.getDataObject().getNodeDelegate()); + setCurrentFileNode(request.getDataObject().getNodeDelegate()); } setHelpContext(request.getHelpCtx()); getCurrentSceneRequest().setDisplayed(true); @@ -393,6 +353,7 @@ public class SceneApplication extends Application implements LookupProvider, Loo camController.disable(); } currentSceneRequest = null; + setCurrentFileNode(null); setWindowTitle("SceneViewer"); } } @@ -416,7 +377,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo } toolsNode.detachAllChildren(); rootNode.detachAllChildren(); - setSelectedNode(null); setHelpContext(null); resetCam(); currentSceneRequest = null; @@ -443,12 +403,11 @@ public class SceneApplication extends Application implements LookupProvider, Loo public void run() { SceneViewerTopComponent.findInstance().setDisplayName(string); - SceneViewerTopComponent.findInstance().requestActive(); } }); } - public void setSelectedNode(final org.openide.nodes.Node node) { + public void setCurrentFileNode(final org.openide.nodes.Node node) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { @@ -456,6 +415,8 @@ public class SceneApplication extends Application implements LookupProvider, Loo SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{}); } else { SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{node}); + SceneViewerTopComponent.findInstance().open(); + SceneViewerTopComponent.findInstance().requestActive(); } } }); @@ -524,20 +485,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo return currentSceneRequest; } - /** - * @return the sceneActive - */ - public boolean isSceneActive() { - return sceneActive; - } - - /** - * @param sceneActive the sceneActive to set - */ - public void setSceneActive(boolean sceneActive) { - this.sceneActive = sceneActive; - } - @Override public void handleError(String msg, Throwable t) { progressHandle.finish(); diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java index edc6c5bf6..a2b4c4495 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java @@ -43,7 +43,6 @@ import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.NotifyDescriptor.Message; import org.openide.awt.UndoRedo; -import org.openide.util.Exceptions; import org.openide.util.HelpCtx; import org.openide.util.Lookup; import org.openide.util.lookup.InstanceContent; @@ -73,8 +72,15 @@ public final class SceneViewerTopComponent extends TopComponent { setIcon(ImageUtilities.loadImage(ICON_PATH, true)); // lookup = new AbstractLookup(lookupContents); // associateLookup(lookup); - putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE); - app = SceneApplication.getApplication(); +// putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE); + try { + app = SceneApplication.getApplication(); + oGLPanel.add(((JmeCanvasContext) app.getContext()).getCanvas()); + } catch (Exception e) { + showOpenGLError(e.toString()); + } catch (Error err) { + showOpenGLError(err.toString()); + } } /** This method is called from within the constructor to @@ -228,7 +234,6 @@ public final class SceneViewerTopComponent extends TopComponent { super.componentOpened(); try { oGLPanel.add(((JmeCanvasContext) app.getContext()).getCanvas()); - app.setSceneActive(true); } catch (Exception e) { showOpenGLError(e.toString()); } catch (Error err) { @@ -249,8 +254,7 @@ public final class SceneViewerTopComponent extends TopComponent { @Override public void componentClosed() { super.componentClosed(); - app.setSceneActive(false); - oGLPanel.removeAll(); +// oGLPanel.removeAll(); } void writeProperties(java.util.Properties p) { diff --git a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/ComposerCameraController.java b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/ComposerCameraController.java index 105c1d85d..d791d0268 100644 --- a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/ComposerCameraController.java +++ b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/ComposerCameraController.java @@ -75,9 +75,9 @@ public class ComposerCameraController extends AbstractCameraController { public void run() { if (result != null && result.getGeometry() != null) { - SceneApplication.getApplication().setSelectedNode(jmeRootNode.getChild(result.getGeometry())); + SceneApplication.getApplication().setCurrentFileNode(jmeRootNode.getChild(result.getGeometry())); } else { - SceneApplication.getApplication().setSelectedNode(jmeRootNode); + SceneApplication.getApplication().setCurrentFileNode(jmeRootNode); } } }); diff --git a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java index 41632df59..be97adfe8 100644 --- a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java +++ b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java @@ -749,7 +749,7 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce setSelectedObjectText(null); setSelectionData(false); } - SceneApplication.getApplication().setSelectedNode(spatial); + SceneApplication.getApplication().setCurrentFileNode(spatial); setActivatedNodes(new org.openide.nodes.Node[]{spatial}); }