01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //limitations under the License.
10: //
11: //The Original Code is "The Columba Project"
12: //
13: //The Initial Developers of the Original Code are Frederik Dietz and Timo
14: // Stich.
15: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16: //
17: //All Rights Reserved.
18:
19: package org.columba.mail.gui.action;
20:
21: import java.awt.Toolkit;
22: import java.awt.event.ActionEvent;
23: import java.awt.event.KeyEvent;
24:
25: import javax.swing.JOptionPane;
26: import javax.swing.KeyStroke;
27:
28: import org.columba.api.gui.frame.IFrameMediator;
29: import org.columba.core.gui.action.AbstractColumbaAction;
30: import org.columba.core.gui.frame.DefaultContainer;
31: import org.columba.core.gui.frame.FrameManager;
32: import org.columba.core.resourceloader.GlobalResourceLoader;
33: import org.columba.mail.config.MailConfig;
34: import org.columba.mail.gui.composer.ComposerController;
35: import org.columba.mail.gui.config.accountwizard.AccountWizardLauncher;
36: import org.columba.mail.resourceloader.IconKeys;
37: import org.columba.mail.resourceloader.MailImageLoader;
38: import org.columba.mail.util.MailResourceLoader;
39:
40: /**
41: * Opens the composer window for creating a new message.
42: */
43: public class NewMessageAction extends AbstractColumbaAction {
44: private static final String RESOURCE_PATH = "org.columba.core.i18n.dialog";
45:
46: public NewMessageAction() {
47: super (null, "New Message Action");
48: }
49:
50: public NewMessageAction(IFrameMediator controller) {
51: super (controller, MailResourceLoader.getString("menu",
52: "mainframe", "menu_message_new"));
53: putValue(TOOLBAR_NAME, MailResourceLoader.getString("menu",
54: "mainframe", "menu_message_new_toolbar"));
55: putValue(SHORT_DESCRIPTION, MailResourceLoader.getString(
56: "menu", "mainframe", "menu_message_new_tooltip")
57: .replaceAll("&", ""));
58: putValue(SMALL_ICON, MailImageLoader
59: .getSmallIcon(IconKeys.MESSAGE_NEW));
60: putValue(LARGE_ICON, MailImageLoader
61: .getIcon(IconKeys.MESSAGE_NEW));
62: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_M,
63: Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
64: }
65:
66: public void actionPerformed(ActionEvent evt) {
67:
68: // if no account exists, return
69: if (MailConfig.getInstance().getAccountList().count() == 0) {
70: JOptionPane.showMessageDialog(FrameManager.getInstance()
71: .getActiveFrame(), GlobalResourceLoader.getString(
72: RESOURCE_PATH, "error", "no_account_defined"), "",
73: JOptionPane.INFORMATION_MESSAGE);
74:
75: new AccountWizardLauncher().launchWizard(true);
76: return;
77: }
78:
79: ComposerController controller = new ComposerController();
80: new DefaultContainer(controller);
81:
82: // model -> view
83: controller.updateComponents(true);
84:
85: }
86: }
|