KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > action > NewMessageAction


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//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 JavaDoc;
22 import java.awt.event.ActionEvent JavaDoc;
23 import java.awt.event.KeyEvent JavaDoc;
24
25 import javax.swing.JOptionPane JavaDoc;
26 import javax.swing.KeyStroke JavaDoc;
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 JavaDoc 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", "mainframe",
52                 "menu_message_new"));
53         putValue(TOOLBAR_NAME, MailResourceLoader.getString("menu",
54                 "mainframe", "menu_message_new_toolbar"));
55         putValue(SHORT_DESCRIPTION, MailResourceLoader.getString("menu",
56                 "mainframe", "menu_message_new_tooltip").replaceAll("&", ""));
57         putValue(SMALL_ICON, MailImageLoader.getSmallIcon(IconKeys.MESSAGE_NEW));
58         putValue(LARGE_ICON, MailImageLoader.getIcon(IconKeys.MESSAGE_NEW));
59         putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_M,
60                 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
61     }
62
63     public void actionPerformed(ActionEvent JavaDoc evt) {
64
65         // if no account exists, return
66
if ( MailConfig.getInstance().getAccountList().count() == 0 ) {
67             JOptionPane.showMessageDialog(FrameManager.getInstance()
68                     .getActiveFrame(), GlobalResourceLoader.getString(RESOURCE_PATH, "error",
69             "no_account_defined"),"",JOptionPane.INFORMATION_MESSAGE);
70
71             new AccountWizardLauncher().launchWizard(true);
72             return;
73         }
74
75         ComposerController controller = new ComposerController();
76         new DefaultContainer(controller);
77
78         // model -> view
79
controller.updateComponents(true);
80
81     }
82 }
Popular Tags