KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.swing.JComboBox JavaDoc;
21
22 import org.columba.api.plugin.IExtensionHandler;
23 import org.columba.core.filter.FilterCriteria;
24 import org.columba.core.gui.base.ColorComboBox;
25 import org.columba.core.gui.base.ColorItem;
26 import org.columba.mail.gui.config.filter.CriteriaList;
27
28 /**
29  * A criteria row for Color filter.
30  *
31  * The user can select that either the message has or has not a specific color.
32  *
33  * @author redsolo
34  */

35 public class ColorCriteriaRow extends DefaultCriteriaRow {
36     private ColorComboBox colorComboBox;
37
38     private JComboBox JavaDoc matchComboBox;
39
40     /**
41      * A criteria row for the color filter.
42      *
43      * @param pluginHandler
44      * a plugin handler
45      * @param criteriaList
46      * the criteria list
47      * @param c
48      * the filter criteria to load/save data
49      */

50     public ColorCriteriaRow(IExtensionHandler pluginHandler,
51             CriteriaList criteriaList, FilterCriteria c) {
52         super(pluginHandler, criteriaList, c);
53     }
54
55     /** {@inheritDoc} */
56     public void initComponents() {
57         super.initComponents();
58
59         matchComboBox = new JComboBox JavaDoc();
60         matchComboBox.addItem("is");
61         matchComboBox.addItem("is not");
62
63         colorComboBox = new ColorComboBox();
64
65         addComponent(matchComboBox);
66         addComponent(colorComboBox);
67     }
68
69     /** {@inheritDoc} */
70     public void updateComponents(boolean b) {
71         super.updateComponents(b);
72
73         if (b) {
74             matchComboBox.setSelectedItem(criteria.getCriteriaString());
75
76             colorComboBox.setSelectedColor(criteria.getPatternString());
77             colorComboBox.setCustomColor(criteria.getIntegerWithDefault("rgb",
78                     Color.black.getRGB()));
79         } else {
80             criteria
81                     .setCriteriaString((String JavaDoc) matchComboBox.getSelectedItem());
82
83             ColorItem item = colorComboBox.getSelectedColorItem();
84             criteria.setPatternString(item.getName());
85             criteria.setInteger("rgb", item.getColor().getRGB());
86         }
87     }
88 }
89
Popular Tags