From 9a7ad5d3cbe28f17ad650f2ea6a8aaa83fc86946 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Mon, 14 Jun 2004 16:58:58 +0000 Subject: [PATCH] Adds a menu item that allows to close all the tabs that have their connections not active. SMACK-139 git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2327 b35dd754-fafc-0310-a699-88a17e54d16e --- .../debugger/EnhancedDebuggerWindow.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/source/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java b/source/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java index fe873528c..9d583db4b 100644 --- a/source/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java +++ b/source/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java @@ -265,6 +265,7 @@ class EnhancedDebuggerWindow { // Add pop-up menu. JPopupMenu menu = new JPopupMenu(); + // Add a menu item that allows to close the current selected tab JMenuItem menuItem = new JMenuItem("Close"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -285,6 +286,33 @@ class EnhancedDebuggerWindow { } }); menu.add(menuItem); + // Add a menu item that allows to close all the tabs that have their connections closed + menuItem = new JMenuItem("Close All Not Active"); + menuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ArrayList debuggersToRemove = new ArrayList(); + // Remove all the debuggers of which their connections are no longer valid + for (int index=0; index < tabbedPane.getComponentCount()-1; index++) { + EnhancedDebugger debugger = (EnhancedDebugger)debuggers.get(index); + if (!debugger.isConnectionActive()) { + // Notify to the debugger to stop debugging + debugger.cancel(); + debuggersToRemove.add(debugger); + } + } + for (Iterator it=debuggersToRemove.iterator(); it.hasNext();) { + EnhancedDebugger debugger = (EnhancedDebugger)it.next(); + // Remove the debugger from the root window + tabbedPane.remove(debugger.tabbedPane); + debuggers.remove(debugger); + } + // Update the root window title + frame.setTitle( + "Smack Debug Window -- Total connections: " + + (tabbedPane.getComponentCount() - 1)); + } + }); + menu.add(menuItem); // Add listener to the text area so the popup menu can come up. tabbedPane.addMouseListener(new PopupListener(menu));