/**
   * Returns this panel that has been configured to display the meta contact and meta contact group
   * cells.
   *
   * @param tree the source tree
   * @param value the tree node
   * @param selected indicates if the node is selected
   * @param expanded indicates if the node is expanded
   * @param leaf indicates if the node is a leaf
   * @param row indicates the row number of the node
   * @param hasFocus indicates if the node has the focus
   * @return this panel
   */
  public Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean selected,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus) {
    this.treeContactList = (TreeContactList) tree;
    this.row = row;
    this.isSelected = selected;
    this.treeNode = (TreeNode) value;

    this.rightLabel.setIcon(null);

    DefaultTreeContactList contactList = (DefaultTreeContactList) tree;

    setBorder();
    addLabels(1);

    // Set background color.
    if (contactList instanceof TreeContactList) {
      ContactListFilter filter = ((TreeContactList) contactList).getCurrentFilter();

      if (filter != null
          && filter.equals(TreeContactList.historyFilter)
          && value instanceof ContactNode
          && row % 2 == 0) {
        setBackground(Constants.CALL_HISTORY_EVEN_ROW_COLOR);
      } else {
        setBackground(Color.WHITE);
      }
    }

    // Make appropriate adjustments for contact nodes and group nodes.
    if (value instanceof ContactNode) {
      UIContactImpl contact = ((ContactNode) value).getContactDescriptor();

      String displayName = contact.getDisplayName();

      if ((displayName == null || displayName.trim().length() < 1)
          && !(contact instanceof ShowMoreContact)) {
        displayName = GuiActivator.getResources().getI18NString("service.gui.UNKNOWN");
      }

      this.nameLabel.setText(displayName);

      if (statusIcon != null
          && contactList.isContactActive(contact)
          && statusIcon instanceof ImageIcon) ((ImageIcon) statusIcon).setImage(msgReceivedImage);
      else statusIcon = contact.getStatusIcon();

      this.statusLabel.setIcon(statusIcon);

      this.nameLabel.setFont(this.getFont().deriveFont(Font.PLAIN));

      if (contactForegroundColor != null) nameLabel.setForeground(contactForegroundColor);

      // Initializes status message components if the given meta contact
      // contains a status message.
      this.initDisplayDetails(contact.getDisplayDetails());

      if (this.treeContactList.isContactButtonsVisible()) this.initButtonsPanel(contact);

      int avatarWidth, avatarHeight;

      if (isSelected && treeContactList.isContactButtonsVisible()) {
        avatarWidth = EXTENDED_AVATAR_WIDTH;
        avatarHeight = EXTENDED_AVATAR_HEIGHT;
      } else {
        avatarWidth = AVATAR_WIDTH;
        avatarHeight = AVATAR_HEIGHT;
      }

      Icon avatar = contact.getAvatar(isSelected, avatarWidth, avatarHeight);

      if (avatar != null) {
        this.rightLabel.setIcon(avatar);
      }

      if (contact instanceof ShowMoreContact) {
        rightLabel.setFont(rightLabel.getFont().deriveFont(12f));
        rightLabel.setForeground(Color.GRAY);
        rightLabel.setText((String) contact.getDescriptor());
      } else {
        rightLabel.setFont(rightLabel.getFont().deriveFont(9f));
        rightLabel.setText("");
      }

      this.setToolTipText(contact.getDescriptor().toString());
    } else if (value instanceof GroupNode) {
      UIGroupImpl groupItem = ((GroupNode) value).getGroupDescriptor();

      this.nameLabel.setText(groupItem.getDisplayName());

      this.nameLabel.setFont(this.getFont().deriveFont(Font.BOLD));

      if (groupForegroundColor != null) this.nameLabel.setForeground(groupForegroundColor);

      this.remove(displayDetailsLabel);
      this.remove(callButton);
      this.remove(callVideoButton);
      this.remove(desktopSharingButton);
      this.remove(chatButton);
      this.remove(addContactButton);

      clearCustomActionButtons();

      statusIcon = expanded ? openedGroupIcon : closedGroupIcon;
      this.statusLabel.setIcon(expanded ? openedGroupIcon : closedGroupIcon);

      // We have no photo icon for groups.
      this.rightLabel.setIcon(null);
      this.rightLabel.setText("");

      if (groupItem.countChildContacts() >= 0) {
        rightLabel.setFont(rightLabel.getFont().deriveFont(9f));
        this.rightLabel.setForeground(Color.BLACK);
        this.rightLabel.setText(
            groupItem.countOnlineChildContacts() + "/" + groupItem.countChildContacts());
      }

      this.initDisplayDetails(groupItem.getDisplayDetails());
      this.initButtonsPanel(groupItem);
      this.setToolTipText(groupItem.getDescriptor().toString());
    }

    return this;
  }
  /** Creates a file conversation component. */
  public FileTransferConversationComponent() {
    imageLabel = new FileImageLabel();

    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 4;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.insets = new Insets(5, 5, 5, 5);

    add(imageLabel, constraints);
    imageLabel.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.DEFAULT_FILE_ICON)));

    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.gridwidth = 3;
    constraints.gridheight = 1;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.insets = new Insets(5, 5, 5, 5);

    add(titleLabel, constraints);
    titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 11f));

    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(0, 5, 5, 5);

    add(fileLabel, constraints);

    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(0, 5, 0, 5);
    constraints.fill = GridBagConstraints.NONE;

    add(errorIconLabel, constraints);
    errorIconLabel.setVisible(false);

    constraints.gridx = 2;
    constraints.gridy = 2;
    constraints.gridwidth = 2;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(0, 5, 0, 5);
    constraints.fill = GridBagConstraints.HORIZONTAL;

    add(errorArea, constraints);
    errorArea.setForeground(new Color(resources.getColor("service.gui.ERROR_FOREGROUND")));
    setTextAreaStyle(errorArea);
    errorArea.setVisible(false);

    constraints.gridx = 1;
    constraints.gridy = 3;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0.0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(0, 5, 0, 5);

    add(retryButton, constraints);
    retryButton.setText(GuiActivator.getResources().getI18NString("service.gui.RETRY"));
    retryButton.setVisible(false);

    constraints.gridx = 1;
    constraints.gridy = 3;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0.0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(0, 5, 0, 5);

    add(cancelButton, constraints);
    cancelButton.setText(GuiActivator.getResources().getI18NString("service.gui.CANCEL"));
    cancelButton.addActionListener(this);
    cancelButton.setVisible(false);

    constraints.gridx = 2;
    constraints.gridy = 3;
    constraints.gridwidth = GridBagConstraints.RELATIVE;
    constraints.gridheight = 1;
    constraints.weightx = 0.0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.EAST;
    constraints.insets = new Insets(0, 5, 0, 5);

    constraints.gridx = 3;
    constraints.gridy = 3;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0.0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.LINE_END;
    constraints.insets = new Insets(0, 5, 0, 5);

    add(progressPropertiesPanel, constraints);

    estimatedTimeLabel.setFont(estimatedTimeLabel.getFont().deriveFont(11f));
    estimatedTimeLabel.setVisible(false);
    progressSpeedLabel.setFont(progressSpeedLabel.getFont().deriveFont(11f));
    progressSpeedLabel.setVisible(false);

    progressPropertiesPanel.add(progressSpeedLabel);
    progressPropertiesPanel.add(estimatedTimeLabel);

    constraints.gridx = 1;
    constraints.gridy = 3;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0.0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(0, 5, 0, 5);
    constraints.fill = GridBagConstraints.NONE;

    add(acceptButton, constraints);
    acceptButton.setText(GuiActivator.getResources().getI18NString("service.gui.ACCEPT"));
    acceptButton.setVisible(false);

    constraints.gridx = 2;
    constraints.gridy = 3;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0.0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(0, 5, 0, 5);
    constraints.fill = GridBagConstraints.NONE;

    add(rejectButton, constraints);
    rejectButton.setText(GuiActivator.getResources().getI18NString("service.gui.REJECT"));
    rejectButton.setVisible(false);

    constraints.gridx = 1;
    constraints.gridy = 3;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0.0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(0, 5, 0, 5);
    constraints.fill = GridBagConstraints.NONE;

    add(openFileButton, constraints);
    openFileButton.setText(GuiActivator.getResources().getI18NString("service.gui.OPEN"));
    openFileButton.setVisible(false);
    openFileButton.addActionListener(this);

    constraints.gridx = 2;
    constraints.gridy = 3;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0.0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(0, 5, 0, 5);
    constraints.fill = GridBagConstraints.NONE;

    add(openFolderButton, constraints);
    openFolderButton.setText(GuiActivator.getResources().getI18NString("service.gui.OPEN_FOLDER"));
    openFolderButton.setVisible(false);
    openFolderButton.addActionListener(this);

    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.gridwidth = 3;
    constraints.gridheight = 1;
    constraints.weightx = 1.0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(0, 5, 0, 5);
    constraints.ipadx = 150;
    constraints.fill = GridBagConstraints.HORIZONTAL;

    add(progressBar, constraints);
    progressBar.setVisible(false);
    progressBar.setStringPainted(true);
  }
Пример #3
0
  /** Creating the configuration form */
  private void init() {
    ResourceManagementService resources = LoggingUtilsActivator.getResourceService();

    enableCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.ENABLE_DISABLE"));
    enableCheckBox.addActionListener(this);

    sipProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME"));
    sipProtocolCheckBox.addActionListener(this);

    jabberProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME"));
    jabberProtocolCheckBox.addActionListener(this);

    String rtpDescription =
        resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION");
    rtpProtocolCheckBox =
        new SIPCommCheckBox(
            resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP")
                + " "
                + rtpDescription);
    rtpProtocolCheckBox.addActionListener(this);
    rtpProtocolCheckBox.setToolTipText(rtpDescription);

    ice4jProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_ICE4J"));
    ice4jProtocolCheckBox.addActionListener(this);

    JPanel mainPanel = new TransparentPanel();

    add(mainPanel, BorderLayout.NORTH);

    mainPanel.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();

    enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    mainPanel.add(enableCheckBox, c);

    String label = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_DESCRIPTION");
    JLabel descriptionLabel = new JLabel(label);
    descriptionLabel.setToolTipText(label);
    enableCheckBox.setToolTipText(label);
    descriptionLabel.setForeground(Color.GRAY);
    descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8));
    c.gridy = 1;
    c.insets = new Insets(0, 25, 10, 0);
    mainPanel.add(descriptionLabel, c);

    final JPanel loggersButtonPanel = new TransparentPanel(new GridLayout(0, 1));

    loggersButtonPanel.setBorder(
        BorderFactory.createTitledBorder(resources.getI18NString("service.gui.PROTOCOL")));

    loggersButtonPanel.add(sipProtocolCheckBox);
    loggersButtonPanel.add(jabberProtocolCheckBox);
    loggersButtonPanel.add(rtpProtocolCheckBox);
    loggersButtonPanel.add(ice4jProtocolCheckBox);

    c.insets = new Insets(0, 20, 10, 0);
    c.gridy = 2;
    mainPanel.add(loggersButtonPanel, c);

    final JPanel advancedPanel = new TransparentPanel(new GridLayout(0, 2));

    advancedPanel.setBorder(
        BorderFactory.createTitledBorder(resources.getI18NString("service.gui.ADVANCED")));

    fileCountField.getDocument().addDocumentListener(this);
    fileSizeField.getDocument().addDocumentListener(this);

    fileCountLabel =
        new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_COUNT"));
    advancedPanel.add(fileCountLabel);
    advancedPanel.add(fileCountField);
    fileSizeLabel =
        new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_SIZE"));
    advancedPanel.add(fileSizeLabel);
    advancedPanel.add(fileSizeField);

    c.gridy = 3;
    mainPanel.add(advancedPanel, c);

    archiveButton = new JButton(resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON"));
    archiveButton.addActionListener(this);

    c = new GridBagConstraints();
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 4;
    mainPanel.add(archiveButton, c);

    if (!StringUtils.isNullOrEmpty(getUploadLocation())) {
      uploadLogsButton =
          new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON"));
      uploadLogsButton.addActionListener(this);

      c.insets = new Insets(10, 0, 0, 0);
      c.gridy = 5;
      mainPanel.add(uploadLogsButton, c);
    }
  }
  /** Initializes this panel. */
  private void init() {
    JPanel mainPanel = new TransparentPanel(new BorderLayout());

    mainPanel.setBorder(
        BorderFactory.createTitledBorder(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sipaccregwizz.CREATE_ACCOUNT_TITLE")));

    JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1));

    JPanel valuesPanel = new TransparentPanel(new GridLayout(0, 1));

    JLabel usernameLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.USERNAME"));

    JLabel displayNameLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sipaccregwizz.DISPLAY_NAME"));

    JLabel passLabel =
        new JLabel(Sip2SipAccRegWizzActivator.getResources().getI18NString("service.gui.PASSWORD"));

    JLabel retypePasswordLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.RETYPE_PASSWORD"));

    JLabel emailLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.EMAIL"));

    labelsPanel.add(displayNameLabel);
    labelsPanel.add(usernameLabel);
    labelsPanel.add(passLabel);
    labelsPanel.add(retypePasswordLabel);
    labelsPanel.add(emailLabel);

    valuesPanel.add(displayNameField);
    valuesPanel.add(usernameField);
    valuesPanel.add(passField);
    valuesPanel.add(retypePassField);
    valuesPanel.add(emailField);

    JLabel emailDescriptionLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.EMAIL_NOTE"),
            SwingConstants.CENTER);
    emailDescriptionLabel.setForeground(Color.GRAY);
    emailDescriptionLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8));
    emailDescriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 8, 10));

    initErrorArea();

    mainPanel.add(labelsPanel, BorderLayout.WEST);
    mainPanel.add(valuesPanel, BorderLayout.CENTER);
    mainPanel.add(emailDescriptionLabel, BorderLayout.SOUTH);

    this.add(mainPanel, BorderLayout.CENTER);

    JLabel infoLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.INFO_NOTE"),
            SwingConstants.RIGHT);
    infoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    infoLabel.setForeground(Color.GRAY);
    infoLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8));
    infoLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
    infoLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            Sip2SipAccRegWizzActivator.getBrowserLauncher().openURL("http://wiki.sip2sip.info");
          }
        });

    this.add(infoLabel, BorderLayout.SOUTH);
  }