Autopsy  4.17.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
GlobalSettingsPanel.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2015-2020 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.centralrepository.optionspanel;
20 
21 import java.awt.EventQueue;
23 import java.beans.PropertyChangeEvent;
24 import java.beans.PropertyChangeListener;
25 import java.util.EnumSet;
26 import java.util.Set;
27 import javax.swing.JOptionPane;
28 import javax.swing.SwingUtilities;
29 import org.netbeans.spi.options.OptionsPanelController;
30 import org.openide.util.NbBundle;
31 import org.openide.util.NbBundle.Messages;
44 import java.awt.Component;
45 import java.beans.PropertyChangeSupport;
46 import java.util.logging.Level;
47 import javax.swing.ImageIcon;
48 import org.openide.util.ImageUtilities;
50 
51 
52 
56 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
57 public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel implements OptionsPanel {
58 
59  private static final long serialVersionUID = 1L;
60  private static final Logger logger = Logger.getLogger(GlobalSettingsPanel.class.getName());
62 
63  // this allows property change events to be fired at a static level but listened to by instances
64  private static final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(GlobalSettingsPanel.class);
65 
66  // tracks the last known instance property change listener so that only one GlobalSettingsPanel is listening for events
67  private static PropertyChangeListener lastRegistered = null;
68 
70 
71  private final ImageIcon goodIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/good.png", false));
72  private final ImageIcon badIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/bad.png", false));
73 
74 
79  ingestJobEventListener = new IngestJobEventPropertyChangeListener();
80  initComponents();
81  customizeComponents();
82  setupSettingsChangeListeners();
83  addIngestJobEventsListener();
84  Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), (PropertyChangeEvent evt) -> {
85  //disable when case is open, enable when case is closed
86  ingestStateUpdated(evt.getNewValue() != null);
87  });
88  }
89 
90 
95  // listen for change events in currently saved choice
96  if (lastRegistered != null) {
98  GlobalSettingsPanel.propertyChangeSupport.removePropertyChangeListener(lastRegistered);
99  }
100 
101  lastRegistered = this::onSettingsChange;
103  GlobalSettingsPanel.propertyChangeSupport.addPropertyChangeListener(lastRegistered);
104  }
105 
106 
107  private void onSettingsChange(PropertyChangeEvent evt) {
108  ingestStateUpdated(Case.isCaseOpen());
109  clearStatus();
110  }
111 
112 
113  private void customizeComponents() {
114  setName(NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.pnCorrelationProperties.border.title"));
115  }
116 
117  private void addIngestJobEventsListener() {
118  IngestManager.getInstance().addIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestJobEventListener);
119  ingestStateUpdated(Case.isCaseOpen());
120  }
121 
133  private static boolean invokeCrChoice(Component parent, CentralRepoDbChoice initialSelection) {
134  EamDbSettingsDialog dialog = (initialSelection != null)
135  ? new EamDbSettingsDialog(initialSelection)
136  : new EamDbSettingsDialog();
137  return dialog.wasConfigurationChanged();
138  }
139 
153  @NbBundle.Messages({
154  "GlobalSettingsPanel.onMultiUserChange.enable.title=Central Repository",
155  "GlobalSettingsPanel.onMultiUserChange.enable.description=Do you want to update the Central Repository to use this PostgreSQL server?",
156  "GlobalSettingsPanel.onMultiUserChange.enable.description2=Any data in an existing SQLite Central Repository will not be transferred to the new database."
157  })
158  public static void onMultiUserChange(Component parent, boolean muPreviouslySelected, boolean muCurrentlySelected) {
159  boolean crEnabled = CentralRepoDbUtil.allowUseOfCentralRepository();
161 
162  if (!muPreviouslySelected && muCurrentlySelected) {
163  SwingUtilities.invokeLater(() -> {
164  if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(parent,
165  "<html><body>"
166  + "<div style='width: 400px;'>"
167  + "<p>" + Bundle.GlobalSettingsPanel_onMultiUserChange_enable_description() + "</p>"
168  + "<p style='margin-top: 10px'>" + Bundle.GlobalSettingsPanel_onMultiUserChange_enable_description2() + "</p>"
169  + "</div>"
170  + "</body></html>",
171  Bundle.GlobalSettingsPanel_onMultiUserChange_enable_title(),
172  JOptionPane.YES_NO_OPTION)) {
173 
174  // setup database for CR
177  checkStatusAndCreateDb(parent);
178  }
179  });
180  } // moving from selected to not selected && 'PostgreSQL using multi-user settings' is selected
181  else if (muPreviouslySelected && !muCurrentlySelected && crEnabled && crMultiUser) {
182  SwingUtilities.invokeLater(() -> {
183  askForCentralRepoDbChoice(parent);
184  });
185  } // changing multi-user settings connection && 'PostgreSQL using multi-user settings' is selected &&
186  // central repo either enabled or was disabled due to error
187  else if (muPreviouslySelected && muCurrentlySelected && crEnabled && crMultiUser) {
188  GlobalSettingsPanel.propertyChangeSupport.firePropertyChange("multiuserSettingsChanged", null, null);
189  checkStatusAndCreateDb(parent);
190  }
191  }
192 
193 
199  private static void checkStatusAndCreateDb(Component parent) {
200  SwingUtilities.invokeLater(() -> {
202  });
203  }
204 
212  @NbBundle.Messages({
213  "GlobalSettingsPanel.onMultiUserChange.disabledMu.title=Central Repository Change Necessary",
214  "GlobalSettingsPanel.onMultiUserChange.disabledMu.description=The Central Repository will be reconfigured to use a local SQLite database.",
215  "GlobalSettingsPanel.onMultiUserChange.disabledMu.description2=Press Configure PostgreSQL to change to a PostgreSQL database.",
216  "GlobalSettingsPanel.askForCentralRepoDbChoice.sqliteChoice.text=Use SQLite",
217  "GlobalSettingsPanel.askForCentralRepoDbChoice.customPostgrestChoice.text=Configure PostgreSQL",
218  "GlobalSettingsPanel.askForCentralRepoDbChoice.disableChoice.text=Disable Central Repository"
219  })
220  private static void askForCentralRepoDbChoice(Component parent) {
221  Object[] options = {
222  Bundle.GlobalSettingsPanel_askForCentralRepoDbChoice_sqliteChoice_text(),
223  Bundle.GlobalSettingsPanel_askForCentralRepoDbChoice_customPostgrestChoice_text(),
224  Bundle.GlobalSettingsPanel_askForCentralRepoDbChoice_disableChoice_text()
225  };
226 
227  int result = JOptionPane.showOptionDialog(
228  parent,
229  "<html><body>"
230  + "<div style='width: 400px;'>"
231  + "<p>" + Bundle.GlobalSettingsPanel_onMultiUserChange_disabledMu_description() + "</p>"
232  + "<p style='margin-top: 10px'>" + Bundle.GlobalSettingsPanel_onMultiUserChange_disabledMu_description2() + "</p>"
233  + "</div>"
234  + "</body></html>",
235  Bundle.GlobalSettingsPanel_onMultiUserChange_disabledMu_title(),
236  JOptionPane.YES_NO_CANCEL_OPTION,
237  JOptionPane.PLAIN_MESSAGE,
238  null,
239  options,
240  options[0]
241  );
242 
243  if (JOptionPane.YES_OPTION == result) {
244  invokeCrChoice(parent, CentralRepoDbChoice.SQLITE);
245  } else if (JOptionPane.NO_OPTION == result) {
246  invokeCrChoice(parent, CentralRepoDbChoice.POSTGRESQL_CUSTOM);
247  }
248  }
249 
250  @NbBundle.Messages({
251  "GlobalSettingsPanel.testCurrentConfiguration.dbDoesNotExist.message=Database does not exist.",
252  })
253  private boolean testCurrentConfiguration() {
254  if (CentralRepoDbManager.getSavedDbChoice() == null ||
257  return false;
258 
260  DatabaseTestResult testResult = manager.testStatus();
261 
262  // if database doesn't exist, prompt user to create database
263  if (testResult == DatabaseTestResult.DB_DOES_NOT_EXIST) {
264  boolean success = EamDbSettingsDialog.promptCreateDatabase(manager, null);
265  if (success)
266  testResult = DatabaseTestResult.TESTED_OK;
267  }
268 
269  // display to the user the status
270  switch (testResult) {
271  case TESTED_OK: return showStatusOkay();
272  case DB_DOES_NOT_EXIST: return showStatusFail(Bundle.GlobalSettingsPanel_testCurrentConfiguration_dbDoesNotExist_message());
273  case SCHEMA_INVALID: return showStatusFail(Bundle.EamDbSettingsDialog_okButton_corruptDatabaseExists_message());
274  case CONNECTION_FAILED:
275  default:
276  return showStatusFail(Bundle.EamDbSettingsDialog_okButton_databaseConnectionFailed_message());
277  }
278  }
279 
280  private boolean showStatusOkay() {
281  return setStatus(goodIcon, " ");
282  }
283 
284  private boolean showStatusFail(String message) {
285  return setStatus(badIcon, message);
286  }
287 
288  private void clearStatus() {
289  setStatus(null, " ");
290  }
291 
292  private boolean setStatus(ImageIcon icon, String text) {
293  synchronized (testStatusLabel) {
294  testStatusLabel.setIcon(icon);
295  testStatusLabel.setText(text);
296  return true;
297  }
298  }
299 
305  @SuppressWarnings("unchecked")
306  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
307  private void initComponents() {
308 
309  jScrollPane1 = new javax.swing.JScrollPane();
310  jPanel1 = new javax.swing.JPanel();
311  lbCentralRepository = new javax.swing.JLabel();
312  cbUseCentralRepo = new javax.swing.JCheckBox();
313  pnDatabaseConfiguration = new javax.swing.JPanel();
314  lbDbPlatformTypeLabel = new javax.swing.JLabel();
315  lbDbNameLabel = new javax.swing.JLabel();
316  lbDbLocationLabel = new javax.swing.JLabel();
317  bnDbConfigure = new javax.swing.JButton();
318  lbDbPlatformValue = new javax.swing.JLabel();
319  lbDbNameValue = new javax.swing.JLabel();
320  lbDbLocationValue = new javax.swing.JLabel();
321  bnTestConfigure = new javax.swing.JButton();
322  testStatusLabel = new javax.swing.JLabel();
323  pnCorrelationProperties = new javax.swing.JPanel();
324  bnManageTypes = new javax.swing.JButton();
325  correlationPropertiesScrollPane = new javax.swing.JScrollPane();
326  correlationPropertiesTextArea = new javax.swing.JTextArea();
327  organizationPanel = new javax.swing.JPanel();
328  manageOrganizationButton = new javax.swing.JButton();
329  organizationScrollPane = new javax.swing.JScrollPane();
330  organizationTextArea = new javax.swing.JTextArea();
331  casesPanel = new javax.swing.JPanel();
332  showCasesButton = new javax.swing.JButton();
333  casesScrollPane = new javax.swing.JScrollPane();
334  casesTextArea = new javax.swing.JTextArea();
335  tbOops = new javax.swing.JTextField();
336  ingestRunningWarningLabel = new javax.swing.JLabel();
337 
338  setName(""); // NOI18N
339  setPreferredSize(new java.awt.Dimension(1022, 488));
340 
341  jScrollPane1.setBorder(null);
342  jScrollPane1.setPreferredSize(new java.awt.Dimension(1022, 407));
343 
344  jPanel1.setMinimumSize(new java.awt.Dimension(0, 0));
345  jPanel1.setPreferredSize(new java.awt.Dimension(1020, 407));
346 
347  org.openide.awt.Mnemonics.setLocalizedText(lbCentralRepository, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.lbCentralRepository.text")); // NOI18N
348 
349  org.openide.awt.Mnemonics.setLocalizedText(cbUseCentralRepo, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.cbUseCentralRepo.text")); // NOI18N
350  cbUseCentralRepo.addActionListener(new java.awt.event.ActionListener() {
351  public void actionPerformed(java.awt.event.ActionEvent evt) {
352  cbUseCentralRepoActionPerformed(evt);
353  }
354  });
355 
356  pnDatabaseConfiguration.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.pnDatabaseConfiguration.title"))); // NOI18N
357 
358  org.openide.awt.Mnemonics.setLocalizedText(lbDbPlatformTypeLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.lbDbPlatformTypeLabel.text")); // NOI18N
359 
360  org.openide.awt.Mnemonics.setLocalizedText(lbDbNameLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.lbDbNameLabel.text")); // NOI18N
361 
362  org.openide.awt.Mnemonics.setLocalizedText(lbDbLocationLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.lbDbLocationLabel.text")); // NOI18N
363 
364  org.openide.awt.Mnemonics.setLocalizedText(bnDbConfigure, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.bnDbConfigure.text")); // NOI18N
365  bnDbConfigure.addActionListener(new java.awt.event.ActionListener() {
366  public void actionPerformed(java.awt.event.ActionEvent evt) {
367  bnDbConfigureActionPerformed(evt);
368  }
369  });
370 
371  org.openide.awt.Mnemonics.setLocalizedText(bnTestConfigure, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.bnTestConfigure.text")); // NOI18N
372  bnTestConfigure.addActionListener(new java.awt.event.ActionListener() {
373  public void actionPerformed(java.awt.event.ActionEvent evt) {
374  bnTestConfigureActionPerformed(evt);
375  }
376  });
377 
378  testStatusLabel.setFont(testStatusLabel.getFont().deriveFont(testStatusLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
379  testStatusLabel.setForeground(new java.awt.Color(255, 0, 0));
380  org.openide.awt.Mnemonics.setLocalizedText(testStatusLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.testStatusLabel.text")); // NOI18N
381  testStatusLabel.setToolTipText(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.testStatusLabel.toolTipText")); // NOI18N
382  testStatusLabel.setMaximumSize(new java.awt.Dimension(387, 16));
383  testStatusLabel.setPreferredSize(new java.awt.Dimension(387, 16));
384 
385  javax.swing.GroupLayout pnDatabaseConfigurationLayout = new javax.swing.GroupLayout(pnDatabaseConfiguration);
386  pnDatabaseConfiguration.setLayout(pnDatabaseConfigurationLayout);
387  pnDatabaseConfigurationLayout.setHorizontalGroup(
388  pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
389  .addGroup(pnDatabaseConfigurationLayout.createSequentialGroup()
390  .addContainerGap()
391  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
392  .addGroup(pnDatabaseConfigurationLayout.createSequentialGroup()
393  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
394  .addComponent(lbDbPlatformTypeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
395  .addComponent(lbDbNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
396  .addComponent(lbDbLocationLabel))
397  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
398  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
399  .addComponent(lbDbNameValue, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
400  .addComponent(lbDbPlatformValue, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
401  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnDatabaseConfigurationLayout.createSequentialGroup()
402  .addComponent(lbDbLocationValue, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)
403  .addGap(681, 681, 681))))
404  .addGroup(pnDatabaseConfigurationLayout.createSequentialGroup()
405  .addComponent(bnDbConfigure)
406  .addGap(18, 18, 18)
407  .addComponent(bnTestConfigure)
408  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
409  .addComponent(testStatusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 675, javax.swing.GroupLayout.PREFERRED_SIZE)
410  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
411  );
412  pnDatabaseConfigurationLayout.setVerticalGroup(
413  pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
414  .addGroup(pnDatabaseConfigurationLayout.createSequentialGroup()
415  .addGap(7, 7, 7)
416  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
417  .addComponent(lbDbPlatformTypeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
418  .addComponent(lbDbPlatformValue, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
419  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
420  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
421  .addComponent(lbDbNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
422  .addComponent(lbDbNameValue, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
423  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
424  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
425  .addComponent(lbDbLocationLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
426  .addComponent(lbDbLocationValue, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
427  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
428  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
429  .addComponent(testStatusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
430  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
431  .addComponent(bnDbConfigure)
432  .addComponent(bnTestConfigure)))
433  .addGap(8, 8, 8))
434  );
435 
436  pnCorrelationProperties.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.pnCorrelationProperties.border.title"))); // NOI18N
437  pnCorrelationProperties.setPreferredSize(new java.awt.Dimension(674, 93));
438 
439  org.openide.awt.Mnemonics.setLocalizedText(bnManageTypes, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.bnManageProperties.text")); // NOI18N
440  bnManageTypes.addActionListener(new java.awt.event.ActionListener() {
441  public void actionPerformed(java.awt.event.ActionEvent evt) {
442  bnManageTypesActionPerformed(evt);
443  }
444  });
445 
446  correlationPropertiesScrollPane.setBorder(null);
447 
448  correlationPropertiesTextArea.setEditable(false);
449  correlationPropertiesTextArea.setBackground(new java.awt.Color(240, 240, 240));
450  correlationPropertiesTextArea.setColumns(20);
451  correlationPropertiesTextArea.setLineWrap(true);
452  correlationPropertiesTextArea.setRows(1);
453  correlationPropertiesTextArea.setText(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.correlationPropertiesTextArea.text")); // NOI18N
454  correlationPropertiesTextArea.setToolTipText("");
455  correlationPropertiesTextArea.setWrapStyleWord(true);
456  correlationPropertiesTextArea.setBorder(null);
457  correlationPropertiesTextArea.setOpaque(false);
458  correlationPropertiesScrollPane.setViewportView(correlationPropertiesTextArea);
459 
460  javax.swing.GroupLayout pnCorrelationPropertiesLayout = new javax.swing.GroupLayout(pnCorrelationProperties);
461  pnCorrelationProperties.setLayout(pnCorrelationPropertiesLayout);
462  pnCorrelationPropertiesLayout.setHorizontalGroup(
463  pnCorrelationPropertiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
464  .addGroup(pnCorrelationPropertiesLayout.createSequentialGroup()
465  .addContainerGap()
466  .addGroup(pnCorrelationPropertiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
467  .addGroup(pnCorrelationPropertiesLayout.createSequentialGroup()
468  .addComponent(bnManageTypes)
469  .addGap(0, 0, Short.MAX_VALUE))
470  .addComponent(correlationPropertiesScrollPane))
471  .addContainerGap())
472  );
473  pnCorrelationPropertiesLayout.setVerticalGroup(
474  pnCorrelationPropertiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
475  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnCorrelationPropertiesLayout.createSequentialGroup()
476  .addComponent(correlationPropertiesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
477  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
478  .addComponent(bnManageTypes)
479  .addGap(8, 8, 8))
480  );
481 
482  organizationPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.organizationPanel.border.title"))); // NOI18N
483 
484  org.openide.awt.Mnemonics.setLocalizedText(manageOrganizationButton, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.manageOrganizationButton.text")); // NOI18N
485  manageOrganizationButton.addActionListener(new java.awt.event.ActionListener() {
486  public void actionPerformed(java.awt.event.ActionEvent evt) {
487  manageOrganizationButtonActionPerformed(evt);
488  }
489  });
490 
491  organizationScrollPane.setBorder(null);
492 
493  organizationTextArea.setEditable(false);
494  organizationTextArea.setBackground(new java.awt.Color(240, 240, 240));
495  organizationTextArea.setColumns(20);
496  organizationTextArea.setLineWrap(true);
497  organizationTextArea.setRows(2);
498  organizationTextArea.setText(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.organizationTextArea.text")); // NOI18N
499  organizationTextArea.setWrapStyleWord(true);
500  organizationTextArea.setBorder(null);
501  organizationTextArea.setOpaque(false);
502  organizationScrollPane.setViewportView(organizationTextArea);
503 
504  javax.swing.GroupLayout organizationPanelLayout = new javax.swing.GroupLayout(organizationPanel);
505  organizationPanel.setLayout(organizationPanelLayout);
506  organizationPanelLayout.setHorizontalGroup(
507  organizationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
508  .addGroup(organizationPanelLayout.createSequentialGroup()
509  .addContainerGap()
510  .addGroup(organizationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
511  .addComponent(organizationScrollPane)
512  .addGroup(organizationPanelLayout.createSequentialGroup()
513  .addComponent(manageOrganizationButton)
514  .addGap(0, 0, Short.MAX_VALUE)))
515  .addContainerGap())
516  );
517  organizationPanelLayout.setVerticalGroup(
518  organizationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
519  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, organizationPanelLayout.createSequentialGroup()
520  .addContainerGap()
521  .addComponent(organizationScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
522  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
523  .addComponent(manageOrganizationButton)
524  .addGap(8, 8, 8))
525  );
526 
527  casesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.casesPanel.border.title"))); // NOI18N
528  casesPanel.setName("Case Details"); // NOI18N
529 
530  org.openide.awt.Mnemonics.setLocalizedText(showCasesButton, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.showCasesButton.text")); // NOI18N
531  showCasesButton.addActionListener(new java.awt.event.ActionListener() {
532  public void actionPerformed(java.awt.event.ActionEvent evt) {
533  showCasesButtonActionPerformed(evt);
534  }
535  });
536 
537  casesScrollPane.setBorder(null);
538 
539  casesTextArea.setEditable(false);
540  casesTextArea.setBackground(new java.awt.Color(240, 240, 240));
541  casesTextArea.setColumns(20);
542  casesTextArea.setLineWrap(true);
543  casesTextArea.setRows(2);
544  casesTextArea.setText(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.casesTextArea.text")); // NOI18N
545  casesTextArea.setWrapStyleWord(true);
546  casesTextArea.setBorder(null);
547  casesTextArea.setOpaque(false);
548  casesScrollPane.setViewportView(casesTextArea);
549 
550  javax.swing.GroupLayout casesPanelLayout = new javax.swing.GroupLayout(casesPanel);
551  casesPanel.setLayout(casesPanelLayout);
552  casesPanelLayout.setHorizontalGroup(
553  casesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
554  .addGroup(casesPanelLayout.createSequentialGroup()
555  .addContainerGap()
556  .addGroup(casesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
557  .addComponent(casesScrollPane)
558  .addGroup(casesPanelLayout.createSequentialGroup()
559  .addComponent(showCasesButton)
560  .addGap(0, 0, Short.MAX_VALUE)))
561  .addContainerGap())
562  );
563  casesPanelLayout.setVerticalGroup(
564  casesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
565  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, casesPanelLayout.createSequentialGroup()
566  .addContainerGap()
567  .addComponent(casesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
568  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
569  .addComponent(showCasesButton)
570  .addGap(8, 8, 8))
571  );
572 
573  tbOops.setEditable(false);
574  tbOops.setFont(tbOops.getFont().deriveFont(tbOops.getFont().getStyle() | java.awt.Font.BOLD, tbOops.getFont().getSize()-1));
575  tbOops.setText(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.tbOops.text")); // NOI18N
576  tbOops.setBorder(null);
577 
578  ingestRunningWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/filetypeid/warning16.png"))); // NOI18N
579  org.openide.awt.Mnemonics.setLocalizedText(ingestRunningWarningLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.ingestRunningWarningLabel.text")); // NOI18N
580 
581  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
582  jPanel1.setLayout(jPanel1Layout);
583  jPanel1Layout.setHorizontalGroup(
584  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
585  .addComponent(lbCentralRepository, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
586  .addGroup(jPanel1Layout.createSequentialGroup()
587  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
588  .addComponent(pnDatabaseConfiguration, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
589  .addComponent(pnCorrelationProperties, javax.swing.GroupLayout.DEFAULT_SIZE, 1016, Short.MAX_VALUE)
590  .addComponent(organizationPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
591  .addComponent(casesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
592  .addGroup(jPanel1Layout.createSequentialGroup()
593  .addComponent(cbUseCentralRepo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
594  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
595  .addComponent(ingestRunningWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 840, Short.MAX_VALUE))
596  .addGroup(jPanel1Layout.createSequentialGroup()
597  .addContainerGap()
598  .addComponent(tbOops, javax.swing.GroupLayout.PREFERRED_SIZE, 974, javax.swing.GroupLayout.PREFERRED_SIZE)))
599  .addContainerGap())
600  );
601  jPanel1Layout.setVerticalGroup(
602  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
603  .addGroup(jPanel1Layout.createSequentialGroup()
604  .addComponent(lbCentralRepository)
605  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
606  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
607  .addComponent(cbUseCentralRepo)
608  .addComponent(ingestRunningWarningLabel))
609  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
610  .addComponent(pnDatabaseConfiguration, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
611  .addGap(0, 0, 0)
612  .addComponent(pnCorrelationProperties, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
613  .addGap(0, 0, 0)
614  .addComponent(organizationPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
615  .addGap(0, 0, 0)
616  .addComponent(casesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
617  .addGap(0, 0, 0)
618  .addComponent(tbOops, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
619  .addContainerGap())
620  );
621 
622  casesPanel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.Case Details.AccessibleContext.accessibleName")); // NOI18N
623 
624  jScrollPane1.setViewportView(jPanel1);
625 
626  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
627  this.setLayout(layout);
628  layout.setHorizontalGroup(
629  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
630  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
631  );
632  layout.setVerticalGroup(
633  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
634  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 512, Short.MAX_VALUE)
635  );
636  }// </editor-fold>//GEN-END:initComponents
637 
638  private void bnManageTypesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnManageTypesActionPerformed
639  store();
640  ManageCorrelationPropertiesDialog manageCorrelationDialog = new ManageCorrelationPropertiesDialog();
641  firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
642  }//GEN-LAST:event_bnManageTypesActionPerformed
643 
644  private void bnDbConfigureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnDbConfigureActionPerformed
645  store();
646  boolean changed = invokeCrChoice(this, null);
647  if (changed) {
648  load(); // reload db settings content and update buttons
649  }
650  }//GEN-LAST:event_bnDbConfigureActionPerformed
651 
652  private void manageOrganizationButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manageOrganizationButtonActionPerformed
653  store();
654  ManageOrganizationsDialog manageOrganizationsDialog = new ManageOrganizationsDialog();
655  }//GEN-LAST:event_manageOrganizationButtonActionPerformed
656 
657  private void showCasesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showCasesButtonActionPerformed
658  store();
659  ManageCasesDialog.displayManageCasesDialog();
660  }//GEN-LAST:event_showCasesButtonActionPerformed
661 
662  private void cbUseCentralRepoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbUseCentralRepoActionPerformed
663  //if saved setting is disabled checkbox should be disabled already
664  store();
665  load();
666  this.ingestStateUpdated(Case.isCaseOpen());
667  }//GEN-LAST:event_cbUseCentralRepoActionPerformed
668 
669  private void bnTestConfigureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnTestConfigureActionPerformed
670  testCurrentConfiguration();
671  }//GEN-LAST:event_bnTestConfigureActionPerformed
672 
673  @Override
674  @Messages({"GlobalSettingsPanel.validationerrMsg.mustConfigure=Configure the database to enable this module."})
675  public void load() {
676  tbOops.setText("");
677  enableButtonSubComponents(false);
679  cbUseCentralRepo.setSelected(CentralRepoDbUtil.allowUseOfCentralRepository()); // NON-NLS
680 
681  lbDbPlatformValue.setText(selectedChoice.getTitle());
682  CentralRepoPlatforms selectedDb = selectedChoice.getDbPlatform();
683 
684  if (selectedChoice == null || selectedDb == CentralRepoPlatforms.DISABLED) {
685  lbDbNameValue.setText("");
686  lbDbLocationValue.setText("");
687  tbOops.setText(Bundle.GlobalSettingsPanel_validationerrMsg_mustConfigure());
688  } else {
689  enableButtonSubComponents(cbUseCentralRepo.isSelected());
690  if (selectedDb == CentralRepoPlatforms.POSTGRESQL) {
691  try {
693  lbDbNameValue.setText(dbSettingsPg.getDbName());
694  lbDbLocationValue.setText(dbSettingsPg.getHost());
695  } catch (CentralRepoException e) {
696  logger.log(Level.WARNING, "Unable to load settings into global panel for postgres settings", e);
697  }
698  } else if (selectedDb == CentralRepoPlatforms.SQLITE) {
699  SqliteCentralRepoSettings dbSettingsSqlite = new SqliteCentralRepoSettings();
700  lbDbNameValue.setText(dbSettingsSqlite.getDbName());
701  lbDbLocationValue.setText(dbSettingsSqlite.getDbDirectory());
702  }
703  }
704  }
705 
706  @Override
707  public void store() { // Click OK or Apply on Options Panel
708  CentralRepoDbUtil.setUseCentralRepo(cbUseCentralRepo.isSelected());
709  }
710 
717  public boolean valid() {
718  return !cbUseCentralRepo.isSelected() || !lbDbPlatformValue.getText().equals(CentralRepoDbChoice.DISABLED.toString());
719  }
720 
721  @Override
722  public void saveSettings() { // Click OK on Global Settings Panel
723  store();
724  }
725 
726  @Override
727  @SuppressWarnings("FinalizeDeclaration")
728  protected void finalize() throws Throwable {
729  IngestManager.getInstance().removeIngestJobEventListener(ingestJobEventListener);
730  super.finalize();
731 
732  }
733 
738  private class IngestJobEventPropertyChangeListener implements PropertyChangeListener {
739 
746  @Override
747  public void propertyChange(PropertyChangeEvent event) {
748  if (isLocalIngestJobEvent(event)) {
749  EventQueue.invokeLater(new Runnable() {
750  @Override
751  public void run() {
752  ingestStateUpdated(Case.isCaseOpen());
753  }
754  });
755  }
756  }
757  };
758 
768  private boolean isLocalIngestJobEvent(PropertyChangeEvent event) {
769  if (event instanceof AutopsyEvent) {
770  if (((AutopsyEvent) event).getSourceType() == AutopsyEvent.SourceType.LOCAL) {
771  String eventType = event.getPropertyName();
772  return (eventType.equals(IngestManager.IngestJobEvent.STARTED.toString())
773  || eventType.equals(IngestManager.IngestJobEvent.CANCELLED.toString())
774  || eventType.equals(IngestManager.IngestJobEvent.COMPLETED.toString()));
775  }
776  }
777  return false;
778  }
779 
780  @Messages({"GlobalSettingsPanel.validationErrMsg.ingestRunning=You cannot change settings while ingest is running."})
781  private void ingestStateUpdated(boolean caseIsOpen) {
782  if (!SwingUtilities.isEventDispatchThread()) {
783  SwingUtilities.invokeLater(() -> {
784  ingestStateUpdated(caseIsOpen);
785  });
786 
787  return;
788  }
789 
790  cbUseCentralRepo.setEnabled(!caseIsOpen);
792  tbOops.setText(Bundle.GlobalSettingsPanel_validationErrMsg_ingestRunning());
793  tbOops.setVisible(true);
794  enableButtonSubComponents(cbUseCentralRepo.isSelected());
795  } else {
796  load();
797  }
798 
799  enableDatabaseConfigureButton(cbUseCentralRepo.isSelected() && !caseIsOpen);
800  }
801 
802 
803 
811  private void enableDatabaseConfigureButton(Boolean enable) {
812  boolean ingestRunning = IngestManager.getInstance().isIngestRunning();
813  ingestRunningWarningLabel.setVisible(ingestRunning);
814 
815  pnDatabaseConfiguration.setEnabled(enable && !ingestRunning);
816  bnDbConfigure.setEnabled(enable && !ingestRunning);
817  bnTestConfigure.setEnabled(enable && !ingestRunning);
818  lbDbLocationLabel.setEnabled(enable && !ingestRunning);
819  lbDbLocationValue.setEnabled(enable && !ingestRunning);
820  lbDbNameLabel.setEnabled(enable && !ingestRunning);
821  lbDbNameValue.setEnabled(enable && !ingestRunning);
822  lbDbPlatformTypeLabel.setEnabled(enable && !ingestRunning);
823  lbDbPlatformValue.setEnabled(enable && !ingestRunning);
824  tbOops.setEnabled(enable && !ingestRunning);
825  }
826 
835  private boolean enableButtonSubComponents(Boolean enable) {
836  boolean ingestRunning = IngestManager.getInstance().isIngestRunning();
837  pnCorrelationProperties.setEnabled(enable && !ingestRunning);
838  bnManageTypes.setEnabled(enable && !ingestRunning);
839  correlationPropertiesTextArea.setEnabled(enable && !ingestRunning);
840  organizationPanel.setEnabled(enable && !ingestRunning);
841  organizationTextArea.setEnabled(enable && !ingestRunning);
842  manageOrganizationButton.setEnabled(enable && !ingestRunning);
843  showCasesButton.setEnabled(enable && !ingestRunning);
844  casesPanel.setEnabled(enable && !ingestRunning);
845  casesTextArea.setEnabled(enable && !ingestRunning);
846  return true;
847  }
848 
849  // Variables declaration - do not modify//GEN-BEGIN:variables
850  private javax.swing.JButton bnDbConfigure;
851  private javax.swing.JButton bnManageTypes;
852  private javax.swing.JButton bnTestConfigure;
853  private javax.swing.JPanel casesPanel;
854  private javax.swing.JScrollPane casesScrollPane;
855  private javax.swing.JTextArea casesTextArea;
856  private javax.swing.JCheckBox cbUseCentralRepo;
857  private javax.swing.JScrollPane correlationPropertiesScrollPane;
858  private javax.swing.JTextArea correlationPropertiesTextArea;
859  private javax.swing.JLabel ingestRunningWarningLabel;
860  private javax.swing.JPanel jPanel1;
861  private javax.swing.JScrollPane jScrollPane1;
862  private javax.swing.JLabel lbCentralRepository;
863  private javax.swing.JLabel lbDbLocationLabel;
864  private javax.swing.JLabel lbDbLocationValue;
865  private javax.swing.JLabel lbDbNameLabel;
866  private javax.swing.JLabel lbDbNameValue;
867  private javax.swing.JLabel lbDbPlatformTypeLabel;
868  private javax.swing.JLabel lbDbPlatformValue;
869  private javax.swing.JButton manageOrganizationButton;
870  private javax.swing.JPanel organizationPanel;
871  private javax.swing.JScrollPane organizationScrollPane;
872  private javax.swing.JTextArea organizationTextArea;
873  private javax.swing.JPanel pnCorrelationProperties;
874  private javax.swing.JPanel pnDatabaseConfiguration;
875  private javax.swing.JButton showCasesButton;
876  private javax.swing.JTextField tbOops;
877  private javax.swing.JLabel testStatusLabel;
878  // End of variables declaration//GEN-END:variables
879 }
static synchronized IngestManager getInstance()
static void onMultiUserChange(Component parent, boolean muPreviouslySelected, boolean muCurrentlySelected)
static void setUseCentralRepo(boolean centralRepoCheckBoxIsSelected)
static CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice)
void removeIngestJobEventListener(final PropertyChangeListener listener)
void addIngestJobEventListener(final PropertyChangeListener listener)
static boolean promptCreateDatabase(CentralRepoDbManager manager, EamDbSettingsDialog dialog)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
Definition: Case.java:491
static boolean testStatusAndCreate(Component parent, CentralRepoDbManager manager)
static boolean invokeCrChoice(Component parent, CentralRepoDbChoice initialSelection)

Copyright © 2012-2021 Basis Technology. Generated on: Tue Jan 19 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.