KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > filter > plugins > ColorMessageFilterAction


1 package org.columba.mail.filter.plugins;
2
3 import java.awt.Color JavaDoc;
4
5 import org.columba.api.command.ICommand;
6 import org.columba.core.filter.AbstractFilterAction;
7 import org.columba.core.filter.FilterAction;
8 import org.columba.core.filter.IFilterAction;
9 import org.columba.core.folder.api.IFolder;
10 import org.columba.mail.command.MailFolderCommandReference;
11 import org.columba.mail.folder.command.ColorMessageCommand;
12
13
14 /**
15  * This Filter Action colors a message with a specified color. The action
16  * retrieves the integer attribute "<b>rgb</b>" from the filter action as
17  * the color to color the message with. In order to keep the memory consumtion
18  * up, it creates the <code>Color</code> object by using the <code>ColorFactory</code>.
19  * The message is colored by setting the "<b>columba.color</b>" header.
20  *
21  * @author redsolo
22  */

23 public class ColorMessageFilterAction extends AbstractFilterAction {
24     /** {@inheritDoc} */
25     public ICommand getCommand(IFilterAction filterAction, IFolder srcFolder,
26         Object JavaDoc[] uids) throws Exception JavaDoc {
27         int rgb = filterAction.getIntegerWithDefault("rgb", Color.black.getRGB());
28
29         // create reference
30
MailFolderCommandReference r = new MailFolderCommandReference(srcFolder, uids);
31         r.setColorValue(rgb);
32
33         // create command
34
return new ColorMessageCommand(r);
35     }
36 }
37
Popular Tags