示例#1
0
 public void valueChanged(TreeSelectionEvent e) {
   TreePath tp = e.getNewLeadSelectionPath();
   if (tp == null) return;
   Object selNode = tp.getLastPathComponent();
   if (selNode instanceof ButtonTreeNode) {
     ButtonTreeNode btn = (ButtonTreeNode) selNode;
     btn.onClick();
     setSelectionPath(e.getOldLeadSelectionPath());
     return;
   }
   if (!(selNode instanceof SelectableTreeNode)) return;
   SelectableTreeNode stn = (SelectableTreeNode) selNode;
   if (stn.wantSelect()) {
     sideBar.clearSelectionExcept(FriendTree.this);
     // If this is a library or playlist node with comments, and the comments tab is showing,
     // mark the
     // comments as read
     FriendTreeModel m = getModel();
     if (stn instanceof LibraryTreeNode) {
       LibraryTreeNode ltn = (LibraryTreeNode) stn;
       ContentPanel cp = frame.mainPanel.getContentPanel("library/" + ltn.userId);
       // library content panel gets created on demand, so might be null
       if (cp != null && cp.tabPane.getSelectedIndex() == 1)
         m.markLibraryCommentsAsRead(ltn.userId);
     } else if (stn instanceof PlaylistTreeNode) {
       PlaylistTreeNode ptn = (PlaylistTreeNode) stn;
       long plId = ptn.getPlaylist().getPlaylistId();
       ContentPanel cp = frame.mainPanel.getContentPanel("playlist/" + plId);
       if (cp.tabPane.getSelectedIndex() == 1) m.markPlaylistCommentsAsRead(plId);
     }
     if (stn.handleSelect()) m.firePathToRootChanged(stn);
   } else setSelectionPath(e.getOldLeadSelectionPath());
 }