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

@@ -14,6 +14,7 @@ import javax.swing.JTree;
import javax.swing.JViewport;
import javax.swing.SwingUtilities;
import javax.swing.TransferHandler;
import javax.swing.plaf.basic.BasicTreeUI;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultTreeCellRenderer;
@@ -97,7 +98,15 @@ public final class ServerTreePanel extends JScrollPane {
root.setUserObject("Not connected");
this.tree = new DropIndicatorTree(treeModel);
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.setBackground(Theme.TREE_BG);
tree.setFont(Theme.UI_FONT);
@@ -437,6 +446,13 @@ public final class ServerTreePanel extends JScrollPane {
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
* the row rectangle, which stops short of the right-aligned icon strip and would