예제 #1
1
  /** Initializes contained components. */
  private void initComponents() {
    final SimpleDateFormat format = new SimpleDateFormat("mm:ss");
    final Calendar c = Calendar.getInstance();
    final JLabel counter = new JLabel();

    counter.setForeground(Color.red);
    counter.setFont(counter.getFont().deriveFont((float) (counter.getFont().getSize() + 5)));

    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    GridBagConstraints constraints = new GridBagConstraints();

    JLabel messageLabel =
        new JLabel(
            GuiActivator.getResources().getI18NString("service.gui.security.SECURITY_ALERT"));

    messageLabel.setForeground(Color.WHITE);

    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 0;
    add(messageLabel, constraints);

    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 1;
    add(counter, constraints);

    ZrtpControl zrtpControl = null;
    if (securityControl instanceof ZrtpControl) zrtpControl = (ZrtpControl) securityControl;

    long initialSeconds = 0;

    if (zrtpControl != null) initialSeconds = zrtpControl.getTimeoutValue();

    c.setTimeInMillis(initialSeconds);

    counter.setText(format.format(c.getTime()));

    if (initialSeconds > 0)
      timer.schedule(
          new TimerTask() {
            @Override
            public void run() {
              if (c.getTimeInMillis() - 1000 > 0) {
                c.add(Calendar.SECOND, -1);
                counter.setText(format.format(c.getTime()));
              }
            }
          },
          1000,
          1000);
  }
예제 #2
0
  /**
   * Creates the <tt>Component</tt> hierarchy of the area of status-related information such as
   * <tt>CallPeer</tt> display name, call duration, security status.
   *
   * @return the root of the <tt>Component</tt> hierarchy of the area of status-related information
   *     such as <tt>CallPeer</tt> display name, call duration, security status
   */
  private Component createStatusBar() {
    // stateLabel
    callStatusLabel.setForeground(Color.WHITE);
    dtmfLabel.setForeground(Color.WHITE);
    callStatusLabel.setText(callPeer.getState().getLocalizedStateString());

    PeerStatusPanel statusPanel = new PeerStatusPanel(new GridBagLayout());

    GridBagConstraints constraints = new GridBagConstraints();

    constraints.gridx = 0;
    constraints.gridy = 0;
    statusPanel.add(securityStatusLabel, constraints);
    initSecurityStatusLabel();

    constraints.gridx++;
    statusPanel.add(holdStatusLabel, constraints);

    constraints.gridx++;
    statusPanel.add(muteStatusLabel, constraints);

    constraints.gridx++;
    callStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 12));
    statusPanel.add(callStatusLabel, constraints);

    constraints.gridx++;
    constraints.weightx = 1f;
    statusPanel.add(dtmfLabel, constraints);

    return statusPanel;
  }
예제 #3
0
  /** Init visible components. */
  private void init() {
    TransparentPanel panel = new TransparentPanel(new BorderLayout());

    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // Title label
    JLabel titleLabel =
        new JLabel(GuiActivator.getResources().getI18NString("service.gui.avatar.RECENT_ICONS"));
    titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));

    // fix for displaying text in menu
    // when using a dark OS theme (as default one in ubuntu)
    titleLabel.setForeground(new JMenuItem().getForeground());

    panel.add(titleLabel, BorderLayout.NORTH);

    // Init recent images grid
    TransparentPanel recentImagesGrid = new TransparentPanel();
    recentImagesGrid.setLayout(new GridLayout(0, IMAGES_PER_COLUMN));

    Dimension thumbsize = new Dimension(THUMB_WIDTH, THUMB_HEIGHT);
    for (int i = 0; i < MAX_STORED_IMAGES; i++) {
      this.recentImagesButtons[i] = new SIPCommButton(null);
      this.recentImagesButtons[i].setBorder(BorderFactory.createEtchedBorder());
      this.recentImagesButtons[i].setMaximumSize(thumbsize);
      this.recentImagesButtons[i].setMinimumSize(thumbsize);
      this.recentImagesButtons[i].setPreferredSize(thumbsize);
      this.recentImagesButtons[i].addActionListener(this);
      this.recentImagesButtons[i].setName("" + i);
      recentImagesGrid.add(this.recentImagesButtons[i]);
    }

    panel.add(recentImagesGrid, BorderLayout.CENTER);

    // Action buttons
    TransparentPanel buttonsPanel = new TransparentPanel();
    buttonsPanel.setLayout(new GridLayout(0, 1));

    // we use this menu item just to get its foreground color.
    Color linkColor = new JMenuItem().getForeground();

    addActionButton(
        buttonsPanel,
        this,
        GuiActivator.getResources().getI18NString("service.gui.avatar.CHOOSE_ICON"),
        CHOSE_BUTTON_NAME,
        linkColor);
    addActionButton(
        buttonsPanel,
        this,
        GuiActivator.getResources().getI18NString("service.gui.avatar.REMOVE_ICON"),
        REMOVE_BUTTON_NAME,
        linkColor);
    addActionButton(
        buttonsPanel,
        this,
        GuiActivator.getResources().getI18NString("service.gui.avatar.CLEAR_RECENT"),
        CLEAR_BUTTON_NAME,
        linkColor);

    panel.add(buttonsPanel, BorderLayout.SOUTH);

    this.setLayout(new BorderLayout());
    this.add(panel, BorderLayout.CENTER);
  }
  /**
   * 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;
  }