001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016: package org.columba.mail.gui.message.action;
017:
018: import java.awt.event.ActionEvent;
019:
020: import javax.swing.AbstractAction;
021:
022: import org.columba.api.gui.frame.IFrameMediator;
023: import org.columba.core.command.CommandProcessor;
024: import org.columba.core.desktop.ColumbaDesktop;
025: import org.columba.core.resourceloader.IconKeys;
026: import org.columba.core.resourceloader.ImageLoader;
027: import org.columba.mail.command.IMailFolderCommandReference;
028: import org.columba.mail.command.MailFolderCommandReference;
029: import org.columba.mail.gui.frame.MessageViewOwner;
030: import org.columba.mail.gui.message.IMessageController;
031: import org.columba.mail.gui.message.command.OpenAttachmentCommand;
032: import org.columba.mail.gui.message.viewer.AttachmentsViewer;
033: import org.columba.mail.util.MailResourceLoader;
034:
035: /**
036: * Open Attachment action.
037: *
038: * @author fdietz
039: */
040: public class OpenAttachmentAction extends AbstractAction {
041:
042: private Integer[] address;
043:
044: private IMessageController mediator;
045: private AttachmentsViewer attachmentViewer;
046:
047: public OpenAttachmentAction(IMessageController mediator,
048: Integer[] address) {
049: super (MailResourceLoader.getString("menu", "mainframe",
050: "attachmentopen"));
051:
052: this .mediator = mediator;
053: this .address = address;
054:
055: // tooltip text
056: putValue(SHORT_DESCRIPTION, MailResourceLoader.getString(
057: "menu", "mainframe", "attachmentopen_tooltip")
058: .replaceAll("&", ""));
059:
060: // icons
061: putValue(SMALL_ICON, ImageLoader
062: .getSmallIcon(IconKeys.FOLDER_OPEN));
063: // putValue(LARGE_ICON, ImageLoader.getIcon(IconKeys.FOLDER_OPEN));
064:
065: setEnabled(ColumbaDesktop.getInstance().supportsOpen());
066:
067: }
068:
069: public OpenAttachmentAction(IMessageController mediator,
070: AttachmentsViewer attachmentViewer) {
071: super (MailResourceLoader.getString("menu", "mainframe",
072: "attachmentopen"));
073:
074: this .mediator = mediator;
075: this .attachmentViewer = attachmentViewer;
076:
077: // tooltip text
078: putValue(SHORT_DESCRIPTION, MailResourceLoader.getString(
079: "menu", "mainframe", "attachmentopen_tooltip")
080: .replaceAll("&", ""));
081:
082: // icons
083: putValue(SMALL_ICON, ImageLoader.getIcon(IconKeys.FOLDER_OPEN));
084: // putValue(LARGE_ICON, ImageLoader.getSmallIcon(IconKeys.FOLDER_OPEN));
085:
086: setEnabled(ColumbaDesktop.getInstance().supportsOpen());
087:
088: }
089:
090: /*
091: * (non-Javadoc)
092: *
093: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
094: */
095: public void actionPerformed(ActionEvent evt) {
096: IMailFolderCommandReference ref = mediator
097: .getSelectedReference();
098:
099: if (attachmentViewer != null) {
100: address = attachmentViewer.getSelected();
101: }
102:
103: CommandProcessor.getInstance().addOp(
104: new OpenAttachmentCommand(
105: new MailFolderCommandReference(ref
106: .getSourceFolder(), ref.getUids(),
107: address)));
108: }
109:
110: }
|