KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > smtp > action > SendAllMessagesAction


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.smtp.action;
17
18 import java.awt.event.ActionEvent JavaDoc;
19
20 import org.columba.api.gui.frame.IFrameMediator;
21 import org.columba.core.command.CommandProcessor;
22 import org.columba.core.connectionstate.ConnectionStateImpl;
23 import org.columba.core.gui.action.AbstractColumbaAction;
24 import org.columba.mail.command.MailFolderCommandReference;
25 import org.columba.mail.folder.outbox.OutboxFolder;
26 import org.columba.mail.gui.tree.FolderTreeModel;
27 import org.columba.mail.resourceloader.MailImageLoader;
28 import org.columba.mail.smtp.command.SendAllMessagesCommand;
29 import org.columba.mail.util.MailResourceLoader;
30
31 /**
32  * @author fdietz
33  *
34  * This action is responsible for starting the command which does the actual
35  * work. It is visually represented with a menuentry and a toolbar.
36  *
37  */

38 public class SendAllMessagesAction extends AbstractColumbaAction {
39     /**
40      * @param controller
41      */

42     public SendAllMessagesAction(IFrameMediator controller) {
43         super(controller, MailResourceLoader.getString("menu", "mainframe",
44                 "menu_file_sendunsentmessages"));
45
46         // tooltip text
47
putValue(SHORT_DESCRIPTION, MailResourceLoader.getString("menu",
48                 "mainframe", "menu_file_sendunsentmessages_tooltip")
49                 .replaceAll("&", ""));
50
51         // icon
52
putValue(LARGE_ICON, MailImageLoader.getIcon("send.png"));
53
54         // shortcut key
55
// no shortcut here, because F10 conflicts with system accelerator key
56
// putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F10,
57
// 0));
58
}
59
60     /**
61      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
62      */

63     public void actionPerformed(ActionEvent JavaDoc evt) {
64         setEnabled(false);
65         // check if we are online
66
if (ConnectionStateImpl.getInstance().isOnline() == false) {
67             // offline -> go online
68
ConnectionStateImpl.getInstance().setOnline(true);
69         }
70
71         // get outbox folder
72
OutboxFolder folder = (OutboxFolder) FolderTreeModel.getInstance()
73                 .getFolder("103");
74
75         // create referenc
76
MailFolderCommandReference r = new MailFolderCommandReference(folder);
77
78         // start command
79
SendAllMessagesCommand c = new SendAllMessagesCommand(this, r);
80
81         CommandProcessor.getInstance().addOp(c);
82     }
83 }
Popular Tags