001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016: package org.columba.mail.config;
017:
018: import java.io.File;
019: import java.util.logging.Logger;
020:
021: import org.columba.core.config.DefaultXmlConfig;
022: import org.columba.core.config.GuiItem;
023: import org.columba.core.config.ViewItem;
024: import org.columba.core.xml.XmlElement;
025:
026: public class MainFrameOptionsXmlConfig extends DefaultXmlConfig {
027:
028: /** JDK 1.4+ logging framework logger, used for logging. */
029: private static final Logger LOG = Logger
030: .getLogger("org.columba.mail.config");
031:
032: GuiItem guiItem;
033:
034: ViewItem viewItem;
035: boolean initialVersionWasApplied = false;
036:
037: public MainFrameOptionsXmlConfig(File file) {
038: super (file);
039: }
040:
041: public boolean load() {
042: boolean result = super .load();
043:
044: //apply initial version information
045: XmlElement root = getRoot().getElement(0);
046: String version = root.getAttribute("version");
047:
048: if (version == null) {
049: initialVersionWasApplied = true;
050: root.addAttribute("version", "1.0");
051: }
052:
053: convert();
054:
055: return result;
056: }
057:
058: protected void convert() {
059: // add initial messageframe treenode
060: XmlElement root = getRoot();
061: if (initialVersionWasApplied) {
062: LOG.fine("converting configuration to new version...");
063:
064: XmlElement gui = root.getElement("/options/gui");
065: XmlElement messageframe = new XmlElement("messageframe");
066: gui.addElement(messageframe);
067:
068: XmlElement view = new XmlElement("view");
069: messageframe.addElement(view);
070: view.addAttribute("id", "messageframe");
071:
072: XmlElement window = new XmlElement("window");
073: window.addAttribute("width", "640");
074: window.addAttribute("height", "480");
075: window.addAttribute("maximized", "true");
076: view.addElement(window);
077:
078: XmlElement toolbars = new XmlElement("toolbars");
079: toolbars.addAttribute("main", "true");
080: view.addElement(toolbars);
081:
082: XmlElement splitpanes = new XmlElement("splitpanes");
083: splitpanes.addAttribute("main", "200");
084: splitpanes.addAttribute("header", "200");
085: splitpanes.addAttribute("attachment", "100");
086: view.addElement(splitpanes);
087: }
088: }
089:
090: public ViewItem getViewItem() {
091: if (viewItem == null) {
092: viewItem = new ViewItem(getRoot().getElement(
093: "/options/gui/viewlist/view"));
094: }
095:
096: return viewItem;
097: }
098:
099: public GuiItem getGuiItem() {
100: if (guiItem == null) {
101: guiItem = new GuiItem(getRoot().getElement("/options/gui"));
102: }
103:
104: return guiItem;
105: }
106:
107: }
|