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.command.CommandProcessor;
23: import org.columba.core.resourceloader.IconKeys;
24: import org.columba.core.resourceloader.ImageLoader;
25: import org.columba.mail.command.IMailFolderCommandReference;
26: import org.columba.mail.command.MailFolderCommandReference;
27: import org.columba.mail.gui.message.IMessageController;
28: import org.columba.mail.gui.message.command.SaveAttachmentAsCommand;
29: import org.columba.mail.gui.message.viewer.AttachmentsViewer;
30: import org.columba.mail.util.MailResourceLoader;
31:
32: /**
33: * Save attachment to file.
34: *
35: * @author frdietz
36: */
37: public class SaveAsAttachmentAction extends AbstractAction {
38:
39: private Integer[] address;
40:
41: private AttachmentsViewer attachmentViewer;
42:
43: private IMessageController mediator;
44:
45: public SaveAsAttachmentAction(IMessageController mediator,
46: Integer[] address) {
47: super (MailResourceLoader.getString("menu", "mainframe",
48: "attachmentsaveas"));
49: this .mediator = mediator;
50: this .address = address;
51:
52: // tooltip text
53: putValue(SHORT_DESCRIPTION, MailResourceLoader.getString(
54: "menu", "mainframe", "attachmentsaveas_tooltip")
55: .replaceAll("&", ""));
56:
57: // icons
58: putValue(SMALL_ICON, ImageLoader
59: .getSmallIcon(IconKeys.DOCUMENT_SAVE_AS));
60: // putValue(LARGE_ICON, ImageLoader.getIcon(IconKeys.DOCUMENT_SAVE_AS));
61:
62: }
63:
64: public SaveAsAttachmentAction(IMessageController mediator,
65: AttachmentsViewer attachmentViewer) {
66: super (MailResourceLoader.getString("menu", "mainframe",
67: "attachmentsaveas"));
68: this .mediator = mediator;
69: this .attachmentViewer = attachmentViewer;
70:
71: // tooltip text
72: putValue(SHORT_DESCRIPTION, MailResourceLoader.getString(
73: "menu", "mainframe", "attachmentsaveas_tooltip")
74: .replaceAll("&", ""));
75:
76: // icons
77: putValue(SMALL_ICON, ImageLoader
78: .getSmallIcon(IconKeys.DOCUMENT_SAVE_AS));
79: // putValue(LARGE_ICON, ImageLoader.getIcon(IconKeys.DOCUMENT_SAVE_AS));
80:
81: }
82:
83: /** {@inheritDoc} */
84: public void actionPerformed(ActionEvent evt) {
85: IMailFolderCommandReference ref = mediator
86: .getSelectedReference();
87:
88: if (attachmentViewer != null)
89: address = attachmentViewer.getSelected();
90:
91: CommandProcessor.getInstance().addOp(
92: new SaveAttachmentAsCommand(
93: new MailFolderCommandReference(ref
94: .getSourceFolder(), ref.getUids(),
95: address)));
96:
97: }
98:
99: }
|