01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //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;
21: import java.util.Observable;
22: import java.util.Observer;
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 {
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)
51: .getViewItem();
52:
53: element = item.getRoot().getElement("splitpanes");
54: if (element == null) {
55: element = new XmlElement("splitpanes");
56: item.getRoot().addElement(element);
57: }
58:
59: element.addObserver(this );
60:
61: update(element, null);
62:
63: }
64:
65: /**
66: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
67: */
68: public void actionPerformed(ActionEvent arg0) {
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 arg0, Object arg1) {
85:
86: IDefaultItem item = new DefaultItem(element);
87: boolean enabled = item.getBooleanWithDefault("header_enabled",
88: true);
89:
90: setState(enabled);
91: }
92: }
|