KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > table > action > SaveMessageSourceAsAction


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.table.action;
17
18 import java.awt.event.ActionEvent JavaDoc;
19 import java.util.logging.Logger JavaDoc;
20
21 import org.columba.api.gui.frame.IFrameMediator;
22 import org.columba.api.selection.ISelectionListener;
23 import org.columba.api.selection.SelectionChangedEvent;
24 import org.columba.core.command.CommandProcessor;
25 import org.columba.core.gui.action.AbstractColumbaAction;
26 import org.columba.core.resourceloader.ImageLoader;
27 import org.columba.mail.command.IMailFolderCommandReference;
28 import org.columba.mail.folder.command.SaveMessageSourceAsCommand;
29 import org.columba.mail.gui.frame.MailFrameMediator;
30 import org.columba.mail.gui.table.selection.TableSelectionChangedEvent;
31 import org.columba.mail.util.MailResourceLoader;
32
33
34 /**
35  * Action for saving message source, i.e. for saving a message
36  * as-is incl. all headers.
37  * @author Karl Peder Olesen (karlpeder), 20030615
38  */

39 public class SaveMessageSourceAsAction extends AbstractColumbaAction
40     implements ISelectionListener {
41
42     /** JDK 1.4+ logging framework logger, used for logging. */
43     private static final Logger JavaDoc LOG = Logger.getLogger("org.columba.mail.gui.table.action");
44
45     public SaveMessageSourceAsAction(IFrameMediator controller) {
46         super(controller,
47             MailResourceLoader.getString("menu", "mainframe", "menu_file_save"));
48
49         // tooltip text
50
putValue(SHORT_DESCRIPTION,
51             MailResourceLoader.getString("menu", "mainframe",
52                 "menu_file_save_tooltip").replaceAll("&", ""));
53
54         // icons
55
putValue(SMALL_ICON, ImageLoader.getSmallIcon("document-save.png"));
56         putValue(LARGE_ICON, ImageLoader.getIcon("document-save.png"));
57
58         setEnabled(false);
59         ((MailFrameMediator) frameMediator).registerTableSelectionListener(this);
60     }
61
62     /**
63      * Executes this action - i.e. saves message source
64      * by invocing the necessary command.
65      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
66      */

67     public void actionPerformed(ActionEvent JavaDoc evt) {
68         IMailFolderCommandReference r = ((MailFrameMediator) getFrameMediator()).getTableSelection();
69
70         LOG.info("Save Message Source As... called");
71
72         SaveMessageSourceAsCommand c = new SaveMessageSourceAsCommand(r);
73
74         CommandProcessor.getInstance().addOp(c);
75     }
76
77     /**
78      * Handles enabling / disabling of menu/action depending
79      * on selection
80      * @see org.columba.core.gui.util.ISelectionListener#selectionChanged(org.columba.core.gui.util.SelectionChangedEvent)
81      */

82     public void selectionChanged(SelectionChangedEvent e) {
83         setEnabled(((TableSelectionChangedEvent) e).getUids().length > 0);
84     }
85 }
86
Popular Tags