/**
   * Returns the preferred size of this component.
   *
   * @return the preferred size of this component
   */
  public Dimension getPreferredSize() {
    Dimension preferredSize = new Dimension();
    int preferredHeight;

    if (treeNode instanceof ContactNode) {
      UIContact contact = ((ContactNode) treeNode).getContactDescriptor();

      preferredHeight = contact.getPreferredHeight();

      if (preferredHeight > 0) preferredSize.height = preferredHeight;
      else if (contact instanceof ShowMoreContact) preferredSize.height = 20;
      else if (isSelected && treeContactList.isContactButtonsVisible()) preferredSize.height = 70;
      else preferredSize.height = 35;
    } else if (treeNode instanceof GroupNode) {
      UIGroup group = ((GroupNode) treeNode).getGroupDescriptor();

      preferredHeight = group.getPreferredHeight();

      if (isSelected && customActionButtonsUIGroup != null && !customActionButtonsUIGroup.isEmpty())
        preferredSize.height = 70;
      else if (preferredHeight > 0) preferredSize.height = preferredHeight;
      else preferredSize.height = 20;
    }

    return preferredSize;
  }
  /**
   * Initializes buttons panel.
   *
   * @param uiGroup the <tt>UIGroup</tt> for which we initialize the button panel
   */
  private void initButtonsPanel(UIGroup uiGroup) {
    if (!isSelected) return;

    int x = (statusIcon == null ? 0 : statusIcon.getIconWidth()) + LEFT_BORDER + H_GAP;
    int gridX = 0;

    // The list of the actions
    // we will create a button for every action
    Collection<SIPCommButton> contactActions = uiGroup.getCustomActionButtons();

    int lastGridX = gridX;
    if (contactActions != null && contactActions.size() > 0) {
      lastGridX = initGroupActionButtons(contactActions, gridX, x);
    } else {
      addLabels(gridX);
    }

    if (lastAddedButton != null) setButtonBg(lastAddedButton, lastGridX, true);

    this.setBounds(0, 0, treeContactList.getWidth(), getPreferredSize().height);
  }