19 package org.sleuthkit.autopsy.corecomponents;
21 import java.awt.image.BufferedImage;
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;
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."
74 @SuppressWarnings(
"PMD.SingularField")
75 final class AutopsyOptionsPanel extends javax.swing.JPanel {
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;
84 private static final int MEGA_IN_GIGA = 1024;
85 private static final int MIN_MEMORY_IN_GB = 2;
86 private static final Logger logger = Logger.getLogger(AutopsyOptionsPanel.class.getName());
87 private String initialMemValue = Long.toString(Runtime.getRuntime().maxMemory() / ONE_BILLION);
92 AutopsyOptionsPanel() {
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));
100 tempDirChooser =
new JFileChooser();
101 tempDirChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
102 tempDirChooser.setMultiSelectionEnabled(
false);
104 if (!PlatformUtil.is64BitJVM() || Version.getBuildType() == Version.Type.DEVELOPMENT) {
109 memField.setEnabled(
false);
110 solrMaxHeapSpinner.setEnabled(
false);
112 systemMemoryTotal.setText(Long.toString(getSystemMemoryInGB()));
115 solrMaxHeapSpinner.setModel(
new javax.swing.SpinnerNumberModel(UserPreferences.getMaxSolrVMSize(),
116 512, ((int) getSystemMemoryInGB()) * MEGA_IN_GIGA, 512));
118 textFieldListener =
new TextFieldListener();
119 agencyLogoPathField.getDocument().addDocumentListener(textFieldListener);
120 tempDirectoryField.getDocument().addDocumentListener(textFieldListener);
121 logFileCount.setText(String.valueOf(UserPreferences.getLogFileCount()));
130 private long getSystemMemoryInGB() {
131 long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory
132 .getOperatingSystemMXBean()).getTotalPhysicalMemorySize();
133 return memorySize / ONE_BILLION;
141 private long getCurrentJvmMaxMemoryInGB() throws IOException {
142 String currentXmx = getCurrentXmxValue();
145 if (currentXmx.length() > 1) {
146 units = currentXmx.charAt(currentXmx.length() - 1);
147 value = Long.parseLong(currentXmx.substring(0, currentXmx.length() - 1));
149 throw new IOException(
"No memory setting found in String: " + currentXmx);
158 return value / MEGA_IN_GIGA;
160 throw new IOException(
"Units were not recognized as parsed: " + units);
175 private String getCurrentXmxValue() throws IOException {
177 String currentSetting =
"";
178 File userConfFile = getUserFolderConfFile();
179 if (!userConfFile.exists()) {
180 settings = getDefaultsFromFileContents(readConfFile(getInstallFolderConfFile()));
182 settings = getDefaultsFromFileContents(readConfFile(userConfFile));
184 for (String option : settings) {
185 if (option.startsWith(
"-J-Xmx")) {
186 currentSetting = option.replace(
"-J-Xmx",
"").trim();
189 return currentSetting;
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());
208 return installFolderConfigFile;
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();
225 return new File(userEtcFolder, confFileName);
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";
247 modifiedLine.add(piece);
249 content.append(modifiedLine.toString());
251 content.append(line);
253 content.append(
"\n");
255 Files.write(getUserFolderConfFile().toPath(), content.toString().getBytes());
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");
273 lines = Files.readAllLines(filePath, charset);
274 }
catch (IOException e) {
275 logger.log(Level.SEVERE,
"Error reading config file contents. {}", configFile.getAbsolutePath());
292 private static String[] getDefaultsFromFileContents(List<String> list) {
293 Optional<String> defaultSettings = list.stream().filter(line -> line.startsWith(
"default_options=")).findFirst();
295 if (defaultSettings.isPresent()) {
296 return defaultSettings.get().replace(
"default_options=",
"").replaceAll(
"\"",
"").split(
" ");
298 return new String[]{};
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());
316 updateAgencyLogo(path);
317 }
catch (IOException ex) {
318 logger.log(Level.WARNING,
"Error loading image from previously saved agency logo path", ex);
320 if (memField.isEnabled()) {
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);
327 memField.setText(initialMemValue);
333 private void setTempDirEnabled() {
334 boolean enabled = !Case.isCaseOpen();
335 this.tempDirectoryBrowseButton.setEnabled(enabled);
336 this.tempDirectoryField.setEnabled(enabled);
337 this.tempDirectoryWarningLabel.setVisible(!enabled);
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());
354 BufferedImage image = ImageIO.read(file);
356 throw new IOException(
"Unable to read file as a BufferedImage for file " + file.toString());
358 agencyLogoIcon =
new ImageIcon(image.getScaledInstance(64, 64, 4));
359 agencyLogoPreview.setText(
"");
362 agencyLogoPreview.setIcon(agencyLogoIcon);
363 agencyLogoPreview.repaint();
367 "AutopsyOptionsPanel_storeTempDir_onError_title=Error Saving Temporary Directory",
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)) {
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);
391 UserPreferences.setLogFileCount(Integer.parseInt(logFileCount.getText()));
394 if (!agencyLogoPathField.getText().isEmpty()) {
395 File file =
new File(agencyLogoPathField.getText());
397 ModuleSettings.setConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP, agencyLogoPathField.getText());
400 ModuleSettings.setConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP,
"");
402 UserPreferences.setMaxSolrVMSize((
int) solrMaxHeapSpinner.getValue());
403 if (memField.isEnabled()) {
406 }
catch (IOException ex) {
407 logger.log(Level.WARNING,
"Unable to save config file to " + PlatformUtil.getUserDirectory() +
"\\" + ETC_FOLDER_NAME, ex);
418 boolean valid =
true;
419 if (!isAgencyLogoPathValid()) {
422 if (!isMemFieldValid()) {
425 if (!isLogNumFieldValid()) {
438 boolean isAgencyLogoPathValid() {
439 boolean valid =
true;
441 if (defaultLogoRB.isSelected()) {
442 agencyLogoPathFieldValidationLabel.setText(
"");
444 String agencyLogoPath = agencyLogoPathField.getText();
445 if (agencyLogoPath.isEmpty()) {
446 agencyLogoPathFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_agencyLogoPathFieldValidationLabel_pathNotSet_text());
449 File file =
new File(agencyLogoPathField.getText());
450 if (file.exists() && file.isFile()) {
453 image = ImageIO.read(file);
455 throw new IOException(
"Unable to read file as a BufferedImage for file " + file.toString());
457 agencyLogoPathFieldValidationLabel.setText(
"");
458 }
catch (IOException | IndexOutOfBoundsException ignored) {
459 agencyLogoPathFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_agencyLogoPathFieldValidationLabel_invalidImageSpecified_text());
463 agencyLogoPathFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_agencyLogoPathFieldValidationLabel_invalidPath_text());
477 private boolean isMemFieldValid() {
478 String memText = memField.getText();
479 memFieldValidationLabel.setText(
"");
480 if (!PlatformUtil.is64BitJVM()) {
481 memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_not64BitInstall_text());
485 if (Version.getBuildType() == Version.Type.DEVELOPMENT) {
486 memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_developerMode_text());
490 if (memText.length() == 0) {
491 memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_noValueEntered_text());
494 if (memText.replaceAll(
"[^\\d]",
"").length() != memText.length()) {
495 memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_invalidCharacters_text());
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));
503 if (parsedInt > getSystemMemoryInGB()) {
504 memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_overMaxMemory_text(getSystemMemoryInGB()));
515 private boolean isLogNumFieldValid() {
516 String count = logFileCount.getText();
517 logNumAlert.setText(
"");
519 int count_num = Integer.parseInt(count);
521 logNumAlert.setText(Bundle.AutopsyOptionsPanel_logNumAlert_invalidInput_text());
524 }
catch (NumberFormatException e) {
525 logNumAlert.setText(Bundle.AutopsyOptionsPanel_logNumAlert_invalidInput_text());
539 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
544 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
549 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
559 private void initComponents() {
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();
594 setPreferredSize(null);
596 jScrollPane1.setBorder(null);
597 jScrollPane1.setPreferredSize(null);
599 jPanel1.setMinimumSize(
new java.awt.Dimension(648, 382));
600 jPanel1.setPreferredSize(null);
602 logoPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.logoPanel.border.title")));
604 agencyLogoPathField.setText(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.agencyLogoPathField.text"));
606 org.openide.awt.Mnemonics.setLocalizedText(browseLogosButton,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.browseLogosButton.text"));
607 browseLogosButton.addActionListener(
new java.awt.event.ActionListener() {
608 public void actionPerformed(java.awt.event.ActionEvent evt) {
609 browseLogosButtonActionPerformed(evt);
613 agencyLogoPreview.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
614 org.openide.awt.Mnemonics.setLocalizedText(agencyLogoPreview,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.agencyLogoPreview.text"));
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));
620 logoSourceButtonGroup.add(defaultLogoRB);
621 org.openide.awt.Mnemonics.setLocalizedText(defaultLogoRB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.defaultLogoRB.text"));
622 defaultLogoRB.addActionListener(
new java.awt.event.ActionListener() {
623 public void actionPerformed(java.awt.event.ActionEvent evt) {
624 defaultLogoRBActionPerformed(evt);
628 logoSourceButtonGroup.add(specifyLogoRB);
629 org.openide.awt.Mnemonics.setLocalizedText(specifyLogoRB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.specifyLogoRB.text"));
630 specifyLogoRB.addActionListener(
new java.awt.event.ActionListener() {
631 public void actionPerformed(java.awt.event.ActionEvent evt) {
632 specifyLogoRBActionPerformed(evt);
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"));
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()
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))
659 logoPanelLayout.setVerticalGroup(
660 logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
661 .addGroup(logoPanelLayout.createSequentialGroup()
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))
676 runtimePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.runtimePanel.border.title")));
678 org.openide.awt.Mnemonics.setLocalizedText(maxMemoryLabel,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.maxMemoryLabel.text"));
680 org.openide.awt.Mnemonics.setLocalizedText(maxMemoryUnitsLabel,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.maxMemoryUnitsLabel.text"));
682 org.openide.awt.Mnemonics.setLocalizedText(totalMemoryLabel,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.totalMemoryLabel.text"));
684 systemMemoryTotal.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
686 restartNecessaryWarning.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/warning16.png")));
687 org.openide.awt.Mnemonics.setLocalizedText(restartNecessaryWarning,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.restartNecessaryWarning.text"));
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);
696 memFieldValidationLabel.setForeground(
new java.awt.Color(255, 0, 0));
698 org.openide.awt.Mnemonics.setLocalizedText(maxMemoryUnitsLabel1,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.maxMemoryUnitsLabel.text"));
700 org.openide.awt.Mnemonics.setLocalizedText(maxLogFileCount,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.maxLogFileCount.text"));
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);
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"));
712 logNumAlert.setBorder(null);
714 org.openide.awt.Mnemonics.setLocalizedText(maxSolrMemoryLabel,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.maxSolrMemoryLabel.text"));
716 org.openide.awt.Mnemonics.setLocalizedText(maxMemoryUnitsLabel2,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.maxMemoryUnitsLabel2.text"));
718 solrMaxHeapSpinner.addChangeListener(
new javax.swing.event.ChangeListener() {
719 public void stateChanged(javax.swing.event.ChangeEvent evt) {
720 solrMaxHeapSpinnerStateChanged(evt);
724 org.openide.awt.Mnemonics.setLocalizedText(solrJVMHeapWarning,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.solrJVMHeapWarning.text"));
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()
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))
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))
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()
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()
757 .addComponent(solrJVMHeapWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 331, javax.swing.GroupLayout.PREFERRED_SIZE)
759 .addComponent(logNumAlert)
760 .addContainerGap())))
761 .addComponent(restartNecessaryWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 615, javax.swing.GroupLayout.PREFERRED_SIZE)))
764 runtimePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {maxLogFileCount, maxMemoryLabel, totalMemoryLabel});
766 runtimePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {logFileCount, memField});
768 runtimePanelLayout.setVerticalGroup(
769 runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
770 .addGroup(runtimePanelLayout.createSequentialGroup()
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)
800 tempDirectoryPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.tempDirectoryPanel.border.title")));
801 tempDirectoryPanel.setName(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.tempDirectoryPanel.name"));
803 tempDirectoryField.setText(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.tempDirectoryField.text"));
805 org.openide.awt.Mnemonics.setLocalizedText(tempDirectoryBrowseButton,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.tempDirectoryBrowseButton.text"));
806 tempDirectoryBrowseButton.addActionListener(
new java.awt.event.ActionListener() {
807 public void actionPerformed(java.awt.event.ActionEvent evt) {
808 tempDirectoryBrowseButtonActionPerformed(evt);
812 tempDirectoryWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/warning16.png")));
813 org.openide.awt.Mnemonics.setLocalizedText(tempDirectoryWarningLabel,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.tempDirectoryWarningLabel.text"));
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()
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))
829 tempDirectoryPanelLayout.setVerticalGroup(
830 tempDirectoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
831 .addGroup(tempDirectoryPanelLayout.createSequentialGroup()
833 .addGroup(tempDirectoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
834 .addComponent(tempDirectoryField)
835 .addComponent(tempDirectoryBrowseButton))
837 .addComponent(tempDirectoryWarningLabel)
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()
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)))
852 jPanel1Layout.setVerticalGroup(
853 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
854 .addGroup(jPanel1Layout.createSequentialGroup()
856 .addComponent(runtimePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
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)
864 tempDirectoryPanel.getAccessibleContext().setAccessibleName(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.tempDirectoryPanel.AccessibleContext.accessibleName"));
866 jScrollPane1.setViewportView(jPanel1);
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)
874 layout.setVerticalGroup(
875 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
876 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
881 "AutopsyOptionsPanel_tempDirectoryBrowseButtonActionPerformed_onInvalidPath_title=Path cannot be used",
883 "AutopsyOptionsPanel_tempDirectoryBrowseButtonActionPerformed_onInvalidPath_description=Unable to create temporary directory within specified path: {0}",})
884 private void tempDirectoryBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {
885 int returnState = tempDirChooser.showOpenDialog(
this);
886 if (returnState == JFileChooser.APPROVE_OPTION) {
887 String specifiedPath = tempDirChooser.getSelectedFile().getPath();
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);
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);
905 private void specifyLogoRBActionPerformed(java.awt.event.ActionEvent evt) {
906 agencyLogoPathField.setEnabled(
true);
907 browseLogosButton.setEnabled(
true);
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);
915 }
catch (IOException ex) {
916 logger.log(Level.WARNING,
"Error loading image from previously saved agency logo path.", ex);
918 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
921 private void defaultLogoRBActionPerformed(java.awt.event.ActionEvent evt) {
922 agencyLogoPathField.setEnabled(
false);
923 browseLogosButton.setEnabled(
false);
925 updateAgencyLogo(
"");
926 }
catch (IOException ex) {
928 logger.log(Level.SEVERE,
"Unexpected error occurred while updating the agency logo.", ex);
930 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
933 private void browseLogosButtonActionPerformed(java.awt.event.ActionEvent evt) {
934 String oldLogoPath = agencyLogoPathField.getText();
935 int returnState = logoFileChooser.showOpenDialog(
this);
936 if (returnState == JFileChooser.APPROVE_OPTION) {
937 String path = logoFileChooser.getSelectedFile().getPath();
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);
948 updateAgencyLogo(oldLogoPath);
949 }
catch (IOException ex1) {
950 logger.log(Level.WARNING,
"Error loading image from previously saved agency logo path", ex1);
956 private void solrMaxHeapSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {
957 int value = (int) solrMaxHeapSpinner.getValue();
958 if (value == UserPreferences.getMaxSolrVMSize()) {
962 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
965 private void logFileCountKeyReleased(java.awt.event.KeyEvent evt) {
966 String count = logFileCount.getText();
967 if (count.equals(String.valueOf(UserPreferences.getDefaultLogFileCount()))) {
971 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
974 private void memFieldKeyReleased(java.awt.event.KeyEvent evt) {
975 String memText = memField.getText();
976 if (memText.equals(initialMemValue)) {
980 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
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;
void insertUpdate(DocumentEvent e)
void removeUpdate(DocumentEvent e)
void changedUpdate(DocumentEvent e)