01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
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.folderoptions;
17:
18: import org.columa.core.config.IDefaultItem;
19: import org.columba.core.config.DefaultItem;
20: import org.columba.core.xml.XmlElement;
21: import org.columba.mail.folder.IMailbox;
22: import org.columba.mail.gui.frame.MailFrameMediator;
23: import org.columba.mail.gui.frame.TableViewOwner;
24: import org.columba.mail.gui.table.ITableController;
25:
26: /**
27: * Handles enabled/disabled state of threaded-view.
28: *
29: * @author fdietz
30: */
31: public class ThreadedViewOptionsPlugin extends
32: AbstractFolderOptionsPlugin {
33: /**
34: * Constructor
35: *
36: * @param mediator
37: * mail framemediator
38: */
39: public ThreadedViewOptionsPlugin(MailFrameMediator mediator) {
40: super ("threadedview", "ThreadedViewOptions", mediator);
41: }
42:
43: /**
44: * @see org.columba.mail.folderoptions.AbstractFolderOptionsPlugin#saveOptionsToXml(IMailbox)
45: */
46: public void saveOptionsToXml(IMailbox folder) {
47: XmlElement parent = getConfigNode(folder);
48: IDefaultItem item = new DefaultItem(parent);
49:
50: ITableController tableController = ((ITableController) ((TableViewOwner) getMediator())
51: .getTableController());
52:
53: item.setBoolean("enabled", tableController
54: .isThreadedViewEnabled());
55: }
56:
57: /**
58: * @see org.columba.mail.folderoptions.AbstractFolderOptionsPlugin#loadOptionsFromXml(IMailbox)
59: */
60: public void loadOptionsFromXml(IMailbox folder) {
61: XmlElement parent = getConfigNode(folder);
62: IDefaultItem item = new DefaultItem(parent);
63:
64: boolean enableThreadedView = item.getBooleanWithDefault(
65: "enabled", false);
66:
67: ITableController tableController = ((ITableController) ((TableViewOwner) getMediator())
68: .getTableController());
69:
70: tableController.enableThreadedView(enableThreadedView, false);
71: }
72:
73: /**
74: * @see org.columba.mail.folderoptions.AbstractFolderOptionsPlugin#createDefaultElement()
75: */
76: public XmlElement createDefaultElement(boolean global) {
77: XmlElement parent = super .createDefaultElement(global);
78: parent.addAttribute("enabled", "false");
79:
80: return parent;
81: }
82: }
|