KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > config > filter > plugins > ColorActionConfig


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.gui.config.filter.plugins;
17
18 import java.awt.Color JavaDoc;
19
20 import org.columba.api.gui.frame.IFrameMediator;
21 import org.columba.core.filter.FilterAction;
22 import org.columba.core.gui.base.ColorComboBox;
23 import org.columba.core.gui.base.ColorFactory;
24 import org.columba.core.gui.base.ColorItem;
25 import org.columba.mail.gui.config.filter.ActionList;
26
27
28 /**
29  * A configuration panel for the <code>ColorMessageFilterAction</code>
30  * This displays a <code>JComboBox</code> filled with different colors.
31  *
32  * @author redsolo
33  */

34 public class ColorActionConfig extends DefaultActionRow {
35     private ColorComboBox colorsComboBox;
36
37     /**
38  * @param list the action list (?)
39  * @param action the action to configure.
40  */

41     public ColorActionConfig(IFrameMediator mediator,ActionList list, FilterAction action) {
42         super(mediator, list, action);
43     }
44
45     /** {@inheritDoc} */
46     public void initComponents() {
47         super.initComponents();
48         colorsComboBox = new ColorComboBox();
49
50         // Add the custom color item.
51
int rgb = getFilterAction().getIntegerWithDefault("rgb", Color.black.getRGB());
52         colorsComboBox.setCustomColor(ColorFactory.getColor(rgb));
53
54         addComponent(colorsComboBox);
55     }
56
57     /** {@inheritDoc} */
58     public void updateComponents(boolean b) {
59         super.updateComponents(b);
60
61         if (b) {
62             String JavaDoc string = getFilterAction().get("color");
63             colorsComboBox.setSelectedColor(string);
64         } else {
65             ColorItem object = (ColorItem) colorsComboBox.getSelectedColorItem();
66
67             if (object != null) {
68                 getFilterAction().setString("color", object.getName());
69                 getFilterAction().setInteger("rgb", object.getColor().getRGB());
70             }
71         }
72     }
73 }
74
Popular Tags