KickJava   Java API By Example, From Geeks To Geeks.

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


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.tree.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.resourceloader.ImageLoader;
26 import org.columba.mail.command.MailFolderCommandReference;
27 import org.columba.mail.folder.IMailFolder;
28 import org.columba.mail.folder.IMailbox;
29 import org.columba.mail.gui.config.folder.FolderOptionsDialog;
30 import org.columba.mail.gui.frame.AbstractMailFrameController;
31 import org.columba.mail.gui.frame.MailFrameMediator;
32 import org.columba.mail.gui.tree.command.MailboxSizeCommand;
33 import org.columba.mail.gui.tree.selection.TreeSelectionChangedEvent;
34 import org.columba.mail.util.MailResourceLoader;
35
36 /**
37  * Opens AbstractMessageFolder Options Dialog.
38  *
39  * @author fdietz
40  */

41 public class FolderOptionsAction extends AbstractColumbaAction implements
42         ISelectionListener {
43     /**
44      * @param frameMediator
45      * @param name
46      */

47     public FolderOptionsAction(IFrameMediator frameMediator) {
48         super(frameMediator, MailResourceLoader.getString("menu", "mainframe",
49                 "menu_folder_folderoptions"));
50
51         // icon for menu
52
// putValue(SMALL_ICON, ImageLoader
53
// .getSmallImageIcon("16_configure_folder.png"));
54

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

65     public void actionPerformed(ActionEvent JavaDoc evt) {
66         // it is safe here to cast to AbstractMailFrameControlller
67
MailFolderCommandReference r = (MailFolderCommandReference) ((AbstractMailFrameController) frameMediator)
68                 .getTreeSelection();
69
70         // only use the first selected folder
71
IMailFolder folder = (IMailFolder) r.getSourceFolder();
72
73         // cast to Folder
74
FolderOptionsDialog dialog = new FolderOptionsDialog((IMailbox) folder,
75                 true, (AbstractMailFrameController) frameMediator);
76
77         // calculate mailbox size in background worker
78
CommandProcessor.getInstance().addOp(new MailboxSizeCommand(r, dialog));
79     }
80
81     public void selectionChanged(SelectionChangedEvent e) {
82         IMailFolder[] r = ((TreeSelectionChangedEvent) e).getSelected();
83
84         if ((r.length > 0) && r[0] instanceof IMailbox) {
85             setEnabled(true);
86         } else {
87             setEnabled(false);
88         }
89     }
90 }
Popular Tags