KickJava   Java API By Example, From Geeks To Geeks.

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


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
20 import org.columba.api.gui.frame.IFrameMediator;
21 import org.columba.api.selection.ISelectionListener;
22 import org.columba.api.selection.SelectionChangedEvent;
23 import org.columba.core.command.CommandProcessor;
24 import org.columba.core.gui.action.AbstractColumbaAction;
25 import org.columba.core.gui.frame.DefaultContainer;
26 import org.columba.mail.command.IMailFolderCommandReference;
27 import org.columba.mail.gui.frame.MailFrameMediator;
28 import org.columba.mail.gui.frame.ThreePaneMailFrameController;
29 import org.columba.mail.gui.message.command.ViewMessageCommand;
30 import org.columba.mail.gui.messageframe.MessageFrameController;
31 import org.columba.mail.gui.table.selection.TableSelectionChangedEvent;
32 import org.columba.mail.resourceloader.MailImageLoader;
33 import org.columba.mail.util.MailResourceLoader;
34
35 /**
36  * @author frd
37  *
38  * To change the template for this generated type comment go to
39  * Window>Preferences>Java>Code Generation>Code and Comments
40  */

41 public class OpenMessageWithMessageFrameAction extends AbstractColumbaAction
42         implements ISelectionListener {
43     public OpenMessageWithMessageFrameAction(IFrameMediator frameMediator) {
44         super(frameMediator, MailResourceLoader.getString("menu", "mainframe",
45                 "menu_message_opennew"));
46
47         // tooltip text
48
putValue(SHORT_DESCRIPTION, MailResourceLoader.getString("menu",
49                 "mainframe", "menu_message_opennew_tooltip")
50                 .replaceAll("&", ""));
51
52 // putValue(SMALL_ICON,
53
// MailImageLoader.getIcon("email_open.png"));
54

55         setEnabled(false);
56
57         ((MailFrameMediator) frameMediator)
58                 .registerTableSelectionListener(this);
59     }
60
61     /**
62      *
63      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
64      */

65     public void actionPerformed(ActionEvent JavaDoc evt) {
66         MessageFrameController c = new MessageFrameController(
67                 (ThreePaneMailFrameController) getFrameMediator());
68         new DefaultContainer(c);
69
70         IMailFolderCommandReference r = ((MailFrameMediator) getFrameMediator())
71                 .getTableSelection();
72
73         c.setTreeSelection(r);
74
75         c.setTableSelection(r);
76
77         CommandProcessor.getInstance().addOp(new ViewMessageCommand(c, r));
78
79     }
80
81     public void selectionChanged(SelectionChangedEvent e) {
82         setEnabled(((TableSelectionChangedEvent) e).getUids().length > 0);
83     }
84 }
Popular Tags