01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //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;
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)
56: throws Exception {
57:
58: // get array of source references
59: IMailFolderCommandReference r = (IMailFolderCommandReference) getReference();
60:
61: // get array of message UIDs
62: Object[] uids = r.getUids();
63:
64: // get source folder
65: IMailbox srcFolder = (IMailbox) r.getSourceFolder();
66:
67: // register for status events
68: ((StatusObservableImpl) srcFolder.getObservable())
69: .setWorker(worker);
70:
71: // which kind of color?
72: int rgbValue = r.getColorValue();
73:
74: // saving last selected Message to the folder
75: srcFolder.setLastSelection(uids[0]);
76:
77: // get color from factory
78: // ->factory shares color objects to save memory
79: Color color = ColorFactory.getColor(rgbValue);
80:
81: // for each message
82: for (int j = 0; j < uids.length; j++) {
83: // set columba.color flag
84: srcFolder.setAttribute(uids[j], "columba.color", color);
85: }
86:
87: }
88: }
|