Connect a left-clicked bookmark on the current tab

Middle-click still opens the server in a new tab.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-20 06:55:29 +00:00
parent 50b71eb12e
commit b85d1e5076
3 changed files with 49 additions and 6 deletions

View File

@@ -230,6 +230,24 @@ final class ServerTab implements ServerTabConnectionEvents.Listener {
}, "identity-resolve").start();
}
/**
* Replaces this tab's connection: leaves the server it is on, then connects to the
* new one in its place — what left-clicking a bookmark does.
*/
void switchTo(String address, int port, String nickname, String password, String identityId,
String channel, String channelPassword) {
if (!isBusy()) {
connect(address, port, nickname, password, identityId, channel, channelPassword);
return;
}
new Thread(() -> {
conn.disconnectBlocking("Switching servers");
// Queued behind the disconnect's own UI work, which clears the "connecting" flag.
SwingUtilities.invokeLater(() ->
connect(address, port, nickname, password, identityId, channel, channelPassword));
}, "ts3j-switch-server").start();
}
void disconnect() {
if (conn.isConnected()) conn.disconnect();
}