1 19 package org.netbeans.modules.debugger.ui; 20 21 import java.beans.PropertyChangeEvent ; 22 import javax.swing.SwingUtilities ; 23 24 import org.netbeans.api.debugger.DebuggerEngine; 25 import org.netbeans.api.debugger.DebuggerManager; 26 import org.netbeans.api.debugger.DebuggerManagerAdapter; 27 28 import org.openide.awt.ToolbarPool; 29 import org.openide.windows.TopComponentGroup; 30 import org.openide.windows.WindowManager; 31 32 33 39 public class DebuggerManagerListener extends DebuggerManagerAdapter { 40 41 private boolean isOpened = false; 42 43 public void propertyChange (PropertyChangeEvent evt) { 44 if ( (DebuggerManager.getDebuggerManager ().getCurrentEngine () 45 != null) && 46 (!isOpened) 47 ) { 48 SwingUtilities.invokeLater (new Runnable () { 50 public void run () { 51 TopComponentGroup group = WindowManager.getDefault (). 52 findTopComponentGroup ("debugger"); if (group != null) { 54 group.open (); 55 if (ToolbarPool.getDefault (). 56 getConfiguration ().equals 57 (ToolbarPool.DEFAULT_CONFIGURATION) 58 ) 59 ToolbarPool.getDefault ().setConfiguration 60 ("Debugging"); } 62 } 63 }); 64 isOpened = true; 65 } 66 if ( (evt.getPropertyName () == DebuggerManager.PROP_DEBUGGER_ENGINES) 67 && 68 ((DebuggerEngine[]) evt.getNewValue ()).length == 0 69 ) { 70 closeDebuggerUI(); 71 isOpened = false; 72 } 73 } 74 75 static void closeDebuggerUI() { 76 82 if (SwingUtilities.isEventDispatchThread()) { 84 doCloseDebuggerUI(); 85 } else { 86 SwingUtilities.invokeLater(new Runnable () { 87 public void run () { 88 doCloseDebuggerUI(); 89 } 90 }); 91 } 92 } 94 95 private static void doCloseDebuggerUI() { 96 TopComponentGroup group = WindowManager.getDefault (). 97 findTopComponentGroup ("debugger"); if (group != null) { 99 group.close (); 100 if (ToolbarPool.getDefault().getConfiguration().equals("Debugging")) { ToolbarPool.getDefault().setConfiguration(ToolbarPool.DEFAULT_CONFIGURATION); 102 } 103 } 104 } 105 106 public String [] getProperties () { 107 return new String [] { 108 DebuggerManager.PROP_DEBUGGER_ENGINES, 109 DebuggerManager.PROP_CURRENT_ENGINE 110 }; 111 } 112 113 } 114 | Popular Tags |