KickJava   Java API By Example, From Geeks To Geeks.

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


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.api.gui.frame.IFrameMediator;
23 import org.columba.core.command.CommandProcessor;
24 import org.columba.core.desktop.ColumbaDesktop;
25 import org.columba.core.resourceloader.IconKeys;
26 import org.columba.core.resourceloader.ImageLoader;
27 import org.columba.mail.command.IMailFolderCommandReference;
28 import org.columba.mail.command.MailFolderCommandReference;
29 import org.columba.mail.gui.frame.MessageViewOwner;
30 import org.columba.mail.gui.message.IMessageController;
31 import org.columba.mail.gui.message.command.OpenAttachmentCommand;
32 import org.columba.mail.gui.message.viewer.AttachmentsViewer;
33 import org.columba.mail.util.MailResourceLoader;
34
35 /**
36  * Open Attachment action.
37  *
38  * @author fdietz
39  */

40 public class OpenAttachmentAction extends AbstractAction JavaDoc {
41
42     private Integer JavaDoc[] address;
43
44     private IMessageController mediator;
45     private AttachmentsViewer attachmentViewer;
46     
47     public OpenAttachmentAction(IMessageController mediator, Integer JavaDoc[] address) {
48         super(MailResourceLoader.getString("menu", "mainframe",
49                 "attachmentopen"));
50
51         this.mediator = mediator;
52         this.address = address;
53
54         // tooltip text
55
putValue(SHORT_DESCRIPTION, MailResourceLoader.getString("menu",
56                 "mainframe", "attachmentopen_tooltip").replaceAll("&", ""));
57
58         // icons
59
putValue(SMALL_ICON, ImageLoader.getSmallIcon(IconKeys.FOLDER_OPEN));
60         // putValue(LARGE_ICON, ImageLoader.getIcon(IconKeys.FOLDER_OPEN));
61

62         setEnabled(ColumbaDesktop.getInstance().supportsOpen());
63
64     }
65
66     public OpenAttachmentAction(IMessageController mediator,
67             AttachmentsViewer attachmentViewer) {
68         super(MailResourceLoader.getString("menu", "mainframe",
69                 "attachmentopen"));
70
71         this.mediator = mediator;
72         this.attachmentViewer = attachmentViewer;
73
74         // tooltip text
75
putValue(SHORT_DESCRIPTION, MailResourceLoader.getString("menu",
76                 "mainframe", "attachmentopen_tooltip").replaceAll("&", ""));
77
78         // icons
79
putValue(SMALL_ICON, ImageLoader.getIcon(IconKeys.FOLDER_OPEN));
80         // putValue(LARGE_ICON, ImageLoader.getSmallIcon(IconKeys.FOLDER_OPEN));
81

82         setEnabled(ColumbaDesktop.getInstance().supportsOpen());
83
84     }
85
86     /*
87      * (non-Javadoc)
88      *
89      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
90      */

91     public void actionPerformed(ActionEvent JavaDoc evt) {
92         IMailFolderCommandReference ref = mediator.getSelectedReference();
93
94         if (attachmentViewer != null) {
95             address = attachmentViewer.getSelected();
96         }
97
98         CommandProcessor.getInstance().addOp(
99                 new OpenAttachmentCommand(new MailFolderCommandReference(ref
100                         .getSourceFolder(), ref.getUids(), address)));
101     }
102
103 }
Popular Tags