1 | public void updateComponents(boolean b) { | | 1 | public void updateComponents(boolean b) { |
2 | | | 2 | if (b) { |
3 | GuiItem item = ((Config) Config.getInstance()).getOptionsConfig() | | 3 | IFilterRule filterRule = destFolder.getFilter().getFilterRule(); |
4 | .getGuiItem(); | | 4 | String value = filterRule.getCondition(); |
5 | | | 5 | |
6 | if (b) { | | 6 | if (value.equals("matchall")) { |
7 | // look and feel | | 7 | condList.setSelectedIndex(0); |
8 | theme = item.getString(GuiItem.THEME, GuiItem.NAME); | | 8 | } else { |
9 | oldLookAndFeelName = theme; | | 9 | condList.setSelectedIndex(1); |
10 | | | 10 | } |
11 | lfComboBox.setSelectedItem(theme); | | 11 | |
12 | | | 12 | boolean isInclude = Boolean.valueOf( |
13 | // fonts | | 13 | destFolder.getConfiguration().getString("property", |
14 | String mainName = item.getStringWithDefault(GuiItem.FONT_MAIN, | | 14 | "include_subfolders")).booleanValue(); |
15 | GuiItem.NAME, "default"); | | 15 | |
16 | int mainSize = item.getIntegerWithDefault(GuiItem.FONT_MAIN, | | 16 | includeSubfolderButton.setSelected(isInclude); |
17 | GuiItem.SIZE_INT, 12); | | 17 | |
18 | mainFont = new Font(mainName, Font.PLAIN, mainSize); | | 18 | String uid = destFolder.getConfiguration().getString("property", |
19 | | | 19 | "source_uid"); |
20 | String textName = item.getStringWithDefault(GuiItem.FONT_TEXT, | | 20 | |
21 | GuiItem.NAME, "default"); | | 21 | IMailFolder f = (IMailFolder) FolderTreeModel.getInstance() |
22 | int textSize = item.getIntegerWithDefault(GuiItem.FONT_TEXT, | | 22 | .getFolder(uid); |
23 | GuiItem.SIZE_INT, 12); | | 23 | |
24 | textFont = new Font(textName, Font.PLAIN, textSize); | | 24 | // If f==null because of deleted AbstractMessageFolder fallback to |
25 | | | 25 | // Inbox |
26 | mainFontButton.setText(mainName); | | 26 | if (f == null) { |
27 | mainFontButton.setFont(mainFont); | | 27 | uid = "101"; |
28 | textFontButton.setText(textName); | | 28 | destFolder.getConfiguration().setString("property", |
29 | textFontButton.setFont(textFont); | | 29 | "source_uid", uid); |
30 | | | 30 | f = (IMailbox) FolderTreeModel.getInstance().getFolder(uid); |
31 | boolean overwrite = item.getBooleanWithDefault(GuiItem.FONT, | | 31 | } |
32 | GuiItem.OVERWRITE_BOOL, false); | | 32 | |
33 | | | 33 | selectButton.setText(f.getTreePath()); |
34 | overwriteCheckBox.setSelected(overwrite); | | 34 | |
35 | | | 35 | criteriaList.updateComponents(b); |
36 | // enable/disable button, too | | 36 | } else { |
37 | textFontButton.setEnabled(overwrite); | | 37 | // get values from components |
38 | textFontLabel.setEnabled(overwrite); | | 38 | IFilterRule filterRule = destFolder.getFilter().getFilterRule(); |
39 | mainFontButton.setEnabled(overwrite); | | 39 | int index = condList.getSelectedIndex(); |
40 | mainFontLabel.setEnabled(overwrite); | | 40 | |
41 | | | 41 | if (index == 0) { |
42 | // language | | 42 | filterRule.setCondition("matchall"); |
43 | Locale[] available = GlobalResourceLoader.getAvailableLocales(); | | 43 | } else { |
44 | languageComboBox.setModel(new DefaultComboBoxModel(available)); | | 44 | filterRule.setCondition("matchany"); |
45 | | | 45 | } |
46 | // select Locale in ComboBox | | 46 | |
47 | for (int i = 0; i < available.length; i++) { | | 47 | if (includeSubfolderButton.isSelected()) { |
48 | if (available[i].equals(Locale.getDefault())) { | | 48 | destFolder.getConfiguration().setString("property", |
49 | languageComboBox.setSelectedIndex(i); | | 49 | "include_subfolders", "true"); |
50 | break; | | 50 | } else { |
51 | } | | 51 | destFolder.getConfiguration().setString("property", |
52 | } | | 52 | "include_subfolders", "false"); |
53 | | | 53 | } |
54 | boolean enableText = item.getBooleanWithDefault(GuiItem.TOOLBAR, | | 54 | |
55 | GuiItem.ENABLE_TEXT_BOOL, true); | | 55 | String path = selectButton.getText(); |
56 | | | 56 | TreeNodeList list = new TreeNodeList(path); |
57 | boolean alignment = item.getBooleanWithDefault(GuiItem.TOOLBAR, | | 57 | IMailFolder folder = (IMailFolder) FolderTreeModel.getInstance() |
58 | GuiItem.TEXT_POSITION_BOOL, true); | | 58 | .getFolder(list); |
59 | | | 59 | String uid = folder.getId(); |
60 | if (enableText) { | | 60 | destFolder.getConfiguration().setString("property", "source_uid", |
61 | toolbarComboBox.setSelectedIndex(alignment ? 1 : 2); | | 61 | uid); |
62 | } | | 62 | |
63 | | | 63 | criteriaList.updateComponents(b); |
64 | proxyHost = System.getProperty("http.proxyHost"); | | 64 | } |
65 | String proxyPortString = System.getProperty("http.proxyPort", "-1"); | | 65 | } |
66 | proxyPort = Integer.parseInt(proxyPortString); | | | |
67 | updateProxyButtonText(); | | | |
68 | } else { | | | |
69 | // fonts | | | |
70 | item.setString(GuiItem.FONT_MAIN, GuiItem.NAME, getMainFont() | | | |
71 | .getName()); | | | |
72 | item.setInteger(GuiItem.FONT_MAIN, GuiItem.SIZE_INT, getMainFont() | | | |
73 | .getSize()); | | | |
74 | | | | |
75 | item.setString(GuiItem.FONT_TEXT, GuiItem.NAME, getTextFont() | | | |
76 | .getName()); | | | |
77 | item.setInteger(GuiItem.FONT_TEXT, GuiItem.SIZE_INT, getTextFont() | | | |
78 | .getSize()); | | | |
79 | | | | |
80 | item.setBoolean(GuiItem.FONT, GuiItem.OVERWRITE_BOOL, | | | |
81 | overwriteCheckBox.isSelected()); | | | |
82 | | | | |
83 | // notify all listeners | | | |
84 | // @see org.columba.core.gui.util.FontProperties | | | |
85 | // @see org.columba.mail.gui.message.TextViewer | | | |
86 | // @see org.columba.mail.gui.composer.text.TextEditorController | | | |
87 | item.getElement("fonts").notifyObservers(); | | | |
88 | | | | |
89 | // look and feel | | | |
90 | item.setString(GuiItem.THEME, GuiItem.NAME, (String) lfComboBox | | | |
91 | .getSelectedItem()); | | | |
92 | | | | |
93 | // remember if Look And Feel has been changed | | | |
94 | if (!oldLookAndFeelName.equals((String) lfComboBox | | | |
95 | .getSelectedItem())) | | | |
96 | restartRequired = true; | | | |
97 | | | | |
98 | // get language configuration | | | |
99 | XmlElement locale = Config.getInstance().get("options").getElement( | | | |
100 | "/options/locale"); | | | |
101 | | | | |
102 | // set language config based on selected item | | | |
103 | Locale l = (Locale) languageComboBox.getSelectedItem(); | | | |
104 | locale.addAttribute("language", l.getLanguage()); | | | |
105 | locale.addAttribute("country", l.getCountry()); | | | |
106 | locale.addAttribute("variant", l.getVariant()); | | | |
107 | | | | |
108 | int state = toolbarComboBox.getSelectedIndex(); | | | |
109 | if (state == 0) { | | | |
110 | item.setBoolean(GuiItem.TOOLBAR, GuiItem.ENABLE_TEXT_BOOL, | | | |
111 | false); | | | |
112 | | | | |
113 | } else { | | | |
114 | item | | | |
115 | .setBoolean(GuiItem.TOOLBAR, GuiItem.ENABLE_TEXT_BOOL, | | | |
116 | true); | | | |
117 | | | | |
118 | item.setBoolean(GuiItem.TOOLBAR, GuiItem.TEXT_POSITION_BOOL, | | | |
119 | state == 1 ? true : false); | | | |
120 | | | | |
121 | } | | | |
122 | | | | |
123 | XmlElement options = Config.getInstance().get("options") | | | |
124 | .getElement("/options"); | | | |
125 | | | | |
126 | XmlElement proxy = options.getElement("proxy"); | | | |
127 | if (proxyHost != null && proxyPort > 0) { | | | |
128 | System.setProperty("http.proxyHost", proxyHost); | | | |
129 | System.setProperty("http.proxyPort", Integer | | | |
130 | .toString(proxyPort)); | | | |
131 | if (proxy == null) { | | | |
132 | proxy = options.addSubElement("proxy"); | | | |
133 | } | | | |
134 | proxy.addAttribute("host", proxyHost); | | | |
135 | proxy.addAttribute("port", Integer.toString(proxyPort)); | | | |
136 | } else { | | | |
137 | Properties properties = System.getProperties(); | | | |
138 | properties.remove("http.proxyHost"); | | | |
139 | properties.remove("http.proxyPort"); | | | |
140 | if (proxy != null) { | | | |
141 | options.removeElement(proxy); | | | |
142 | } | | | |
143 | } | | | |
144 | } | | | |
145 | } | | | |