KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.swing.JComboBox JavaDoc;
19 import javax.swing.JTextField JavaDoc;
20
21 import org.columba.api.plugin.IExtensionHandler;
22 import org.columba.core.filter.FilterCriteria;
23 import org.columba.mail.filter.MailFilterCriteria;
24 import org.columba.mail.gui.config.filter.CriteriaList;
25
26 public class CustomHeaderfieldCriteriaRow extends DefaultCriteriaRow {
27     private JComboBox JavaDoc matchComboBox;
28
29     private JTextField JavaDoc patternTextField;
30
31     private JTextField JavaDoc headerTextField;
32
33     public CustomHeaderfieldCriteriaRow(IExtensionHandler pluginHandler,
34             CriteriaList criteriaList, FilterCriteria c) {
35         super(pluginHandler, criteriaList, c);
36     }
37
38     public void updateComponents(boolean b) {
39         super.updateComponents(b);
40
41         if (b) {
42             matchComboBox.setSelectedItem(criteria.getCriteriaString());
43             patternTextField.setText(criteria.getPatternString());
44             headerTextField.setText(new MailFilterCriteria(criteria)
45                     .getHeaderfieldString());
46         } else {
47             criteria
48                     .setCriteriaString((String JavaDoc) matchComboBox.getSelectedItem());
49             criteria.setPatternString((String JavaDoc) patternTextField.getText());
50             new MailFilterCriteria(criteria)
51                     .setHeaderfieldString((String JavaDoc) headerTextField.getText());
52         }
53     }
54
55     public void initComponents() {
56         super.initComponents();
57
58         headerTextField = new JTextField JavaDoc("header", 12);
59
60         addComponent(headerTextField);
61
62         matchComboBox = new JComboBox JavaDoc();
63         matchComboBox.addItem("contains");
64         matchComboBox.addItem("contains not");
65
66         /*
67          * matchComboBox.addItem("is"); matchComboBox.addItem("is not");
68          * matchComboBox.addItem("begins with"); matchComboBox.addItem("ends
69          * with");
70          */

71         addComponent(matchComboBox);
72
73         patternTextField = new JTextField JavaDoc("pattern", 12);
74
75         addComponent(patternTextField);
76     }
77 }
78
Popular Tags