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 lbTestDbWarning.setText(
"");
511 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
513 CaseDbConnectionInfo info =
new CaseDbConnectionInfo(
514 this.tbDbHostname.getText().trim(),
515 this.tbDbPort.getText().trim(),
516 this.tbDbUsername.getText().trim(),
517 new String(this.tbDbPassword.getPassword()),
520 SleuthkitCase.tryConnect(info);
521 lbTestDatabase.setIcon(goodIcon);
522 lbTestDbWarning.setText(
"");
523 }
catch (TskCoreException ex) {
524 lbTestDatabase.setIcon(badIcon);
525 lbTestDbWarning.setText(ex.getMessage());
527 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
532 lbTestMessageService.setIcon(null);
533 lbTestMessageWarning.setText(
"");
534 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
538 port = Integer.parseInt(this.tbMsgPort.getText().trim());
539 }
catch (NumberFormatException ex) {
540 lbTestMessageService.setIcon(badIcon);
541 lbTestMessageWarning.setText(NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.InvalidPortNumber"));
546 this.tbMsgHostname.getText().trim(),
548 this.tbMsgUsername.getText().trim(),
549 new String(this.tbMsgPassword.getPassword()));
552 lbTestMessageService.setIcon(goodIcon);
553 lbTestMessageWarning.setText(
"");
555 lbTestMessageService.setIcon(badIcon);
556 lbTestMessageWarning.setText(ex.getMessage());
558 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
563 lbTestSolr.setIcon(null);
564 lbTestSolrWarning.setText(
"");
565 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
569 if (kwsService != null) {
570 int port = Integer.parseInt(tbSolrPort.getText().trim());
571 kwsService.
tryConnect(tbSolrHostname.getText().trim(), port);
572 lbTestSolr.setIcon(goodIcon);
573 lbTestSolrWarning.setText(
"");
575 lbTestSolr.setIcon(badIcon);
576 lbTestSolrWarning.setText(NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.KeywordSearchNull"));
578 }
catch (NumberFormatException ex) {
579 lbTestSolr.setIcon(badIcon);
580 lbTestSolrWarning.setText(NbBundle.getMessage(
MultiUserSettingsPanel.class,
"MultiUserSettingsPanel.InvalidPortNumber"));
582 lbTestSolr.setIcon(badIcon);
583 lbTestSolrWarning.setText(ex.getMessage());
585 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
590 lbTestDatabase.setIcon(null);
591 lbTestSolr.setIcon(null);
592 lbTestMessageService.setIcon(null);
593 lbTestDbWarning.setText(
"");
594 lbTestSolrWarning.setText(
"");
595 lbTestMessageWarning.setText(
"");
599 tbDbHostname.setText(dbInfo.getHost().trim());
600 tbDbPort.setText(dbInfo.getPort().trim());
601 tbDbUsername.setText(dbInfo.getUserName().trim());
602 tbDbPassword.setText(dbInfo.getPassword());
603 }
catch (UserPreferencesException ex) {
604 logger.log(Level.SEVERE,
"Error accessing case database connection info", ex);
608 MessageServiceConnectionInfo msgServiceInfo = UserPreferences.getMessageServiceConnectionInfo();
609 tbMsgHostname.setText(msgServiceInfo.getHost().trim());
610 tbMsgPort.setText(Integer.toString(msgServiceInfo.getPort()));
611 tbMsgUsername.setText(msgServiceInfo.getUserName().trim());
612 tbMsgPassword.setText(msgServiceInfo.getPassword());
613 }
catch (UserPreferencesException ex) {
614 logger.log(Level.SEVERE,
"Error accessing case database connection info", ex);
617 String indexingServerHost = UserPreferences.getIndexingServerHost().trim();
618 if (!indexingServerHost.isEmpty()) {
619 tbSolrHostname.setText(indexingServerHost);
621 String indexingServerPort = UserPreferences.getIndexingServerPort().trim();
622 if (portNumberIsValid(indexingServerPort)) {
623 tbSolrPort.setText(indexingServerPort);
626 lbTestDatabase.setIcon(null);
627 lbTestSolr.setIcon(null);
628 lbTestMessageService.setIcon(null);
630 bnTestDatabase.setEnabled(
false);
631 bnTestSolr.setEnabled(
false);
632 bnTestMessageService.setEnabled(
false);
634 cbEnableMultiUser.setSelected(UserPreferences.getIsMultiUserModeEnabled());
645 return !tbDbHostname.getText().trim().isEmpty()
646 && !tbDbPort.getText().trim().isEmpty()
647 && !tbDbUsername.getText().trim().isEmpty()
648 && tbDbPassword.getPassword().length != 0;
658 return !tbSolrHostname.getText().trim().isEmpty()
659 && !tbSolrPort.getText().trim().isEmpty();
670 if ((tbMsgHostname.getText().trim().isEmpty())
671 || (tbMsgPort.getText().trim().isEmpty())) {
676 boolean isUserSet = (tbMsgUsername.getText().trim().isEmpty() ==
false);
677 boolean isPwSet = (tbMsgPassword.getPassword().length != 0);
678 return (isUserSet == isPwSet);
683 boolean multiUserCasesEnabled = cbEnableMultiUser.isSelected();
685 if (multiUserCasesEnabled ==
false) {
693 DbType dbType = DbType.POSTGRESQL;
694 CaseDbConnectionInfo info =
new CaseDbConnectionInfo(
695 tbDbHostname.getText().trim(),
696 tbDbPort.getText().trim(),
697 tbDbUsername.getText().trim(),
698 new String(tbDbPassword.getPassword()),
701 UserPreferences.setDatabaseConnectionInfo(info);
702 }
catch (UserPreferencesException ex) {
703 logger.log(Level.SEVERE,
"Error saving case database connection info", ex);
706 int msgServicePort = 0;
708 msgServicePort = Integer.parseInt(this.tbMsgPort.getText().trim());
709 }
catch (NumberFormatException ex) {
710 logger.log(Level.SEVERE,
"Could not parse messaging service port setting", ex);
713 MessageServiceConnectionInfo msgServiceInfo =
new MessageServiceConnectionInfo(
714 tbMsgHostname.getText().trim(),
716 tbMsgUsername.getText().trim(),
717 new String(tbMsgPassword.getPassword()));
720 UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
721 }
catch (UserPreferencesException ex) {
722 logger.log(Level.SEVERE,
"Error saving messaging service connection info", ex);
725 UserPreferences.setIndexingServerHost(tbSolrHostname.getText().trim());
726 UserPreferences.setIndexingServerPort(Integer.parseInt(tbSolrPort.getText().trim()));
738 if (cbEnableMultiUser.isSelected()) {
739 return checkFieldsAndEnableButtons()
740 && databaseSettingsAreValid()
741 && indexingServerSettingsAreValid()
742 && messageServiceSettingsAreValid();
754 boolean checkFieldsAndEnableButtons() {
755 boolean result =
true;
757 boolean dbPopulated = databaseFieldsArePopulated();
758 boolean solrPopulated = solrFieldsArePopulated();
759 boolean messageServicePopulated = messageServiceFieldsArePopulated();
762 bnTestDatabase.setEnabled(dbPopulated);
765 bnTestSolr.setEnabled(solrPopulated);
768 bnTestMessageService.setEnabled(messageServicePopulated);
770 if (!dbPopulated || !solrPopulated || !messageServicePopulated) {
773 tbOops.setText(INCOMPLETE_SETTINGS_MSG);
783 boolean databaseSettingsAreValid() {
784 if (portNumberIsValid(tbDbPort.getText().trim())) {
787 tbOops.setText(INVALID_DB_PORT_MSG);
797 boolean messageServiceSettingsAreValid() {
798 if (!portNumberIsValid(tbMsgPort.getText().trim())) {
799 tbOops.setText(INVALID_MESSAGE_SERVICE_PORT_MSG);
811 boolean indexingServerSettingsAreValid() {
812 if (!portNumberIsValid(tbSolrPort.getText().trim())) {
813 tbOops.setText(INVALID_INDEXING_SERVER_PORT_MSG);
830 int value = Integer.parseInt(portNumber);
831 if (value < 0 || value > 65535) {
834 }
catch (NumberFormatException detailsNotImportant) {
876 class TextBoxChangedListener
implements DocumentListener {
879 public void changedUpdate(DocumentEvent e) {
880 Object statusIcon = e.getDocument().getProperty(
"statusIcon");
881 if (statusIcon != null) {
882 ((javax.swing.JLabel) statusIcon).setIcon(null);
888 public void insertUpdate(DocumentEvent e) {
889 Object statusIcon = e.getDocument().getProperty(
"statusIcon");
890 if (statusIcon != null) {
891 ((javax.swing.JLabel) statusIcon).setIcon(null);
897 public void removeUpdate(DocumentEvent e) {
898 Object statusIcon = e.getDocument().getProperty(
"statusIcon");
899 if (statusIcon != null) {
900 ((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