1 package org.columba.mail.config; 17 18 import java.io.File ; 19 import java.util.logging.Logger ; 20 21 import org.columba.core.config.DefaultXmlConfig; 22 import org.columba.core.config.GuiItem; 23 import org.columba.core.config.ViewItem; 24 import org.columba.core.xml.XmlElement; 25 26 27 public class MainFrameOptionsXmlConfig extends DefaultXmlConfig { 28 29 30 private static final Logger LOG = Logger.getLogger("org.columba.mail.config"); 31 32 33 GuiItem guiItem; 34 35 ViewItem viewItem; 36 boolean initialVersionWasApplied = false; 37 38 public MainFrameOptionsXmlConfig(File file) { 39 super(file); 40 } 41 42 public boolean load() { 43 boolean result = super.load(); 44 45 XmlElement root = getRoot().getElement(0); 47 String version = root.getAttribute("version"); 48 49 if (version == null) { 50 initialVersionWasApplied = true; 51 root.addAttribute("version", "1.0"); 52 } 53 54 convert(); 55 56 return result; 57 } 58 59 protected void convert() { 60 XmlElement root = getRoot(); 62 if (initialVersionWasApplied) { 63 LOG.fine("converting configuration to new version..."); 64 65 XmlElement gui = root.getElement("/options/gui"); 66 XmlElement messageframe = new XmlElement("messageframe"); 67 gui.addElement(messageframe); 68 69 XmlElement view = new XmlElement("view"); 70 messageframe.addElement(view); 71 view.addAttribute("id", "messageframe"); 72 73 XmlElement window = new XmlElement("window"); 74 window.addAttribute("width", "640"); 75 window.addAttribute("height", "480"); 76 window.addAttribute("maximized", "true"); 77 view.addElement(window); 78 79 XmlElement toolbars = new XmlElement("toolbars"); 80 toolbars.addAttribute("main", "true"); 81 view.addElement(toolbars); 82 83 XmlElement splitpanes = new XmlElement("splitpanes"); 84 splitpanes.addAttribute("main", "200"); 85 splitpanes.addAttribute("header", "200"); 86 splitpanes.addAttribute("attachment", "100"); 87 view.addElement(splitpanes); 88 } 89 } 90 91 public ViewItem getViewItem() { 92 if (viewItem == null) { 93 viewItem = new ViewItem(getRoot().getElement("/options/gui/viewlist/view")); 94 } 95 96 return viewItem; 97 } 98 99 public GuiItem getGuiItem() { 100 if (guiItem == null) { 101 guiItem = new GuiItem(getRoot().getElement("/options/gui")); 102 } 103 104 return guiItem; 105 } 106 107 } 108 | Popular Tags |