001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.mail.folder.command;
019:
020: import org.columba.api.command.ICommandReference;
021: import org.columba.api.command.IWorkerStatusController;
022: import org.columba.core.command.Command;
023: import org.columba.core.command.StatusObservableImpl;
024: import org.columba.core.command.Worker;
025: import org.columba.mail.command.IMailFolderCommandReference;
026: import org.columba.mail.folder.IMailbox;
027:
028: /**
029: * Mark selected messages with specific variant.
030: * <p>
031: *
032: * Variant can be: - read/unread - flagged/unflagged - expunged/unexpunged -
033: * answered
034: *
035: * @author fdietz
036: */
037: public class MarkMessageCommand extends Command {
038:
039: public final static int MARK_AS_READ = 1;
040:
041: public final static int MARK_AS_UNREAD = -1;
042:
043: public final static int MARK_AS_FLAGGED = 2;
044:
045: public final static int MARK_AS_UNFLAGGED = -2;
046:
047: public final static int MARK_AS_EXPUNGED = 3;
048:
049: public final static int MARK_AS_UNEXPUNGED = -3;
050:
051: public final static int MARK_AS_ANSWERED = 4;
052:
053: public final static int MARK_AS_UNANSWERED = -4;
054:
055: public final static int MARK_AS_SPAM = 5;
056:
057: public final static int MARK_AS_NOTSPAM = -5;
058:
059: public final static int MARK_AS_DRAFT = 6;
060:
061: public final static int MARK_AS_NOTDRAFT = -6;
062:
063: public final static int MARK_AS_RECENT = 7;
064:
065: public final static int MARK_AS_NOTRECENT = -7;
066:
067: /**
068: * Constructor for MarkMessageCommand.
069: *
070: * @param frameMediator
071: * @param references
072: */
073: public MarkMessageCommand(ICommandReference reference) {
074: super (reference);
075: }
076:
077: /**
078: * @see org.columba.api.command.Command#execute(Worker)
079: */
080: public void execute(IWorkerStatusController worker)
081: throws Exception {
082:
083: /*
084: * // use wrapper class for easier handling of references array adapter =
085: * new FolderCommandAdapter( (MailFolderCommandReference[])
086: * getReferences()); // get array of source references
087: * MailFolderCommandReference[] r = adapter.getSourceFolderReferences();
088: */
089: IMailFolderCommandReference r = (IMailFolderCommandReference) getReference();
090:
091: // get array of message UIDs
092: Object[] uids = r.getUids();
093:
094: // get source folder
095: IMailbox srcFolder = (IMailbox) r.getSourceFolder();
096:
097: // register for status events
098: ((StatusObservableImpl) srcFolder.getObservable())
099: .setWorker(worker);
100:
101: // which kind of mark?
102: int markVariant = r.getMarkVariant();
103:
104: // saving last selected message to the folder
105: srcFolder.setLastSelection(uids[0]);
106:
107: // mark message
108: srcFolder.markMessage(uids, markVariant);
109:
110: }
111:
112: }
|