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: package org.columba.mail.gui.action;
19:
20: import java.awt.event.ActionEvent;
21: import java.awt.event.KeyEvent;
22:
23: import javax.swing.Action;
24: import javax.swing.KeyStroke;
25:
26: import org.columba.api.gui.frame.IFrameMediator;
27: import org.columba.api.plugin.IExtension;
28: import org.columba.api.plugin.IExtensionHandlerKeys;
29: import org.columba.api.plugin.PluginException;
30: import org.columba.api.plugin.PluginHandlerNotFoundException;
31: import org.columba.core.gui.action.AbstractColumbaAction;
32: import org.columba.core.plugin.PluginManager;
33: import org.columba.mail.mailchecking.MailCheckingManager;
34: import org.columba.mail.resourceloader.MailImageLoader;
35: import org.columba.mail.util.MailResourceLoader;
36:
37: public class ReceiveSendAction extends AbstractColumbaAction {
38: public ReceiveSendAction(IFrameMediator controller) {
39: super (controller, MailResourceLoader.getString("menu",
40: "mainframe", "menu_file_receivesend"));
41:
42: // tooltip text
43: putValue(SHORT_DESCRIPTION, MailResourceLoader.getString(
44: "menu", "mainframe", "menu_file_receivesend_tooltip")
45: .replaceAll("&", ""));
46:
47: // toolbar text
48: putValue(TOOLBAR_NAME, MailResourceLoader.getString("menu",
49: "mainframe", "menu_file_receivesend_toolbar"));
50:
51: // small icon for menu
52: putValue(SMALL_ICON, MailImageLoader
53: .getSmallIcon("mail-send-receive.png"));
54:
55: // large icon for toolbar
56: putValue(LARGE_ICON, MailImageLoader
57: .getIcon("mail-send-receive.png"));
58:
59: // shortcut key
60: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(
61: KeyEvent.VK_F9, 0));
62: }
63:
64: /*
65: * (non-Javadoc)
66: *
67: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
68: */
69: public void actionPerformed(ActionEvent evt) {
70: // check for new messages
71: MailCheckingManager.getInstance().checkAll();
72:
73: try {
74: // send all unsent messages found in Outbox
75:
76: Action sendAllAction;
77:
78: IExtension extension = PluginManager
79: .getInstance()
80: .getExtensionHandler(
81: IExtensionHandlerKeys.ORG_COLUMBA_CORE_ACTION)
82: .getExtension("SendAll");
83: sendAllAction = (Action) extension
84: .instanciateExtension(new Object[] { getFrameMediator() });
85: if (sendAllAction.isEnabled())
86: sendAllAction.actionPerformed(evt);
87:
88: } catch (PluginHandlerNotFoundException e) {
89: e.printStackTrace();
90: } catch (PluginException e) {
91: e.printStackTrace();
92: }
93: }
94: }
|