001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018:
019: package org.columba.mail.gui.config.account;
020:
021: import java.awt.Font;
022: import java.awt.GridBagConstraints;
023: import java.awt.GridBagLayout;
024: import java.awt.Insets;
025: import java.awt.event.ActionEvent;
026: import java.awt.event.ActionListener;
027: import java.io.File;
028: import java.text.MessageFormat;
029: import java.util.Iterator;
030: import java.util.LinkedList;
031: import java.util.List;
032: import java.util.logging.Logger;
033: import java.util.regex.Matcher;
034: import java.util.regex.Pattern;
035:
036: import javax.swing.BorderFactory;
037: import javax.swing.JButton;
038: import javax.swing.JCheckBox;
039: import javax.swing.JComboBox;
040: import javax.swing.JDialog;
041: import javax.swing.JLabel;
042: import javax.swing.JOptionPane;
043: import javax.swing.JPanel;
044: import javax.swing.JSpinner;
045: import javax.swing.JTextField;
046: import javax.swing.SpinnerNumberModel;
047: import javax.swing.SwingUtilities;
048:
049: import org.columa.core.config.IDefaultItem;
050: import org.columba.core.config.DefaultConfigDirectory;
051: import org.columba.core.gui.base.ButtonWithMnemonic;
052: import org.columba.core.gui.base.CheckBoxWithMnemonic;
053: import org.columba.core.gui.base.LabelWithMnemonic;
054: import org.columba.core.gui.exception.ExceptionHandler;
055: import org.columba.mail.config.AccountItem;
056: import org.columba.mail.config.ImapItem;
057: import org.columba.mail.config.IncomingItem;
058: import org.columba.mail.config.MailConfig;
059: import org.columba.mail.config.PopItem;
060: import org.columba.mail.imap.IImapServer;
061: import org.columba.mail.imap.IMAPServer;
062: import org.columba.mail.pop3.POP3Store;
063: import org.columba.mail.util.MailResourceLoader;
064: import org.columba.ristretto.imap.IMAPProtocol;
065: import org.columba.ristretto.pop3.POP3Protocol;
066:
067: import com.jgoodies.forms.builder.DefaultFormBuilder;
068: import com.jgoodies.forms.layout.FormLayout;
069:
070: /**
071: * @author fdietz
072: */
073: public class IncomingServerPanel extends DefaultPanel implements
074: ActionListener {
075:
076: /** JDK 1.4+ logging framework logger, used for logging. */
077: private static final Logger LOG = Logger
078: .getLogger("org.columba.mail.gui.config.account");
079:
080: private static final Pattern AUTH_MODE_TOKENIZE_PATTERN = Pattern
081: .compile("(\\d+);?");
082:
083: private JLabel loginLabel;
084:
085: private JTextField loginTextField;
086:
087: private JTextField passwordTextField;
088:
089: private JLabel hostLabel;
090:
091: private JTextField hostTextField;
092:
093: private JLabel portLabel;
094:
095: private JSpinner portSpinner;
096:
097: private JLabel typeLabel;
098:
099: private JComboBox typeComboBox;
100:
101: private JCheckBox storePasswordCheckBox;
102:
103: private JCheckBox secureCheckBox;
104:
105: private JLabel authenticationLabel;
106:
107: private JComboBox authenticationComboBox;
108:
109: private JLabel typeDescriptionLabel;
110:
111: private IDefaultItem serverItem = null;
112:
113: private AccountItem accountItem;
114:
115: private JCheckBox defaultAccountCheckBox;
116:
117: private ReceiveOptionsPanel receiveOptionsPanel;
118:
119: private JButton checkAuthMethods;
120:
121: private JComboBox sslComboBox;
122:
123: // private ConfigFrame frame;
124: private JDialog dialog;
125:
126: public IncomingServerPanel(JDialog dialog, AccountItem account,
127: ReceiveOptionsPanel receiveOptionsPanel) {
128: super ();
129:
130: this .dialog = dialog;
131:
132: this .accountItem = account;
133: this .receiveOptionsPanel = receiveOptionsPanel;
134:
135: if (account.isPopAccount()) {
136: serverItem = account.getPopItem();
137: } else {
138: serverItem = account.getImapItem();
139: }
140:
141: initComponents();
142:
143: updateComponents(true);
144: }
145:
146: public String getHost() {
147: return hostTextField.getText();
148: }
149:
150: public String getLogin() {
151: return loginTextField.getText();
152: }
153:
154: public boolean isPopAccount() {
155: return accountItem.isPopAccount();
156: }
157:
158: protected void updateComponents(boolean b) {
159: if (b) {
160: loginTextField.setText(serverItem.get(IncomingItem.USER));
161: passwordTextField.setText(serverItem
162: .get(IncomingItem.PASSWORD));
163: hostTextField.setText(serverItem.get(IncomingItem.HOST));
164: String port = serverItem.get(IncomingItem.PORT);
165: portSpinner.setValue(new Integer(port));
166:
167: storePasswordCheckBox.setSelected(serverItem
168: .getBoolean(IncomingItem.SAVE_PASSWORD));
169:
170: defaultAccountCheckBox.setSelected(serverItem
171: .getBoolean(IncomingItem.USE_DEFAULT_ACCOUNT));
172:
173: try {
174: authenticationComboBox.setSelectedItem(new Integer(
175: serverItem.get(IncomingItem.LOGIN_METHOD)));
176: } catch (NumberFormatException e) {
177: }
178:
179: // disable the actionlistener for this period
180: // to avoid an unwanted port check
181: secureCheckBox.removeActionListener(this );
182: sslComboBox.removeActionListener(this );
183:
184: secureCheckBox.setSelected(serverItem
185: .getBooleanWithDefault(IncomingItem.ENABLE_SSL,
186: false));
187:
188: sslComboBox.setSelectedIndex(serverItem
189: .getIntegerWithDefault(IncomingItem.SSL_TYPE, 1));
190: sslComboBox.setEnabled(secureCheckBox.isSelected());
191: // reactivate
192: secureCheckBox.addActionListener(this );
193: sslComboBox.addActionListener(this );
194:
195: defaultAccountCheckBox
196: .setEnabled(MailConfig.getInstance()
197: .getAccountList().getDefaultAccountUid() != accountItem
198: .getInteger(IncomingItem.UID));
199:
200: if (defaultAccountCheckBox.isEnabled()
201: && defaultAccountCheckBox.isSelected()) {
202: showDefaultAccountWarning();
203: } else {
204: layoutComponents();
205: }
206: } else {
207: serverItem.setString(IncomingItem.USER, loginTextField
208: .getText());
209: serverItem.setString(IncomingItem.HOST, hostTextField
210: .getText());
211: serverItem.setString(IncomingItem.PASSWORD,
212: passwordTextField.getText());
213: serverItem.setString(IncomingItem.PORT,
214: ((Integer) portSpinner.getValue()).toString());
215:
216: serverItem.setBoolean(IncomingItem.SAVE_PASSWORD,
217: storePasswordCheckBox.isSelected());
218:
219: serverItem.setBoolean(IncomingItem.ENABLE_SSL,
220: secureCheckBox.isSelected());
221: serverItem.setInteger(IncomingItem.SSL_TYPE, sslComboBox
222: .getSelectedIndex());
223:
224: // if securest write DEFAULT
225: serverItem
226: .setString(IncomingItem.LOGIN_METHOD,
227: authenticationComboBox.getSelectedItem()
228: .toString());
229:
230: serverItem.setBoolean(IncomingItem.USE_DEFAULT_ACCOUNT,
231: defaultAccountCheckBox.isSelected());
232:
233: serverItem.getRoot().notifyObservers();
234: }
235: }
236:
237: protected void showDefaultAccountWarning() {
238: setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
239:
240: GridBagLayout mainLayout = new GridBagLayout();
241: GridBagConstraints mainConstraints = new GridBagConstraints();
242:
243: setLayout(mainLayout);
244:
245: mainConstraints.gridwidth = GridBagConstraints.REMAINDER;
246: mainConstraints.anchor = GridBagConstraints.NORTHWEST;
247: mainConstraints.weightx = 1.0;
248: mainConstraints.insets = new Insets(0, 10, 5, 0);
249: mainLayout.setConstraints(defaultAccountCheckBox,
250: mainConstraints);
251: add(defaultAccountCheckBox);
252:
253: mainConstraints = new GridBagConstraints();
254: mainConstraints.weighty = 1.0;
255: mainConstraints.gridwidth = GridBagConstraints.REMAINDER;
256:
257: /*
258: * mainConstraints.fill = GridBagConstraints.BOTH;
259: * mainConstraints.insets = new Insets(0, 0, 0, 0);
260: * mainConstraints.gridwidth = GridBagConstraints.REMAINDER;
261: * mainConstraints.weightx = 1.0; mainConstraints.weighty = 1.0;
262: */
263: JLabel label = new JLabel(MailResourceLoader.getString(
264: "dialog", "account", "using_default_account_settings"));
265: Font newFont = label.getFont().deriveFont(Font.BOLD);
266: label.setFont(newFont);
267: mainLayout.setConstraints(label, mainConstraints);
268: add(label);
269: }
270:
271: protected void layoutComponents() {
272: // Create a FormLayout instance.
273: FormLayout layout = new FormLayout(
274: "10dlu, max(70dlu;default), 3dlu, fill:max(150dlu;default):grow, 3dlu, default, 3dlu, default",
275:
276: // 2 columns
277: ""); // rows are added dynamically (no need to
278: // define them here)
279:
280: // create a form builder
281: DefaultFormBuilder builder = new DefaultFormBuilder(layout,
282: this );
283:
284: // create EmptyBorder between components and dialog-frame
285: builder.setDefaultDialogBorder();
286:
287: // skip the first column
288: builder.setLeadingColumnOffset(1);
289:
290: // Add components to the panel:
291: // builder.append(defaultAccountCheckBox, 7);
292: // builder.nextLine();
293:
294: builder.appendSeparator(MailResourceLoader.getString("dialog",
295: "account", "configuration"));
296: builder.nextLine();
297:
298: builder.append(loginLabel, 1);
299: builder.append(loginTextField, 5);
300: builder.nextLine();
301:
302: builder.append(hostLabel, 1);
303: builder.append(hostTextField);
304: // builder.nextLine();
305:
306: builder.append(portLabel);
307: builder.append(portSpinner);
308: builder.nextLine();
309:
310: builder.appendSeparator(MailResourceLoader.getString("dialog",
311: "account", "security"));
312: builder.nextLine();
313:
314: JPanel panel = new JPanel();
315: FormLayout l = new FormLayout(
316: "default, 3dlu, fill:pref:grow, 3dlu, fill:pref:grow",
317:
318: // 2 columns
319: "fill:default:grow"); // rows are added dynamically (no need
320: // to
321: // define them here)
322:
323: // create a form builder
324: DefaultFormBuilder b = new DefaultFormBuilder(l, panel);
325: b.append(authenticationLabel, authenticationComboBox,
326: checkAuthMethods);
327: builder.append(panel, 3);
328: builder.nextLine();
329:
330: builder.append(secureCheckBox, 3);
331: builder.nextLine();
332:
333: JPanel panel2 = new JPanel();
334: FormLayout l2 = new FormLayout("default, 3dlu, left:pref",
335:
336: // 2 columns
337: "fill:default:grow"); // rows are added dynamically (no need
338: // to
339: // define them here)
340:
341: // create a form builder
342: DefaultFormBuilder b2 = new DefaultFormBuilder(l2, panel2);
343: b2.setRowGroupingEnabled(true);
344: b2.append(secureCheckBox, sslComboBox);
345: builder.append(panel2, 3);
346: builder.nextLine();
347:
348: builder.append(storePasswordCheckBox, 3);
349: builder.nextLine();
350:
351: /*
352: * builder.append(sslLabel, 3); builder.nextLine();
353: *
354: * builder.append(disableSSLConnectionRadioButton, 2);
355: * builder.nextLine(); builder.append(enableSSLConnectionRadioButton,
356: * 2); builder.nextLine();
357: * builder.append(enableSTARTTLSExtensionRadioButton, 2);
358: * builder.nextLine();
359: */
360: }
361:
362: protected void initComponents() {
363: defaultAccountCheckBox = new CheckBoxWithMnemonic(
364: MailResourceLoader.getString("dialog", "account",
365: "use_default_account_settings"));
366:
367: defaultAccountCheckBox.setActionCommand("DEFAULT_ACCOUNT");
368: defaultAccountCheckBox.addActionListener(this );
369:
370: // defaultAccountCheckBox.setEnabled(false);
371: typeLabel = new LabelWithMnemonic(MailResourceLoader.getString(
372: "dialog", "account", "server_type"));
373:
374: typeComboBox = new JComboBox();
375: typeComboBox.addItem("POP3");
376: typeComboBox.addItem("IMAP4");
377:
378: if (accountItem.isPopAccount()) {
379: typeComboBox.setSelectedIndex(0);
380: } else {
381: typeComboBox.setSelectedIndex(1);
382: }
383:
384: typeLabel.setLabelFor(typeComboBox);
385: typeComboBox.setEnabled(false);
386:
387: // TODO (@author fdietz): i18n
388: typeDescriptionLabel = new JLabel(
389: "Description: To connect to and fetch new messages from a POP3-server.");
390: typeDescriptionLabel.setEnabled(false);
391:
392: loginLabel = new LabelWithMnemonic(MailResourceLoader
393: .getString("dialog", "account", "login"));
394:
395: loginTextField = new JTextField();
396: loginLabel.setLabelFor(loginTextField);
397:
398: passwordTextField = new JTextField();
399:
400: hostLabel = new LabelWithMnemonic(MailResourceLoader.getString(
401: "dialog", "account", IncomingItem.HOST));
402:
403: hostTextField = new JTextField();
404: hostLabel.setLabelFor(hostTextField);
405:
406: portLabel = new LabelWithMnemonic(MailResourceLoader.getString(
407: "dialog", "account", IncomingItem.PORT));
408:
409: portSpinner = new JSpinner(new SpinnerNumberModel(100, 1,
410: 65535, 1));
411: portSpinner.setEditor(new JSpinner.NumberEditor(portSpinner,
412: "#####"));
413: portLabel.setLabelFor(portSpinner);
414:
415: storePasswordCheckBox = new CheckBoxWithMnemonic(
416: MailResourceLoader.getString("dialog", "account",
417: "store_password_in_configuration_file"));
418:
419: storePasswordCheckBox.setActionCommand("SAVE");
420: storePasswordCheckBox.addActionListener(this );
421:
422: secureCheckBox = new CheckBoxWithMnemonic(MailResourceLoader
423: .getString("dialog", "account",
424: "use_SSL_for_secure_connection"));
425: secureCheckBox.setActionCommand("SSL");
426: secureCheckBox.addActionListener(this );
427:
428: authenticationLabel = new LabelWithMnemonic(MailResourceLoader
429: .getString("dialog", "account", "authentication_type"));
430:
431: authenticationComboBox = new JComboBox();
432: authenticationComboBox
433: .setRenderer(new AuthenticationListCellRenderer());
434: authenticationLabel.setLabelFor(authenticationComboBox);
435:
436: updateAuthenticationComboBox();
437:
438: checkAuthMethods = new ButtonWithMnemonic(MailResourceLoader
439: .getString("dialog", "account",
440: "authentication_checkout_methods"));
441: checkAuthMethods.setActionCommand("CHECK_AUTHMETHODS");
442: checkAuthMethods.addActionListener(this );
443:
444: sslComboBox = new JComboBox();
445: if (isPopAccount()) {
446: sslComboBox.addItem(MailResourceLoader.getString("dialog",
447: "account", "pop3s_in_checkbox"));
448: } else {
449: sslComboBox.addItem(MailResourceLoader.getString("dialog",
450: "account", "imaps_in_checkbox"));
451: }
452: sslComboBox.addItem(MailResourceLoader.getString("dialog",
453: "account", "tls_in_checkbox"));
454: sslComboBox.setActionCommand("SSL");
455: sslComboBox.addActionListener(this );
456: }
457:
458: private void updateAuthenticationComboBox() {
459: authenticationComboBox.removeAllItems();
460:
461: authenticationComboBox.addItem(new Integer(0));
462:
463: String authMethods;
464: if (isPopAccount()) {
465: authMethods = accountItem.getString(IncomingItem.POPSERVER,
466: "authentication_methods");
467: } else {
468: authMethods = accountItem.getString("imapserver",
469: "authentication_methods");
470: }
471: // Add previously fetch authentication modes
472: if (authMethods != null) {
473: Matcher matcher = AUTH_MODE_TOKENIZE_PATTERN
474: .matcher(authMethods);
475:
476: while (matcher.find()) {
477: authenticationComboBox.addItem(new Integer(matcher
478: .group(1)));
479: }
480: }
481: }
482:
483: public void actionPerformed(ActionEvent e) {
484: String action = e.getActionCommand();
485:
486: if (action.equals("SERVER")) {//$NON-NLS-1$
487: LOG.info("selection changed");
488: } else if (action.equals("DEFAULT_ACCOUNT")) {
489: removeAll();
490: receiveOptionsPanel.removeAll();
491:
492: if (defaultAccountCheckBox.isSelected()) {
493: showDefaultAccountWarning();
494: receiveOptionsPanel.showDefaultAccountWarning();
495: } else {
496: layoutComponents();
497: receiveOptionsPanel.layoutComponents();
498: }
499:
500: revalidate();
501: receiveOptionsPanel.revalidate();
502: } else if (action.equals("CHECK_AUTHMETHODS")) {
503: fetchAuthMechanisms();
504: } else if (action.equals("SSL")) {
505: sslComboBox.setEnabled(secureCheckBox.isSelected());
506:
507: if (secureCheckBox.isSelected()) {
508: // Update the Port
509: if (sslComboBox.getSelectedIndex() == IncomingItem.TLS) {
510: // Default Port
511: if (isPopAccount()) {
512: if (((Integer) portSpinner.getValue())
513: .intValue() != POP3Protocol.DEFAULT_PORT) {
514: portSpinner.setValue(new Integer(
515: POP3Protocol.DEFAULT_PORT));
516: showPortChangeMessageBox();
517: }
518: } else {
519: if (((Integer) portSpinner.getValue())
520: .intValue() != IMAPProtocol.DEFAULT_PORT) {
521: portSpinner.setValue(new Integer(
522: IMAPProtocol.DEFAULT_PORT));
523: showPortChangeMessageBox();
524: }
525: }
526: } else {
527: // POP3s / IMAPs
528: if (isPopAccount()) {
529: if (((Integer) portSpinner.getValue())
530: .intValue() != POP3Protocol.DEFAULT_SSL_PORT) {
531: portSpinner.setValue(new Integer(
532: POP3Protocol.DEFAULT_SSL_PORT));
533: showPortChangeMessageBox();
534: }
535: } else {
536: if (((Integer) portSpinner.getValue())
537: .intValue() != IMAPProtocol.DEFAULT_SSL_PORT) {
538: portSpinner.setValue(new Integer(
539: IMAPProtocol.DEFAULT_SSL_PORT));
540: showPortChangeMessageBox();
541: }
542: }
543: }
544: } else {
545: // Check for default Ports
546: if (isPopAccount()) {
547: if (((Integer) portSpinner.getValue()).intValue() != POP3Protocol.DEFAULT_PORT) {
548: portSpinner.setValue(new Integer(
549: POP3Protocol.DEFAULT_PORT));
550: showPortChangeMessageBox();
551: }
552: } else {
553: if (((Integer) portSpinner.getValue()).intValue() != IMAPProtocol.DEFAULT_PORT) {
554: portSpinner.setValue(new Integer(
555: IMAPProtocol.DEFAULT_PORT));
556: showPortChangeMessageBox();
557: }
558: }
559: }
560: } else if (action.equals("SAVE")) {
561: if (!storePasswordCheckBox.isSelected()) {
562: return;
563: } else {
564: File configPath = DefaultConfigDirectory.getInstance()
565: .getCurrentPath();
566: File defaultConfigPath = DefaultConfigDirectory
567: .getDefaultPath();
568: while (!configPath.equals(defaultConfigPath)) {
569: configPath = configPath.getParentFile();
570: if (configPath == null) {
571: JOptionPane.showMessageDialog(dialog,
572: MailResourceLoader.getString("dialog",
573: IncomingItem.PASSWORD,
574: "warn_save_msg"),
575: MailResourceLoader.getString("dialog",
576: IncomingItem.PASSWORD,
577: "warn_save_title"),
578: JOptionPane.WARNING_MESSAGE);
579: return;
580: }
581: }
582: }
583: }
584: }
585:
586: /**
587: *
588: */
589: private void showPortChangeMessageBox() {
590: Runnable doHelloWorld = new Runnable() {
591: public void run() {
592: JOptionPane.showMessageDialog(dialog,
593: MailResourceLoader.getString("dialog",
594: "account", "change_port_ssl"),
595: "Information", JOptionPane.INFORMATION_MESSAGE);
596: }
597: };
598:
599: SwingUtilities.invokeLater(doHelloWorld);
600: }
601:
602: private IDefaultItem getCurrentDialogSettings() {
603: IDefaultItem server = null;
604:
605: if (accountItem.isPopAccount()) {
606: server = (IDefaultItem) accountItem.getPopItem().clone();
607: } else {
608: server = (IDefaultItem) accountItem.getImapItem().clone();
609: }
610:
611: server.setString(IncomingItem.USER, loginTextField.getText());
612: server.setString(IncomingItem.HOST, hostTextField.getText());
613: server.setString(IncomingItem.PASSWORD, passwordTextField
614: .getText());
615: server.setString(IncomingItem.PORT, ((Integer) portSpinner
616: .getValue()).toString());
617:
618: server.setBoolean(IncomingItem.ENABLE_SSL, secureCheckBox
619: .isSelected());
620: server.setInteger(IncomingItem.SSL_TYPE, sslComboBox
621: .getSelectedIndex());
622:
623: return server;
624: }
625:
626: private void fetchAuthMechanisms() {
627: List list = new LinkedList();
628: IDefaultItem serverItem = getCurrentDialogSettings();
629:
630: if (isPopAccount()) {
631: // user may have changed hostname. use dialog settings instead of
632: // stored settings
633:
634: POP3Store store = new POP3Store((PopItem) serverItem/* accountItem.getPopItem() */);
635:
636: try {
637: list = store.checkSupportedAuthenticationMethods();
638: } catch (Exception e) {
639: // let exception handler process other errors
640: new ExceptionHandler().processException(e);
641: }
642: } else {
643: IImapServer server = new IMAPServer((ImapItem) serverItem);
644:
645: try {
646: list = server.checkSupportedAuthenticationMethods();
647: } catch (Exception e) {
648: // let exception handler process other errors
649: new ExceptionHandler().processException(e);
650: }
651:
652: }
653:
654: // Save the authentication modes
655: if (list.size() > 0) {
656: StringBuffer authMethods = new StringBuffer();
657: Iterator it = list.iterator();
658: authMethods.append(it.next());
659:
660: while (it.hasNext()) {
661: authMethods.append(';');
662: authMethods.append(it.next());
663: }
664:
665: if (isPopAccount()) {
666: accountItem.setString(IncomingItem.POPSERVER,
667: "authentication_methods", authMethods
668: .toString());
669: } else {
670: accountItem.setString("imapserver",
671: "authentication_methods", authMethods
672: .toString());
673: }
674:
675: }
676:
677: updateAuthenticationComboBox();
678: }
679:
680: public boolean isFinished() {
681: String host = getHost();
682: String login = getLogin();
683:
684: if (host.length() == 0) {
685: JOptionPane.showMessageDialog(this , MailResourceLoader
686: .getString("dialog", "account",
687: "You_have_to_enter_a_host_name"));
688:
689: //$NON-NLS-1$
690: return false;
691: } else if (login.length() == 0) {
692: JOptionPane.showMessageDialog(this , MailResourceLoader
693: .getString("dialog", "account",
694: "You_have_to_enter_a_login_name"));
695:
696: //$NON-NLS-1$
697: return false;
698: } else if (defaultAccountCheckBox.isSelected()) {
699: AccountItem defaultAccount = MailConfig.getInstance()
700: .getAccountList().getDefaultAccount();
701:
702: if (defaultAccount.getAccountType() != accountItem
703: .getAccountType()) {
704:
705: String errorMessage = MailResourceLoader.getString(
706: "dialog", "account",
707: "cannot_use_default_account");
708:
709: Object[] accountType = new Object[] { defaultAccount
710: .getAccountTypeDescription() };
711:
712: errorMessage = MessageFormat.format(errorMessage,
713: accountType);
714:
715: JOptionPane.showMessageDialog(null, errorMessage);
716:
717: return false;
718: }
719: }
720:
721: return true;
722: }
723: }
|