KickJava   Java API By Example, From Geeks To Geeks.

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


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
package org.columba.mail.gui.action;
19
20 import java.awt.event.ActionEvent JavaDoc;
21 import java.awt.event.KeyEvent JavaDoc;
22
23 import javax.swing.Action JavaDoc;
24 import javax.swing.KeyStroke JavaDoc;
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", "mainframe",
40                 "menu_file_receivesend"));
41
42         // tooltip text
43
putValue(SHORT_DESCRIPTION, MailResourceLoader.getString("menu",
44                 "mainframe", "menu_file_receivesend_tooltip").replaceAll("&",
45                 ""));
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.getSmallIcon("mail-send-receive.png"));
53
54         // large icon for toolbar
55
putValue(LARGE_ICON, MailImageLoader.getIcon("mail-send-receive.png"));
56
57         // shortcut key
58
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0));
59     }
60
61     /*
62      * (non-Javadoc)
63      *
64      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
65      */

66     public void actionPerformed(ActionEvent JavaDoc evt) {
67         // check for new messages
68
MailCheckingManager.getInstance().checkAll();
69
70         try {
71             // send all unsent messages found in Outbox
72

73             Action JavaDoc sendAllAction;
74
75             IExtension extension = PluginManager
76                     .getInstance().getExtensionHandler(IExtensionHandlerKeys.ORG_COLUMBA_CORE_ACTION)
77                     .getExtension("SendAll");
78             sendAllAction = (Action JavaDoc) extension
79                     .instanciateExtension(new Object JavaDoc[] { getFrameMediator() });
80             if (sendAllAction.isEnabled())
81                 sendAllAction.actionPerformed(evt);
82
83         } catch (PluginHandlerNotFoundException e) {
84             e.printStackTrace();
85         } catch (PluginException e) {
86             e.printStackTrace();
87         }
88     }
89 }
Popular Tags