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;
34 import java.awt.Cursor;
35 import java.util.logging.Level;
36 import javax.swing.ImageIcon;
37 import org.openide.util.ImageUtilities;
38 import org.openide.util.Lookup;
50 @SuppressWarnings(
"PMD.SingularField")
53 private static final String HOST_NAME_OR_IP_PROMPT = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbHostname.toolTipText");
54 private static final String PORT_PROMPT = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbPort.toolTipText");
55 private static final String USER_NAME_PROMPT = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbUsername.toolTipText");
56 private static final String PASSWORD_PROMPT = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbPassword.toolTipText");
57 private static final String USER_NAME_PROMPT_OPT = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgUsername.toolTipText");
58 private static final String PASSWORD_PROMPT_OPT = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgPassword.toolTipText");
59 private static final String INCOMPLETE_SETTINGS_MSG = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.validationErrMsg.incomplete");
60 private static final String INVALID_DB_PORT_MSG = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.validationErrMsg.invalidDatabasePort");
61 private static final String INVALID_MESSAGE_SERVICE_PORT_MSG = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.validationErrMsg.invalidMessageServicePort");
62 private static final String INVALID_INDEXING_SERVER_PORT_MSG = NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.validationErrMsg.invalidIndexingServerPort");
63 private static final long serialVersionUID = 1L;
65 private final Collection<JTextField> textBoxes =
new ArrayList<>();
79 controller = theController;
85 Collection<TextPrompt> textPrompts =
new ArrayList<>();
86 textPrompts.add(
new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbDbHostname));
87 textPrompts.add(
new TextPrompt(PORT_PROMPT, tbDbPort));
88 textPrompts.add(
new TextPrompt(USER_NAME_PROMPT, tbDbUsername));
89 textPrompts.add(
new TextPrompt(PASSWORD_PROMPT, tbDbPassword));
90 textPrompts.add(
new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbMsgHostname));
91 textPrompts.add(
new TextPrompt(PORT_PROMPT, tbMsgPort));
92 textPrompts.add(
new TextPrompt(USER_NAME_PROMPT_OPT, tbMsgUsername));
93 textPrompts.add(
new TextPrompt(PASSWORD_PROMPT_OPT, tbMsgPassword));
94 textPrompts.add(
new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbSolrHostname));
95 textPrompts.add(
new TextPrompt(PORT_PROMPT, tbSolrPort));
96 configureTextPrompts(textPrompts);
102 tbDbHostname.getDocument().putProperty(
"statusIcon", lbTestDatabase);
103 tbDbPort.getDocument().putProperty(
"statusIcon", lbTestDatabase);
104 tbDbUsername.getDocument().putProperty(
"statusIcon", lbTestDatabase);
105 tbDbPassword.getDocument().putProperty(
"statusIcon", lbTestDatabase);
107 tbSolrHostname.getDocument().putProperty(
"statusIcon", lbTestSolr);
108 tbSolrPort.getDocument().putProperty(
"statusIcon", lbTestSolr);
110 tbMsgHostname.getDocument().putProperty(
"statusIcon", lbTestMessageService);
111 tbMsgPort.getDocument().putProperty(
"statusIcon", lbTestMessageService);
112 tbMsgUsername.getDocument().putProperty(
"statusIcon", lbTestMessageService);
113 tbMsgPassword.getDocument().putProperty(
"statusIcon", lbTestMessageService);
116 textBoxChangedListener =
new TextBoxChangedListener();
117 textBoxes.add(tbDbHostname);
118 textBoxes.add(tbDbPort);
119 textBoxes.add(tbDbUsername);
120 textBoxes.add(tbDbPassword);
121 textBoxes.add(tbMsgHostname);
122 textBoxes.add(tbMsgPort);
123 textBoxes.add(tbMsgUsername);
124 textBoxes.add(tbMsgPassword);
125 textBoxes.add(tbSolrHostname);
126 textBoxes.add(tbSolrPort);
128 addDocumentListeners(textBoxes, textBoxChangedListener);
129 goodIcon =
new ImageIcon(ImageUtilities.loadImage(
"org/sleuthkit/autopsy/images/good.png",
false));
130 badIcon =
new ImageIcon(ImageUtilities.loadImage(
"org/sleuthkit/autopsy/images/bad.png",
false));
131 enableMultiUserComponents(textBoxes, cbEnableMultiUser.isSelected());
143 textPrompt.setForeground(Color.LIGHT_GRAY);
144 textPrompt.changeAlpha(alpha);
155 for (JTextField textField : textFields) {
156 textField.getDocument().addDocumentListener(listener);
165 @SuppressWarnings(
"unchecked")
167 private
void initComponents() {
169 jScrollPane =
new javax.swing.JScrollPane();
170 pnOverallPanel =
new javax.swing.JPanel();
171 pnDatabaseSettings =
new javax.swing.JPanel();
172 tbDbHostname =
new javax.swing.JTextField();
173 tbDbPort =
new javax.swing.JTextField();
174 tbDbUsername =
new javax.swing.JTextField();
175 tbDbPassword =
new javax.swing.JPasswordField();
176 lbDatabaseSettings =
new javax.swing.JLabel();
177 bnTestDatabase =
new javax.swing.JButton();
178 lbTestDatabase =
new javax.swing.JLabel();
179 lbTestDbWarning =
new javax.swing.JLabel();
180 pnSolrSettings =
new javax.swing.JPanel();
181 lbSolrSettings =
new javax.swing.JLabel();
182 tbSolrHostname =
new javax.swing.JTextField();
183 tbSolrPort =
new javax.swing.JTextField();
184 bnTestSolr =
new javax.swing.JButton();
185 lbTestSolr =
new javax.swing.JLabel();
186 lbTestSolrWarning =
new javax.swing.JLabel();
187 pnMessagingSettings =
new javax.swing.JPanel();
188 lbMessageServiceSettings =
new javax.swing.JLabel();
189 tbMsgHostname =
new javax.swing.JTextField();
190 tbMsgUsername =
new javax.swing.JTextField();
191 tbMsgPort =
new javax.swing.JTextField();
192 tbMsgPassword =
new javax.swing.JPasswordField();
193 bnTestMessageService =
new javax.swing.JButton();
194 lbTestMessageService =
new javax.swing.JLabel();
195 lbTestMessageWarning =
new javax.swing.JLabel();
196 cbEnableMultiUser =
new javax.swing.JCheckBox();
197 tbOops =
new javax.swing.JTextField();
199 pnDatabaseSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
201 tbDbHostname.setFont(tbDbHostname.getFont().deriveFont(tbDbHostname.getFont().getSize()+1f));
202 tbDbHostname.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbHostname.text"));
203 tbDbHostname.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbHostname.toolTipText"));
205 tbDbPort.setFont(tbDbPort.getFont().deriveFont(tbDbPort.getFont().getSize()+1f));
206 tbDbPort.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbPort.text"));
207 tbDbPort.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbPort.toolTipText"));
209 tbDbUsername.setFont(tbDbUsername.getFont().deriveFont(tbDbUsername.getFont().getSize()+1f));
210 tbDbUsername.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbUsername.text"));
211 tbDbUsername.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbUsername.toolTipText"));
213 tbDbPassword.setFont(tbDbPassword.getFont().deriveFont(tbDbPassword.getFont().getSize()+1f));
214 tbDbPassword.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbPassword.text"));
215 tbDbPassword.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbDbPassword.toolTipText"));
217 lbDatabaseSettings.setFont(lbDatabaseSettings.getFont().deriveFont(lbDatabaseSettings.getFont().getSize()+1f));
218 org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseSettings,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbDatabaseSettings.text"));
219 lbDatabaseSettings.setVerticalAlignment(javax.swing.SwingConstants.TOP);
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().getSize()+1f));
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().getSize()+1f));
283 tbSolrHostname.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbSolrHostname.toolTipText"));
285 tbSolrPort.setFont(tbSolrPort.getFont().deriveFont(tbSolrPort.getFont().getSize()+1f));
286 tbSolrPort.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbSolrPort.toolTipText"));
288 org.openide.awt.Mnemonics.setLocalizedText(bnTestSolr,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.bnTestSolr.text"));
289 bnTestSolr.addActionListener(
new java.awt.event.ActionListener() {
290 public void actionPerformed(java.awt.event.ActionEvent evt) {
291 bnTestSolrActionPerformed(evt);
295 org.openide.awt.Mnemonics.setLocalizedText(lbTestSolr,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbTestSolr.text"));
297 lbTestSolrWarning.setForeground(
new java.awt.Color(255, 0, 0));
298 org.openide.awt.Mnemonics.setLocalizedText(lbTestSolrWarning,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbTestSolrWarning.text"));
300 javax.swing.GroupLayout pnSolrSettingsLayout =
new javax.swing.GroupLayout(pnSolrSettings);
301 pnSolrSettings.setLayout(pnSolrSettingsLayout);
302 pnSolrSettingsLayout.setHorizontalGroup(
303 pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
304 .addGroup(pnSolrSettingsLayout.createSequentialGroup()
306 .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
307 .addComponent(tbSolrHostname)
308 .addGroup(pnSolrSettingsLayout.createSequentialGroup()
309 .addComponent(lbSolrSettings)
310 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
311 .addComponent(bnTestSolr)
313 .addComponent(lbTestSolr, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
314 .addComponent(tbSolrPort)
315 .addGroup(pnSolrSettingsLayout.createSequentialGroup()
316 .addComponent(lbTestSolrWarning)
317 .addGap(0, 0, Short.MAX_VALUE)))
320 pnSolrSettingsLayout.setVerticalGroup(
321 pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
322 .addGroup(pnSolrSettingsLayout.createSequentialGroup()
324 .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
325 .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
326 .addComponent(bnTestSolr, javax.swing.GroupLayout.Alignment.TRAILING)
327 .addComponent(lbSolrSettings))
328 .addComponent(lbTestSolr, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
329 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
330 .addComponent(tbSolrHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
331 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
332 .addComponent(tbSolrPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
333 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
334 .addComponent(lbTestSolrWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
338 pnMessagingSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
340 lbMessageServiceSettings.setFont(lbMessageServiceSettings.getFont().deriveFont((
float)12));
341 org.openide.awt.Mnemonics.setLocalizedText(lbMessageServiceSettings,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbMessageServiceSettings.text"));
343 tbMsgHostname.setFont(tbMsgHostname.getFont().deriveFont(tbMsgHostname.getFont().getSize()+1f));
344 tbMsgHostname.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgHostname.text"));
345 tbMsgHostname.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgHostname.toolTipText"));
347 tbMsgUsername.setFont(tbMsgUsername.getFont().deriveFont(tbMsgUsername.getFont().getSize()+1f));
348 tbMsgUsername.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgUsername.text"));
349 tbMsgUsername.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgUsername.toolTipText"));
351 tbMsgPort.setFont(tbMsgPort.getFont().deriveFont(tbMsgPort.getFont().getSize()+1f));
352 tbMsgPort.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgPort.text"));
353 tbMsgPort.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgPort.toolTipText"));
355 tbMsgPassword.setFont(tbMsgPassword.getFont().deriveFont(tbMsgPassword.getFont().getSize()+1f));
356 tbMsgPassword.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgPassword.text"));
357 tbMsgPassword.setToolTipText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbMsgPassword.toolTipText"));
359 org.openide.awt.Mnemonics.setLocalizedText(bnTestMessageService,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.bnTestMessageService.text"));
360 bnTestMessageService.addActionListener(
new java.awt.event.ActionListener() {
361 public void actionPerformed(java.awt.event.ActionEvent evt) {
362 bnTestMessageServiceActionPerformed(evt);
366 org.openide.awt.Mnemonics.setLocalizedText(lbTestMessageService,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbTestMessageService.text"));
368 lbTestMessageWarning.setForeground(
new java.awt.Color(255, 0, 0));
369 org.openide.awt.Mnemonics.setLocalizedText(lbTestMessageWarning,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.lbTestMessageWarning.text"));
371 javax.swing.GroupLayout pnMessagingSettingsLayout =
new javax.swing.GroupLayout(pnMessagingSettings);
372 pnMessagingSettings.setLayout(pnMessagingSettingsLayout);
373 pnMessagingSettingsLayout.setHorizontalGroup(
374 pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
375 .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
377 .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
378 .addComponent(tbMsgHostname)
379 .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
380 .addComponent(lbMessageServiceSettings)
381 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 229, Short.MAX_VALUE)
382 .addComponent(bnTestMessageService)
384 .addComponent(lbTestMessageService, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
385 .addComponent(tbMsgPort)
386 .addComponent(tbMsgUsername)
387 .addComponent(tbMsgPassword)
388 .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
389 .addComponent(lbTestMessageWarning)
390 .addGap(0, 0, Short.MAX_VALUE)))
393 pnMessagingSettingsLayout.setVerticalGroup(
394 pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
395 .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
397 .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
398 .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
399 .addComponent(bnTestMessageService, javax.swing.GroupLayout.Alignment.TRAILING)
400 .addComponent(lbMessageServiceSettings))
401 .addComponent(lbTestMessageService, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
402 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
403 .addComponent(tbMsgHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
404 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
405 .addComponent(tbMsgPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
406 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
407 .addComponent(tbMsgUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
408 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
409 .addComponent(tbMsgPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
410 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
411 .addComponent(lbTestMessageWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
412 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
415 org.openide.awt.Mnemonics.setLocalizedText(cbEnableMultiUser,
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.cbEnableMultiUser.text"));
416 cbEnableMultiUser.addItemListener(
new java.awt.event.ItemListener() {
417 public void itemStateChanged(java.awt.event.ItemEvent evt) {
418 cbEnableMultiUserItemStateChanged(evt);
422 tbOops.setEditable(
false);
423 tbOops.setFont(tbOops.getFont().deriveFont(tbOops.getFont().getStyle() | java.awt.Font.BOLD, tbOops.getFont().getSize()+1));
424 tbOops.setForeground(
new java.awt.Color(255, 0, 0));
425 tbOops.setText(
org.openide.util.NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.tbOops.text"));
426 tbOops.setBorder(null);
428 javax.swing.GroupLayout pnOverallPanelLayout =
new javax.swing.GroupLayout(pnOverallPanel);
429 pnOverallPanel.setLayout(pnOverallPanelLayout);
430 pnOverallPanelLayout.setHorizontalGroup(
431 pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
432 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOverallPanelLayout.createSequentialGroup()
434 .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
435 .addGroup(pnOverallPanelLayout.createSequentialGroup()
436 .addComponent(cbEnableMultiUser)
437 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
438 .addComponent(tbOops))
439 .addComponent(pnSolrSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
440 .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
441 .addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
444 pnOverallPanelLayout.setVerticalGroup(
445 pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
446 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOverallPanelLayout.createSequentialGroup()
447 .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
448 .addComponent(tbOops, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
449 .addComponent(cbEnableMultiUser))
450 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
451 .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
452 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
453 .addComponent(pnSolrSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
454 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
455 .addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
456 .addContainerGap(39, Short.MAX_VALUE))
459 jScrollPane.setViewportView(pnOverallPanel);
461 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
462 this.setLayout(layout);
463 layout.setHorizontalGroup(
464 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
465 .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)
467 layout.setVerticalGroup(
468 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
469 .addGroup(layout.createSequentialGroup()
471 .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)
483 for (JTextField textField : textFields) {
484 textField.setEnabled(enabled);
489 if (!cbEnableMultiUser.isSelected()) {
491 bnTestDatabase.setEnabled(
false);
492 lbTestDatabase.setIcon(null);
493 bnTestSolr.setEnabled(
false);
494 lbTestSolr.setIcon(null);
495 bnTestMessageService.setEnabled(
false);
496 lbTestMessageService.setIcon(null);
497 lbTestDbWarning.setText(
"");
498 lbTestSolrWarning.setText(
"");
499 lbTestMessageWarning.setText(
"");
501 enableMultiUserComponents(textBoxes, cbEnableMultiUser.isSelected());
506 lbTestDatabase.setIcon(null);
507 lbTestDatabase.paintImmediately(lbTestDatabase.getVisibleRect());
508 lbTestDbWarning.setText(
"");
509 lbTestDbWarning.paintImmediately(lbTestDbWarning.getVisibleRect());
510 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
512 CaseDbConnectionInfo info =
new CaseDbConnectionInfo(
513 this.tbDbHostname.getText().trim(),
514 this.tbDbPort.getText().trim(),
515 this.tbDbUsername.getText().trim(),
516 new String(this.tbDbPassword.getPassword()),
519 SleuthkitCase.tryConnect(info);
520 lbTestDatabase.setIcon(goodIcon);
521 lbTestDbWarning.setText(
"");
522 }
catch (TskCoreException ex) {
523 lbTestDatabase.setIcon(badIcon);
524 lbTestDbWarning.setText(ex.getMessage());
526 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
531 lbTestMessageService.setIcon(null);
532 lbTestMessageService.paintImmediately(lbTestMessageService.getVisibleRect());
533 lbTestMessageWarning.setText(
"");
534 lbTestMessageWarning.paintImmediately(lbTestMessageWarning.getVisibleRect());
535 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
539 port = Integer.parseInt(this.tbMsgPort.getText().trim());
540 }
catch (NumberFormatException ex) {
541 lbTestMessageService.setIcon(badIcon);
542 lbTestMessageWarning.setText(NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.InvalidPortNumber"));
547 this.tbMsgHostname.getText().trim(),
549 this.tbMsgUsername.getText().trim(),
550 new String(this.tbMsgPassword.getPassword()));
553 lbTestMessageService.setIcon(goodIcon);
554 lbTestMessageWarning.setText(
"");
556 lbTestMessageService.setIcon(badIcon);
557 lbTestMessageWarning.setText(ex.getMessage());
559 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
564 lbTestSolr.setIcon(null);
565 lbTestSolr.paintImmediately(lbTestSolr.getVisibleRect());
566 lbTestSolrWarning.setText(
"");
567 lbTestSolrWarning.paintImmediately(lbTestSolrWarning.getVisibleRect());
568 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
572 if (kwsService != null) {
573 int port = Integer.parseInt(tbSolrPort.getText().trim());
574 kwsService.
tryConnect(tbSolrHostname.getText().trim(), port);
575 lbTestSolr.setIcon(goodIcon);
576 lbTestSolrWarning.setText(
"");
578 lbTestSolr.setIcon(badIcon);
579 lbTestSolrWarning.setText(NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.KeywordSearchNull"));
581 }
catch (NumberFormatException ex) {
582 lbTestSolr.setIcon(badIcon);
583 lbTestSolrWarning.setText(NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.InvalidPortNumber"));
585 lbTestSolr.setIcon(badIcon);
586 lbTestSolrWarning.setText(ex.getMessage());
588 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
593 lbTestDatabase.setIcon(null);
594 lbTestSolr.setIcon(null);
595 lbTestMessageService.setIcon(null);
596 lbTestDbWarning.setText(
"");
597 lbTestSolrWarning.setText(
"");
598 lbTestMessageWarning.setText(
"");
602 tbDbHostname.setText(dbInfo.getHost().trim());
603 tbDbPort.setText(dbInfo.getPort().trim());
604 tbDbUsername.setText(dbInfo.getUserName().trim());
605 tbDbPassword.setText(dbInfo.getPassword());
606 }
catch (UserPreferencesException ex) {
607 logger.log(Level.SEVERE,
"Error accessing case database connection info", ex);
611 MessageServiceConnectionInfo msgServiceInfo = UserPreferences.getMessageServiceConnectionInfo();
612 tbMsgHostname.setText(msgServiceInfo.getHost().trim());
613 tbMsgPort.setText(Integer.toString(msgServiceInfo.getPort()));
614 tbMsgUsername.setText(msgServiceInfo.getUserName().trim());
615 tbMsgPassword.setText(msgServiceInfo.getPassword());
616 }
catch (UserPreferencesException ex) {
617 logger.log(Level.SEVERE,
"Error accessing case database connection info", ex);
620 String indexingServerHost = UserPreferences.getIndexingServerHost().trim();
621 if (!indexingServerHost.isEmpty()) {
622 tbSolrHostname.setText(indexingServerHost);
624 String indexingServerPort = UserPreferences.getIndexingServerPort().trim();
625 if (portNumberIsValid(indexingServerPort)) {
626 tbSolrPort.setText(indexingServerPort);
629 lbTestDatabase.setIcon(null);
630 lbTestSolr.setIcon(null);
631 lbTestMessageService.setIcon(null);
633 bnTestDatabase.setEnabled(
false);
634 bnTestSolr.setEnabled(
false);
635 bnTestMessageService.setEnabled(
false);
637 cbEnableMultiUser.setSelected(UserPreferences.getIsMultiUserModeEnabled());
648 return !tbDbHostname.getText().trim().isEmpty()
649 && !tbDbPort.getText().trim().isEmpty()
650 && !tbDbUsername.getText().trim().isEmpty()
651 && tbDbPassword.getPassword().length != 0;
661 return !tbSolrHostname.getText().trim().isEmpty()
662 && !tbSolrPort.getText().trim().isEmpty();
673 if ((tbMsgHostname.getText().trim().isEmpty())
674 || (tbMsgPort.getText().trim().isEmpty())) {
679 boolean isUserSet = (tbMsgUsername.getText().trim().isEmpty() ==
false);
680 boolean isPwSet = (tbMsgPassword.getPassword().length != 0);
681 return (isUserSet == isPwSet);
688 CaseDbConnectionInfo prevConn = null;
691 }
catch (UserPreferencesException ex) {
692 logger.log(Level.SEVERE,
"There was an error while fetching previous connection settings while trying to save", ex);
695 boolean multiUserCasesEnabled = cbEnableMultiUser.isSelected();
696 UserPreferences.setIsMultiUserModeEnabled(multiUserCasesEnabled);
698 CaseDbConnectionInfo info = null;
700 if (multiUserCasesEnabled ==
true) {
706 DbType dbType = DbType.POSTGRESQL;
707 info =
new CaseDbConnectionInfo(
708 tbDbHostname.getText().trim(),
709 tbDbPort.getText().trim(),
710 tbDbUsername.getText().trim(),
711 new String(tbDbPassword.getPassword()),
714 UserPreferences.setDatabaseConnectionInfo(info);
715 }
catch (UserPreferencesException ex) {
716 logger.log(Level.SEVERE,
"Error saving case database connection info", ex);
719 int msgServicePort = 0;
721 msgServicePort = Integer.parseInt(this.tbMsgPort.getText().trim());
722 }
catch (NumberFormatException ex) {
723 logger.log(Level.SEVERE,
"Could not parse messaging service port setting", ex);
726 MessageServiceConnectionInfo msgServiceInfo =
new MessageServiceConnectionInfo(
727 tbMsgHostname.getText().trim(),
729 tbMsgUsername.getText().trim(),
730 new String(tbMsgPassword.getPassword()));
733 UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
734 }
catch (UserPreferencesException ex) {
735 logger.log(Level.SEVERE,
"Error saving messaging service connection info", ex);
738 UserPreferences.setIndexingServerHost(tbSolrHostname.getText().trim());
739 UserPreferences.setIndexingServerPort(Integer.parseInt(tbSolrPort.getText().trim()));
743 if (prevSelected != multiUserCasesEnabled || !areCaseDbConnectionEqual(prevConn, info))
744 GlobalSettingsPanel.onMultiUserChange(
this, prevSelected, multiUserCasesEnabled);
748 if (a == null || b == null) {
749 return (a == null && b == null);
757 if (a == null || b == null) {
758 return (a == null && b == null);
762 arePropsEqual(a.getDbType(), b.getDbType()) &&
763 arePropsEqual(a.getHost(), b.getHost()) &&
764 arePropsEqual(a.getPassword(), b.getPassword()) &&
765 arePropsEqual(a.getPort(), b.getPort()) &&
766 arePropsEqual(a.getUserName(), b.getUserName());
778 if (cbEnableMultiUser.isSelected()) {
779 return checkFieldsAndEnableButtons()
780 && databaseSettingsAreValid()
781 && indexingServerSettingsAreValid()
782 && messageServiceSettingsAreValid();
794 boolean checkFieldsAndEnableButtons() {
795 boolean result =
true;
797 boolean dbPopulated = databaseFieldsArePopulated();
798 boolean solrPopulated = solrFieldsArePopulated();
799 boolean messageServicePopulated = messageServiceFieldsArePopulated();
802 bnTestDatabase.setEnabled(dbPopulated);
805 bnTestSolr.setEnabled(solrPopulated);
808 bnTestMessageService.setEnabled(messageServicePopulated);
810 if (!dbPopulated || !solrPopulated || !messageServicePopulated) {
813 tbOops.setText(INCOMPLETE_SETTINGS_MSG);
823 boolean databaseSettingsAreValid() {
824 if (portNumberIsValid(tbDbPort.getText().trim())) {
827 tbOops.setText(INVALID_DB_PORT_MSG);
837 boolean messageServiceSettingsAreValid() {
838 if (!portNumberIsValid(tbMsgPort.getText().trim())) {
839 tbOops.setText(INVALID_MESSAGE_SERVICE_PORT_MSG);
851 boolean indexingServerSettingsAreValid() {
852 if (!portNumberIsValid(tbSolrPort.getText().trim())) {
853 tbOops.setText(INVALID_INDEXING_SERVER_PORT_MSG);
870 int value = Integer.parseInt(portNumber);
871 if (value < 0 || value > 65535) {
874 }
catch (NumberFormatException detailsNotImportant) {
916 class TextBoxChangedListener
implements DocumentListener {
919 public void changedUpdate(DocumentEvent e) {
920 Object statusIcon = e.getDocument().getProperty(
"statusIcon");
921 if (statusIcon != null) {
922 ((javax.swing.JLabel) statusIcon).setIcon(null);
928 public void insertUpdate(DocumentEvent e) {
929 Object statusIcon = e.getDocument().getProperty(
"statusIcon");
930 if (statusIcon != null) {
931 ((javax.swing.JLabel) statusIcon).setIcon(null);
937 public void removeUpdate(DocumentEvent e) {
938 Object statusIcon = e.getDocument().getProperty(
"statusIcon");
939 if (statusIcon != null) {
940 ((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
static boolean arePropsEqual(Object a, Object b)
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)
static boolean areCaseDbConnectionEqual(CaseDbConnectionInfo a, CaseDbConnectionInfo b)
static boolean getIsMultiUserModeEnabled()
javax.swing.JTextField tbSolrPort
static CaseDbConnectionInfo getDatabaseConnectionInfo()
javax.swing.JTextField tbOops
MultiUserSettingsPanel(MultiUserSettingsPanelController theController)
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