1 | |
package org.jtheque.core.managers.view.impl.components.config; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.Managers; |
20 | |
import org.jtheque.core.managers.error.JThequeError; |
21 | |
import org.jtheque.core.managers.language.ILanguageManager; |
22 | |
import org.jtheque.core.managers.view.able.config.IOthersConfigView; |
23 | |
import org.jtheque.core.managers.view.impl.components.JThequeCheckBox; |
24 | |
import org.jtheque.core.utils.ui.Borders; |
25 | |
import org.jtheque.core.utils.ui.PanelBuilder; |
26 | |
import org.jtheque.utils.ui.GridBagUtils; |
27 | |
|
28 | |
import javax.swing.JCheckBox; |
29 | |
import javax.swing.JComponent; |
30 | |
import javax.swing.JPanel; |
31 | |
import javax.swing.JTextField; |
32 | |
import java.util.Collection; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public final class JPanelConfigOthers extends JPanel implements IOthersConfigView, ConfigTabComponent { |
40 | |
private JCheckBox boxDeleteLogs; |
41 | |
private JCheckBox checkBoxStart; |
42 | |
private JTextField fieldEmail; |
43 | |
private JTextField fieldSmtpHost; |
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
public JPanelConfigOthers() { |
49 | 0 | super(); |
50 | |
|
51 | 0 | build(); |
52 | |
|
53 | 0 | fillAllFields(); |
54 | 0 | } |
55 | |
|
56 | |
@Override |
57 | |
public String getTitle() { |
58 | 0 | return Managers.getManager(ILanguageManager.class).getMessage("config.view.tab.others"); |
59 | |
} |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
private void build() { |
65 | 0 | PanelBuilder builder = new PanelBuilder(this); |
66 | |
|
67 | 0 | addLogsPanel(builder); |
68 | 0 | addMailPanel(builder); |
69 | |
|
70 | 0 | checkBoxStart = new JThequeCheckBox("update.view.verify"); |
71 | 0 | add(checkBoxStart, builder.gbcSet(0, 2)); |
72 | 0 | } |
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
private void addLogsPanel(PanelBuilder parent) { |
80 | 0 | PanelBuilder builder = parent.addPanel(parent.gbcSet(0, 0, GridBagUtils.HORIZONTAL, GridBagUtils.FIRST_LINE_START)); |
81 | 0 | builder.getPanel().setBorder(Borders.createTitledBorder("config.others.logs.title")); |
82 | |
|
83 | 0 | boxDeleteLogs = builder.addI18nCheckBox("config.others.logs.delete", |
84 | |
builder.gbcSet(0, 0, GridBagUtils.HORIZONTAL, GridBagUtils.BASELINE_LEADING, 2, 1)); |
85 | |
|
86 | 0 | builder.addI18nLabel("config.others.logs.days", builder.gbcSet(0, 1)); |
87 | 0 | } |
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
private void addMailPanel(PanelBuilder parent) { |
95 | 0 | PanelBuilder builder = parent.addPanel(parent.gbcSet(0, 1, GridBagUtils.HORIZONTAL, GridBagUtils.FIRST_LINE_START)); |
96 | 0 | builder.getPanel().setBorder(Borders.createTitledBorder("config.others.mail.title")); |
97 | |
|
98 | 0 | builder.addI18nLabel("config.others.mail.userEmail", builder.gbcSet(0, 0, GridBagUtils.NONE, GridBagUtils.BASELINE_TRAILING)); |
99 | 0 | builder.addI18nLabel("config.others.mail.smtpHost", builder.gbcSet(0, 1, GridBagUtils.NONE, GridBagUtils.BASELINE_TRAILING)); |
100 | |
|
101 | 0 | fieldEmail = builder.add(new JTextField(10), builder.gbcSet(1, 0, GridBagUtils.HORIZONTAL)); |
102 | 0 | fieldSmtpHost = builder.add(new JTextField(10), builder.gbcSet(1, 1, GridBagUtils.HORIZONTAL)); |
103 | 0 | } |
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
private void fillAllFields() { |
109 | 0 | checkBoxStart.setSelected(Managers.getCore().getConfiguration().verifyUpdateOnStartup()); |
110 | 0 | boxDeleteLogs.setSelected(Managers.getCore().getConfiguration().mustDeleteLogs()); |
111 | 0 | fieldEmail.setText(Managers.getCore().getConfiguration().getUserEmail()); |
112 | 0 | fieldSmtpHost.setText(Managers.getCore().getConfiguration().getSmtpHost()); |
113 | 0 | } |
114 | |
|
115 | |
@Override |
116 | |
public void apply() { |
117 | 0 | Managers.getCore().getConfiguration().setVerifyUpdateOnStartup(checkBoxStart.isSelected()); |
118 | 0 | Managers.getCore().getConfiguration().setMustDeleteLogs(boxDeleteLogs.isSelected()); |
119 | 0 | Managers.getCore().getConfiguration().setUserEmail(fieldEmail.getText()); |
120 | 0 | Managers.getCore().getConfiguration().setSmtpHost(fieldSmtpHost.getText()); |
121 | 0 | } |
122 | |
|
123 | |
@Override |
124 | |
public void cancel() { |
125 | 0 | fillAllFields(); |
126 | 0 | } |
127 | |
|
128 | |
@Override |
129 | |
public JCheckBox getBoxDeleteLogs() { |
130 | 0 | return boxDeleteLogs; |
131 | |
} |
132 | |
|
133 | |
@Override |
134 | |
public void validate(Collection<JThequeError> errors) { |
135 | |
|
136 | 0 | } |
137 | |
|
138 | |
@Override |
139 | |
public JComponent getComponent() { |
140 | 0 | return this; |
141 | |
} |
142 | |
} |