KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > folder > command > MarkMessageCommand


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.mail.folder.command;
19
20 import org.columba.api.command.ICommandReference;
21 import org.columba.api.command.IWorkerStatusController;
22 import org.columba.core.command.Command;
23 import org.columba.core.command.StatusObservableImpl;
24 import org.columba.core.command.Worker;
25 import org.columba.mail.command.IMailFolderCommandReference;
26 import org.columba.mail.folder.IMailbox;
27
28 /**
29  * Mark selected messages with specific variant.
30  * <p>
31  *
32  * Variant can be: - read/unread - flagged/unflagged - expunged/unexpunged -
33  * answered
34  *
35  * @author fdietz
36  */

37 public class MarkMessageCommand extends Command {
38
39     public final static int MARK_AS_READ = 1;
40
41     public final static int MARK_AS_UNREAD = -1;
42
43     public final static int MARK_AS_FLAGGED = 2;
44
45     public final static int MARK_AS_UNFLAGGED = -2;
46
47     public final static int MARK_AS_EXPUNGED = 3;
48
49     public final static int MARK_AS_UNEXPUNGED = -3;
50
51     public final static int MARK_AS_ANSWERED = 4;
52
53     public final static int MARK_AS_UNANSWERED = -4;
54
55     public final static int MARK_AS_SPAM = 5;
56
57     public final static int MARK_AS_NOTSPAM = -5;
58
59     public final static int MARK_AS_DRAFT = 6;
60
61     public final static int MARK_AS_NOTDRAFT = -6;
62
63     public final static int MARK_AS_RECENT = 7;
64
65     public final static int MARK_AS_NOTRECENT = -7;
66
67     /**
68      * Constructor for MarkMessageCommand.
69      *
70      * @param frameMediator
71      * @param references
72      */

73     public MarkMessageCommand(ICommandReference reference) {
74         super(reference);
75     }
76
77     /**
78      * @see org.columba.api.command.Command#execute(Worker)
79      */

80     public void execute(IWorkerStatusController worker) throws Exception JavaDoc {
81
82         /*
83          * // use wrapper class for easier handling of references array adapter =
84          * new FolderCommandAdapter( (MailFolderCommandReference[])
85          * getReferences()); // get array of source references
86          * MailFolderCommandReference[] r = adapter.getSourceFolderReferences();
87          */

88         IMailFolderCommandReference r = (IMailFolderCommandReference) getReference();
89
90         // get array of message UIDs
91
Object JavaDoc[] uids = r.getUids();
92
93         // get source folder
94
IMailbox srcFolder = (IMailbox) r.getSourceFolder();
95
96         // register for status events
97
((StatusObservableImpl) srcFolder.getObservable()).setWorker(worker);
98
99         // which kind of mark?
100
int markVariant = r.getMarkVariant();
101
102         // saving last selected message to the folder
103
srcFolder.setLastSelection(uids[0]);
104
105         // mark message
106
srcFolder.markMessage(uids, markVariant);
107
108     }
109
110 }
Popular Tags