KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.awt.Color JavaDoc;
21
22 import org.columba.api.command.ICommandReference;
23 import org.columba.api.command.IWorkerStatusController;
24 import org.columba.core.command.Command;
25 import org.columba.core.command.StatusObservableImpl;
26 import org.columba.core.command.Worker;
27 import org.columba.core.gui.base.ColorFactory;
28 import org.columba.mail.command.IMailFolderCommandReference;
29 import org.columba.mail.folder.IMailbox;
30
31 /**
32  * Mark selected messages with specific variant.
33  * <p>
34  *
35  * Variant can be: - read/unread - flagged/unflagged - expunged/unexpunged -
36  * answered
37  *
38  * @author fdietz
39  */

40 public class ColorMessageCommand extends Command {
41
42     /**
43      * Constructor for MarkMessageCommand.
44      *
45      * @param frameMediator
46      * @param references
47      */

48     public ColorMessageCommand(ICommandReference reference) {
49         super(reference);
50     }
51
52     /**
53      * @see org.columba.api.command.Command#execute(Worker)
54      */

55     public void execute(IWorkerStatusController worker) throws Exception JavaDoc {
56
57         // get array of source references
58
IMailFolderCommandReference r = (IMailFolderCommandReference) getReference();
59
60         // get array of message UIDs
61
Object JavaDoc[] uids = r.getUids();
62
63         // get source folder
64
IMailbox srcFolder = (IMailbox) r.getSourceFolder();
65
66         // register for status events
67
((StatusObservableImpl) srcFolder.getObservable()).setWorker(worker);
68
69         // which kind of color?
70
int rgbValue = r.getColorValue();
71
72         // saving last selected Message to the folder
73
srcFolder.setLastSelection(uids[0]);
74
75         // get color from factory
76
// ->factory shares color objects to save memory
77
Color JavaDoc color = ColorFactory.getColor(rgbValue);
78
79         // for each message
80
for (int j = 0; j < uids.length; j++) {
81             // set columba.color flag
82
srcFolder.setAttribute(uids[j], "columba.color", color);
83         }
84
85     }
86 }
Popular Tags