[hg] main-silver: #101452: Do close the debugger UI just before ...

  • From:
  • To:
  • Subject: [hg] main-silver: #101452: Do close the debugger UI just before ...
  • Date: Sat, 01 Dec 2012 13:36:44 -0800

changeset 4e767a2d0354 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/4e767a2d0354
description:
        #101452: Do close the debugger UI just before the window system is 
saved. This way it's assured, that the UI is not closed when the exit is 
canceled.

diffstat:

 
spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerManagerListener.java
 |  20 ++-
 spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerModule.java     
     |  64 +++++++++-
 2 files changed, 81 insertions(+), 3 deletions(-)

diffs (117 lines):

diff --git 
a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerManagerListener.java
 
b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerManagerListener.java
--- 
a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerManagerListener.java
+++ 
b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerManagerListener.java
@@ -394,7 +394,25 @@
     }
 
     @Override
-    public void engineRemoved (DebuggerEngine engine) {
+    public void engineRemoved (final DebuggerEngine engine) {
+        if (DebuggerModule.findObject(DebuggerModule.class).isClosing()) {
+            // Do not interfere with closeDebuggerUI()
+            SwingUtilities.invokeLater(new Runnable() {
+                @Override
+                public void run() {
+                    if (SwingUtilities.isEventDispatchThread()) {
+                        RP.post(this);
+                    } else {
+                        doEngineRemoved(engine);
+                    }
+                }
+            });
+        } else {
+            doEngineRemoved(engine);
+        }
+    }
+    
+    private void doEngineRemoved(DebuggerEngine engine) {
         //boolean doCloseToolbar = false;
         synchronized (openedComponents) {
             final Map<EngineComponentsProvider, List<? extends 
ComponentInfo>> openedWindowsByProvider = openedComponents.remove(engine);
diff --git 
a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerModule.java 
b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerModule.java
--- a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerModule.java
+++ b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerModule.java
@@ -44,21 +44,81 @@
 
 package org.netbeans.modules.debugger.ui;
 
+import java.lang.reflect.Method;
+import org.openide.LifecycleManager;
 import org.openide.modules.ModuleInstall;
+import org.openide.windows.WindowManager;
+import org.openide.windows.WindowSystemEvent;
+import org.openide.windows.WindowSystemListener;
 
 /**
  *
  * @author Martin Entlicher
  */
-public class DebuggerModule extends ModuleInstall {
+public class DebuggerModule extends ModuleInstall implements 
WindowSystemListener {
+    
+    private volatile boolean closing = false;
     
     /** Creates a new instance of DebuggerModule */
     public DebuggerModule() {
     }
 
+    @Override
+    public void restored() {
+        WindowManager.getDefault().addWindowSystemListener(this);
+        super.restored();
+    }
+    
+    @Override
     public boolean closing() {
-        DebuggerManagerListener.closeDebuggerUI();
+        closing = true;
         return true;
     }
     
+    public boolean isClosing() {
+        return closing && isExiting();
 }
+    
+    private boolean isExiting() {
+        LifecycleManager lcm = LifecycleManager.getDefault();
+        try {
+            Method isExitingMethod = lcm.getClass().getMethod("isExiting");
+            return (Boolean) isExitingMethod.invoke(lcm);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            return false;
+        }
+    }
+    
+    @Override
+    public void close() {
+        WindowManager.getDefault().removeWindowSystemListener(this);
+        super.close();
+    }
+
+    @Override
+    public void uninstalled() {
+        super.uninstalled();
+        WindowManager.getDefault().removeWindowSystemListener(this);
+    }
+    
+    @Override
+    public void beforeLoad(WindowSystemEvent event) {
+    }
+
+    @Override
+    public void afterLoad(WindowSystemEvent event) {
+    }
+
+    @Override
+    public void beforeSave(WindowSystemEvent event) {
+        if (isClosing()) {
+            DebuggerManagerListener.closeDebuggerUI();
+        }
+    }
+
+    @Override
+    public void afterSave(WindowSystemEvent event) {
+    }
+    
+}

[hg] main-silver: #101452: Do close the debugger UI just before ...

mentlicher 12/01/2012

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close