Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AutopsyOptionsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2019 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.image.BufferedImage;
22 import java.io.File;
23 import java.io.IOException;
24 import java.lang.management.ManagementFactory;
25 import java.nio.charset.Charset;
26 import java.nio.file.Files;
27 import java.nio.file.InvalidPathException;
28 import java.nio.file.Path;
29 import java.util.ArrayList;
30 import java.util.List;
31 import java.util.Optional;
32 import java.util.StringJoiner;
33 import java.util.logging.Level;
34 import javax.imageio.ImageIO;
35 import javax.swing.ImageIcon;
36 import javax.swing.JFileChooser;
37 import javax.swing.JOptionPane;
38 import javax.swing.SwingUtilities;
39 import javax.swing.event.DocumentEvent;
40 import javax.swing.event.DocumentListener;
41 import org.netbeans.spi.options.OptionsPanelController;
42 import org.openide.util.NbBundle;
44 import org.openide.util.NbBundle.Messages;
54 
58 @Messages({
59  "AutopsyOptionsPanel.invalidImageFile.msg=The selected file was not able to be used as an agency logo.",
60  "AutopsyOptionsPanel.invalidImageFile.title=Invalid Image File",
61  "AutopsyOptionsPanel.memFieldValidationLabel.not64BitInstall.text=JVM memory settings only enabled for 64 bit version",
62  "AutopsyOptionsPanel.memFieldValidationLabel.noValueEntered.text=No value entered",
63  "AutopsyOptionsPanel.memFieldValidationLabel.invalidCharacters.text=Invalid characters, value must be a positive integer",
64  "# {0} - minimumMemory",
65  "AutopsyOptionsPanel.memFieldValidationLabel.underMinMemory.text=Value must be at least {0}GB",
66  "# {0} - systemMemory",
67  "AutopsyOptionsPanel.memFieldValidationLabel.overMaxMemory.text=Value must be less than the total system memory of {0}GB",
68  "AutopsyOptionsPanel.memFieldValidationLabel.developerMode.text=Memory settings are not available while running in developer mode",
69  "AutopsyOptionsPanel.agencyLogoPathFieldValidationLabel.invalidPath.text=Path is not valid.",
70  "AutopsyOptionsPanel.agencyLogoPathFieldValidationLabel.invalidImageSpecified.text=Invalid image file specified.",
71  "AutopsyOptionsPanel.agencyLogoPathFieldValidationLabel.pathNotSet.text=Agency logo path must be set.",
72  "AutopsyOptionsPanel.logNumAlert.invalidInput.text=A positive integer is required here."
73 })
74 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
75 final class AutopsyOptionsPanel extends javax.swing.JPanel {
76 
77  private static final long serialVersionUID = 1L;
78  private final JFileChooser logoFileChooser;
79  private final JFileChooser tempDirChooser;
80  private final TextFieldListener textFieldListener;
81  private static final String ETC_FOLDER_NAME = "etc";
82  private static final String CONFIG_FILE_EXTENSION = ".conf";
83  private static final long ONE_BILLION = 1000000000L; //used to roughly convert system memory from bytes to gigabytes
84  private static final int MEGA_IN_GIGA = 1024; //used to convert memory settings saved as megabytes to gigabytes
85  private static final int MIN_MEMORY_IN_GB = 2; //the enforced minimum memory in gigabytes
86  private static final Logger logger = Logger.getLogger(AutopsyOptionsPanel.class.getName());
87  private String initialMemValue = Long.toString(Runtime.getRuntime().maxMemory() / ONE_BILLION);
88 
92  AutopsyOptionsPanel() {
93  initComponents();
94  logoFileChooser = new JFileChooser();
95  logoFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
96  logoFileChooser.setMultiSelectionEnabled(false);
97  logoFileChooser.setAcceptAllFileFilterUsed(false);
98  logoFileChooser.setFileFilter(new GeneralFilter(GeneralFilter.GRAPHIC_IMAGE_EXTS, GeneralFilter.GRAPHIC_IMG_DECR));
99 
100  tempDirChooser = new JFileChooser();
101  tempDirChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
102  tempDirChooser.setMultiSelectionEnabled(false);
103 
104  if (!PlatformUtil.is64BitJVM() || Version.getBuildType() == Version.Type.DEVELOPMENT) {
105  //32 bit JVM has a max heap size of 1.4 gb to 4 gb depending on OS
106  //So disabling the setting of heap size when the JVM is not 64 bit
107  //Is the safest course of action
108  //And the file won't exist in the install folder when running through netbeans
109  memField.setEnabled(false);
110  solrMaxHeapSpinner.setEnabled(false);
111  }
112  systemMemoryTotal.setText(Long.toString(getSystemMemoryInGB()));
113  // The cast to int in the following is to ensure that the correct SpinnerNumberModel
114  // constructor is called.
115  solrMaxHeapSpinner.setModel(new javax.swing.SpinnerNumberModel(UserPreferences.getMaxSolrVMSize(),
116  512, ((int) getSystemMemoryInGB()) * MEGA_IN_GIGA, 512));
117 
118  textFieldListener = new TextFieldListener();
119  agencyLogoPathField.getDocument().addDocumentListener(textFieldListener);
120  tempDirectoryField.getDocument().addDocumentListener(textFieldListener);
121  logFileCount.setText(String.valueOf(UserPreferences.getLogFileCount()));
122  }
123 
130  private long getSystemMemoryInGB() {
131  long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory
132  .getOperatingSystemMXBean()).getTotalPhysicalMemorySize();
133  return memorySize / ONE_BILLION;
134  }
135 
141  private long getCurrentJvmMaxMemoryInGB() throws IOException {
142  String currentXmx = getCurrentXmxValue();
143  char units = '-';
144  Long value = 0L;
145  if (currentXmx.length() > 1) {
146  units = currentXmx.charAt(currentXmx.length() - 1);
147  value = Long.parseLong(currentXmx.substring(0, currentXmx.length() - 1));
148  } else {
149  throw new IOException("No memory setting found in String: " + currentXmx);
150  }
151  //some older .conf files might have the units as megabytes instead of gigabytes
152  switch (units) {
153  case 'g':
154  case 'G':
155  return value;
156  case 'm':
157  case 'M':
158  return value / MEGA_IN_GIGA;
159  default:
160  throw new IOException("Units were not recognized as parsed: " + units);
161  }
162  }
163 
164  /*
165  * The value currently saved in the conf file as the max java heap space
166  * available to this application. Form will be an integer followed by a
167  * character indicating units. Helper method for
168  * getCurrentJvmMaxMemoryInGB()
169  *
170  * @return the saved value for the max java heap space
171  *
172  * @throws IOException if the conf file does not exist in either the user
173  * directory or the install directory
174  */
175  private String getCurrentXmxValue() throws IOException {
176  String[] settings;
177  String currentSetting = "";
178  File userConfFile = getUserFolderConfFile();
179  if (!userConfFile.exists()) {
180  settings = getDefaultsFromFileContents(readConfFile(getInstallFolderConfFile()));
181  } else {
182  settings = getDefaultsFromFileContents(readConfFile(userConfFile));
183  }
184  for (String option : settings) {
185  if (option.startsWith("-J-Xmx")) {
186  currentSetting = option.replace("-J-Xmx", "").trim();
187  }
188  }
189  return currentSetting;
190  }
191 
200  private static File getInstallFolderConfFile() throws IOException {
201  String confFileName = UserPreferences.getAppName() + CONFIG_FILE_EXTENSION;
202  String installFolder = PlatformUtil.getInstallPath();
203  File installFolderEtc = new File(installFolder, ETC_FOLDER_NAME);
204  File installFolderConfigFile = new File(installFolderEtc, confFileName);
205  if (!installFolderConfigFile.exists()) {
206  throw new IOException("Conf file could not be found" + installFolderConfigFile.toString());
207  }
208  return installFolderConfigFile;
209  }
210 
218  private static File getUserFolderConfFile() {
219  String confFileName = UserPreferences.getAppName() + CONFIG_FILE_EXTENSION;
220  File userFolder = PlatformUtil.getUserDirectory();
221  File userEtcFolder = new File(userFolder, ETC_FOLDER_NAME);
222  if (!userEtcFolder.exists()) {
223  userEtcFolder.mkdir();
224  }
225  return new File(userEtcFolder, confFileName);
226  }
227 
236  private void writeEtcConfFile() throws IOException {
237  StringBuilder content = new StringBuilder();
238  List<String> confFile = readConfFile(getInstallFolderConfFile());
239  for (String line : confFile) {
240  if (line.contains("-J-Xmx")) {
241  String[] splitLine = line.split(" ");
242  StringJoiner modifiedLine = new StringJoiner(" ");
243  for (String piece : splitLine) {
244  if (piece.contains("-J-Xmx")) {
245  piece = "-J-Xmx" + memField.getText() + "g";
246  }
247  modifiedLine.add(piece);
248  }
249  content.append(modifiedLine.toString());
250  } else {
251  content.append(line);
252  }
253  content.append("\n");
254  }
255  Files.write(getUserFolderConfFile().toPath(), content.toString().getBytes());
256  }
257 
267  private static List<String> readConfFile(File configFile) {
268  List<String> lines = new ArrayList<>();
269  if (null != configFile) {
270  Path filePath = configFile.toPath();
271  Charset charset = Charset.forName("UTF-8");
272  try {
273  lines = Files.readAllLines(filePath, charset);
274  } catch (IOException e) {
275  logger.log(Level.SEVERE, "Error reading config file contents. {}", configFile.getAbsolutePath());
276  }
277  }
278  return lines;
279  }
280 
292  private static String[] getDefaultsFromFileContents(List<String> list) {
293  Optional<String> defaultSettings = list.stream().filter(line -> line.startsWith("default_options=")).findFirst();
294 
295  if (defaultSettings.isPresent()) {
296  return defaultSettings.get().replace("default_options=", "").replaceAll("\"", "").split(" ");
297  }
298  return new String[]{};
299  }
300 
304  void load() {
305  String path = ModuleSettings.getConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP);
306  boolean useDefault = (path == null || path.isEmpty());
307  defaultLogoRB.setSelected(useDefault);
308  specifyLogoRB.setSelected(!useDefault);
309  agencyLogoPathField.setEnabled(!useDefault);
310  browseLogosButton.setEnabled(!useDefault);
311  tempDirectoryField.setText(UserMachinePreferences.getBaseTempDirectory());
312  logFileCount.setText(String.valueOf(UserPreferences.getLogFileCount()));
313  solrMaxHeapSpinner.setValue(UserPreferences.getMaxSolrVMSize());
314  tempDirectoryField.setText(UserMachinePreferences.getBaseTempDirectory());
315  try {
316  updateAgencyLogo(path);
317  } catch (IOException ex) {
318  logger.log(Level.WARNING, "Error loading image from previously saved agency logo path", ex);
319  }
320  if (memField.isEnabled()) {
321  try {
322  initialMemValue = Long.toString(getCurrentJvmMaxMemoryInGB());
323  } catch (IOException ex) {
324  logger.log(Level.SEVERE, "Can't read current Jvm max memory setting from file", ex);
325  memField.setEnabled(false);
326  }
327  memField.setText(initialMemValue);
328  }
329  setTempDirEnabled();
330  valid(); //ensure the error messages are up to date
331  }
332 
333  private void setTempDirEnabled() {
334  boolean enabled = !Case.isCaseOpen();
335  this.tempDirectoryBrowseButton.setEnabled(enabled);
336  this.tempDirectoryField.setEnabled(enabled);
337  this.tempDirectoryWarningLabel.setVisible(!enabled);
338  }
339 
347  private void updateAgencyLogo(String path) throws IOException {
348  agencyLogoPathField.setText(path);
349  ImageIcon agencyLogoIcon = new ImageIcon();
350  agencyLogoPreview.setText(NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.agencyLogoPreview.text"));
351  if (!agencyLogoPathField.getText().isEmpty()) {
352  File file = new File(agencyLogoPathField.getText());
353  if (file.exists()) {
354  BufferedImage image = ImageIO.read(file); //create it as an image first to support BMP files
355  if (image == null) {
356  throw new IOException("Unable to read file as a BufferedImage for file " + file.toString());
357  }
358  agencyLogoIcon = new ImageIcon(image.getScaledInstance(64, 64, 4));
359  agencyLogoPreview.setText("");
360  }
361  }
362  agencyLogoPreview.setIcon(agencyLogoIcon);
363  agencyLogoPreview.repaint();
364  }
365 
366  @Messages({
367  "AutopsyOptionsPanel_storeTempDir_onError_title=Error Saving Temporary Directory",
368  "# {0} - path",
369  "AutopsyOptionsPanel_storeTempDir_onError_description=There was an error creating the temporary directory on the filesystem at: {0}.",})
370  private void storeTempDir() {
371  String tempDirectoryPath = tempDirectoryField.getText();
372  if (!UserMachinePreferences.getBaseTempDirectory().equals(tempDirectoryPath)) {
373  try {
374  UserMachinePreferences.setBaseTempDirectory(tempDirectoryPath);
375  } catch (UserMachinePreferencesException ex) {
376  logger.log(Level.WARNING, "There was an error creating the temporary directory defined by the user: " + tempDirectoryPath, ex);
377  SwingUtilities.invokeLater(() -> {
378  JOptionPane.showMessageDialog(this,
379  String.format("<html>%s</html>", Bundle.AutopsyOptionsPanel_storeTempDir_onError_description(tempDirectoryPath)),
380  Bundle.AutopsyOptionsPanel_storeTempDir_onError_title(),
381  JOptionPane.ERROR_MESSAGE);
382  });
383  }
384  }
385  }
386 
390  void store() {
391  UserPreferences.setLogFileCount(Integer.parseInt(logFileCount.getText()));
392  storeTempDir();
393 
394  if (!agencyLogoPathField.getText().isEmpty()) {
395  File file = new File(agencyLogoPathField.getText());
396  if (file.exists()) {
397  ModuleSettings.setConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP, agencyLogoPathField.getText());
398  }
399  } else {
400  ModuleSettings.setConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP, "");
401  }
402  UserPreferences.setMaxSolrVMSize((int) solrMaxHeapSpinner.getValue());
403  if (memField.isEnabled()) { //if the field could of been changed we need to try and save it
404  try {
405  writeEtcConfFile();
406  } catch (IOException ex) {
407  logger.log(Level.WARNING, "Unable to save config file to " + PlatformUtil.getUserDirectory() + "\\" + ETC_FOLDER_NAME, ex);
408  }
409  }
410  }
411 
417  boolean valid() {
418  boolean valid = true;
419  if (!isAgencyLogoPathValid()) {
420  valid = false;
421  }
422  if (!isMemFieldValid()) {
423  valid = false;
424  }
425  if (!isLogNumFieldValid()) {
426  valid = false;
427  }
428 
429  return valid;
430  }
431 
438  boolean isAgencyLogoPathValid() {
439  boolean valid = true;
440 
441  if (defaultLogoRB.isSelected()) {
442  agencyLogoPathFieldValidationLabel.setText("");
443  } else {
444  String agencyLogoPath = agencyLogoPathField.getText();
445  if (agencyLogoPath.isEmpty()) {
446  agencyLogoPathFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_agencyLogoPathFieldValidationLabel_pathNotSet_text());
447  valid = false;
448  } else {
449  File file = new File(agencyLogoPathField.getText());
450  if (file.exists() && file.isFile()) {
451  BufferedImage image;
452  try { //ensure the image can be read
453  image = ImageIO.read(file); //create it as an image first to support BMP files
454  if (image == null) {
455  throw new IOException("Unable to read file as a BufferedImage for file " + file.toString());
456  }
457  agencyLogoPathFieldValidationLabel.setText("");
458  } catch (IOException | IndexOutOfBoundsException ignored) {
459  agencyLogoPathFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_agencyLogoPathFieldValidationLabel_invalidImageSpecified_text());
460  valid = false;
461  }
462  } else {
463  agencyLogoPathFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_agencyLogoPathFieldValidationLabel_invalidPath_text());
464  valid = false;
465  }
466  }
467  }
468 
469  return valid;
470  }
471 
477  private boolean isMemFieldValid() {
478  String memText = memField.getText();
479  memFieldValidationLabel.setText("");
480  if (!PlatformUtil.is64BitJVM()) {
481  memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_not64BitInstall_text());
482  //the panel should be valid when it is a 32 bit jvm because the memfield will be disabled.
483  return true;
484  }
485  if (Version.getBuildType() == Version.Type.DEVELOPMENT) {
486  memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_developerMode_text());
487  //the panel should be valid when you are running in developer mode because the memfield will be disabled
488  return true;
489  }
490  if (memText.length() == 0) {
491  memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_noValueEntered_text());
492  return false;
493  }
494  if (memText.replaceAll("[^\\d]", "").length() != memText.length()) {
495  memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_invalidCharacters_text());
496  return false;
497  }
498  int parsedInt = Integer.parseInt(memText);
499  if (parsedInt < MIN_MEMORY_IN_GB) {
500  memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_underMinMemory_text(MIN_MEMORY_IN_GB));
501  return false;
502  }
503  if (parsedInt > getSystemMemoryInGB()) {
504  memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_overMaxMemory_text(getSystemMemoryInGB()));
505  return false;
506  }
507  return true;
508  }
509 
515  private boolean isLogNumFieldValid() {
516  String count = logFileCount.getText();
517  logNumAlert.setText("");
518  try {
519  int count_num = Integer.parseInt(count);
520  if (count_num < 1) {
521  logNumAlert.setText(Bundle.AutopsyOptionsPanel_logNumAlert_invalidInput_text());
522  return false;
523  }
524  } catch (NumberFormatException e) {
525  logNumAlert.setText(Bundle.AutopsyOptionsPanel_logNumAlert_invalidInput_text());
526  return false;
527  }
528  return true;
529  }
530 
535  private class TextFieldListener implements DocumentListener {
536 
537  @Override
538  public void insertUpdate(DocumentEvent e) {
539  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
540  }
541 
542  @Override
543  public void removeUpdate(DocumentEvent e) {
544  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
545  }
546 
547  @Override
548  public void changedUpdate(DocumentEvent e) {
549  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
550  }
551  }
552 
558  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
559  private void initComponents() {
560 
561  fileSelectionButtonGroup = new javax.swing.ButtonGroup();
562  displayTimesButtonGroup = new javax.swing.ButtonGroup();
563  logoSourceButtonGroup = new javax.swing.ButtonGroup();
564  jScrollPane1 = new javax.swing.JScrollPane();
565  jPanel1 = new javax.swing.JPanel();
566  logoPanel = new javax.swing.JPanel();
567  agencyLogoPathField = new javax.swing.JTextField();
568  browseLogosButton = new javax.swing.JButton();
569  agencyLogoPreview = new javax.swing.JLabel();
570  defaultLogoRB = new javax.swing.JRadioButton();
571  specifyLogoRB = new javax.swing.JRadioButton();
572  agencyLogoPathFieldValidationLabel = new javax.swing.JLabel();
573  runtimePanel = new javax.swing.JPanel();
574  maxMemoryLabel = new javax.swing.JLabel();
575  maxMemoryUnitsLabel = new javax.swing.JLabel();
576  totalMemoryLabel = new javax.swing.JLabel();
577  systemMemoryTotal = new javax.swing.JLabel();
578  restartNecessaryWarning = new javax.swing.JLabel();
579  memField = new javax.swing.JTextField();
580  memFieldValidationLabel = new javax.swing.JLabel();
581  maxMemoryUnitsLabel1 = new javax.swing.JLabel();
582  maxLogFileCount = new javax.swing.JLabel();
583  logFileCount = new javax.swing.JTextField();
584  logNumAlert = new javax.swing.JTextField();
585  maxSolrMemoryLabel = new javax.swing.JLabel();
586  maxMemoryUnitsLabel2 = new javax.swing.JLabel();
587  solrMaxHeapSpinner = new javax.swing.JSpinner();
588  solrJVMHeapWarning = new javax.swing.JLabel();
589  tempDirectoryPanel = new javax.swing.JPanel();
590  tempDirectoryField = new javax.swing.JTextField();
591  tempDirectoryBrowseButton = new javax.swing.JButton();
592  tempDirectoryWarningLabel = new javax.swing.JLabel();
593 
594  setPreferredSize(null);
595 
596  jScrollPane1.setBorder(null);
597  jScrollPane1.setPreferredSize(null);
598 
599  jPanel1.setMinimumSize(new java.awt.Dimension(648, 382));
600  jPanel1.setPreferredSize(null);
601 
602  logoPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.logoPanel.border.title"))); // NOI18N
603 
604  agencyLogoPathField.setText(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.agencyLogoPathField.text")); // NOI18N
605 
606  org.openide.awt.Mnemonics.setLocalizedText(browseLogosButton, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.browseLogosButton.text")); // NOI18N
607  browseLogosButton.addActionListener(new java.awt.event.ActionListener() {
608  public void actionPerformed(java.awt.event.ActionEvent evt) {
609  browseLogosButtonActionPerformed(evt);
610  }
611  });
612 
613  agencyLogoPreview.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
614  org.openide.awt.Mnemonics.setLocalizedText(agencyLogoPreview, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.agencyLogoPreview.text")); // NOI18N
615  agencyLogoPreview.setBorder(javax.swing.BorderFactory.createEtchedBorder());
616  agencyLogoPreview.setMaximumSize(new java.awt.Dimension(64, 64));
617  agencyLogoPreview.setMinimumSize(new java.awt.Dimension(64, 64));
618  agencyLogoPreview.setPreferredSize(new java.awt.Dimension(64, 64));
619 
620  logoSourceButtonGroup.add(defaultLogoRB);
621  org.openide.awt.Mnemonics.setLocalizedText(defaultLogoRB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.defaultLogoRB.text")); // NOI18N
622  defaultLogoRB.addActionListener(new java.awt.event.ActionListener() {
623  public void actionPerformed(java.awt.event.ActionEvent evt) {
624  defaultLogoRBActionPerformed(evt);
625  }
626  });
627 
628  logoSourceButtonGroup.add(specifyLogoRB);
629  org.openide.awt.Mnemonics.setLocalizedText(specifyLogoRB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.specifyLogoRB.text")); // NOI18N
630  specifyLogoRB.addActionListener(new java.awt.event.ActionListener() {
631  public void actionPerformed(java.awt.event.ActionEvent evt) {
632  specifyLogoRBActionPerformed(evt);
633  }
634  });
635 
636  agencyLogoPathFieldValidationLabel.setForeground(new java.awt.Color(255, 0, 0));
637  org.openide.awt.Mnemonics.setLocalizedText(agencyLogoPathFieldValidationLabel, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.agencyLogoPathFieldValidationLabel.text")); // NOI18N
638 
639  javax.swing.GroupLayout logoPanelLayout = new javax.swing.GroupLayout(logoPanel);
640  logoPanel.setLayout(logoPanelLayout);
641  logoPanelLayout.setHorizontalGroup(
642  logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
643  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logoPanelLayout.createSequentialGroup()
644  .addContainerGap()
645  .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
646  .addComponent(specifyLogoRB)
647  .addComponent(defaultLogoRB))
648  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
649  .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
650  .addComponent(agencyLogoPathFieldValidationLabel)
651  .addGroup(logoPanelLayout.createSequentialGroup()
652  .addComponent(agencyLogoPathField, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
653  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
654  .addComponent(browseLogosButton)))
655  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
656  .addComponent(agencyLogoPreview, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
657  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
658  );
659  logoPanelLayout.setVerticalGroup(
660  logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
661  .addGroup(logoPanelLayout.createSequentialGroup()
662  .addGap(6, 6, 6)
663  .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
664  .addComponent(defaultLogoRB)
665  .addComponent(agencyLogoPathFieldValidationLabel))
666  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
667  .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
668  .addComponent(specifyLogoRB)
669  .addComponent(agencyLogoPathField)
670  .addComponent(browseLogosButton)))
671  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logoPanelLayout.createSequentialGroup()
672  .addComponent(agencyLogoPreview, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
673  .addGap(0, 12, Short.MAX_VALUE))
674  );
675 
676  runtimePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.runtimePanel.border.title"))); // NOI18N
677 
678  org.openide.awt.Mnemonics.setLocalizedText(maxMemoryLabel, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.maxMemoryLabel.text")); // NOI18N
679 
680  org.openide.awt.Mnemonics.setLocalizedText(maxMemoryUnitsLabel, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.maxMemoryUnitsLabel.text")); // NOI18N
681 
682  org.openide.awt.Mnemonics.setLocalizedText(totalMemoryLabel, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.totalMemoryLabel.text")); // NOI18N
683 
684  systemMemoryTotal.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
685 
686  restartNecessaryWarning.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/warning16.png"))); // NOI18N
687  org.openide.awt.Mnemonics.setLocalizedText(restartNecessaryWarning, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.restartNecessaryWarning.text")); // NOI18N
688 
689  memField.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
690  memField.addKeyListener(new java.awt.event.KeyAdapter() {
691  public void keyReleased(java.awt.event.KeyEvent evt) {
692  memFieldKeyReleased(evt);
693  }
694  });
695 
696  memFieldValidationLabel.setForeground(new java.awt.Color(255, 0, 0));
697 
698  org.openide.awt.Mnemonics.setLocalizedText(maxMemoryUnitsLabel1, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.maxMemoryUnitsLabel.text")); // NOI18N
699 
700  org.openide.awt.Mnemonics.setLocalizedText(maxLogFileCount, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.maxLogFileCount.text")); // NOI18N
701 
702  logFileCount.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
703  logFileCount.addKeyListener(new java.awt.event.KeyAdapter() {
704  public void keyReleased(java.awt.event.KeyEvent evt) {
705  logFileCountKeyReleased(evt);
706  }
707  });
708 
709  logNumAlert.setEditable(false);
710  logNumAlert.setForeground(new java.awt.Color(255, 0, 0));
711  logNumAlert.setText(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.logNumAlert.text")); // NOI18N
712  logNumAlert.setBorder(null);
713 
714  org.openide.awt.Mnemonics.setLocalizedText(maxSolrMemoryLabel, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.maxSolrMemoryLabel.text")); // NOI18N
715 
716  org.openide.awt.Mnemonics.setLocalizedText(maxMemoryUnitsLabel2, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.maxMemoryUnitsLabel2.text")); // NOI18N
717 
718  solrMaxHeapSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
719  public void stateChanged(javax.swing.event.ChangeEvent evt) {
720  solrMaxHeapSpinnerStateChanged(evt);
721  }
722  });
723 
724  org.openide.awt.Mnemonics.setLocalizedText(solrJVMHeapWarning, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.solrJVMHeapWarning.text")); // NOI18N
725 
726  javax.swing.GroupLayout runtimePanelLayout = new javax.swing.GroupLayout(runtimePanel);
727  runtimePanel.setLayout(runtimePanelLayout);
728  runtimePanelLayout.setHorizontalGroup(
729  runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
730  .addGroup(runtimePanelLayout.createSequentialGroup()
731  .addContainerGap()
732  .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
733  .addGroup(runtimePanelLayout.createSequentialGroup()
734  .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
735  .addComponent(totalMemoryLabel)
736  .addComponent(maxSolrMemoryLabel)
737  .addComponent(maxMemoryLabel)
738  .addComponent(maxLogFileCount))
739  .addGap(12, 12, 12)
740  .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
741  .addComponent(logFileCount, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
742  .addComponent(solrMaxHeapSpinner, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
743  .addComponent(memField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
744  .addComponent(systemMemoryTotal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
745  .addGap(18, 18, 18)
746  .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
747  .addComponent(maxMemoryUnitsLabel1)
748  .addComponent(maxMemoryUnitsLabel)
749  .addComponent(maxMemoryUnitsLabel2))
750  .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
751  .addGroup(runtimePanelLayout.createSequentialGroup()
752  .addGap(23, 23, 23)
753  .addComponent(memFieldValidationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 478, javax.swing.GroupLayout.PREFERRED_SIZE)
754  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
755  .addGroup(runtimePanelLayout.createSequentialGroup()
756  .addGap(18, 18, 18)
757  .addComponent(solrJVMHeapWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 331, javax.swing.GroupLayout.PREFERRED_SIZE)
758  .addGap(44, 44, 44)
759  .addComponent(logNumAlert)
760  .addContainerGap())))
761  .addComponent(restartNecessaryWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 615, javax.swing.GroupLayout.PREFERRED_SIZE)))
762  );
763 
764  runtimePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {maxLogFileCount, maxMemoryLabel, totalMemoryLabel});
765 
766  runtimePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {logFileCount, memField});
767 
768  runtimePanelLayout.setVerticalGroup(
769  runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
770  .addGroup(runtimePanelLayout.createSequentialGroup()
771  .addContainerGap()
772  .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
773  .addComponent(totalMemoryLabel)
774  .addComponent(maxMemoryUnitsLabel1)
775  .addComponent(systemMemoryTotal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
776  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
777  .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
778  .addComponent(memFieldValidationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
779  .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
780  .addComponent(maxMemoryLabel)
781  .addComponent(memField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
782  .addComponent(maxMemoryUnitsLabel)))
783  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
784  .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
785  .addComponent(logNumAlert, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
786  .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
787  .addComponent(maxSolrMemoryLabel)
788  .addComponent(maxMemoryUnitsLabel2)
789  .addComponent(solrMaxHeapSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
790  .addComponent(solrJVMHeapWarning)))
791  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
792  .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
793  .addComponent(maxLogFileCount)
794  .addComponent(logFileCount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
795  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
796  .addComponent(restartNecessaryWarning)
797  .addContainerGap())
798  );
799 
800  tempDirectoryPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.tempDirectoryPanel.border.title"))); // NOI18N
801  tempDirectoryPanel.setName(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.tempDirectoryPanel.name")); // NOI18N
802 
803  tempDirectoryField.setText(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.tempDirectoryField.text")); // NOI18N
804 
805  org.openide.awt.Mnemonics.setLocalizedText(tempDirectoryBrowseButton, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.tempDirectoryBrowseButton.text")); // NOI18N
806  tempDirectoryBrowseButton.addActionListener(new java.awt.event.ActionListener() {
807  public void actionPerformed(java.awt.event.ActionEvent evt) {
808  tempDirectoryBrowseButtonActionPerformed(evt);
809  }
810  });
811 
812  tempDirectoryWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/warning16.png"))); // NOI18N
813  org.openide.awt.Mnemonics.setLocalizedText(tempDirectoryWarningLabel, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.tempDirectoryWarningLabel.text")); // NOI18N
814 
815  javax.swing.GroupLayout tempDirectoryPanelLayout = new javax.swing.GroupLayout(tempDirectoryPanel);
816  tempDirectoryPanel.setLayout(tempDirectoryPanelLayout);
817  tempDirectoryPanelLayout.setHorizontalGroup(
818  tempDirectoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
819  .addGroup(tempDirectoryPanelLayout.createSequentialGroup()
820  .addContainerGap()
821  .addGroup(tempDirectoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
822  .addComponent(tempDirectoryWarningLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 615, javax.swing.GroupLayout.PREFERRED_SIZE)
823  .addGroup(tempDirectoryPanelLayout.createSequentialGroup()
824  .addComponent(tempDirectoryField, javax.swing.GroupLayout.PREFERRED_SIZE, 367, javax.swing.GroupLayout.PREFERRED_SIZE)
825  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
826  .addComponent(tempDirectoryBrowseButton)))
827  .addGap(0, 0, Short.MAX_VALUE))
828  );
829  tempDirectoryPanelLayout.setVerticalGroup(
830  tempDirectoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
831  .addGroup(tempDirectoryPanelLayout.createSequentialGroup()
832  .addContainerGap()
833  .addGroup(tempDirectoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
834  .addComponent(tempDirectoryField)
835  .addComponent(tempDirectoryBrowseButton))
836  .addGap(18, 18, 18)
837  .addComponent(tempDirectoryWarningLabel)
838  .addContainerGap())
839  );
840 
841  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
842  jPanel1.setLayout(jPanel1Layout);
843  jPanel1Layout.setHorizontalGroup(
844  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
845  .addGroup(jPanel1Layout.createSequentialGroup()
846  .addContainerGap()
847  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
848  .addComponent(logoPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
849  .addComponent(tempDirectoryPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
850  .addComponent(runtimePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 631, javax.swing.GroupLayout.PREFERRED_SIZE)))
851  );
852  jPanel1Layout.setVerticalGroup(
853  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
854  .addGroup(jPanel1Layout.createSequentialGroup()
855  .addContainerGap()
856  .addComponent(runtimePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
857  .addGap(3, 3, 3)
858  .addComponent(tempDirectoryPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
859  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
860  .addComponent(logoPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
861  .addContainerGap())
862  );
863 
864  tempDirectoryPanel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.tempDirectoryPanel.AccessibleContext.accessibleName")); // NOI18N
865 
866  jScrollPane1.setViewportView(jPanel1);
867 
868  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
869  this.setLayout(layout);
870  layout.setHorizontalGroup(
871  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
872  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 648, Short.MAX_VALUE)
873  );
874  layout.setVerticalGroup(
875  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
876  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
877  );
878  }// </editor-fold>//GEN-END:initComponents
879 
880  @Messages({
881  "AutopsyOptionsPanel_tempDirectoryBrowseButtonActionPerformed_onInvalidPath_title=Path cannot be used",
882  "# {0} - path",
883  "AutopsyOptionsPanel_tempDirectoryBrowseButtonActionPerformed_onInvalidPath_description=Unable to create temporary directory within specified path: {0}",})
884  private void tempDirectoryBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tempDirectoryBrowseButtonActionPerformed
885  int returnState = tempDirChooser.showOpenDialog(this);
886  if (returnState == JFileChooser.APPROVE_OPTION) {
887  String specifiedPath = tempDirChooser.getSelectedFile().getPath();
888  try {
889  File f = new File(specifiedPath);
890  if (!f.exists() && !f.mkdirs()) {
891  throw new InvalidPathException(specifiedPath, "Unable to create parent directories leading to " + specifiedPath);
892  }
893  tempDirectoryField.setText(specifiedPath);
894  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
895  } catch (InvalidPathException ex) {
896  logger.log(Level.WARNING, "Unable to create temporary directory in " + specifiedPath, ex);
897  JOptionPane.showMessageDialog(this,
898  Bundle.AutopsyOptionsPanel_tempDirectoryBrowseButtonActionPerformed_onInvalidPath_description(specifiedPath),
899  Bundle.AutopsyOptionsPanel_tempDirectoryBrowseButtonActionPerformed_onInvalidPath_title(),
900  JOptionPane.ERROR_MESSAGE);
901  }
902  }
903  }//GEN-LAST:event_tempDirectoryBrowseButtonActionPerformed
904 
905  private void specifyLogoRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_specifyLogoRBActionPerformed
906  agencyLogoPathField.setEnabled(true);
907  browseLogosButton.setEnabled(true);
908  try {
909  if (agencyLogoPathField.getText().isEmpty()) {
910  String path = ModuleSettings.getConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP);
911  if (path != null && !path.isEmpty()) {
912  updateAgencyLogo(path);
913  }
914  }
915  } catch (IOException ex) {
916  logger.log(Level.WARNING, "Error loading image from previously saved agency logo path.", ex);
917  }
918  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
919  }//GEN-LAST:event_specifyLogoRBActionPerformed
920 
921  private void defaultLogoRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_defaultLogoRBActionPerformed
922  agencyLogoPathField.setEnabled(false);
923  browseLogosButton.setEnabled(false);
924  try {
925  updateAgencyLogo("");
926  } catch (IOException ex) {
927  // This should never happen since we're not reading from a file.
928  logger.log(Level.SEVERE, "Unexpected error occurred while updating the agency logo.", ex);
929  }
930  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
931  }//GEN-LAST:event_defaultLogoRBActionPerformed
932 
933  private void browseLogosButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLogosButtonActionPerformed
934  String oldLogoPath = agencyLogoPathField.getText();
935  int returnState = logoFileChooser.showOpenDialog(this);
936  if (returnState == JFileChooser.APPROVE_OPTION) {
937  String path = logoFileChooser.getSelectedFile().getPath();
938  try {
939  updateAgencyLogo(path);
940  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
941  } catch (IOException | IndexOutOfBoundsException ex) {
942  JOptionPane.showMessageDialog(this,
943  NbBundle.getMessage(this.getClass(),
944  "AutopsyOptionsPanel.invalidImageFile.msg"),
945  NbBundle.getMessage(this.getClass(), "AutopsyOptionsPanel.invalidImageFile.title"),
946  JOptionPane.ERROR_MESSAGE);
947  try {
948  updateAgencyLogo(oldLogoPath); //restore previous setting if new one is invalid
949  } catch (IOException ex1) {
950  logger.log(Level.WARNING, "Error loading image from previously saved agency logo path", ex1);
951  }
952  }
953  }
954  }//GEN-LAST:event_browseLogosButtonActionPerformed
955 
956  private void solrMaxHeapSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_solrMaxHeapSpinnerStateChanged
957  int value = (int) solrMaxHeapSpinner.getValue();
958  if (value == UserPreferences.getMaxSolrVMSize()) {
959  // if the value hasn't changed there's nothing to do.
960  return;
961  }
962  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
963  }//GEN-LAST:event_solrMaxHeapSpinnerStateChanged
964 
965  private void logFileCountKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_logFileCountKeyReleased
966  String count = logFileCount.getText();
967  if (count.equals(String.valueOf(UserPreferences.getDefaultLogFileCount()))) {
968  //if it is still the default value don't fire change
969  return;
970  }
971  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
972  }//GEN-LAST:event_logFileCountKeyReleased
973 
974  private void memFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_memFieldKeyReleased
975  String memText = memField.getText();
976  if (memText.equals(initialMemValue)) {
977  //if it is still the initial value don't fire change
978  return;
979  }
980  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
981  }//GEN-LAST:event_memFieldKeyReleased
982 
983  // Variables declaration - do not modify//GEN-BEGIN:variables
984  private javax.swing.JTextField agencyLogoPathField;
985  private javax.swing.JLabel agencyLogoPathFieldValidationLabel;
986  private javax.swing.JLabel agencyLogoPreview;
987  private javax.swing.JButton browseLogosButton;
988  private javax.swing.JRadioButton defaultLogoRB;
989  private javax.swing.ButtonGroup displayTimesButtonGroup;
990  private javax.swing.ButtonGroup fileSelectionButtonGroup;
991  private javax.swing.JPanel jPanel1;
992  private javax.swing.JScrollPane jScrollPane1;
993  private javax.swing.JTextField logFileCount;
994  private javax.swing.JTextField logNumAlert;
995  private javax.swing.JPanel logoPanel;
996  private javax.swing.ButtonGroup logoSourceButtonGroup;
997  private javax.swing.JLabel maxLogFileCount;
998  private javax.swing.JLabel maxMemoryLabel;
999  private javax.swing.JLabel maxMemoryUnitsLabel;
1000  private javax.swing.JLabel maxMemoryUnitsLabel1;
1001  private javax.swing.JLabel maxMemoryUnitsLabel2;
1002  private javax.swing.JLabel maxSolrMemoryLabel;
1003  private javax.swing.JTextField memField;
1004  private javax.swing.JLabel memFieldValidationLabel;
1005  private javax.swing.JLabel restartNecessaryWarning;
1006  private javax.swing.JPanel runtimePanel;
1007  private javax.swing.JLabel solrJVMHeapWarning;
1008  private javax.swing.JSpinner solrMaxHeapSpinner;
1009  private javax.swing.JRadioButton specifyLogoRB;
1010  private javax.swing.JLabel systemMemoryTotal;
1011  private javax.swing.JButton tempDirectoryBrowseButton;
1012  private javax.swing.JTextField tempDirectoryField;
1013  private javax.swing.JPanel tempDirectoryPanel;
1014  private javax.swing.JLabel tempDirectoryWarningLabel;
1015  private javax.swing.JLabel totalMemoryLabel;
1016  // End of variables declaration//GEN-END:variables
1017 
1018 }

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