Ejemplo n.º 1
0
  /**
   * Returns list of <tt>ChatTransport</tt> (i.e. contact) that supports the specified
   * <tt>OperationSet</tt>.
   *
   * @param transports list of <tt>ChatTransport</tt>
   * @param opSetClass <tt>OperationSet</tt> to find
   * @return list of <tt>ChatTransport</tt> (i.e. contact) that supports the specified
   *     <tt>OperationSet</tt>.
   */
  private List<ChatTransport> getOperationSetForCapabilities(
      List<ChatTransport> transports, Class<? extends OperationSet> opSetClass) {
    List<ChatTransport> list = new ArrayList<ChatTransport>();

    for (ChatTransport transport : transports) {
      ProtocolProviderService protocolProvider = transport.getProtocolProvider();
      OperationSetContactCapabilities capOpSet =
          protocolProvider.getOperationSet(OperationSetContactCapabilities.class);
      OperationSetPersistentPresence presOpSet =
          protocolProvider.getOperationSet(OperationSetPersistentPresence.class);

      if (capOpSet == null) {
        list.add(transport);
      } else if (presOpSet != null) {
        Contact contact = presOpSet.findContactByID(transport.getName());

        if ((contact != null) && (capOpSet.getOperationSet(contact, opSetClass) != null)) {
          // It supports OpSet for at least one of its
          // ChatTransports
          list.add(transport);
        }
      }
    }

    return list;
  }
Ejemplo n.º 2
0
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      ProtocolProviderService pps = (ProtocolProviderService) value;
      OperationSetPresence presence = pps.getOperationSet(OperationSetPresence.class);

      if (presence != null) {
        byte[] protocolStatusImage = presence.getPresenceStatus().getStatusIcon();

        if (protocolStatusImage != null) {
          this.setIcon(new ImageIcon(protocolStatusImage));
        } else {
          this.setIcon(null);
        }
      }

      this.setText(pps.getAccountID().getDisplayName());

      if (isSelected) this.setBackground(table.getSelectionBackground());
      else this.setBackground(UIManager.getColor("Table.background"));

      return this;
    }