001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.ndation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
016: package org.columba.mail.gui.composer;
017:
018: import java.awt.event.ActionEvent;
019: import java.awt.event.ActionListener;
020: import java.util.Arrays;
021: import java.util.regex.Pattern;
022:
023: import javax.swing.JButton;
024: import javax.swing.JPanel;
025: import javax.swing.JTextField;
026:
027: import org.columba.mail.gui.composer.action.AddressbookAction;
028: import org.columba.mail.gui.composer.util.AddressCollector;
029: import org.columba.mail.util.MailResourceLoader;
030: import org.frapuccino.addresscombobox.CommaSeparatedAutoCompleter;
031: import org.frapuccino.addresscombobox.PatternSeparatedAutoCompleter;
032:
033: import com.jgoodies.forms.layout.CellConstraints;
034:
035: /**
036: *
037: * @author fdietz
038: */
039: public class HeaderView extends JPanel implements ActionListener {
040:
041: private HeaderController controller;
042:
043: private JButton toButton;
044:
045: private JButton ccButton;
046:
047: private JButton bccButton;
048:
049: private JTextField toComboBox;
050:
051: private JTextField ccComboBox;
052:
053: private JTextField bccComboBox;
054:
055: public HeaderView(HeaderController controller) {
056: super ();
057:
058: this .controller = controller;
059:
060: initComponents();
061:
062: // layoutComponents();
063: }
064:
065: /**
066: * Init address autocompletion
067: *
068: */
069: public void initAutocompletion() {
070:
071: AddressCollector addressCollector = AddressCollector
072: .getInstance();
073:
074: if (addressCollector != null) {
075: // pass contact data along to AddressComboBox
076: new EmailNameAutoCompleter(toComboBox, Arrays
077: .asList(addressCollector.getAddresses()), Pattern
078: .compile(","), true);
079: new EmailNameAutoCompleter(ccComboBox, Arrays
080: .asList(addressCollector.getAddresses()), Pattern
081: .compile(","), true);
082: new EmailNameAutoCompleter(bccComboBox, Arrays
083: .asList(addressCollector.getAddresses()), Pattern
084: .compile(","), true);
085:
086: }
087: }
088:
089: /**
090: *
091: */
092: public void layoutComponents(JPanel panel) {
093:
094: CellConstraints cc = new CellConstraints();
095:
096: panel.add(toButton, cc.xy(1, 3, CellConstraints.FILL,
097: CellConstraints.DEFAULT));
098: panel.add(toComboBox, cc.xywh(3, 3, 5, 1));
099:
100: panel.add(ccButton, cc.xy(1, 5, CellConstraints.FILL,
101: CellConstraints.DEFAULT));
102: panel.add(ccComboBox, cc.xywh(3, 5, 5, 1));
103:
104: panel.add(bccButton, cc.xy(1, 7, CellConstraints.FILL,
105: CellConstraints.DEFAULT));
106: panel.add(bccComboBox, cc.xywh(3, 7, 5, 1));
107:
108: }
109:
110: protected void initComponents() {
111:
112: toButton = new JButton("To:");
113: toButton.addActionListener(this );
114: ccButton = new JButton("Cc:");
115: ccButton.addActionListener(this );
116: bccButton = new JButton("Bcc:");
117: bccButton.addActionListener(this );
118:
119: toComboBox = new JTextField();
120: toComboBox.setToolTipText(MailResourceLoader.getString(
121: "dialog", "composer", "recipient_separator"));
122: ccComboBox = new JTextField();
123: ccComboBox.setToolTipText(MailResourceLoader.getString(
124: "dialog", "composer", "recipient_separator"));
125: bccComboBox = new JTextField();
126: bccComboBox.setToolTipText(MailResourceLoader.getString(
127: "dialog", "composer", "recipient_separator"));
128: }
129:
130: /**
131: * @return Returns the bccComboBox.
132: */
133: public JTextField getBccComboBox() {
134: return bccComboBox;
135: }
136:
137: /**
138: * @return Returns the ccComboBox.
139: */
140: public JTextField getCcComboBox() {
141: return ccComboBox;
142: }
143:
144: /**
145: * @return Returns the toComboBox.
146: */
147: public JTextField getToComboBox() {
148: return toComboBox;
149: }
150:
151: /**
152: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
153: */
154: public void actionPerformed(ActionEvent arg0) {
155: new AddressbookAction(controller.getComposerController())
156: .actionPerformed(null);
157:
158: }
159: }
|