1 | public void updateComponents(boolean b) { | | 1 | protected void initComponents() { |
2 | | | 2 | defaultAccountCheckBox = new CheckBoxWithMnemonic(MailResourceLoader |
3 | GuiItem item = ((Config) Config.getInstance()).getOptionsConfig() | | 3 | .getString("dialog", "account", "use_default_account_settings")); |
4 | .getGuiItem(); | | 4 | |
5 | | | 5 | defaultAccountCheckBox.setActionCommand("DEFAULT_ACCOUNT"); |
6 | if (b) { | | 6 | defaultAccountCheckBox.addActionListener(this); |
7 | // look and feel | | 7 | |
8 | theme = item.getString(GuiItem.THEME, GuiItem.NAME); | | 8 | // defaultAccountCheckBox.setEnabled(false); |
9 | oldLookAndFeelName = theme; | | 9 | typeLabel = new LabelWithMnemonic(MailResourceLoader.getString( |
10 | | | 10 | "dialog", "account", "server_type")); |
11 | lfComboBox.setSelectedItem(theme); | | 11 | |
12 | | | 12 | typeComboBox = new JComboBox(); |
13 | // fonts | | 13 | typeComboBox.addItem("POP3"); |
14 | String mainName = item.getStringWithDefault(GuiItem.FONT_MAIN, | | 14 | typeComboBox.addItem("IMAP4"); |
15 | GuiItem.NAME, "default"); | | 15 | |
16 | int mainSize = item.getIntegerWithDefault(GuiItem.FONT_MAIN, | | 16 | if (accountItem.isPopAccount()) { |
17 | GuiItem.SIZE_INT, 12); | | 17 | typeComboBox.setSelectedIndex(0); |
18 | mainFont = new Font(mainName, Font.PLAIN, mainSize); | | 18 | } else { |
19 | | | 19 | typeComboBox.setSelectedIndex(1); |
20 | String textName = item.getStringWithDefault(GuiItem.FONT_TEXT, | | 20 | } |
21 | GuiItem.NAME, "default"); | | 21 | |
22 | int textSize = item.getIntegerWithDefault(GuiItem.FONT_TEXT, | | 22 | typeLabel.setLabelFor(typeComboBox); |
23 | GuiItem.SIZE_INT, 12); | | 23 | typeComboBox.setEnabled(false); |
24 | textFont = new Font(textName, Font.PLAIN, textSize); | | 24 | |
25 | | | 25 | // TODO (@author fdietz): i18n |
26 | mainFontButton.setText(mainName); | | 26 | typeDescriptionLabel = new JLabel( |
27 | mainFontButton.setFont(mainFont); | | 27 | "Description: To connect to and fetch new messages from a POP3-server."); |
28 | textFontButton.setText(textName); | | 28 | typeDescriptionLabel.setEnabled(false); |
29 | textFontButton.setFont(textFont); | | 29 | |
30 | | | 30 | loginLabel = new LabelWithMnemonic(MailResourceLoader.getString( |
31 | boolean overwrite = item.getBooleanWithDefault(GuiItem.FONT, | | 31 | "dialog", "account", "login")); |
32 | GuiItem.OVERWRITE_BOOL, false); | | 32 | |
33 | | | 33 | loginTextField = new JTextField(); |
34 | overwriteCheckBox.setSelected(overwrite); | | 34 | loginLabel.setLabelFor(loginTextField); |
35 | | | 35 | |
36 | // enable/disable button, too | | 36 | passwordTextField = new JTextField(); |
37 | textFontButton.setEnabled(overwrite); | | 37 | |
38 | textFontLabel.setEnabled(overwrite); | | 38 | hostLabel = new LabelWithMnemonic(MailResourceLoader.getString( |
39 | mainFontButton.setEnabled(overwrite); | | 39 | "dialog", "account", IncomingItem.HOST)); |
40 | mainFontLabel.setEnabled(overwrite); | | 40 | |
41 | | | 41 | hostTextField = new JTextField(); |
42 | // language | | 42 | hostLabel.setLabelFor(hostTextField); |
43 | Locale[] available = GlobalResourceLoader.getAvailableLocales(); | | 43 | |
44 | languageComboBox.setModel(new DefaultComboBoxModel(available)); | | 44 | portLabel = new LabelWithMnemonic(MailResourceLoader.getString( |
45 | | | 45 | "dialog", "account", IncomingItem.PORT)); |
46 | // select Locale in ComboBox | | 46 | |
47 | for (int i = 0; i < available.length; i++) { | | 47 | portSpinner = new JSpinner(new SpinnerNumberModel(100, 1, 65535, 1)); |
48 | if (available[i].equals(Locale.getDefault())) { | | 48 | portSpinner.setEditor(new JSpinner.NumberEditor(portSpinner, "#####")); |
49 | languageComboBox.setSelectedIndex(i); | | 49 | portLabel.setLabelFor(portSpinner); |
50 | break; | | 50 | |
51 | } | | 51 | storePasswordCheckBox = new CheckBoxWithMnemonic(MailResourceLoader |
52 | } | | 52 | .getString("dialog", "account", |
53 | | | 53 | "store_password_in_configuration_file")); |
54 | boolean enableText = item.getBooleanWithDefault(GuiItem.TOOLBAR, | | 54 | |
55 | GuiItem.ENABLE_TEXT_BOOL, true); | | 55 | storePasswordCheckBox.setActionCommand("SAVE"); |
56 | | | 56 | storePasswordCheckBox.addActionListener(this); |
57 | boolean alignment = item.getBooleanWithDefault(GuiItem.TOOLBAR, | | 57 | |
58 | GuiItem.TEXT_POSITION_BOOL, true); | | 58 | secureCheckBox = new CheckBoxWithMnemonic(MailResourceLoader.getString( |
59 | | | 59 | "dialog", "account", "use_SSL_for_secure_connection")); |
60 | if (enableText) { | | 60 | secureCheckBox.setActionCommand("SSL"); |
61 | toolbarComboBox.setSelectedIndex(alignment ? 1 : 2); | | 61 | secureCheckBox.addActionListener(this); |
62 | } | | 62 | |
63 | | | 63 | authenticationLabel = new LabelWithMnemonic(MailResourceLoader |
64 | proxyHost = System.getProperty("http.proxyHost"); | | 64 | .getString("dialog", "account", "authentication_type")); |
65 | String proxyPortString = System.getProperty("http.proxyPort", "-1"); | | 65 | |
66 | proxyPort = Integer.parseInt(proxyPortString); | | 66 | authenticationComboBox = new JComboBox(); |
67 | updateProxyButtonText(); | | 67 | authenticationComboBox |
68 | } else { | | 68 | .setRenderer(new AuthenticationListCellRenderer()); |
69 | // fonts | | 69 | authenticationLabel.setLabelFor(authenticationComboBox); |
70 | item.setString(GuiItem.FONT_MAIN, GuiItem.NAME, getMainFont() | | 70 | |
71 | .getName()); | | 71 | updateAuthenticationComboBox(); |
72 | item.setInteger(GuiItem.FONT_MAIN, GuiItem.SIZE_INT, getMainFont() | | 72 | |
73 | .getSize()); | | 73 | checkAuthMethods = new ButtonWithMnemonic(MailResourceLoader.getString( |
74 | | | 74 | "dialog", "account", "authentication_checkout_methods")); |
75 | item.setString(GuiItem.FONT_TEXT, GuiItem.NAME, getTextFont() | | 75 | checkAuthMethods.setActionCommand("CHECK_AUTHMETHODS"); |
76 | .getName()); | | 76 | checkAuthMethods.addActionListener(this); |
77 | item.setInteger(GuiItem.FONT_TEXT, GuiItem.SIZE_INT, getTextFont() | | 77 | |
78 | .getSize()); | | 78 | sslComboBox = new JComboBox(); |
79 | | | 79 | if (isPopAccount()) { |
80 | item.setBoolean(GuiItem.FONT, GuiItem.OVERWRITE_BOOL, | | 80 | sslComboBox.addItem(MailResourceLoader.getString("dialog", |
81 | overwriteCheckBox.isSelected()); | | 81 | "account", "pop3s_in_checkbox")); |
82 | | | 82 | } else { |
83 | // notify all listeners | | 83 | sslComboBox.addItem(MailResourceLoader.getString("dialog", |
84 | // @see org.columba.core.gui.util.FontProperties | | 84 | "account", "imaps_in_checkbox")); |
85 | // @see org.columba.mail.gui.message.TextViewer | | 85 | } |
86 | // @see org.columba.mail.gui.composer.text.TextEditorController | | 86 | sslComboBox.addItem(MailResourceLoader.getString("dialog", "account", |
87 | item.getElement("fonts").notifyObservers(); | | 87 | "tls_in_checkbox")); |
88 | | | 88 | sslComboBox.setActionCommand("SSL"); |
89 | // look and feel | | 89 | sslComboBox.addActionListener(this); |
90 | item.setString(GuiItem.THEME, GuiItem.NAME, (String) lfComboBox | | 90 | } |
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 | } | | | |