KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > tree > action > FilterPreferencesAction


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
13
// Stich.
14
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
15
//
16
//All Rights Reserved.
17
package org.columba.mail.gui.tree.action;
18
19 import java.awt.event.ActionEvent 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.gui.action.AbstractColumbaAction;
25 import org.columba.mail.command.IMailFolderCommandReference;
26 import org.columba.mail.config.IFolderItem;
27 import org.columba.mail.folder.IMailbox;
28 import org.columba.mail.folder.virtual.VirtualFolder;
29 import org.columba.mail.gui.config.filter.ConfigFrame;
30 import org.columba.mail.gui.config.search.SearchFrame;
31 import org.columba.mail.gui.frame.AbstractMailFrameController;
32 import org.columba.mail.gui.frame.MailFrameMediator;
33 import org.columba.mail.gui.tree.selection.TreeSelectionChangedEvent;
34 import org.columba.mail.util.MailResourceLoader;
35
36 /**
37  * @author frd
38  *
39  * To change this generated comment go to Window>Preferences>Java>Code
40  * Generation>Code and Comments
41  */

42
43 public class FilterPreferencesAction extends AbstractColumbaAction implements
44         ISelectionListener {
45
46     public FilterPreferencesAction(IFrameMediator frameMediator) {
47         super(frameMediator, MailResourceLoader.getString("menu", "mainframe",
48                 "menu_folder_filterconfig"));
49
50         // tooltip text
51
putValue(SHORT_DESCRIPTION, MailResourceLoader.getString("menu",
52                 "mainframe", "menu_folder_filterconfig").replaceAll("&", ""));
53
54         setEnabled(false);
55
56         ((MailFrameMediator) frameMediator).registerTreeSelectionListener(this);
57     }
58
59     /*
60      * (non-Javadoc)
61      *
62      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
63      */

64     public void actionPerformed(ActionEvent JavaDoc evt) {
65         IMailFolderCommandReference r = ((MailFrameMediator) getFrameMediator())
66                 .getTreeSelection();
67         IMailbox folder = (IMailbox) r.getSourceFolder();
68
69         if (folder == null) {
70             return;
71         }
72
73         IFolderItem item = folder.getConfiguration();
74
75         if (item == null) {
76             return;
77         }
78
79         if (folder instanceof VirtualFolder) {
80             new SearchFrame((AbstractMailFrameController) frameMediator,
81                     (VirtualFolder) folder);
82         } else {
83             new ConfigFrame(frameMediator, folder);
84         }
85         // folder.showFilterDialog(((AbstractMailFrameController)
86
// getFrameMediator()));
87
}
88
89     /*
90      * (non-Javadoc)
91      *
92      * @see org.columba.core.gui.util.ISelectionListener#selectionChanged(org.columba.core.gui.util.SelectionChangedEvent)
93      */

94     public void selectionChanged(SelectionChangedEvent e) {
95         TreeSelectionChangedEvent treeEvent = (TreeSelectionChangedEvent) e;
96         
97         if (treeEvent.getSelected().length == 1 && treeEvent.getSelected()[0] instanceof IMailbox) {
98             setEnabled(true);
99         } else {
100             setEnabled(false);
101         }
102     }
103 }
104
Popular Tags