1 package org.wcb.gui.forms;
2
3 import org.jdesktop.swingx.VerticalLayout;
4 import org.wcb.gui.component.JMessageTextPane;
5 import org.wcb.gui.component.IntegerJTextField;
6
7 import javax.swing.*;
8 import java.text.ParseException;
9 import java.awt.*;
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 public class ConfigureAppForm extends JPanel {
38
39 private JCheckBox jCheckBoxLogin, jCheckBoxEnableCloseEffect, jCheckBoxWarnIfr, jCheckBoxWarnStartUp;
40 private JComboBox rowCount;
41 private IntegerJTextField warningDays;
42 private IntegerJTextField warningNight;
43 private IntegerJTextField warningIfr;
44
45 public ConfigureAppForm() {
46 initComponents();
47 }
48
49 private void initComponents() {
50 jCheckBoxLogin = new JCheckBox("User authentication.");
51 jCheckBoxLogin.setToolTipText("Check this if you want to be presented with user name and password login to access the application.");
52 jCheckBoxEnableCloseEffect = new JCheckBox("Enable special effect.");
53 jCheckBoxEnableCloseEffect.setToolTipText("Shows spinning application as it closes, just visual eye candy.");
54 jCheckBoxWarnStartUp = new JCheckBox("Warn about pilot currency at start-up");
55 jCheckBoxWarnStartUp.setToolTipText("Show warning dialog of pilot currency.");
56 jCheckBoxWarnStartUp = new JCheckBox("Show pilot currency at start-up.");
57 warningDays = new IntegerJTextField(3);
58 warningDays.setToolTipText("Number of days before a warning message shows.");
59 warningNight = new IntegerJTextField(3);
60 warningNight.setToolTipText("Number of days before warning message shows.");
61 warningIfr = new IntegerJTextField(3);
62 warningIfr.setToolTipText("Number of days before warning message shows.");
63 jCheckBoxWarnIfr = new JCheckBox("Warn at number of days for IFR currency:");
64 rowCount = new JComboBox(new DefaultComboBoxModel(new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}));
65 setLayout(new VerticalLayout(5));
66 add(this.getMessagePanel());
67 add(this.getLoginPanel());
68 add(this.getSpecialEffectPanel());
69 add(this.getWarningPanel());
70 add(this.getWarningNoticePanel());
71 }
72
73 private JPanel getMessagePanel() {
74 JPanel messagePanel = new JPanel();
75 String[] initString =
76 { " " ,
77 "This screen is to configure settings in the overall application.",
78 " " ,
79 "You can select any of the options below to configure the application",
80 "to your liking. ",
81 "NOTE: Many of these configuration changes may not",
82 "take effect until the next start-up of the application.",
83 " ",
84 };
85 JMessageTextPane messagePane = new JMessageTextPane(initString);
86 messagePanel.add(messagePane.getTextPane());
87 return messagePanel;
88 }
89
90 private JPanel getLoginPanel() {
91 JPanel returnPanel = new JPanel();
92 returnPanel.add(jCheckBoxLogin);
93 return returnPanel;
94 }
95
96 private JPanel getSpecialEffectPanel() {
97 JPanel returnPanel = new JPanel();
98 returnPanel.add(jCheckBoxEnableCloseEffect);
99 return returnPanel;
100 }
101
102 private JPanel getWarningPanel() {
103 JPanel returnPanel = new JPanel();
104 returnPanel.add(jCheckBoxWarnStartUp);
105 return returnPanel;
106 }
107
108 private JPanel getWarningNoticePanel() {
109 JPanel rowCountPanel = new JPanel();
110 rowCountPanel.setLayout(new GridBagLayout());
111 GridBagConstraints gridBagConstraints;
112
113 gridBagConstraints = new GridBagConstraints();
114 gridBagConstraints.gridx = 0;
115 gridBagConstraints.gridy = 1;
116 gridBagConstraints.anchor = GridBagConstraints.WEST;
117 rowCountPanel.add(new JLabel("Number of log entries per page: "), gridBagConstraints);
118
119 gridBagConstraints = new GridBagConstraints();
120 gridBagConstraints.gridx = 1;
121 gridBagConstraints.gridy = 1;
122 gridBagConstraints.anchor = GridBagConstraints.WEST;
123 rowCountPanel.add(rowCount, gridBagConstraints);
124
125 gridBagConstraints = new GridBagConstraints();
126 gridBagConstraints.gridx = 0;
127 gridBagConstraints.gridy = 2;
128 gridBagConstraints.anchor = GridBagConstraints.WEST;
129 rowCountPanel.add(new JLabel("Warn at number of days to carry passengers: "), gridBagConstraints);
130
131 gridBagConstraints = new GridBagConstraints();
132 gridBagConstraints.gridx = 1;
133 gridBagConstraints.gridy = 2;
134 gridBagConstraints.anchor = GridBagConstraints.WEST;
135 rowCountPanel.add(warningDays, gridBagConstraints);
136
137 gridBagConstraints = new GridBagConstraints();
138 gridBagConstraints.gridx = 0;
139 gridBagConstraints.gridy = 3;
140 gridBagConstraints.anchor = GridBagConstraints.WEST;
141 rowCountPanel.add(new JLabel("Warn at number of days to passengers at night: "), gridBagConstraints);
142
143 gridBagConstraints = new GridBagConstraints();
144 gridBagConstraints.gridx = 1;
145 gridBagConstraints.gridy = 3;
146 gridBagConstraints.anchor = GridBagConstraints.WEST;
147 rowCountPanel.add(warningNight, gridBagConstraints);
148
149 gridBagConstraints = new GridBagConstraints();
150 gridBagConstraints.gridx = 0;
151 gridBagConstraints.gridy = 4;
152 gridBagConstraints.anchor = GridBagConstraints.WEST;
153 rowCountPanel.add(jCheckBoxWarnIfr, gridBagConstraints);
154
155 gridBagConstraints = new GridBagConstraints();
156 gridBagConstraints.gridx = 1;
157 gridBagConstraints.gridy = 4;
158 gridBagConstraints.anchor = GridBagConstraints.WEST;
159 rowCountPanel.add(warningIfr, gridBagConstraints);
160 return rowCountPanel;
161 }
162
163
164
165
166
167
168 public boolean isEnableLogin() {
169 return jCheckBoxLogin.isSelected();
170 }
171
172 public void setEnableLogin(boolean isEnabled) {
173 jCheckBoxLogin.setSelected(isEnabled);
174 }
175
176
177
178
179
180 public int getNumberRows() {
181 return (Integer) rowCount.getSelectedItem();
182 }
183
184 public void setNumberRows(int value) {
185 rowCount.setSelectedIndex(value -1);
186 }
187
188
189
190
191
192 public boolean isEnableEffect() {
193 return jCheckBoxEnableCloseEffect.isSelected();
194 }
195
196 public void setEnableEffect(boolean isEnabled) {
197 jCheckBoxEnableCloseEffect.setSelected(isEnabled);
198 }
199
200
201
202
203
204
205 public boolean isEnableRecencyWarning() {
206 return jCheckBoxWarnStartUp.isSelected();
207 }
208
209 public void setEnableRecencyWarning(boolean isEnabled) {
210 jCheckBoxWarnStartUp.setSelected(isEnabled);
211 }
212
213 public int getWarningDays() throws ParseException {
214 return Integer.parseInt(warningDays.getText());
215 }
216
217 public void setWarningDays(int value) {
218 this.warningDays.setText(value + "");
219 }
220
221 public int getWarningNight() throws ParseException {
222 return Integer.parseInt(warningNight.getText());
223 }
224
225 public void setWarningNight(int warningNight) {
226 this.warningNight.setText(warningNight + "");
227 }
228
229
230
231
232
233
234 public boolean isIfr() {
235 return jCheckBoxWarnIfr.isSelected();
236 }
237
238 public void setEnableIfr(boolean isEnabled) {
239 jCheckBoxWarnIfr.setSelected(isEnabled);
240 }
241
242
243
244
245
246
247 public int getWarningIfr() throws ParseException {
248 return Integer.parseInt(warningIfr.getText());
249 }
250
251 public void setWarningIfr(int warningIfr) {
252 this.warningIfr.setText(warningIfr + "");
253 }
254 }