Beispiel #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());
 }
Beispiel #2
0
 @Override
 public String getToolTipText(MouseEvent evt) {
   Point p = evt.getPoint();
   TreePath tp = getClosestPathForLocation(p.x, p.y);
   Object node = tp.getLastPathComponent();
   if (node instanceof PlaylistTreeNode) {
     PlaylistTreeNode ptn = (PlaylistTreeNode) node;
     int unseen = ptn.numUnseenTracks;
     if (unseen > 0) {
       String nt = numItems(unseen, "new track");
       if (ptn.hasComments) {
         // html allows us to have linebreaks
         return "<html>" + nt + "<br>Unread comments</html>";
       } else return nt;
     }
     if (ptn.hasComments) return "Unread comments";
   } else if (node instanceof LibraryTreeNode) {
     LibraryTreeNode ltn = (LibraryTreeNode) node;
     int unseen = ltn.numUnseenTracks;
     if (unseen > 0) {
       String nt = numItems(unseen, "new track");
       if (ltn.hasComments) {
         // html allows us to have linebreaks
         return "<html>" + nt + "<br>Unread comments</html>";
       } else return nt;
     }
     if (ltn.hasComments) return "Unread comments";
   }
   return null;
 }