final JSplitPane splitPane = new JSplitPane();
splitPane.setContinuousLayout(true);
main.add(splitPane, cc.xy(1, 1));
final SingleAndDoubleClickTreeUI treeUI = new SingleAndDoubleClickTreeUI(SingleAndDoubleClickTreeUI.AUTO_COLLAPSE_EXPAND, null);
mRootNode = createSelectionTree();
mSelectionTree = new JTree(mRootNode) {
public void updateUI() {
setUI(treeUI);
invalidate();
}
};
mSelectionTree.setRootVisible(false);
mSelectionTree.setShowsRootHandles(true);
mSelectionTree.getSelectionModel().setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION);
mSelectionTree.setCellRenderer(new SettingNodeCellRenderer());
mSelectionTree.setSelectionRow(1);
mSelectionTree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent evt) {
showSettingsPanelForSelectedNode();
}
});
mSelectionTree.setRowHeight(17);
JScrollPane scrollPane = new JScrollPane(mSelectionTree);
scrollPane.setMinimumSize(new Dimension(150, 0));
scrollPane.setBorder(null);
splitPane.setLeftComponent(scrollPane);
splitPane.setDividerLocation(Settings.propSettingsDialogDividerLocation
.getInt());
int categoryCount = mRootNode.getChildCount();
// Let the tree collapse
for (int i = 1; i <= categoryCount; i++) {
mSelectionTree.collapseRow(i);
}
mSettingsPn = new JPanel(new BorderLayout());
splitPane.setRightComponent(mSettingsPn);
ButtonBarBuilder2 builder = new ButtonBarBuilder2();
mHelpBt = new JButton(mLocalizer.msg("help", "Online help"));
mHelpBt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Launch.openURL(mHelpBt.getToolTipText());
}
});
builder.addButton(mHelpBt);
JButton okBt = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
okBt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
saveSettingsTab();
saveSettings();
invalidateTree();
close();
}
});
mDialog.getRootPane().setDefaultButton(okBt);
JButton cancelBt = new JButton(Localizer
.getLocalization(Localizer.I18N_CANCEL));
cancelBt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
cancelSettings();
close();
}
});
JButton applyBt = new JButton(mLocalizer.msg("apply", "Apply"));
applyBt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
saveSettings();
invalidateTree();
Settings.handleChangedSettings();
showSettingsPanelForSelectedNode();
}
});
builder.addGlue();
builder.addButton(new JButton[] { okBt, cancelBt, applyBt });
main.add(builder.getPanel(), cc.xy(1, 3));
mDialog.pack();
if (selectedTabId == null) {
selectedTabId = SettingsItem.CHANNELS;
}
SettingNode n = findSettingNodeById((SettingNode) mRootNode, selectedTabId);
if (n == null) {
n = findSettingNodeByPath((SettingNode) mRootNode, selectedTabId);
}
if (n != null) {
showSettingsPanelForNode(n);
TreePath selectedPath = new TreePath(n.getPath());
mSelectionTree.setSelectionPath(selectedPath);
mSelectionTree.makeVisible(selectedPath);
treeUI.setLastSelectedPath(selectedPath);
// always expand plugin management node initially
if (selectedTabId.equals(SettingsItem.PLUGINS)) {
mSelectionTree.expandPath(selectedPath);
}
} else {