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.gui.message.action;
17:
18: import java.awt.event.ActionEvent;
19:
20: import javax.swing.AbstractAction;
21:
22: import org.columba.core.gui.frame.DefaultContainer;
23: import org.columba.mail.gui.composer.ComposerController;
24: import org.columba.mail.gui.composer.ComposerModel;
25: import org.columba.mail.gui.message.util.ColumbaURL;
26: import org.columba.mail.util.MailResourceLoader;
27:
28: /**
29: * Compose message using selected address.
30: *
31: * @author fdietz
32: */
33:
34: public class ComposeMessageAction extends AbstractAction {
35:
36: private String emailAddress;
37:
38: private ColumbaURL url = null;
39:
40: /**
41: *
42: */
43: public ComposeMessageAction(String emailAddress) {
44: super (MailResourceLoader.getString("menu", "mainframe",
45: "viewer_compose"));
46:
47: this .emailAddress = emailAddress;
48:
49: setEnabled(emailAddress != null);
50: }
51:
52: public ComposeMessageAction(ColumbaURL url) {
53: super (MailResourceLoader.getString("menu", "mainframe",
54: "viewer_compose"));
55: this .url = url;
56: setEnabled(url != null);
57:
58: if (url != null)
59: setEnabled(url.isMailTo());
60: }
61:
62: public void actionPerformed(ActionEvent evt) {
63: ComposerController controller = new ComposerController();
64: new DefaultContainer(controller);
65:
66: ComposerModel model = new ComposerModel();
67: if (emailAddress != null)
68: model.setTo(emailAddress);
69: else
70: model.setTo(url.getEmailAddress());
71:
72: // apply model
73: controller.setComposerModel(model);
74:
75: controller.updateComponents(true);
76:
77: }
78:
79: }
|