示例#1
0
 public void messageChanged(MessageChangedEvent e) {
   Message changedMessage = e.getMessage();
   for (int i = 0; i < messages.size(); ++i) {
     if (messages.get(i) == changedMessage) {
       fireTableRowsUpdated(i, i);
     }
   }
 }
示例#2
0
        public void messagesAdded(MessageCountEvent e) {
          try {
            // I don't think it matters where we put the new messages, but for the sanity of users
            // who don't sort, and because it's the cheapest option, we'll bung them at the end.
            Message[] newMessages = e.getMessages();

            // Work out where the new items will appear.
            final int firstNewRow = messages.size();
            final int lastNewRow = firstNewRow + newMessages.length - 1;

            // Actually insert the new items, and notify the listeners.
            messages.addAll(Arrays.asList(newMessages));
            fireTableRowsInserted(firstNewRow, lastNewRow);
          } catch (Exception ex) {
            ex.printStackTrace();
          }
        }
示例#3
0
  public void removeMessages(Message[] removedMessages) {
    try {
      // Translate the array of removed Message instances into a list of all the row indexes to be
      // removed from the model.
      // Assumes the list of removed messages is small.
      ArrayList<Integer> deadIndexes = new ArrayList<Integer>();
      for (Message message : removedMessages) {
        int deadIndex = messages.indexOf(message);
        if (deadIndex != -1) {
          deadIndexes.add(deadIndex);
        }
      }

      // Actually remove the rows, notifying the listeners as we go (rather than bother trying to
      // coalesce).
      for (int i = deadIndexes.size() - 1; i >= 0; --i) {
        int deadIndex = deadIndexes.get(i);
        messages.remove(deadIndex);
        fireTableRowsDeleted(deadIndex, deadIndex);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
示例#4
0
  public void scanWholeFolder() throws MessagingException {
    if (folder.isOpen() == false) {
      folder.open(Folder.READ_WRITE);
    }

    // Bulk-fetch the message envelopes.
    Message[] newMessages = folder.getMessages();
    FetchProfile fetchProfile = new FetchProfile();
    // FIXME: add CONTENT_INFO if we start to display the size
    // fetchProfile.add(FetchProfile.Item.CONTENT_INFO);
    fetchProfile.add(FetchProfile.Item.ENVELOPE);
    fetchProfile.add(FetchProfile.Item.FLAGS);
    folder.fetch(newMessages, fetchProfile);

    this.messages = new ArrayList<Message>();
    messages.addAll(Arrays.asList(newMessages));

    fireTableDataChanged();
  }
示例#5
0
 public int getRowCount() {
   return messages.size();
 }
示例#6
0
 public Message getMessage(int row) {
   return messages.get(row);
 }