Name the server node and stop it collapsing

The tree's top row showed the placeholder name, since nothing ever read the
real one; take it from initserver, which ts3j now keeps.

There is only ever one top-level row, so its expand control bought nothing and
cost horizontal space in a narrow view. Drop it, ignore collapse requests on
the root, and tighten the per-level indent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-14 14:15:32 +00:00
parent 46206e3047
commit d37c6c9ba9
3 changed files with 20 additions and 2 deletions

View File

@@ -338,6 +338,8 @@ public final class TeamspeakConnection implements TS3Listener {
} catch (Exception e) { } catch (Exception e) {
ui.onStatus("Limited subscription: " + rootMessage(e)); ui.onStatus("Limited subscription: " + rootMessage(e));
} }
// The name comes with initserver; servergetvariables never reports it.
model.setServerName(client.getServerName());
try { try {
for (Channel ch : client.listChannels()) { for (Channel ch : client.listChannels()) {
model.putChannel(ch.getId(), ch.getName(), ch.getParentChannelId(), ch.getOrder()); model.putChannel(ch.getId(), ch.getName(), ch.getParentChannelId(), ch.getOrder());

View File

@@ -14,6 +14,7 @@ import javax.swing.JTree;
import javax.swing.JViewport; import javax.swing.JViewport;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.TransferHandler; import javax.swing.TransferHandler;
import javax.swing.plaf.basic.BasicTreeUI;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeCellRenderer;
@@ -97,7 +98,15 @@ public final class ServerTreePanel extends JScrollPane {
root.setUserObject("Not connected"); root.setUserObject("Not connected");
this.tree = new DropIndicatorTree(treeModel); this.tree = new DropIndicatorTree(treeModel);
tree.setRootVisible(true); tree.setRootVisible(true);
tree.setShowsRootHandles(true); // The server node is the only top-level row and always stays open, so it gets
// no expand control. Nesting is tightened too: horizontal space in this view
// is scarce and channel names are long.
tree.setShowsRootHandles(false);
if (tree.getUI() instanceof BasicTreeUI) {
BasicTreeUI ui = (BasicTreeUI) tree.getUI();
ui.setLeftChildIndent(4);
ui.setRightChildIndent(10);
}
tree.setRowHeight(20); tree.setRowHeight(20);
tree.setBackground(Theme.TREE_BG); tree.setBackground(Theme.TREE_BG);
tree.setFont(Theme.UI_FONT); tree.setFont(Theme.UI_FONT);
@@ -437,6 +446,13 @@ public final class ServerTreePanel extends JScrollPane {
super(model); super(model);
} }
/** Keeps the server row permanently open; collapsing it would hide everything. */
@Override
public void setExpandedState(TreePath path, boolean state) {
if (!state && path.getPathCount() == 1) return;
super.setExpandedState(path, state);
}
/** /**
* Widens every repaint request to the full visible width. Swing only asks for * Widens every repaint request to the full visible width. Swing only asks for
* the row rectangle, which stops short of the right-aligned icon strip and would * the row rectangle, which stops short of the right-aligned icon strip and would

2
ts3j

Submodule ts3j updated: dce4e68150...0e5724b877