KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > composer > HeaderView


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.ndation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
package org.columba.mail.gui.composer;
17
18 import java.awt.event.ActionEvent JavaDoc;
19 import java.awt.event.ActionListener JavaDoc;
20 import java.util.Arrays JavaDoc;
21 import java.util.regex.Pattern JavaDoc;
22
23 import javax.swing.JButton JavaDoc;
24 import javax.swing.JPanel JavaDoc;
25 import javax.swing.JTextField JavaDoc;
26
27 import org.columba.mail.gui.composer.action.AddressbookAction;
28 import org.columba.mail.gui.composer.util.AddressCollector;
29 import org.columba.mail.util.MailResourceLoader;
30 import org.frapuccino.addresscombobox.CommaSeparatedAutoCompleter;
31 import org.frapuccino.addresscombobox.PatternSeparatedAutoCompleter;
32
33 import com.jgoodies.forms.layout.CellConstraints;
34
35 /**
36  *
37  * @author fdietz
38  */

39 public class HeaderView extends JPanel JavaDoc implements ActionListener JavaDoc {
40
41     private HeaderController controller;
42
43     private JButton JavaDoc toButton;
44
45     private JButton JavaDoc ccButton;
46
47     private JButton JavaDoc bccButton;
48
49     private JTextField JavaDoc toComboBox;
50
51     private JTextField JavaDoc ccComboBox;
52
53     private JTextField JavaDoc bccComboBox;
54
55     public HeaderView(HeaderController controller) {
56         super();
57
58         this.controller = controller;
59
60         initComponents();
61
62         // layoutComponents();
63
}
64
65     /**
66      * Init address autocompletion
67      *
68      */

69     public void initAutocompletion() {
70
71         AddressCollector addressCollector = AddressCollector.getInstance();
72
73         if (addressCollector != null) {
74             // pass contact data along to AddressComboBox
75
new EmailNameAutoCompleter(toComboBox, Arrays
76                     .asList(addressCollector.getAddresses()), Pattern.compile(","), true);
77             new EmailNameAutoCompleter(ccComboBox, Arrays
78                     .asList(addressCollector.getAddresses()), Pattern.compile(","), true);
79             new EmailNameAutoCompleter(bccComboBox, Arrays
80                     .asList(addressCollector.getAddresses()), Pattern.compile(","), true);
81
82         }
83     }
84
85     /**
86      *
87      */

88     public void layoutComponents(JPanel JavaDoc panel) {
89
90         CellConstraints cc = new CellConstraints();
91
92         panel.add(toButton, cc.xy(1, 3, CellConstraints.FILL,
93                 CellConstraints.DEFAULT));
94         panel.add(toComboBox, cc.xywh(3, 3, 5, 1));
95
96         panel.add(ccButton, cc.xy(1, 5, CellConstraints.FILL,
97                 CellConstraints.DEFAULT));
98         panel.add(ccComboBox, cc.xywh(3, 5, 5, 1));
99
100         panel.add(bccButton, cc.xy(1, 7, CellConstraints.FILL,
101                 CellConstraints.DEFAULT));
102         panel.add(bccComboBox, cc.xywh(3, 7, 5, 1));
103
104     }
105
106     protected void initComponents() {
107
108         toButton = new JButton JavaDoc("To:");
109         toButton.addActionListener(this);
110         ccButton = new JButton JavaDoc("Cc:");
111         ccButton.addActionListener(this);
112         bccButton = new JButton JavaDoc("Bcc:");
113         bccButton.addActionListener(this);
114
115         toComboBox = new JTextField JavaDoc();
116         toComboBox.setToolTipText(MailResourceLoader.getString(
117                 "dialog", "composer", "recipient_separator"));
118         ccComboBox = new JTextField JavaDoc();
119         ccComboBox.setToolTipText(MailResourceLoader.getString(
120                 "dialog", "composer", "recipient_separator"));
121         bccComboBox = new JTextField JavaDoc();
122         bccComboBox.setToolTipText(MailResourceLoader.getString(
123                 "dialog", "composer", "recipient_separator"));
124     }
125
126     /**
127      * @return Returns the bccComboBox.
128      */

129     public JTextField JavaDoc getBccComboBox() {
130         return bccComboBox;
131     }
132
133     /**
134      * @return Returns the ccComboBox.
135      */

136     public JTextField JavaDoc getCcComboBox() {
137         return ccComboBox;
138     }
139
140     /**
141      * @return Returns the toComboBox.
142      */

143     public JTextField JavaDoc getToComboBox() {
144         return toComboBox;
145     }
146
147     /**
148      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
149      */

150     public void actionPerformed(ActionEvent JavaDoc arg0) {
151         new AddressbookAction(controller.getComposerController())
152                 .actionPerformed(null);
153
154     }
155 }
Popular Tags