01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
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;
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",
44: "mainframe", "menu_file_sendunsentmessages"));
45:
46: // tooltip text
47: putValue(SHORT_DESCRIPTION, MailResourceLoader.getString(
48: "menu", "mainframe",
49: "menu_file_sendunsentmessages_tooltip").replaceAll("&",
50: ""));
51:
52: // icon
53: putValue(LARGE_ICON, MailImageLoader.getIcon("send.png"));
54:
55: // shortcut key
56: // no shortcut here, because F10 conflicts with system accelerator key
57: // putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F10,
58: // 0));
59: }
60:
61: /**
62: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
63: */
64: public void actionPerformed(ActionEvent evt) {
65: setEnabled(false);
66: // check if we are online
67: if (ConnectionStateImpl.getInstance().isOnline() == false) {
68: // offline -> go online
69: ConnectionStateImpl.getInstance().setOnline(true);
70: }
71:
72: // get outbox folder
73: OutboxFolder folder = (OutboxFolder) FolderTreeModel
74: .getInstance().getFolder("103");
75:
76: // create referenc
77: MailFolderCommandReference r = new MailFolderCommandReference(
78: folder);
79:
80: // start command
81: SendAllMessagesCommand c = new SendAllMessagesCommand(this, r);
82:
83: CommandProcessor.getInstance().addOp(c);
84: }
85: }
|