1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 18:48:00 +01:00

Merge pull request #483 from guusdk/SMACK-908_debugger-tabs

SMACK-908: Don't use components to count tabs in Debugger
This commit is contained in:
Florian Schmaus 2021-07-08 12:03:31 +02:00 committed by GitHub
commit c9af25c674
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -140,12 +140,12 @@ public final class EnhancedDebuggerWindow {
if (frame == null) { if (frame == null) {
createDebug(); createDebug();
} }
debugger.tabbedPane.setName("XMPPConnection_" + tabbedPane.getComponentCount()); debugger.tabbedPane.setName("XMPPConnection_" + tabbedPane.getTabCount());
tabbedPane.add(debugger.tabbedPane, tabbedPane.getComponentCount() - 1); tabbedPane.add(debugger.tabbedPane, -1);
tabbedPane.setIconAt(tabbedPane.indexOfComponent(debugger.tabbedPane), connectionCreatedIcon); tabbedPane.setIconAt(tabbedPane.indexOfComponent(debugger.tabbedPane), connectionCreatedIcon);
tabbedPane.setSelectedIndex(tabbedPane.indexOfComponent(debugger.tabbedPane)); tabbedPane.setSelectedIndex(tabbedPane.indexOfComponent(debugger.tabbedPane));
frame.setTitle( frame.setTitle(
"Smack Debug Window -- Total connections: " + (tabbedPane.getComponentCount() - 1)); "Smack Debug Window -- Total connections: " + (tabbedPane.getTabCount() - 1));
// Keep the added debugger for later access // Keep the added debugger for later access
debuggers.add(debugger); debuggers.add(debugger);
} }
@ -286,7 +286,7 @@ public final class EnhancedDebuggerWindow {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// Remove the selected tab pane if it's not the Smack info pane // Remove the selected tab pane if it's not the Smack info pane
if (tabbedPane.getSelectedIndex() < tabbedPane.getComponentCount() - 1) { if (tabbedPane.getSelectedIndex() < tabbedPane.getTabCount() - 1) {
int index = tabbedPane.getSelectedIndex(); int index = tabbedPane.getSelectedIndex();
// Notify to the debugger to stop debugging // Notify to the debugger to stop debugging
EnhancedDebugger debugger = debuggers.get(index); EnhancedDebugger debugger = debuggers.get(index);
@ -297,7 +297,7 @@ public final class EnhancedDebuggerWindow {
// Update the root window title // Update the root window title
frame.setTitle( frame.setTitle(
"Smack Debug Window -- Total connections: " "Smack Debug Window -- Total connections: "
+ (tabbedPane.getComponentCount() - 1)); + (tabbedPane.getTabCount() - 1));
} }
} }
}); });
@ -309,7 +309,7 @@ public final class EnhancedDebuggerWindow {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
ArrayList<EnhancedDebugger> debuggersToRemove = new ArrayList<>(); ArrayList<EnhancedDebugger> debuggersToRemove = new ArrayList<>();
// Remove all the debuggers of which their connections are no longer valid // Remove all the debuggers of which their connections are no longer valid
for (int index = 0; index < tabbedPane.getComponentCount() - 1; index++) { for (int index = 0; index < tabbedPane.getTabCount() - 1; index++) {
EnhancedDebugger debugger = debuggers.get(index); EnhancedDebugger debugger = debuggers.get(index);
if (!debugger.isConnectionActive()) { if (!debugger.isConnectionActive()) {
// Notify to the debugger to stop debugging // Notify to the debugger to stop debugging
@ -325,7 +325,7 @@ public final class EnhancedDebuggerWindow {
// Update the root window title // Update the root window title
frame.setTitle( frame.setTitle(
"Smack Debug Window -- Total connections: " "Smack Debug Window -- Total connections: "
+ (tabbedPane.getComponentCount() - 1)); + (tabbedPane.getTabCount() - 1));
} }
}); });
menu.add(menuItem); menu.add(menuItem);