KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > message > action > SaveAsAttachmentAction


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.gui.message.action;
17
18 import java.awt.event.ActionEvent JavaDoc;
19
20 import javax.swing.AbstractAction JavaDoc;
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 JavaDoc {
38
39     private Integer JavaDoc[] address;
40
41     private AttachmentsViewer attachmentViewer;
42
43     private IMessageController mediator;
44
45     public SaveAsAttachmentAction(IMessageController mediator, Integer JavaDoc[] address) {
46         super(MailResourceLoader.getString("menu", "mainframe",
47                 "attachmentsaveas"));
48         this.mediator = mediator;
49         this.address = address;
50
51         // tooltip text
52
putValue(SHORT_DESCRIPTION, MailResourceLoader.getString("menu",
53                 "mainframe", "attachmentsaveas_tooltip").replaceAll("&", ""));
54
55         // icons
56
putValue(SMALL_ICON, ImageLoader
57                 .getSmallIcon(IconKeys.DOCUMENT_SAVE_AS));
58         // putValue(LARGE_ICON, ImageLoader.getIcon(IconKeys.DOCUMENT_SAVE_AS));
59

60     }
61
62     public SaveAsAttachmentAction(IMessageController mediator,
63             AttachmentsViewer attachmentViewer) {
64         super(MailResourceLoader.getString("menu", "mainframe",
65                 "attachmentsaveas"));
66         this.mediator = mediator;
67         this.attachmentViewer = attachmentViewer;
68
69         // tooltip text
70
putValue(SHORT_DESCRIPTION, MailResourceLoader.getString("menu",
71                 "mainframe", "attachmentsaveas_tooltip").replaceAll("&", ""));
72
73         // icons
74
putValue(SMALL_ICON, ImageLoader
75                 .getSmallIcon(IconKeys.DOCUMENT_SAVE_AS));
76         // putValue(LARGE_ICON, ImageLoader.getIcon(IconKeys.DOCUMENT_SAVE_AS));
77

78     }
79
80     /** {@inheritDoc} */
81     public void actionPerformed(ActionEvent JavaDoc evt) {
82         IMailFolderCommandReference ref = mediator.getSelectedReference();
83
84         if (attachmentViewer != null)
85             address = attachmentViewer.getSelected();
86
87         CommandProcessor.getInstance().addOp(
88                 new SaveAttachmentAsCommand(new MailFolderCommandReference(ref
89                         .getSourceFolder(), ref.getUids(), address)));
90
91     }
92
93 }
Popular Tags