m_componentTree = new JTree(model) {
public String getToolTipText(MouseEvent e) {
if ((getRowForLocation(e.getX(), e.getY())) == -1) {
return null;
}
TreePath currPath = getPathForLocation(e.getX(), e.getY());
if (currPath.getLastPathComponent() instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode node =
(DefaultMutableTreeNode)currPath.getLastPathComponent();
if (node.isLeaf()) {
JTreeLeafDetails leaf = (JTreeLeafDetails)node.getUserObject();
return leaf.getToolTipText();
}
}
return null;
}
};
m_componentTree.setEnabled(true);
m_componentTree.setToolTipText("");
m_componentTree.setRootVisible(false);
m_componentTree.setShowsRootHandles(true);
m_componentTree.setCellRenderer(new BeanIconRenderer());
DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
m_componentTree.setSelectionModel(selectionModel);
m_componentTree.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (((e.getModifiers() & InputEvent.BUTTON1_MASK)
!= InputEvent.BUTTON1_MASK) || e.isAltDown()) {
boolean clearSelection = true;
/*TreePath path =
m_componentTree.getPathForLocation(e.getX(), e.getY());
if (path != null) {
DefaultMutableTreeNode tNode =
(DefaultMutableTreeNode)path.getLastPathComponent();
if (tNode.isLeaf()) {
System.out.println("Rick click selection");
// m_componentTree.setSelectionPath(path);
}
}*/
if (clearSelection) {
// right click cancels selected component
m_toolBarBean = null;
m_mode = NONE;
KnowledgeFlowApp.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
m_componentTree.clearSelection();
}
}
TreePath p = m_componentTree.getSelectionPath();
if (p != null) {
if (p.getLastPathComponent() instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode tNode = (DefaultMutableTreeNode)p.getLastPathComponent();
if (tNode.isLeaf()) {
// System.err.println("Selected : " + tNode.getUserObject().toString());
Object userObject = tNode.getUserObject();
if (userObject instanceof JTreeLeafDetails) {