19 package org.sleuthkit.autopsy.corecomponents;
21 import java.awt.Color;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import javax.swing.JTextField;
25 import javax.swing.event.DocumentEvent;
26 import javax.swing.event.DocumentListener;
27 import org.openide.util.NbBundle;
33 import java.awt.Cursor;
34 import java.util.logging.Level;
35 import javax.swing.ImageIcon;
36 import org.openide.util.ImageUtilities;
37 import org.openide.util.Lookup;
49 @SuppressWarnings(
"PMD.SingularField")
52 private static final String HOST_NAME_OR_IP_PROMPT = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbHostname.toolTipText");
53 private static final String PORT_PROMPT = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbPort.toolTipText");
54 private static final String USER_NAME_PROMPT = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbUsername.toolTipText");
55 private static final String PASSWORD_PROMPT = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbPassword.toolTipText");
56 private static final String USER_NAME_PROMPT_OPT = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgUsername.toolTipText");
57 private static final String PASSWORD_PROMPT_OPT = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgPassword.toolTipText");
58 private static final String INCOMPLETE_SETTINGS_MSG = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.validationErrMsg.incomplete");
59 private static final String INVALID_DB_PORT_MSG = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.validationErrMsg.invalidDatabasePort");
60 private static final String INVALID_MESSAGE_SERVICE_PORT_MSG = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.validationErrMsg.invalidMessageServicePort");
61 private static final String INVALID_INDEXING_SERVER_PORT_MSG = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.validationErrMsg.invalidIndexingServerPort");
62 private static final long serialVersionUID = 1L;
64 private final Collection<JTextField> textBoxes =
new ArrayList<>();
78 controller = theController;
84 Collection<TextPrompt> textPrompts =
new ArrayList<>();
85 textPrompts.add(
new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbDbHostname));
86 textPrompts.add(
new TextPrompt(PORT_PROMPT, tbDbPort));
87 textPrompts.add(
new TextPrompt(USER_NAME_PROMPT, tbDbUsername));
88 textPrompts.add(
new TextPrompt(PASSWORD_PROMPT, tbDbPassword));
89 textPrompts.add(
new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbMsgHostname));
90 textPrompts.add(
new TextPrompt(PORT_PROMPT, tbMsgPort));
91 textPrompts.add(
new TextPrompt(USER_NAME_PROMPT_OPT, tbMsgUsername));
92 textPrompts.add(
new TextPrompt(PASSWORD_PROMPT_OPT, tbMsgPassword));
93 textPrompts.add(
new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbSolrHostname));
94 textPrompts.add(
new TextPrompt(PORT_PROMPT, tbSolrPort));
95 configureTextPrompts(textPrompts);
101 tbDbHostname.getDocument().putProperty(
"statusIcon", lbTestDatabase);
102 tbDbPort.getDocument().putProperty(
"statusIcon", lbTestDatabase);
103 tbDbUsername.getDocument().putProperty(
"statusIcon", lbTestDatabase);
104 tbDbPassword.getDocument().putProperty(
"statusIcon", lbTestDatabase);
106 tbSolrHostname.getDocument().putProperty(
"statusIcon", lbTestSolr);
107 tbSolrPort.getDocument().putProperty(
"statusIcon", lbTestSolr);
109 tbMsgHostname.getDocument().putProperty(
"statusIcon", lbTestMessageService);
110 tbMsgPort.getDocument().putProperty(
"statusIcon", lbTestMessageService);
111 tbMsgUsername.getDocument().putProperty(
"statusIcon", lbTestMessageService);
112 tbMsgPassword.getDocument().putProperty(
"statusIcon", lbTestMessageService);
115 textBoxChangedListener =
new TextBoxChangedListener();
116 textBoxes.add(tbDbHostname);
117 textBoxes.add(tbDbPort);
118 textBoxes.add(tbDbUsername);
119 textBoxes.add(tbDbPassword);
120 textBoxes.add(tbMsgHostname);
121 textBoxes.add(tbMsgPort);
122 textBoxes.add(tbMsgUsername);
123 textBoxes.add(tbMsgPassword);
124 textBoxes.add(tbSolrHostname);
125 textBoxes.add(tbSolrPort);
127 addDocumentListeners(textBoxes, textBoxChangedListener);
128 goodIcon =
new ImageIcon(ImageUtilities.loadImage(
"org/sleuthkit/autopsy/images/good.png",
false));
129 badIcon =
new ImageIcon(ImageUtilities.loadImage(
"org/sleuthkit/autopsy/images/bad.png",
false));
130 enableMultiUserComponents(textBoxes, cbEnableMultiUser.isSelected());
142 textPrompt.setForeground(Color.LIGHT_GRAY);
143 textPrompt.changeAlpha(alpha);
154 for (JTextField textField : textFields) {
155 textField.getDocument().addDocumentListener(listener);
164 @SuppressWarnings(
"unchecked")
166 private
void initComponents() {
168 jScrollPane =
new javax.swing.JScrollPane();
169 pnOverallPanel =
new javax.swing.JPanel();
170 pnDatabaseSettings =
new javax.swing.JPanel();
171 tbDbHostname =
new javax.swing.JTextField();
172 tbDbPort =
new javax.swing.JTextField();
173 tbDbUsername =
new javax.swing.JTextField();
174 tbDbPassword =
new javax.swing.JPasswordField();
175 lbDatabaseSettings =
new javax.swing.JLabel();
176 bnTestDatabase =
new javax.swing.JButton();
177 lbTestDatabase =
new javax.swing.JLabel();
178 lbTestDbWarning =
new javax.swing.JLabel();
179 pnSolrSettings =
new javax.swing.JPanel();
180 lbSolrSettings =
new javax.swing.JLabel();
181 tbSolrHostname =
new javax.swing.JTextField();
182 tbSolrPort =
new javax.swing.JTextField();
183 bnTestSolr =
new javax.swing.JButton();
184 lbTestSolr =
new javax.swing.JLabel();
185 lbTestSolrWarning =
new javax.swing.JLabel();
186 pnMessagingSettings =
new javax.swing.JPanel();
187 lbMessageServiceSettings =
new javax.swing.JLabel();
188 tbMsgHostname =
new javax.swing.JTextField();
189 tbMsgUsername =
new javax.swing.JTextField();
190 tbMsgPort =
new javax.swing.JTextField();
191 tbMsgPassword =
new javax.swing.JPasswordField();
192 bnTestMessageService =
new javax.swing.JButton();
193 lbTestMessageService =
new javax.swing.JLabel();
194 lbTestMessageWarning =
new javax.swing.JLabel();
195 cbEnableMultiUser =
new javax.swing.JCheckBox();
196 tbOops =
new javax.swing.JTextField();
198 pnDatabaseSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
200 tbDbHostname.setFont(tbDbHostname.getFont().deriveFont(tbDbHostname.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
201 tbDbHostname.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbHostname.text"));
202 tbDbHostname.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbHostname.toolTipText"));
204 tbDbPort.setFont(tbDbPort.getFont().deriveFont(tbDbPort.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
205 tbDbPort.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbPort.text"));
206 tbDbPort.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbPort.toolTipText"));
208 tbDbUsername.setFont(tbDbUsername.getFont().deriveFont(tbDbUsername.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
209 tbDbUsername.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbUsername.text"));
210 tbDbUsername.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbUsername.toolTipText"));
212 tbDbPassword.setFont(tbDbPassword.getFont().deriveFont(tbDbPassword.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
213 tbDbPassword.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbPassword.text"));
214 tbDbPassword.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbPassword.toolTipText"));
216 lbDatabaseSettings.setFont(lbDatabaseSettings.getFont().deriveFont(lbDatabaseSettings.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
217 org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseSettings,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbDatabaseSettings.text"));
218 lbDatabaseSettings.setVerticalAlignment(javax.swing.SwingConstants.TOP);
220 bnTestDatabase.setFont(bnTestDatabase.getFont().deriveFont(bnTestDatabase.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
221 org.openide.awt.Mnemonics.setLocalizedText(bnTestDatabase,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.bnTestDatabase.text"));
222 bnTestDatabase.addActionListener(
new java.awt.event.ActionListener() {
223 public void actionPerformed(java.awt.event.ActionEvent evt) {
224 bnTestDatabaseActionPerformed(evt);
228 org.openide.awt.Mnemonics.setLocalizedText(lbTestDatabase,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbTestDatabase.text"));
229 lbTestDatabase.setAutoscrolls(
true);
231 lbTestDbWarning.setForeground(
new java.awt.Color(255, 0, 0));
232 org.openide.awt.Mnemonics.setLocalizedText(lbTestDbWarning,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbTestDbWarning.text"));
234 javax.swing.GroupLayout pnDatabaseSettingsLayout =
new javax.swing.GroupLayout(pnDatabaseSettings);
235 pnDatabaseSettings.setLayout(pnDatabaseSettingsLayout);
236 pnDatabaseSettingsLayout.setHorizontalGroup(
237 pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
238 .addGroup(pnDatabaseSettingsLayout.createSequentialGroup()
240 .addGroup(pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
241 .addComponent(tbDbHostname)
242 .addGroup(pnDatabaseSettingsLayout.createSequentialGroup()
243 .addComponent(lbDatabaseSettings)
244 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
245 .addComponent(bnTestDatabase)
247 .addComponent(lbTestDatabase, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
248 .addComponent(tbDbPort)
249 .addComponent(tbDbUsername)
250 .addComponent(tbDbPassword)
251 .addGroup(pnDatabaseSettingsLayout.createSequentialGroup()
252 .addComponent(lbTestDbWarning)
253 .addGap(0, 0, Short.MAX_VALUE)))
256 pnDatabaseSettingsLayout.setVerticalGroup(
257 pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
258 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnDatabaseSettingsLayout.createSequentialGroup()
260 .addGroup(pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
261 .addComponent(bnTestDatabase)
262 .addComponent(lbTestDatabase, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
263 .addComponent(lbDatabaseSettings))
264 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
265 .addComponent(tbDbHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
266 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
267 .addComponent(tbDbPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
268 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
269 .addComponent(tbDbUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
270 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
271 .addComponent(tbDbPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
272 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
273 .addComponent(lbTestDbWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
277 pnSolrSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
279 lbSolrSettings.setFont(lbSolrSettings.getFont().deriveFont(lbSolrSettings.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
280 org.openide.awt.Mnemonics.setLocalizedText(lbSolrSettings,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbSolrSettings.text"));
282 tbSolrHostname.setFont(tbSolrHostname.getFont().deriveFont(tbSolrHostname.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
283 tbSolrHostname.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbSolrHostname.toolTipText"));
285 tbSolrPort.setFont(tbSolrPort.getFont().deriveFont(tbSolrPort.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
286 tbSolrPort.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbSolrPort.toolTipText"));
288 bnTestSolr.setFont(bnTestSolr.getFont().deriveFont(bnTestSolr.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
289 org.openide.awt.Mnemonics.setLocalizedText(bnTestSolr,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.bnTestSolr.text"));
290 bnTestSolr.addActionListener(
new java.awt.event.ActionListener() {
291 public void actionPerformed(java.awt.event.ActionEvent evt) {
292 bnTestSolrActionPerformed(evt);
296 org.openide.awt.Mnemonics.setLocalizedText(lbTestSolr,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbTestSolr.text"));
298 lbTestSolrWarning.setForeground(
new java.awt.Color(255, 0, 0));
299 org.openide.awt.Mnemonics.setLocalizedText(lbTestSolrWarning,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbTestSolrWarning.text"));
301 javax.swing.GroupLayout pnSolrSettingsLayout =
new javax.swing.GroupLayout(pnSolrSettings);
302 pnSolrSettings.setLayout(pnSolrSettingsLayout);
303 pnSolrSettingsLayout.setHorizontalGroup(
304 pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
305 .addGroup(pnSolrSettingsLayout.createSequentialGroup()
307 .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
308 .addComponent(tbSolrHostname)
309 .addGroup(pnSolrSettingsLayout.createSequentialGroup()
310 .addComponent(lbSolrSettings)
311 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
312 .addComponent(bnTestSolr)
314 .addComponent(lbTestSolr, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
315 .addComponent(tbSolrPort)
316 .addGroup(pnSolrSettingsLayout.createSequentialGroup()
317 .addComponent(lbTestSolrWarning)
318 .addGap(0, 0, Short.MAX_VALUE)))
321 pnSolrSettingsLayout.setVerticalGroup(
322 pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
323 .addGroup(pnSolrSettingsLayout.createSequentialGroup()
325 .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
326 .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
327 .addComponent(bnTestSolr, javax.swing.GroupLayout.Alignment.TRAILING)
328 .addComponent(lbSolrSettings))
329 .addComponent(lbTestSolr, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
330 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
331 .addComponent(tbSolrHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
332 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
333 .addComponent(tbSolrPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
334 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
335 .addComponent(lbTestSolrWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
339 pnMessagingSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
341 lbMessageServiceSettings.setFont(lbMessageServiceSettings.getFont().deriveFont(lbMessageServiceSettings.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
342 org.openide.awt.Mnemonics.setLocalizedText(lbMessageServiceSettings,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbMessageServiceSettings.text"));
344 tbMsgHostname.setFont(tbMsgHostname.getFont().deriveFont(tbMsgHostname.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
345 tbMsgHostname.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgHostname.text"));
346 tbMsgHostname.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgHostname.toolTipText"));
348 tbMsgUsername.setFont(tbMsgUsername.getFont().deriveFont(tbMsgUsername.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
349 tbMsgUsername.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgUsername.text"));
350 tbMsgUsername.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgUsername.toolTipText"));
352 tbMsgPort.setFont(tbMsgPort.getFont().deriveFont(tbMsgPort.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
353 tbMsgPort.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgPort.text"));
354 tbMsgPort.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgPort.toolTipText"));
356 tbMsgPassword.setFont(tbMsgPassword.getFont().deriveFont(tbMsgPassword.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
357 tbMsgPassword.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgPassword.text"));
358 tbMsgPassword.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgPassword.toolTipText"));
360 bnTestMessageService.setFont(bnTestMessageService.getFont().deriveFont(bnTestMessageService.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
361 org.openide.awt.Mnemonics.setLocalizedText(bnTestMessageService,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.bnTestMessageService.text"));
362 bnTestMessageService.addActionListener(
new java.awt.event.ActionListener() {
363 public void actionPerformed(java.awt.event.ActionEvent evt) {
364 bnTestMessageServiceActionPerformed(evt);
368 org.openide.awt.Mnemonics.setLocalizedText(lbTestMessageService,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbTestMessageService.text"));
370 lbTestMessageWarning.setForeground(
new java.awt.Color(255, 0, 0));
371 org.openide.awt.Mnemonics.setLocalizedText(lbTestMessageWarning,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbTestMessageWarning.text"));
373 javax.swing.GroupLayout pnMessagingSettingsLayout =
new javax.swing.GroupLayout(pnMessagingSettings);
374 pnMessagingSettings.setLayout(pnMessagingSettingsLayout);
375 pnMessagingSettingsLayout.setHorizontalGroup(
376 pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
377 .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
379 .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
380 .addComponent(tbMsgHostname)
381 .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
382 .addComponent(lbMessageServiceSettings)
383 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 229, Short.MAX_VALUE)
384 .addComponent(bnTestMessageService)
386 .addComponent(lbTestMessageService, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
387 .addComponent(tbMsgPort)
388 .addComponent(tbMsgUsername)
389 .addComponent(tbMsgPassword)
390 .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
391 .addComponent(lbTestMessageWarning)
392 .addGap(0, 0, Short.MAX_VALUE)))
395 pnMessagingSettingsLayout.setVerticalGroup(
396 pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
397 .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
399 .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
400 .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
401 .addComponent(bnTestMessageService, javax.swing.GroupLayout.Alignment.TRAILING)
402 .addComponent(lbMessageServiceSettings))
403 .addComponent(lbTestMessageService, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
404 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
405 .addComponent(tbMsgHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
406 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
407 .addComponent(tbMsgPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
408 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
409 .addComponent(tbMsgUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
410 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
411 .addComponent(tbMsgPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
412 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
413 .addComponent(lbTestMessageWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
414 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
417 cbEnableMultiUser.setFont(cbEnableMultiUser.getFont().deriveFont(cbEnableMultiUser.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
418 org.openide.awt.Mnemonics.setLocalizedText(cbEnableMultiUser,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.cbEnableMultiUser.text"));
419 cbEnableMultiUser.addItemListener(
new java.awt.event.ItemListener() {
420 public void itemStateChanged(java.awt.event.ItemEvent evt) {
421 cbEnableMultiUserItemStateChanged(evt);
425 tbOops.setEditable(
false);
426 tbOops.setFont(tbOops.getFont().deriveFont(tbOops.getFont().getStyle() | java.awt.Font.BOLD, 12));
427 tbOops.setForeground(
new java.awt.Color(255, 0, 0));
428 tbOops.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbOops.text"));
429 tbOops.setBorder(null);
431 javax.swing.GroupLayout pnOverallPanelLayout =
new javax.swing.GroupLayout(pnOverallPanel);
432 pnOverallPanel.setLayout(pnOverallPanelLayout);
433 pnOverallPanelLayout.setHorizontalGroup(
434 pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
435 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOverallPanelLayout.createSequentialGroup()
437 .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
438 .addGroup(pnOverallPanelLayout.createSequentialGroup()
439 .addComponent(cbEnableMultiUser)
440 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
441 .addComponent(tbOops))
442 .addComponent(pnSolrSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
443 .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
444 .addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
447 pnOverallPanelLayout.setVerticalGroup(
448 pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
449 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOverallPanelLayout.createSequentialGroup()
450 .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
451 .addComponent(tbOops, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
452 .addComponent(cbEnableMultiUser))
453 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
454 .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
455 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
456 .addComponent(pnSolrSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
457 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
458 .addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
459 .addContainerGap(39, Short.MAX_VALUE))
462 jScrollPane.setViewportView(pnOverallPanel);
464 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
465 this.setLayout(layout);
466 layout.setHorizontalGroup(
467 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
468 .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)
470 layout.setVerticalGroup(
471 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
472 .addGroup(layout.createSequentialGroup()
474 .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)
486 for (JTextField textField : textFields) {
487 textField.setEnabled(enabled);
492 if (!cbEnableMultiUser.isSelected()) {
494 bnTestDatabase.setEnabled(
false);
495 lbTestDatabase.setIcon(null);
496 bnTestSolr.setEnabled(
false);
497 lbTestSolr.setIcon(null);
498 bnTestMessageService.setEnabled(
false);
499 lbTestMessageService.setIcon(null);
500 lbTestDbWarning.setText(
"");
501 lbTestSolrWarning.setText(
"");
502 lbTestMessageWarning.setText(
"");
504 enableMultiUserComponents(textBoxes, cbEnableMultiUser.isSelected());
509 lbTestDatabase.setIcon(null);
510 lbTestDatabase.paintImmediately(lbTestDatabase.getVisibleRect());
511 lbTestDbWarning.setText(
"");
512 lbTestDbWarning.paintImmediately(lbTestDbWarning.getVisibleRect());
513 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
515 CaseDbConnectionInfo info =
new CaseDbConnectionInfo(
516 this.tbDbHostname.getText().trim(),
517 this.tbDbPort.getText().trim(),
518 this.tbDbUsername.getText().trim(),
519 new String(this.tbDbPassword.getPassword()),
522 SleuthkitCase.tryConnect(info);
523 lbTestDatabase.setIcon(goodIcon);
524 lbTestDbWarning.setText(
"");
525 }
catch (TskCoreException ex) {
526 lbTestDatabase.setIcon(badIcon);
527 lbTestDbWarning.setText(ex.getMessage());
529 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
534 lbTestMessageService.setIcon(null);
535 lbTestMessageService.paintImmediately(lbTestMessageService.getVisibleRect());
536 lbTestMessageWarning.setText(
"");
537 lbTestMessageWarning.paintImmediately(lbTestMessageWarning.getVisibleRect());
538 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
542 port = Integer.parseInt(this.tbMsgPort.getText().trim());
543 }
catch (NumberFormatException ex) {
544 lbTestMessageService.setIcon(badIcon);
545 lbTestMessageWarning.setText(NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.InvalidPortNumber"));
550 this.tbMsgHostname.getText().trim(),
552 this.tbMsgUsername.getText().trim(),
553 new String(this.tbMsgPassword.getPassword()));
556 lbTestMessageService.setIcon(goodIcon);
557 lbTestMessageWarning.setText(
"");
559 lbTestMessageService.setIcon(badIcon);
560 lbTestMessageWarning.setText(ex.getMessage());
562 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
567 lbTestSolr.setIcon(null);
568 lbTestSolr.paintImmediately(lbTestSolr.getVisibleRect());
569 lbTestSolrWarning.setText(
"");
570 lbTestSolrWarning.paintImmediately(lbTestSolrWarning.getVisibleRect());
571 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
575 if (kwsService != null) {
576 int port = Integer.parseInt(tbSolrPort.getText().trim());
577 kwsService.
tryConnect(tbSolrHostname.getText().trim(), port);
578 lbTestSolr.setIcon(goodIcon);
579 lbTestSolrWarning.setText(
"");
581 lbTestSolr.setIcon(badIcon);
582 lbTestSolrWarning.setText(NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.KeywordSearchNull"));
584 }
catch (NumberFormatException ex) {
585 lbTestSolr.setIcon(badIcon);
586 lbTestSolrWarning.setText(NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.InvalidPortNumber"));
588 lbTestSolr.setIcon(badIcon);
589 lbTestSolrWarning.setText(ex.getMessage());
591 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
596 lbTestDatabase.setIcon(null);
597 lbTestSolr.setIcon(null);
598 lbTestMessageService.setIcon(null);
599 lbTestDbWarning.setText(
"");
600 lbTestSolrWarning.setText(
"");
601 lbTestMessageWarning.setText(
"");
605 tbDbHostname.setText(dbInfo.getHost().trim());
606 tbDbPort.setText(dbInfo.getPort().trim());
607 tbDbUsername.setText(dbInfo.getUserName().trim());
608 tbDbPassword.setText(dbInfo.getPassword());
609 }
catch (UserPreferencesException ex) {
610 logger.log(Level.SEVERE,
"Error accessing case database connection info", ex);
614 MessageServiceConnectionInfo msgServiceInfo = UserPreferences.getMessageServiceConnectionInfo();
615 tbMsgHostname.setText(msgServiceInfo.getHost().trim());
616 tbMsgPort.setText(Integer.toString(msgServiceInfo.getPort()));
617 tbMsgUsername.setText(msgServiceInfo.getUserName().trim());
618 tbMsgPassword.setText(msgServiceInfo.getPassword());
619 }
catch (UserPreferencesException ex) {
620 logger.log(Level.SEVERE,
"Error accessing case database connection info", ex);
623 String indexingServerHost = UserPreferences.getIndexingServerHost().trim();
624 if (!indexingServerHost.isEmpty()) {
625 tbSolrHostname.setText(indexingServerHost);
627 String indexingServerPort = UserPreferences.getIndexingServerPort().trim();
628 if (portNumberIsValid(indexingServerPort)) {
629 tbSolrPort.setText(indexingServerPort);
632 lbTestDatabase.setIcon(null);
633 lbTestSolr.setIcon(null);
634 lbTestMessageService.setIcon(null);
636 bnTestDatabase.setEnabled(
false);
637 bnTestSolr.setEnabled(
false);
638 bnTestMessageService.setEnabled(
false);
640 cbEnableMultiUser.setSelected(UserPreferences.getIsMultiUserModeEnabled());
651 return !tbDbHostname.getText().trim().isEmpty()
652 && !tbDbPort.getText().trim().isEmpty()
653 && !tbDbUsername.getText().trim().isEmpty()
654 && tbDbPassword.getPassword().length != 0;
664 return !tbSolrHostname.getText().trim().isEmpty()
665 && !tbSolrPort.getText().trim().isEmpty();
676 if ((tbMsgHostname.getText().trim().isEmpty())
677 || (tbMsgPort.getText().trim().isEmpty())) {
682 boolean isUserSet = (tbMsgUsername.getText().trim().isEmpty() ==
false);
683 boolean isPwSet = (tbMsgPassword.getPassword().length != 0);
684 return (isUserSet == isPwSet);
689 boolean multiUserCasesEnabled = cbEnableMultiUser.isSelected();
691 if (multiUserCasesEnabled ==
false) {
699 DbType dbType = DbType.POSTGRESQL;
700 CaseDbConnectionInfo info =
new CaseDbConnectionInfo(
701 tbDbHostname.getText().trim(),
702 tbDbPort.getText().trim(),
703 tbDbUsername.getText().trim(),
704 new String(tbDbPassword.getPassword()),
707 UserPreferences.setDatabaseConnectionInfo(info);
708 }
catch (UserPreferencesException ex) {
709 logger.log(Level.SEVERE,
"Error saving case database connection info", ex);
712 int msgServicePort = 0;
714 msgServicePort = Integer.parseInt(this.tbMsgPort.getText().trim());
715 }
catch (NumberFormatException ex) {
716 logger.log(Level.SEVERE,
"Could not parse messaging service port setting", ex);
719 MessageServiceConnectionInfo msgServiceInfo =
new MessageServiceConnectionInfo(
720 tbMsgHostname.getText().trim(),
722 tbMsgUsername.getText().trim(),
723 new String(tbMsgPassword.getPassword()));
726 UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
727 }
catch (UserPreferencesException ex) {
728 logger.log(Level.SEVERE,
"Error saving messaging service connection info", ex);
731 UserPreferences.setIndexingServerHost(tbSolrHostname.getText().trim());
732 UserPreferences.setIndexingServerPort(Integer.parseInt(tbSolrPort.getText().trim()));
744 if (cbEnableMultiUser.isSelected()) {
745 return checkFieldsAndEnableButtons()
746 && databaseSettingsAreValid()
747 && indexingServerSettingsAreValid()
748 && messageServiceSettingsAreValid();
760 boolean checkFieldsAndEnableButtons() {
761 boolean result =
true;
763 boolean dbPopulated = databaseFieldsArePopulated();
764 boolean solrPopulated = solrFieldsArePopulated();
765 boolean messageServicePopulated = messageServiceFieldsArePopulated();
768 bnTestDatabase.setEnabled(dbPopulated);
771 bnTestSolr.setEnabled(solrPopulated);
774 bnTestMessageService.setEnabled(messageServicePopulated);
776 if (!dbPopulated || !solrPopulated || !messageServicePopulated) {
779 tbOops.setText(INCOMPLETE_SETTINGS_MSG);
789 boolean databaseSettingsAreValid() {
790 if (portNumberIsValid(tbDbPort.getText().trim())) {
793 tbOops.setText(INVALID_DB_PORT_MSG);
803 boolean messageServiceSettingsAreValid() {
804 if (!portNumberIsValid(tbMsgPort.getText().trim())) {
805 tbOops.setText(INVALID_MESSAGE_SERVICE_PORT_MSG);
817 boolean indexingServerSettingsAreValid() {
818 if (!portNumberIsValid(tbSolrPort.getText().trim())) {
819 tbOops.setText(INVALID_INDEXING_SERVER_PORT_MSG);
836 int value = Integer.parseInt(portNumber);
837 if (value < 0 || value > 65535) {
840 }
catch (NumberFormatException detailsNotImportant) {
882 class TextBoxChangedListener
implements DocumentListener {
885 public void changedUpdate(DocumentEvent e) {
886 Object statusIcon = e.getDocument().getProperty(
"statusIcon");
887 if (statusIcon != null) {
888 ((javax.swing.JLabel) statusIcon).setIcon(null);
894 public void insertUpdate(DocumentEvent e) {
895 Object statusIcon = e.getDocument().getProperty(
"statusIcon");
896 if (statusIcon != null) {
897 ((javax.swing.JLabel) statusIcon).setIcon(null);
903 public void removeUpdate(DocumentEvent e) {
904 Object statusIcon = e.getDocument().getProperty(
"statusIcon");
905 if (statusIcon != null) {
906 ((javax.swing.JLabel) statusIcon).setIcon(null);
void cbEnableMultiUserItemStateChanged(java.awt.event.ItemEvent evt)
static void configureTextPrompts(Collection< TextPrompt > textPrompts)
javax.swing.JPanel pnSolrSettings
javax.swing.JLabel lbTestDatabase
javax.swing.JTextField tbSolrHostname
javax.swing.JPanel pnMessagingSettings
javax.swing.JPanel pnDatabaseSettings
javax.swing.JTextField tbDbUsername
void tryConnect(String host, int port)
javax.swing.JLabel lbTestDbWarning
javax.swing.JLabel lbDatabaseSettings
javax.swing.JLabel lbTestSolrWarning
final TextBoxChangedListener textBoxChangedListener
javax.swing.JPanel pnOverallPanel
javax.swing.JTextField tbMsgHostname
javax.swing.JCheckBox cbEnableMultiUser
void bnTestDatabaseActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JTextField tbSolrPort
static CaseDbConnectionInfo getDatabaseConnectionInfo()
javax.swing.JTextField tbOops
MultiUserSettingsPanel(MultiUserSettingsPanelController theController)
static void setIsMultiUserModeEnabled(boolean enabled)
javax.swing.JTextField tbDbPort
javax.swing.JButton bnTestSolr
javax.swing.JLabel lbTestMessageWarning
javax.swing.JTextField tbMsgPort
static boolean portNumberIsValid(String portNumber)
javax.swing.JLabel lbTestMessageService
boolean messageServiceFieldsArePopulated()
javax.swing.JTextField tbDbHostname
boolean databaseFieldsArePopulated()
void bnTestSolrActionPerformed(java.awt.event.ActionEvent evt)
final MultiUserSettingsPanelController controller
javax.swing.JTextField tbMsgUsername
synchronized static Logger getLogger(String name)
boolean solrFieldsArePopulated()
static void enableMultiUserComponents(Collection< JTextField > textFields, boolean enabled)
javax.swing.JButton bnTestMessageService
void bnTestMessageServiceActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JPasswordField tbDbPassword
javax.swing.JLabel lbSolrSettings
javax.swing.JPasswordField tbMsgPassword
javax.swing.JLabel lbMessageServiceSettings
javax.swing.JScrollPane jScrollPane
javax.swing.JButton bnTestDatabase
static void addDocumentListeners(Collection< JTextField > textFields, TextBoxChangedListener listener)
javax.swing.JLabel lbTestSolr