Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
MultiUserSettingsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-2016 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.corecomponents;
20 
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;
45 
46 public final class MultiUserSettingsPanel extends javax.swing.JPanel {
47 
48  private static final String HOST_NAME_OR_IP_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbHostname.toolTipText");
49  private static final String PORT_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPort.toolTipText");
50  private static final String USER_NAME_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbUsername.toolTipText");
51  private static final String PASSWORD_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPassword.toolTipText");
52  private static final String USER_NAME_PROMPT_OPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgUsername.toolTipText");
53  private static final String PASSWORD_PROMPT_OPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPassword.toolTipText");
54  private static final String INCOMPLETE_SETTINGS_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.incomplete");
55  private static final String INVALID_DB_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidDatabasePort");
56  private static final String INVALID_MESSAGE_SERVICE_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidMessageServicePort");
57  private static final String INVALID_INDEXING_SERVER_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidIndexingServerPort");
58  private static final String NON_WINDOWS_OS_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.nonWindowsOs.msg");
59  private static final long serialVersionUID = 1L;
61  private final Collection<JTextField> textBoxes = new ArrayList<>();
62  private final TextBoxChangedListener textBoxChangedListener;
63  private static final Logger logger = Logger.getLogger(MultiUserSettingsPanel.class.getName());
64  private final ImageIcon goodIcon;
65  private final ImageIcon badIcon;
66  private static final boolean isWindowsOS = PlatformUtil.isWindowsOS();
67 
75  controller = theController;
76  setSize(555, 600);
77 
81  Collection<TextPrompt> textPrompts = new ArrayList<>();
82  textPrompts.add(new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbDbHostname));
83  textPrompts.add(new TextPrompt(PORT_PROMPT, tbDbPort));
84  textPrompts.add(new TextPrompt(USER_NAME_PROMPT, tbDbUsername));
85  textPrompts.add(new TextPrompt(PASSWORD_PROMPT, tbDbPassword));
86  textPrompts.add(new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbMsgHostname));
87  textPrompts.add(new TextPrompt(PORT_PROMPT, tbMsgPort));
88  textPrompts.add(new TextPrompt(USER_NAME_PROMPT_OPT, tbMsgUsername));
89  textPrompts.add(new TextPrompt(PASSWORD_PROMPT_OPT, tbMsgPassword));
90  textPrompts.add(new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbSolrHostname));
91  textPrompts.add(new TextPrompt(PORT_PROMPT, tbSolrPort));
92  configureTextPrompts(textPrompts);
93 
94  /*
95  * Set each textbox with a "statusIcon" property enabling the
96  * DocumentListeners to know which icon to erase when changes are made
97  */
98  tbDbHostname.getDocument().putProperty("statusIcon", lbTestDatabase);
99  tbDbPort.getDocument().putProperty("statusIcon", lbTestDatabase);
100  tbDbUsername.getDocument().putProperty("statusIcon", lbTestDatabase);
101  tbDbPassword.getDocument().putProperty("statusIcon", lbTestDatabase);
102 
103  tbSolrHostname.getDocument().putProperty("statusIcon", lbTestSolr);
104  tbSolrPort.getDocument().putProperty("statusIcon", lbTestSolr);
105 
106  tbMsgHostname.getDocument().putProperty("statusIcon", lbTestMessageService);
107  tbMsgPort.getDocument().putProperty("statusIcon", lbTestMessageService);
108  tbMsgUsername.getDocument().putProperty("statusIcon", lbTestMessageService);
109  tbMsgPassword.getDocument().putProperty("statusIcon", lbTestMessageService);
110 
112  textBoxChangedListener = new TextBoxChangedListener();
113  textBoxes.add(tbDbHostname);
114  textBoxes.add(tbDbPort);
115  textBoxes.add(tbDbUsername);
116  textBoxes.add(tbDbPassword);
117  textBoxes.add(tbMsgHostname);
118  textBoxes.add(tbMsgPort);
119  textBoxes.add(tbMsgUsername);
120  textBoxes.add(tbMsgPassword);
121  textBoxes.add(tbSolrHostname);
122  textBoxes.add(tbSolrPort);
123 
124  addDocumentListeners(textBoxes, textBoxChangedListener);
125  goodIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/good.png", false));
126  badIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/bad.png", false));
127  if (!isWindowsOS) {
128  cbEnableMultiUser.setEnabled(false);
129  cbEnableMultiUser.setSelected(false);
130  }
131  enableMultiUserComponents(textBoxes, cbEnableMultiUser.isSelected());
132  }
133 
140  private static void configureTextPrompts(Collection<TextPrompt> textPrompts) {
141  float alpha = 0.9f; // Mostly opaque
142  for (TextPrompt textPrompt : textPrompts) {
143  textPrompt.setForeground(Color.LIGHT_GRAY);
144  textPrompt.changeAlpha(alpha);
145  }
146  }
147 
154  private static void addDocumentListeners(Collection<JTextField> textFields, TextBoxChangedListener listener) {
155  for (JTextField textField : textFields) {
156  textField.getDocument().addDocumentListener(listener);
157  }
158  }
159 
165  @SuppressWarnings("unchecked")
166  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
167  private void initComponents() {
168 
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();
198 
199  pnDatabaseSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
200 
201  tbDbHostname.setFont(tbDbHostname.getFont().deriveFont(tbDbHostname.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
202  tbDbHostname.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbHostname.text")); // NOI18N
203  tbDbHostname.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbHostname.toolTipText")); // NOI18N
204 
205  tbDbPort.setFont(tbDbPort.getFont().deriveFont(tbDbPort.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
206  tbDbPort.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPort.text")); // NOI18N
207  tbDbPort.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPort.toolTipText")); // NOI18N
208 
209  tbDbUsername.setFont(tbDbUsername.getFont().deriveFont(tbDbUsername.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
210  tbDbUsername.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbUsername.text")); // NOI18N
211  tbDbUsername.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbUsername.toolTipText")); // NOI18N
212 
213  tbDbPassword.setFont(tbDbPassword.getFont().deriveFont(tbDbPassword.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
214  tbDbPassword.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPassword.text")); // NOI18N
215  tbDbPassword.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPassword.toolTipText")); // NOI18N
216 
217  lbDatabaseSettings.setFont(lbDatabaseSettings.getFont().deriveFont(lbDatabaseSettings.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
218  org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseSettings, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbDatabaseSettings.text")); // NOI18N
219  lbDatabaseSettings.setVerticalAlignment(javax.swing.SwingConstants.TOP);
220 
221  bnTestDatabase.setFont(bnTestDatabase.getFont().deriveFont(bnTestDatabase.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
222  org.openide.awt.Mnemonics.setLocalizedText(bnTestDatabase, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.bnTestDatabase.text")); // NOI18N
223  bnTestDatabase.addActionListener(new java.awt.event.ActionListener() {
224  public void actionPerformed(java.awt.event.ActionEvent evt) {
226  }
227  });
228 
229  org.openide.awt.Mnemonics.setLocalizedText(lbTestDatabase, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestDatabase.text")); // NOI18N
230  lbTestDatabase.setAutoscrolls(true);
231 
232  lbTestDbWarning.setForeground(new java.awt.Color(255, 0, 0));
233  org.openide.awt.Mnemonics.setLocalizedText(lbTestDbWarning, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestDbWarning.text")); // NOI18N
234 
235  javax.swing.GroupLayout pnDatabaseSettingsLayout = new javax.swing.GroupLayout(pnDatabaseSettings);
236  pnDatabaseSettings.setLayout(pnDatabaseSettingsLayout);
237  pnDatabaseSettingsLayout.setHorizontalGroup(
238  pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
239  .addGroup(pnDatabaseSettingsLayout.createSequentialGroup()
240  .addContainerGap()
241  .addGroup(pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
242  .addComponent(tbDbHostname)
243  .addGroup(pnDatabaseSettingsLayout.createSequentialGroup()
244  .addComponent(lbDatabaseSettings)
245  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
246  .addComponent(bnTestDatabase)
247  .addGap(18, 18, 18)
248  .addComponent(lbTestDatabase, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
249  .addComponent(tbDbPort)
250  .addComponent(tbDbUsername)
251  .addComponent(tbDbPassword)
252  .addGroup(pnDatabaseSettingsLayout.createSequentialGroup()
253  .addComponent(lbTestDbWarning)
254  .addGap(0, 0, Short.MAX_VALUE)))
255  .addContainerGap())
256  );
257  pnDatabaseSettingsLayout.setVerticalGroup(
258  pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
259  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnDatabaseSettingsLayout.createSequentialGroup()
260  .addContainerGap()
261  .addGroup(pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
262  .addComponent(bnTestDatabase)
263  .addComponent(lbTestDatabase, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
264  .addComponent(lbDatabaseSettings))
265  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
266  .addComponent(tbDbHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
267  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
268  .addComponent(tbDbPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
269  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
270  .addComponent(tbDbUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
271  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
272  .addComponent(tbDbPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
273  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
274  .addComponent(lbTestDbWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
275  .addContainerGap())
276  );
277 
278  pnSolrSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
279 
280  lbSolrSettings.setFont(lbSolrSettings.getFont().deriveFont(lbSolrSettings.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
281  org.openide.awt.Mnemonics.setLocalizedText(lbSolrSettings, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbSolrSettings.text")); // NOI18N
282 
283  tbSolrHostname.setFont(tbSolrHostname.getFont().deriveFont(tbSolrHostname.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
284  tbSolrHostname.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbSolrHostname.toolTipText")); // NOI18N
285 
286  tbSolrPort.setFont(tbSolrPort.getFont().deriveFont(tbSolrPort.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
287  tbSolrPort.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbSolrPort.toolTipText")); // NOI18N
288 
289  bnTestSolr.setFont(bnTestSolr.getFont().deriveFont(bnTestSolr.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
290  org.openide.awt.Mnemonics.setLocalizedText(bnTestSolr, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.bnTestSolr.text")); // NOI18N
291  bnTestSolr.addActionListener(new java.awt.event.ActionListener() {
292  public void actionPerformed(java.awt.event.ActionEvent evt) {
294  }
295  });
296 
297  org.openide.awt.Mnemonics.setLocalizedText(lbTestSolr, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestSolr.text")); // NOI18N
298 
299  lbTestSolrWarning.setForeground(new java.awt.Color(255, 0, 0));
300  org.openide.awt.Mnemonics.setLocalizedText(lbTestSolrWarning, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestSolrWarning.text")); // NOI18N
301 
302  javax.swing.GroupLayout pnSolrSettingsLayout = new javax.swing.GroupLayout(pnSolrSettings);
303  pnSolrSettings.setLayout(pnSolrSettingsLayout);
304  pnSolrSettingsLayout.setHorizontalGroup(
305  pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
306  .addGroup(pnSolrSettingsLayout.createSequentialGroup()
307  .addContainerGap()
308  .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
309  .addComponent(tbSolrHostname)
310  .addGroup(pnSolrSettingsLayout.createSequentialGroup()
311  .addComponent(lbSolrSettings)
312  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
313  .addComponent(bnTestSolr)
314  .addGap(18, 18, 18)
315  .addComponent(lbTestSolr, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
316  .addComponent(tbSolrPort)
317  .addGroup(pnSolrSettingsLayout.createSequentialGroup()
318  .addComponent(lbTestSolrWarning)
319  .addGap(0, 0, Short.MAX_VALUE)))
320  .addContainerGap())
321  );
322  pnSolrSettingsLayout.setVerticalGroup(
323  pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
324  .addGroup(pnSolrSettingsLayout.createSequentialGroup()
325  .addContainerGap()
326  .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
327  .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
328  .addComponent(bnTestSolr, javax.swing.GroupLayout.Alignment.TRAILING)
329  .addComponent(lbSolrSettings))
330  .addComponent(lbTestSolr, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
331  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
332  .addComponent(tbSolrHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
333  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
334  .addComponent(tbSolrPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
335  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
336  .addComponent(lbTestSolrWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
337  .addContainerGap())
338  );
339 
340  pnMessagingSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
341 
342  lbMessageServiceSettings.setFont(lbMessageServiceSettings.getFont().deriveFont(lbMessageServiceSettings.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
343  org.openide.awt.Mnemonics.setLocalizedText(lbMessageServiceSettings, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbMessageServiceSettings.text")); // NOI18N
344 
345  tbMsgHostname.setFont(tbMsgHostname.getFont().deriveFont(tbMsgHostname.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
346  tbMsgHostname.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgHostname.text")); // NOI18N
347  tbMsgHostname.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgHostname.toolTipText")); // NOI18N
348 
349  tbMsgUsername.setFont(tbMsgUsername.getFont().deriveFont(tbMsgUsername.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
350  tbMsgUsername.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgUsername.text")); // NOI18N
351  tbMsgUsername.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgUsername.toolTipText")); // NOI18N
352 
353  tbMsgPort.setFont(tbMsgPort.getFont().deriveFont(tbMsgPort.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
354  tbMsgPort.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPort.text")); // NOI18N
355  tbMsgPort.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPort.toolTipText")); // NOI18N
356 
357  tbMsgPassword.setFont(tbMsgPassword.getFont().deriveFont(tbMsgPassword.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
358  tbMsgPassword.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPassword.text")); // NOI18N
359  tbMsgPassword.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPassword.toolTipText")); // NOI18N
360 
361  bnTestMessageService.setFont(bnTestMessageService.getFont().deriveFont(bnTestMessageService.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
362  org.openide.awt.Mnemonics.setLocalizedText(bnTestMessageService, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.bnTestMessageService.text")); // NOI18N
363  bnTestMessageService.addActionListener(new java.awt.event.ActionListener() {
364  public void actionPerformed(java.awt.event.ActionEvent evt) {
366  }
367  });
368 
369  org.openide.awt.Mnemonics.setLocalizedText(lbTestMessageService, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestMessageService.text")); // NOI18N
370 
371  lbTestMessageWarning.setForeground(new java.awt.Color(255, 0, 0));
372  org.openide.awt.Mnemonics.setLocalizedText(lbTestMessageWarning, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestMessageWarning.text")); // NOI18N
373 
374  javax.swing.GroupLayout pnMessagingSettingsLayout = new javax.swing.GroupLayout(pnMessagingSettings);
375  pnMessagingSettings.setLayout(pnMessagingSettingsLayout);
376  pnMessagingSettingsLayout.setHorizontalGroup(
377  pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
378  .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
379  .addContainerGap()
380  .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
381  .addComponent(tbMsgHostname)
382  .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
383  .addComponent(lbMessageServiceSettings)
384  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 229, Short.MAX_VALUE)
385  .addComponent(bnTestMessageService)
386  .addGap(18, 18, 18)
387  .addComponent(lbTestMessageService, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
388  .addComponent(tbMsgPort)
389  .addComponent(tbMsgUsername)
390  .addComponent(tbMsgPassword)
391  .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
392  .addComponent(lbTestMessageWarning)
393  .addGap(0, 0, Short.MAX_VALUE)))
394  .addContainerGap())
395  );
396  pnMessagingSettingsLayout.setVerticalGroup(
397  pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
398  .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
399  .addContainerGap()
400  .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
401  .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
402  .addComponent(bnTestMessageService, javax.swing.GroupLayout.Alignment.TRAILING)
403  .addComponent(lbMessageServiceSettings))
404  .addComponent(lbTestMessageService, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
405  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
406  .addComponent(tbMsgHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
407  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
408  .addComponent(tbMsgPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
409  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
410  .addComponent(tbMsgUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
411  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
412  .addComponent(tbMsgPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
413  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
414  .addComponent(lbTestMessageWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
415  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
416  );
417 
418  cbEnableMultiUser.setFont(cbEnableMultiUser.getFont().deriveFont(cbEnableMultiUser.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
419  org.openide.awt.Mnemonics.setLocalizedText(cbEnableMultiUser, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.cbEnableMultiUser.text")); // NOI18N
420  cbEnableMultiUser.addItemListener(new java.awt.event.ItemListener() {
421  public void itemStateChanged(java.awt.event.ItemEvent evt) {
423  }
424  });
425 
426  tbOops.setEditable(false);
427  tbOops.setFont(tbOops.getFont().deriveFont(tbOops.getFont().getStyle() | java.awt.Font.BOLD, 12));
428  tbOops.setForeground(new java.awt.Color(255, 0, 0));
429  tbOops.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbOops.text")); // NOI18N
430  tbOops.setBorder(null);
431 
432  javax.swing.GroupLayout pnOverallPanelLayout = new javax.swing.GroupLayout(pnOverallPanel);
433  pnOverallPanel.setLayout(pnOverallPanelLayout);
434  pnOverallPanelLayout.setHorizontalGroup(
435  pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
436  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOverallPanelLayout.createSequentialGroup()
437  .addContainerGap()
438  .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
439  .addGroup(pnOverallPanelLayout.createSequentialGroup()
440  .addComponent(cbEnableMultiUser)
441  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
442  .addComponent(tbOops))
443  .addComponent(pnSolrSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
444  .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
445  .addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
446  .addContainerGap())
447  );
448  pnOverallPanelLayout.setVerticalGroup(
449  pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
450  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOverallPanelLayout.createSequentialGroup()
451  .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
452  .addComponent(tbOops, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
453  .addComponent(cbEnableMultiUser))
454  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
455  .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
456  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
457  .addComponent(pnSolrSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
458  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
459  .addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
460  .addContainerGap(39, Short.MAX_VALUE))
461  );
462 
463  jScrollPane.setViewportView(pnOverallPanel);
464 
465  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
466  this.setLayout(layout);
467  layout.setHorizontalGroup(
468  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
469  .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)
470  );
471  layout.setVerticalGroup(
472  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
473  .addGroup(layout.createSequentialGroup()
474  .addContainerGap()
475  .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)
476  .addContainerGap())
477  );
478  }// </editor-fold>//GEN-END:initComponents
479 
486  private static void enableMultiUserComponents(Collection<JTextField> textFields, boolean enabled) {
487  for (JTextField textField : textFields) {
488  textField.setEnabled(enabled);
489  }
490  }
491 
492  private void cbEnableMultiUserItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbEnableMultiUserItemStateChanged
493  if (!cbEnableMultiUser.isSelected()) {
494  if (!isWindowsOS) {
495  tbOops.setText(NON_WINDOWS_OS_MSG);
496  } else {
497  tbOops.setText("");
498  }
499  bnTestDatabase.setEnabled(false);
500  lbTestDatabase.setIcon(null);
501  bnTestSolr.setEnabled(false);
502  lbTestSolr.setIcon(null);
503  bnTestMessageService.setEnabled(false);
504  lbTestMessageService.setIcon(null);
505  lbTestDbWarning.setText("");
506  lbTestSolrWarning.setText("");
507  lbTestMessageWarning.setText("");
508  }
509  enableMultiUserComponents(textBoxes, cbEnableMultiUser.isSelected());
510  controller.changed();
511  }//GEN-LAST:event_cbEnableMultiUserItemStateChanged
512 
513  private void bnTestDatabaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnTestDatabaseActionPerformed
514  lbTestDatabase.setIcon(null);
515  lbTestDbWarning.setText("");
516  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
517  try {
519  this.tbDbHostname.getText().trim(),
520  this.tbDbPort.getText().trim(),
521  this.tbDbUsername.getText().trim(),
522  new String(this.tbDbPassword.getPassword()),
524 
526  lbTestDatabase.setIcon(goodIcon);
527  lbTestDbWarning.setText("");
528  } catch (TskCoreException ex) {
529  lbTestDatabase.setIcon(badIcon);
530  lbTestDbWarning.setText(ex.getMessage());
531  } finally {
532  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
533  }
534  }//GEN-LAST:event_bnTestDatabaseActionPerformed
535 
536  private void bnTestMessageServiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnTestMessageServiceActionPerformed
537  lbTestMessageService.setIcon(null);
538  lbTestMessageWarning.setText("");
539  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
540 
541  int port;
542  try {
543  port = Integer.parseInt(this.tbMsgPort.getText().trim());
544  } catch (NumberFormatException ex) {
545  lbTestMessageService.setIcon(badIcon);
546  lbTestMessageWarning.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.InvalidPortNumber"));
547  return;
548  }
549 
551  this.tbMsgHostname.getText().trim(),
552  port,
553  this.tbMsgUsername.getText().trim(),
554  new String(this.tbMsgPassword.getPassword()));
555  try {
556  info.tryConnect();
557  lbTestMessageService.setIcon(goodIcon);
558  lbTestMessageWarning.setText("");
559  } catch (MessageServiceException ex) {
560  lbTestMessageService.setIcon(badIcon);
561  lbTestMessageWarning.setText(ex.getMessage());
562  } finally {
563  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
564  }
565  }//GEN-LAST:event_bnTestMessageServiceActionPerformed
566 
567  private void bnTestSolrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnTestSolrActionPerformed
568  lbTestSolr.setIcon(null);
569  lbTestSolrWarning.setText("");
570  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
571 
572  KeywordSearchService kwsService = Lookup.getDefault().lookup(KeywordSearchService.class);
573  try {
574  if (kwsService != null) {
575  int port = Integer.parseInt(tbSolrPort.getText().trim());
576  kwsService.tryConnect(tbSolrHostname.getText().trim(), port);
577  lbTestSolr.setIcon(goodIcon);
578  lbTestSolrWarning.setText("");
579  } else {
580  lbTestSolr.setIcon(badIcon);
581  lbTestSolrWarning.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.KeywordSearchNull"));
582  }
583  } catch (NumberFormatException ex) {
584  lbTestSolr.setIcon(badIcon);
585  lbTestSolrWarning.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.InvalidPortNumber"));
586  } catch (KeywordSearchServiceException ex) {
587  lbTestSolr.setIcon(badIcon);
588  lbTestSolrWarning.setText(ex.getMessage());
589  } finally {
590  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
591  }
592  }//GEN-LAST:event_bnTestSolrActionPerformed
593 
594  void load() {
595  lbTestDatabase.setIcon(null);
596  lbTestSolr.setIcon(null);
597  lbTestMessageService.setIcon(null);
598  lbTestDbWarning.setText("");
599  lbTestSolrWarning.setText("");
600  lbTestMessageWarning.setText("");
601 
602  try {
604  tbDbHostname.setText(dbInfo.getHost().trim());
605  tbDbPort.setText(dbInfo.getPort().trim());
606  tbDbUsername.setText(dbInfo.getUserName().trim());
607  tbDbPassword.setText(dbInfo.getPassword());
608  } catch (UserPreferencesException ex) {
609  logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
610  }
611 
612  try {
613  MessageServiceConnectionInfo msgServiceInfo = UserPreferences.getMessageServiceConnectionInfo();
614  tbMsgHostname.setText(msgServiceInfo.getHost().trim());
615  tbMsgPort.setText(Integer.toString(msgServiceInfo.getPort()));
616  tbMsgUsername.setText(msgServiceInfo.getUserName().trim());
617  tbMsgPassword.setText(msgServiceInfo.getPassword());
618  } catch (UserPreferencesException ex) {
619  logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
620  }
621 
622  String indexingServerHost = UserPreferences.getIndexingServerHost().trim();
623  if (!indexingServerHost.isEmpty()) {
624  tbSolrHostname.setText(indexingServerHost);
625  }
626  String indexingServerPort = UserPreferences.getIndexingServerPort().trim();
627  if (portNumberIsValid(indexingServerPort)) {
628  tbSolrPort.setText(indexingServerPort);
629  }
630 
631  lbTestDatabase.setIcon(null);
632  lbTestSolr.setIcon(null);
633  lbTestMessageService.setIcon(null);
634 
635  bnTestDatabase.setEnabled(false);
636  bnTestSolr.setEnabled(false);
637  bnTestMessageService.setEnabled(false);
638 
639  cbEnableMultiUser.setSelected(UserPreferences.getIsMultiUserModeEnabled());
640  this.valid(); // trigger validation to enable buttons based on current settings
641  }
642 
649  private boolean databaseFieldsArePopulated() {
650  return !tbDbHostname.getText().trim().isEmpty()
651  && !tbDbPort.getText().trim().isEmpty()
652  && !tbDbUsername.getText().trim().isEmpty()
653  && tbDbPassword.getPassword().length != 0;
654  }
655 
662  private boolean solrFieldsArePopulated() {
663  return !tbSolrHostname.getText().trim().isEmpty()
664  && !tbSolrPort.getText().trim().isEmpty();
665  }
666 
674 
675  if ((tbMsgHostname.getText().trim().isEmpty())
676  || (tbMsgPort.getText().trim().isEmpty())) {
677  return false;
678  }
679 
680  // user name and pw are optional, but make sure they are both set or both empty
681  boolean isUserSet = (tbMsgUsername.getText().trim().isEmpty() == false);
682  boolean isPwSet = (tbMsgPassword.getPassword().length != 0);
683  return (isUserSet == isPwSet);
684  }
685 
686  void store() {
687  if (!isWindowsOS) {
688  return;
689  }
690 
691  boolean multiUserCasesEnabled = cbEnableMultiUser.isSelected();
692  UserPreferences.setIsMultiUserModeEnabled(multiUserCasesEnabled);
693  if (multiUserCasesEnabled == false) {
694  return;
695  }
696 
697  /*
698  * Currently only supporting multi-user cases with PostgreSQL case
699  * databases.
700  */
701  DbType dbType = DbType.POSTGRESQL;
702  CaseDbConnectionInfo info = new CaseDbConnectionInfo(
703  tbDbHostname.getText().trim(),
704  tbDbPort.getText().trim(),
705  tbDbUsername.getText().trim(),
706  new String(tbDbPassword.getPassword()),
707  dbType);
708  try {
709  UserPreferences.setDatabaseConnectionInfo(info);
710  } catch (UserPreferencesException ex) {
711  logger.log(Level.SEVERE, "Error saving case database connection info", ex); //NON-NLS
712  }
713 
714  int msgServicePort = 0;
715  try {
716  msgServicePort = Integer.parseInt(this.tbMsgPort.getText().trim());
717  } catch (NumberFormatException ex) {
718  logger.log(Level.SEVERE, "Could not parse messaging service port setting", ex);
719  }
720 
721  MessageServiceConnectionInfo msgServiceInfo = new MessageServiceConnectionInfo(
722  tbMsgHostname.getText().trim(),
723  msgServicePort,
724  tbMsgUsername.getText().trim(),
725  new String(tbMsgPassword.getPassword()));
726 
727  try {
728  UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
729  } catch (UserPreferencesException ex) {
730  logger.log(Level.SEVERE, "Error saving messaging service connection info", ex); //NON-NLS
731  }
732 
733  UserPreferences.setIndexingServerHost(tbSolrHostname.getText().trim());
734  UserPreferences.setIndexingServerPort(Integer.parseInt(tbSolrPort.getText().trim()));
735 
736  }
737 
743  boolean valid() {
744  if (!isWindowsOS) {
745  tbOops.setText(NON_WINDOWS_OS_MSG);
746  } else {
747  tbOops.setText("");
748  }
749 
750  if (cbEnableMultiUser.isSelected()) {
751  return checkFieldsAndEnableButtons()
752  && databaseSettingsAreValid()
753  && indexingServerSettingsAreValid()
754  && messageServiceSettingsAreValid();
755  } else {
756  return true;
757  }
758  }
759 
766  boolean checkFieldsAndEnableButtons() {
767  boolean result = true;
768 
769  boolean dbPopulated = databaseFieldsArePopulated();
770  boolean solrPopulated = solrFieldsArePopulated();
771  boolean messageServicePopulated = messageServiceFieldsArePopulated();
772 
773  // PostgreSQL Database
774  bnTestDatabase.setEnabled(dbPopulated);
775 
776  // Solr Indexing
777  bnTestSolr.setEnabled(solrPopulated);
778 
779  // ActiveMQ Messaging
780  bnTestMessageService.setEnabled(messageServicePopulated);
781 
782  if (!dbPopulated || !solrPopulated || !messageServicePopulated) {
783  // We don't even have everything filled out
784  result = false;
785  tbOops.setText(INCOMPLETE_SETTINGS_MSG);
786  }
787  return result;
788  }
789 
795  boolean databaseSettingsAreValid() {
796  if (portNumberIsValid(tbDbPort.getText().trim())) {
797  return true;
798  } else {
799  tbOops.setText(INVALID_DB_PORT_MSG);
800  return false;
801  }
802  }
803 
809  boolean messageServiceSettingsAreValid() {
810  if (!portNumberIsValid(tbMsgPort.getText().trim())) {
811  tbOops.setText(INVALID_MESSAGE_SERVICE_PORT_MSG);
812  return false;
813  }
814 
815  return true;
816  }
817 
823  boolean indexingServerSettingsAreValid() {
824  if (!portNumberIsValid(tbSolrPort.getText().trim())) {
825  tbOops.setText(INVALID_INDEXING_SERVER_PORT_MSG);
826  return false;
827  }
828 
829  return true;
830  }
831 
840  private static boolean portNumberIsValid(String portNumber) {
841  try {
842  int value = Integer.parseInt(portNumber);
843  if (value < 0 || value > 65535) { // invalid port numbers
844  return false;
845  }
846  } catch (NumberFormatException detailsNotImportant) {
847  return false;
848  }
849  return true;
850  }
851 
852  // Variables declaration - do not modify//GEN-BEGIN:variables
853  private javax.swing.JButton bnTestDatabase;
854  private javax.swing.JButton bnTestMessageService;
855  private javax.swing.JButton bnTestSolr;
856  private javax.swing.JCheckBox cbEnableMultiUser;
857  private javax.swing.JScrollPane jScrollPane;
858  private javax.swing.JLabel lbDatabaseSettings;
859  private javax.swing.JLabel lbMessageServiceSettings;
860  private javax.swing.JLabel lbSolrSettings;
861  private javax.swing.JLabel lbTestDatabase;
862  private javax.swing.JLabel lbTestDbWarning;
863  private javax.swing.JLabel lbTestMessageService;
864  private javax.swing.JLabel lbTestMessageWarning;
865  private javax.swing.JLabel lbTestSolr;
866  private javax.swing.JLabel lbTestSolrWarning;
867  private javax.swing.JPanel pnDatabaseSettings;
868  private javax.swing.JPanel pnMessagingSettings;
869  private javax.swing.JPanel pnOverallPanel;
870  private javax.swing.JPanel pnSolrSettings;
871  private javax.swing.JTextField tbDbHostname;
872  private javax.swing.JPasswordField tbDbPassword;
873  private javax.swing.JTextField tbDbPort;
874  private javax.swing.JTextField tbDbUsername;
875  private javax.swing.JTextField tbMsgHostname;
876  private javax.swing.JPasswordField tbMsgPassword;
877  private javax.swing.JTextField tbMsgPort;
878  private javax.swing.JTextField tbMsgUsername;
879  private javax.swing.JTextField tbOops;
880  private javax.swing.JTextField tbSolrHostname;
881  private javax.swing.JTextField tbSolrPort;
882  // End of variables declaration//GEN-END:variables
883 
888  class TextBoxChangedListener implements DocumentListener {
889 
890  @Override
891  public void changedUpdate(DocumentEvent e) {
892  Object statusIcon = e.getDocument().getProperty("statusIcon");
893  if (statusIcon != null) {
894  ((javax.swing.JLabel) statusIcon).setIcon(null);
895  }
896  controller.changed();
897  }
898 
899  @Override
900  public void insertUpdate(DocumentEvent e) {
901  Object statusIcon = e.getDocument().getProperty("statusIcon");
902  if (statusIcon != null) {
903  ((javax.swing.JLabel) statusIcon).setIcon(null);
904  }
905  controller.changed();
906  }
907 
908  @Override
909  public void removeUpdate(DocumentEvent e) {
910  Object statusIcon = e.getDocument().getProperty("statusIcon");
911  if (statusIcon != null) {
912  ((javax.swing.JLabel) statusIcon).setIcon(null);
913  }
914  controller.changed();
915  }
916  }
917 }
static void configureTextPrompts(Collection< TextPrompt > textPrompts)
static CaseDbConnectionInfo getDatabaseConnectionInfo()
MultiUserSettingsPanel(MultiUserSettingsPanelController theController)
synchronized static Logger getLogger(String name)
Definition: Logger.java:161
static void tryConnect(CaseDbConnectionInfo info)
static void enableMultiUserComponents(Collection< JTextField > textFields, boolean enabled)
static void addDocumentListeners(Collection< JTextField > textFields, TextBoxChangedListener listener)

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.