Example #1
0
 public FriendTree(LeftSidebar sb, RobonoboFrame frame) {
   super(new FriendTreeModel(frame), frame);
   this.sideBar = sb;
   getModel().setTree(this);
   normalFont = RoboFont.getFont(12, false);
   boldFont = RoboFont.getFont(12, true);
   setName("robonobo.playlist.tree");
   setAlignmentX(0.0f);
   setRootVisible(true);
   collapseRow(0);
   rootIcon = createImageIcon("/icon/friends.png");
   addFriendsIcon = createImageIcon("/icon/add_friends.png");
   friendIcon = createImageIcon("/icon/friend.png");
   playlistIcon = createImageIcon("/icon/playlist.png");
   libraryIcon = createImageIcon("/icon/home.png");
   // Special playlist icons
   specIcons.put("loves", createImageIcon("/icon/heart-small.png"));
   specIcons.put("radio", createImageIcon("/icon/radio-small.png"));
   setCellRenderer(new CellRenderer());
   setSelectionModel(new SelectionModel());
   getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
   addTreeSelectionListener(new SelectionListener());
   // This is required for tooltips to work
   ToolTipManager.sharedInstance().registerComponent(this);
 }
  /**
   * Initializes custom contact action buttons.
   *
   * @param contactActionButtons the list of buttons to initialize
   * @param gridX the X grid of the first button
   * @param xBounds the x bounds of the first button
   * @return the new grid X coordinate after adding all the buttons
   */
  private int initGroupActionButtons(
      Collection<SIPCommButton> contactActionButtons, int gridX, int xBounds) {
    // Reinit the labels to take the whole horizontal space.
    addLabels(gridX + contactActionButtons.size());

    Iterator<SIPCommButton> actionsIter = contactActionButtons.iterator();
    while (actionsIter.hasNext()) {
      final SIPCommButton actionButton = actionsIter.next();

      // We need to explicitly remove the buttons from the tooltip manager,
      // because we're going to manager the tooltip ourselves in the
      // DefaultTreeContactList class. We need to do this in order to have
      // a different tooltip for every button and for non button area.
      ToolTipManager.sharedInstance().unregisterComponent(actionButton);

      if (customActionButtonsUIGroup == null)
        customActionButtonsUIGroup = new LinkedList<JButton>();

      customActionButtonsUIGroup.add(actionButton);

      xBounds += addButton(actionButton, ++gridX, xBounds, false);
    }

    return gridX;
  }
 private static JTree createTree() {
   JTree resultsTree = new JTree();
   resultsTree.setName("TREEVIEW");
   resultsTree.setRootVisible(false);
   resultsTree.setEditable(false);
   resultsTree.setShowsRootHandles(true);
   resultsTree.setCellRenderer(new FailureCellRenderer());
   ToolTipManager tipManager = ToolTipManager.sharedInstance();
   tipManager.registerComponent(resultsTree);
   resultsTree.addKeyListener(new EnterPressListener());
   return resultsTree;
 }
 @Override
 public void dispose() {
   synchronized (lock) {
     isDisposed = true;
     ToolTipManager.sharedInstance().unregisterComponent(myTree);
     myModelTracker.removeListener(this);
     myUpdateAlarm.cancelAllRequests();
     if (myUsagePreviewPanel != null) {
       UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS =
           ((Splitter) myUsagePreviewPanel.getParent()).getProportion();
       myUsagePreviewPanel = null;
     }
   }
 }
  // ===============================================================
  // ===============================================================
  private void buildTree() {
    //  Create the nodes.
    root = new DefaultMutableTreeNode(server);
    createThreadsNodes();

    //	Create the tree that allows one selection at a time.
    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    //	Create Tree and Tree model
    treeModel = new DefaultTreeModel(root);
    setModel(treeModel);

    // Enable tool tips.
    ToolTipManager.sharedInstance().registerComponent(this);

    //  Set the icon for leaf nodes.
    renderer = new TangoRenderer();
    setCellRenderer(renderer);

    //	Listen for collapse tree
    addTreeExpansionListener(
        new TreeExpansionListener() {
          public void treeCollapsed(TreeExpansionEvent e) {
            // collapsedPerformed(e);
          }

          public void treeExpanded(TreeExpansionEvent e) {
            // expandedPerformed(e);
          }
        });
    //	Add Action listener
    addMouseListener(
        new java.awt.event.MouseAdapter() {

          public void mousePressed(java.awt.event.MouseEvent evt) {
            treeMousePressed(evt);
          }

          public void mouseReleased(java.awt.event.MouseEvent evt) {
            treeMouseReleased(evt);
          }

          public void mouseClicked(java.awt.event.MouseEvent evt) {
            treeMouseClicked(evt);
          }
        });
  }
  /** Constructor. */
  public DatasetTreeView() {
    // the catalog tree
    tree =
        new JTree() {
          public JToolTip createToolTip() {
            return new MultilineTooltip();
          }
        };
    tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode(null, false)));
    tree.setCellRenderer(new MyTreeCellRenderer());

    tree.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            int selRow = tree.getRowForLocation(e.getX(), e.getY());
            if (selRow != -1) {
              TreeNode node = (TreeNode) tree.getLastSelectedPathComponent();
              if (node instanceof VariableNode) {
                VariableIF v = ((VariableNode) node).var;
                firePropertyChangeEvent(new PropertyChangeEvent(this, "Selection", null, v));
              }
            }

            if ((selRow != -1) && (e.getClickCount() == 2)) {
              // acceptSelected();
            }
          }
        });

    tree.putClientProperty("JTree.lineStyle", "Angled");
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setToggleClickCount(1);
    ToolTipManager.sharedInstance().registerComponent(tree);

    // layout
    setLayout(new BorderLayout());
    add(new JScrollPane(tree), BorderLayout.CENTER);
  }
  /** Inializes button tool tips. */
  private void initButtonToolTips() {
    callButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));
    callVideoButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.VIDEO_CALL"));
    desktopSharingButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SHARE_DESKTOP"));
    chatButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SEND_MESSAGE"));
    addContactButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT"));

    // We need to explicitly remove the buttons from the tooltip manager,
    // because we're going to manager the tooltip ourselves in the
    // DefaultTreeContactList class. We need to do this in order to have
    // a different tooltip for every button and for non button area.
    ToolTipManager ttManager = ToolTipManager.sharedInstance();
    ttManager.unregisterComponent(callButton);
    ttManager.unregisterComponent(callVideoButton);
    ttManager.unregisterComponent(desktopSharingButton);
    ttManager.unregisterComponent(chatButton);
    ttManager.unregisterComponent(addContactButton);
  }