- commit closeable sceneviewer
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7084 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
f6d070afe6
commit
beeb32c9d4
@ -58,9 +58,6 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
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 java.util.logging.Logger;
|
||||||
import org.netbeans.api.progress.ProgressHandle;
|
import org.netbeans.api.progress.ProgressHandle;
|
||||||
import org.netbeans.api.progress.ProgressHandleFactory;
|
import org.netbeans.api.progress.ProgressHandleFactory;
|
||||||
@ -110,7 +107,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo
|
|||||||
private ApplicationLogHandler logHandler = new ApplicationLogHandler();
|
private ApplicationLogHandler logHandler = new ApplicationLogHandler();
|
||||||
private WireProcessor wireProcessor;
|
private WireProcessor wireProcessor;
|
||||||
private ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening SceneViewer..");
|
private ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening SceneViewer..");
|
||||||
private boolean sceneActive = true;
|
|
||||||
private String lastError = "";
|
private String lastError = "";
|
||||||
private boolean started = false;
|
private boolean started = false;
|
||||||
|
|
||||||
@ -246,42 +242,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <V> Future<V> enqueue(Callable<V> callable) {
|
|
||||||
if (sceneActive) {
|
|
||||||
return super.enqueue(callable);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
final V value = callable.call();
|
|
||||||
return new Future<V>() {
|
|
||||||
|
|
||||||
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
|
//TODO: Lookup for Application
|
||||||
public Lookup createAdditionalLookup(Lookup baseContext) {
|
public Lookup createAdditionalLookup(Lookup baseContext) {
|
||||||
return Lookups.fixed(getApplication());
|
return Lookups.fixed(getApplication());
|
||||||
@ -359,7 +319,7 @@ public class SceneApplication extends Application implements LookupProvider, Loo
|
|||||||
}
|
}
|
||||||
currentSceneRequest = request;
|
currentSceneRequest = request;
|
||||||
if (request.getDataObject() != null) {
|
if (request.getDataObject() != null) {
|
||||||
setSelectedNode(request.getDataObject().getNodeDelegate());
|
setCurrentFileNode(request.getDataObject().getNodeDelegate());
|
||||||
}
|
}
|
||||||
setHelpContext(request.getHelpCtx());
|
setHelpContext(request.getHelpCtx());
|
||||||
getCurrentSceneRequest().setDisplayed(true);
|
getCurrentSceneRequest().setDisplayed(true);
|
||||||
@ -393,6 +353,7 @@ public class SceneApplication extends Application implements LookupProvider, Loo
|
|||||||
camController.disable();
|
camController.disable();
|
||||||
}
|
}
|
||||||
currentSceneRequest = null;
|
currentSceneRequest = null;
|
||||||
|
setCurrentFileNode(null);
|
||||||
setWindowTitle("SceneViewer");
|
setWindowTitle("SceneViewer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -416,7 +377,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo
|
|||||||
}
|
}
|
||||||
toolsNode.detachAllChildren();
|
toolsNode.detachAllChildren();
|
||||||
rootNode.detachAllChildren();
|
rootNode.detachAllChildren();
|
||||||
setSelectedNode(null);
|
|
||||||
setHelpContext(null);
|
setHelpContext(null);
|
||||||
resetCam();
|
resetCam();
|
||||||
currentSceneRequest = null;
|
currentSceneRequest = null;
|
||||||
@ -443,12 +403,11 @@ public class SceneApplication extends Application implements LookupProvider, Loo
|
|||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
SceneViewerTopComponent.findInstance().setDisplayName(string);
|
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() {
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -456,6 +415,8 @@ public class SceneApplication extends Application implements LookupProvider, Loo
|
|||||||
SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{});
|
SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{});
|
||||||
} else {
|
} else {
|
||||||
SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{node});
|
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 currentSceneRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the sceneActive
|
|
||||||
*/
|
|
||||||
public boolean isSceneActive() {
|
|
||||||
return sceneActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param sceneActive the sceneActive to set
|
|
||||||
*/
|
|
||||||
public void setSceneActive(boolean sceneActive) {
|
|
||||||
this.sceneActive = sceneActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleError(String msg, Throwable t) {
|
public void handleError(String msg, Throwable t) {
|
||||||
progressHandle.finish();
|
progressHandle.finish();
|
||||||
|
@ -43,7 +43,6 @@ import org.openide.DialogDisplayer;
|
|||||||
import org.openide.NotifyDescriptor;
|
import org.openide.NotifyDescriptor;
|
||||||
import org.openide.NotifyDescriptor.Message;
|
import org.openide.NotifyDescriptor.Message;
|
||||||
import org.openide.awt.UndoRedo;
|
import org.openide.awt.UndoRedo;
|
||||||
import org.openide.util.Exceptions;
|
|
||||||
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.InstanceContent;
|
import org.openide.util.lookup.InstanceContent;
|
||||||
@ -73,8 +72,15 @@ public final class SceneViewerTopComponent extends TopComponent {
|
|||||||
setIcon(ImageUtilities.loadImage(ICON_PATH, true));
|
setIcon(ImageUtilities.loadImage(ICON_PATH, true));
|
||||||
// lookup = new AbstractLookup(lookupContents);
|
// lookup = new AbstractLookup(lookupContents);
|
||||||
// associateLookup(lookup);
|
// associateLookup(lookup);
|
||||||
putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE);
|
// putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE);
|
||||||
|
try {
|
||||||
app = SceneApplication.getApplication();
|
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
|
/** This method is called from within the constructor to
|
||||||
@ -228,7 +234,6 @@ public final class SceneViewerTopComponent extends TopComponent {
|
|||||||
super.componentOpened();
|
super.componentOpened();
|
||||||
try {
|
try {
|
||||||
oGLPanel.add(((JmeCanvasContext) app.getContext()).getCanvas());
|
oGLPanel.add(((JmeCanvasContext) app.getContext()).getCanvas());
|
||||||
app.setSceneActive(true);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
showOpenGLError(e.toString());
|
showOpenGLError(e.toString());
|
||||||
} catch (Error err) {
|
} catch (Error err) {
|
||||||
@ -249,8 +254,7 @@ public final class SceneViewerTopComponent extends TopComponent {
|
|||||||
@Override
|
@Override
|
||||||
public void componentClosed() {
|
public void componentClosed() {
|
||||||
super.componentClosed();
|
super.componentClosed();
|
||||||
app.setSceneActive(false);
|
// oGLPanel.removeAll();
|
||||||
oGLPanel.removeAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeProperties(java.util.Properties p) {
|
void writeProperties(java.util.Properties p) {
|
||||||
|
@ -75,9 +75,9 @@ public class ComposerCameraController extends AbstractCameraController {
|
|||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if (result != null && result.getGeometry() != null) {
|
if (result != null && result.getGeometry() != null) {
|
||||||
SceneApplication.getApplication().setSelectedNode(jmeRootNode.getChild(result.getGeometry()));
|
SceneApplication.getApplication().setCurrentFileNode(jmeRootNode.getChild(result.getGeometry()));
|
||||||
} else {
|
} else {
|
||||||
SceneApplication.getApplication().setSelectedNode(jmeRootNode);
|
SceneApplication.getApplication().setCurrentFileNode(jmeRootNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -749,7 +749,7 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
|
|||||||
setSelectedObjectText(null);
|
setSelectedObjectText(null);
|
||||||
setSelectionData(false);
|
setSelectionData(false);
|
||||||
}
|
}
|
||||||
SceneApplication.getApplication().setSelectedNode(spatial);
|
SceneApplication.getApplication().setCurrentFileNode(spatial);
|
||||||
setActivatedNodes(new org.openide.nodes.Node[]{spatial});
|
setActivatedNodes(new org.openide.nodes.Node[]{spatial});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user