KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > action > ShowMessagePreviewAction


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.mail.gui.action;
19
20 import java.awt.event.ActionEvent JavaDoc;
21 import java.util.Observable JavaDoc;
22 import java.util.Observer JavaDoc;
23
24 import org.columa.core.config.IDefaultItem;
25 import org.columba.api.gui.frame.IFrameMediator;
26 import org.columba.core.config.DefaultItem;
27 import org.columba.core.config.ViewItem;
28 import org.columba.core.gui.action.AbstractSelectableAction;
29 import org.columba.core.gui.frame.DefaultFrameController;
30 import org.columba.core.xml.XmlElement;
31 import org.columba.mail.gui.frame.ThreePaneMailFrameController;
32
33 /**
34  * Show/Hide message previous window.
35  *
36  * @author fdietz
37  *
38  */

39 public class ShowMessagePreviewAction extends AbstractSelectableAction
40         implements Observer JavaDoc {
41
42     private XmlElement element;
43
44     /**
45      * @param controller
46      */

47     public ShowMessagePreviewAction(IFrameMediator controller) {
48         super(controller, "Message Preview");
49
50         ViewItem item = ((DefaultFrameController)frameMediator).getViewItem();
51                 
52         element = item.getRoot().getElement("splitpanes");
53         if ( element == null ) {
54             element = new XmlElement("splitpanes");
55             item.getRoot().addElement(element);
56         }
57         
58         element.addObserver(this);
59
60         update(element, null);
61
62     }
63
64     /**
65      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
66      */

67     public void actionPerformed(ActionEvent JavaDoc arg0) {
68
69         
70         ((ThreePaneMailFrameController) frameMediator)
71                 .enableMessagePreview(getState());
72         
73         //DefaultItem item = new DefaultItem(element);
74
//item.set("header_enabled", getState());
75

76     }
77
78     /**
79      * Method is called when configuration changes.
80      *
81      * @param arg0
82      * @param arg1
83      */

84     public void update(Observable JavaDoc arg0, Object JavaDoc arg1) {
85
86         IDefaultItem item = new DefaultItem(element);
87         boolean enabled = item.getBooleanWithDefault("header_enabled", true);
88         
89         setState(enabled);
90     }
91 }
Popular Tags