// Create help tree
rootNode = new HelpNode();
rootTreeNode = new DefaultMutableTreeNode();
DefaultTreeModel treeModel = new DefaultTreeModel(rootTreeNode);
helpTree = new JTree();
helpTree.setModel(treeModel);
helpTree.setRootVisible(false);
helpTree.setShowsRootHandles(true);
helpTree.addTreeSelectionListener(this);
// Renderer
DefaultTreeCellRenderer helpTreeRenderer = (DefaultTreeCellRenderer) helpTree.getCellRenderer();
helpTreeRenderer.setOpenIcon(resources.getIcon("folderIcon"));
helpTreeRenderer.setClosedIcon(resources.getIcon("folderIcon"));
helpTreeRenderer.setLeafIcon(resources.getIcon("leafIcon"));
createHelpContents();
// Create help search panel
// search tree
searchRootTreeNode = new DefaultMutableTreeNode();
searchTreeModel = new DefaultTreeModel(searchRootTreeNode);
searchTree = new JTree();
searchTree.setModel(searchTreeModel);
searchTree.setRootVisible(false);
searchTree.setShowsRootHandles(true);
searchTree.addTreeSelectionListener(this);
JScrollPane scrollSearchTree = new JScrollPane(searchTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
DefaultTreeCellRenderer searchTreeRenderer = (DefaultTreeCellRenderer) searchTree.getCellRenderer();
searchTreeRenderer.setOpenIcon(resources.getIcon("folderIcon"));
searchTreeRenderer.setClosedIcon(resources.getIcon("folderIcon"));
searchTreeRenderer.setLeafIcon(resources.getIcon("leafIcon"));
// search field
JToolBar toolbar = new JToolBar();
toolbar.setRollover(true);
toolbar.setFloatable(false);
bClearFilter = resources.getBox("clearFilter", this);
bClearFilter.setEnabled(false);
toolbar.add(bClearFilter);
bApplyFilter = resources.getBox("applyFilter", this);
toolbar.add(bApplyFilter);
JLabel searchTip = new JLabel(resources.getString("filter"));
searchField = new JTextField(15);
searchField.addKeyListener(
new KeyListener() {
public void keyPressed(KeyEvent keyEvent) {}
public void keyReleased(KeyEvent keyEvent) {
boolean enable = !searchField.getText().equals("");
bApplyFilter.setEnabled(enable);
bClearFilter.setEnabled(enable);
}
public void keyTyped(KeyEvent keyEvent) {}
}
);
searchField.addActionListener(this);
// HTML parser
htmlParser = new SourceForgeHTMLParser();
GridBagPanel helpSearchPanel = new GridBagPanel();
helpSearchPanel.addOnCurrentRow(searchTip);
helpSearchPanel.addOnCurrentRow(searchField, 3, true, false, false);
helpSearchPanel.addOnCurrentRow(toolbar,1,false, false, true);
helpSearchPanel.addOnCurrentRow(scrollSearchTree, 5, true, true, true);
// HELP PANES
JTabbedPane helpTreePane = new JTabbedPane();
// Tree contents pane
JScrollPane treeScrollPane = new JScrollPane(helpTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
helpTreePane.addTab(resources.getString("contents"),resources.getIcon("folderIcon"),treeScrollPane, resources.getString("contentsTips"));
// Search pane
helpTreePane.addTab(resources.getString("search"),resources.getIcon("searchIcon"),helpSearchPanel, resources.getString("searchTips"));
treeModel.reload();
// Create global frame
JSplitPane helpSlitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,helpTreePane ,scrollPane);
helpSlitPane.setDividerLocation(300);
Container content = getContentPane();