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.Path;
28 import java.util.ArrayList;
29 import java.util.List;
30 import java.util.Optional;
31 import java.util.StringJoiner;
32 import java.util.logging.Level;
33 import javax.imageio.ImageIO;
34 import javax.swing.ImageIcon;
35 import javax.swing.JFileChooser;
36 import javax.swing.JOptionPane;
37 import javax.swing.event.DocumentEvent;
38 import javax.swing.event.DocumentListener;
39 import org.netbeans.spi.options.OptionsPanelController;
40 import org.openide.util.NbBundle;
42 import org.openide.util.NbBundle.Messages;
54 "AutopsyOptionsPanel.invalidImageFile.msg=The selected file was not able to be used as an agency logo.",
55 "AutopsyOptionsPanel.invalidImageFile.title=Invalid Image File",
56 "AutopsyOptionsPanel.memFieldValidationLabel.not64BitInstall.text=JVM memory settings only enabled for 64 bit version",
57 "AutopsyOptionsPanel.memFieldValidationLabel.noValueEntered.text=No value entered",
58 "AutopsyOptionsPanel.memFieldValidationLabel.invalidCharacters.text=Invalid characters, value must be a positive integer",
59 "# {0} - minimumMemory",
60 "AutopsyOptionsPanel.memFieldValidationLabel.underMinMemory.text=Value must be at least {0}GB",
61 "# {0} - systemMemory",
62 "AutopsyOptionsPanel.memFieldValidationLabel.overMaxMemory.text=Value must be less than the total system memory of {0}GB",
63 "AutopsyOptionsPanel.memFieldValidationLabel.developerMode.text=Memory settings are not available while running in developer mode",
64 "AutopsyOptionsPanel.agencyLogoPathFieldValidationLabel.invalidPath.text=Path is not valid.",
65 "AutopsyOptionsPanel.agencyLogoPathFieldValidationLabel.invalidImageSpecified.text=Invalid image file specified.",
66 "AutopsyOptionsPanel.agencyLogoPathFieldValidationLabel.pathNotSet.text=Agency logo path must be set.",
67 "AutopsyOptionsPanel.logNumAlert.invalidInput.text=A positive integer is required here."
69 @SuppressWarnings(
"PMD.SingularField")
70 final class AutopsyOptionsPanel extends javax.swing.JPanel {
72 private static final long serialVersionUID = 1L;
73 private final JFileChooser fileChooser;
74 private final TextFieldListener textFieldListener;
75 private static final String ETC_FOLDER_NAME =
"etc";
76 private static final String CONFIG_FILE_EXTENSION =
".conf";
77 private static final long ONE_BILLION = 1000000000L;
78 private static final long MEGA_IN_GIGA = 1024;
79 private static final int MIN_MEMORY_IN_GB = 2;
80 private static final Logger logger = Logger.getLogger(AutopsyOptionsPanel.class.getName());
81 private String initialMemValue = Long.toString(Runtime.getRuntime().maxMemory() / ONE_BILLION);
86 AutopsyOptionsPanel() {
88 fileChooser =
new JFileChooser();
89 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
90 fileChooser.setMultiSelectionEnabled(
false);
91 fileChooser.setAcceptAllFileFilterUsed(
false);
92 fileChooser.setFileFilter(
new GeneralFilter(GeneralFilter.GRAPHIC_IMAGE_EXTS, GeneralFilter.GRAPHIC_IMG_DECR));
93 if (!PlatformUtil.is64BitJVM() || Version.getBuildType() == Version.Type.DEVELOPMENT) {
98 memField.setEnabled(
false);
100 systemMemoryTotal.setText(Long.toString(getSystemMemoryInGB()));
102 textFieldListener =
new TextFieldListener();
103 agencyLogoPathField.getDocument().addDocumentListener(textFieldListener);
104 logFileCount.setText(String.valueOf(UserPreferences.getLogFileCount()));
113 private long getSystemMemoryInGB() {
114 long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory
115 .getOperatingSystemMXBean()).getTotalPhysicalMemorySize();
116 return memorySize / ONE_BILLION;
124 private long getCurrentJvmMaxMemoryInGB() throws IOException {
125 String currentXmx = getCurrentXmxValue();
128 if (currentXmx.length() > 1) {
129 units = currentXmx.charAt(currentXmx.length() - 1);
130 value = Long.parseLong(currentXmx.substring(0, currentXmx.length() - 1));
132 throw new IOException(
"No memory setting found in String: " + currentXmx);
141 return value / MEGA_IN_GIGA;
143 throw new IOException(
"Units were not recognized as parsed: " + units);
158 private String getCurrentXmxValue() throws IOException {
160 String currentSetting =
"";
161 File userConfFile = getUserFolderConfFile();
162 if (!userConfFile.exists()) {
163 settings = getDefaultsFromFileContents(readConfFile(getInstallFolderConfFile()));
165 settings = getDefaultsFromFileContents(readConfFile(userConfFile));
167 for (String option : settings) {
168 if (option.startsWith(
"-J-Xmx")) {
169 currentSetting = option.replace(
"-J-Xmx",
"").trim();
172 return currentSetting;
183 private static File getInstallFolderConfFile() throws IOException {
184 String confFileName = UserPreferences.getAppName() + CONFIG_FILE_EXTENSION;
185 String installFolder = PlatformUtil.getInstallPath();
186 File installFolderEtc =
new File(installFolder, ETC_FOLDER_NAME);
187 File installFolderConfigFile =
new File(installFolderEtc, confFileName);
188 if (!installFolderConfigFile.exists()) {
189 throw new IOException(
"Conf file could not be found" + installFolderConfigFile.toString());
191 return installFolderConfigFile;
201 private static File getUserFolderConfFile() {
202 String confFileName = UserPreferences.getAppName() + CONFIG_FILE_EXTENSION;
203 File userFolder = PlatformUtil.getUserDirectory();
204 File userEtcFolder =
new File(userFolder, ETC_FOLDER_NAME);
205 if (!userEtcFolder.exists()) {
206 userEtcFolder.mkdir();
208 return new File(userEtcFolder, confFileName);
219 private void writeEtcConfFile() throws IOException {
220 StringBuilder content =
new StringBuilder();
221 List<String> confFile = readConfFile(getInstallFolderConfFile());
222 for (String line : confFile) {
223 if (line.contains(
"-J-Xmx")) {
224 String[] splitLine = line.split(
" ");
225 StringJoiner modifiedLine =
new StringJoiner(
" ");
226 for (String piece : splitLine) {
227 if (piece.contains(
"-J-Xmx")) {
228 piece =
"-J-Xmx" + memField.getText() +
"g";
230 modifiedLine.add(piece);
232 content.append(modifiedLine.toString());
234 content.append(line);
236 content.append(
"\n");
238 Files.write(getUserFolderConfFile().toPath(), content.toString().getBytes());
250 private static List<String> readConfFile(File configFile) {
251 List<String> lines =
new ArrayList<>();
252 if (null != configFile) {
253 Path filePath = configFile.toPath();
254 Charset charset = Charset.forName(
"UTF-8");
256 lines = Files.readAllLines(filePath, charset);
257 }
catch (IOException e) {
258 logger.log(Level.SEVERE,
"Error reading config file contents. {}", configFile.getAbsolutePath());
275 private static String[] getDefaultsFromFileContents(List<String> list) {
276 Optional<String> defaultSettings = list.stream().filter(line -> line.startsWith(
"default_options=")).findFirst();
278 if (defaultSettings.isPresent()) {
279 return defaultSettings.get().replace(
"default_options=",
"").replaceAll(
"\"",
"").split(
" ");
281 return new String[]{};
288 String path = ModuleSettings.getConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP);
289 boolean useDefault = (path == null || path.isEmpty());
290 defaultLogoRB.setSelected(useDefault);
291 specifyLogoRB.setSelected(!useDefault);
292 agencyLogoPathField.setEnabled(!useDefault);
293 browseLogosButton.setEnabled(!useDefault);
294 logFileCount.setText(String.valueOf(UserPreferences.getLogFileCount()));
296 updateAgencyLogo(path);
297 }
catch (IOException ex) {
298 logger.log(Level.WARNING,
"Error loading image from previously saved agency logo path", ex);
300 if (memField.isEnabled()) {
302 initialMemValue = Long.toString(getCurrentJvmMaxMemoryInGB());
303 }
catch (IOException ex) {
304 logger.log(Level.SEVERE,
"Can't read current Jvm max memory setting from file", ex);
305 memField.setEnabled(
false);
307 memField.setText(initialMemValue);
320 private void updateAgencyLogo(String path)
throws IOException {
321 agencyLogoPathField.setText(path);
322 ImageIcon agencyLogoIcon =
new ImageIcon();
323 agencyLogoPreview.setText(NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.agencyLogoPreview.text"));
324 if (!agencyLogoPathField.getText().isEmpty()) {
325 File file =
new File(agencyLogoPathField.getText());
327 BufferedImage image = ImageIO.read(file);
329 throw new IOException(
"Unable to read file as a BufferedImage for file " + file.toString());
331 agencyLogoIcon =
new ImageIcon(image.getScaledInstance(64, 64, 4));
332 agencyLogoPreview.setText(
"");
335 agencyLogoPreview.setIcon(agencyLogoIcon);
336 agencyLogoPreview.repaint();
343 UserPreferences.setLogFileCount(Integer.parseInt(logFileCount.getText()));
344 if (!agencyLogoPathField.getText().isEmpty()) {
345 File file =
new File(agencyLogoPathField.getText());
347 ModuleSettings.setConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP, agencyLogoPathField.getText());
350 ModuleSettings.setConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP,
"");
352 if (memField.isEnabled()) {
355 }
catch (IOException ex) {
356 logger.log(Level.WARNING,
"Unable to save config file to " + PlatformUtil.getUserDirectory() +
"\\" + ETC_FOLDER_NAME, ex);
367 boolean valid =
true;
369 if (!isAgencyLogoPathValid()) {
372 if (!isMemFieldValid()) {
375 if (!isLogNumFieldValid()) {
388 boolean isAgencyLogoPathValid() {
389 boolean valid =
true;
391 if (defaultLogoRB.isSelected()) {
392 agencyLogoPathFieldValidationLabel.setText(
"");
394 String agencyLogoPath = agencyLogoPathField.getText();
395 if (agencyLogoPath.isEmpty()) {
396 agencyLogoPathFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_agencyLogoPathFieldValidationLabel_pathNotSet_text());
399 File file =
new File(agencyLogoPathField.getText());
400 if (file.exists() && file.isFile()) {
403 image = ImageIO.read(file);
405 throw new IOException(
"Unable to read file as a BufferedImage for file " + file.toString());
407 agencyLogoPathFieldValidationLabel.setText(
"");
408 }
catch (IOException | IndexOutOfBoundsException ignored) {
409 agencyLogoPathFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_agencyLogoPathFieldValidationLabel_invalidImageSpecified_text());
413 agencyLogoPathFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_agencyLogoPathFieldValidationLabel_invalidPath_text());
427 private boolean isMemFieldValid() {
428 String memText = memField.getText();
429 memFieldValidationLabel.setText(
"");
430 if (!PlatformUtil.is64BitJVM()) {
431 memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_not64BitInstall_text());
435 if (Version.getBuildType() == Version.Type.DEVELOPMENT) {
436 memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_developerMode_text());
440 if (memText.length() == 0) {
441 memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_noValueEntered_text());
444 if (memText.replaceAll(
"[^\\d]",
"").length() != memText.length()) {
445 memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_invalidCharacters_text());
448 int parsedInt = Integer.parseInt(memText);
449 if (parsedInt < MIN_MEMORY_IN_GB) {
450 memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_underMinMemory_text(MIN_MEMORY_IN_GB));
453 if (parsedInt > getSystemMemoryInGB()) {
454 memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_overMaxMemory_text(getSystemMemoryInGB()));
465 private boolean isLogNumFieldValid() {
466 String count = logFileCount.getText();
467 logNumAlert.setText(
"");
469 int count_num = Integer.parseInt(count);
471 logNumAlert.setText(Bundle.AutopsyOptionsPanel_logNumAlert_invalidInput_text());
474 }
catch (NumberFormatException e) {
475 logNumAlert.setText(Bundle.AutopsyOptionsPanel_logNumAlert_invalidInput_text());
488 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
493 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
498 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
508 private void initComponents() {
510 fileSelectionButtonGroup =
new javax.swing.ButtonGroup();
511 displayTimesButtonGroup =
new javax.swing.ButtonGroup();
512 logoSourceButtonGroup =
new javax.swing.ButtonGroup();
513 jScrollPane1 =
new javax.swing.JScrollPane();
514 jPanel1 =
new javax.swing.JPanel();
515 logoPanel =
new javax.swing.JPanel();
516 agencyLogoPathField =
new javax.swing.JTextField();
517 browseLogosButton =
new javax.swing.JButton();
518 agencyLogoPreview =
new javax.swing.JLabel();
519 defaultLogoRB =
new javax.swing.JRadioButton();
520 specifyLogoRB =
new javax.swing.JRadioButton();
521 agencyLogoPathFieldValidationLabel =
new javax.swing.JLabel();
522 runtimePanel =
new javax.swing.JPanel();
523 maxMemoryLabel =
new javax.swing.JLabel();
524 maxMemoryUnitsLabel =
new javax.swing.JLabel();
525 totalMemoryLabel =
new javax.swing.JLabel();
526 systemMemoryTotal =
new javax.swing.JLabel();
527 restartNecessaryWarning =
new javax.swing.JLabel();
528 memField =
new javax.swing.JTextField();
529 memFieldValidationLabel =
new javax.swing.JLabel();
530 maxMemoryUnitsLabel1 =
new javax.swing.JLabel();
531 maxLogFileCount =
new javax.swing.JLabel();
532 logFileCount =
new javax.swing.JTextField();
533 logNumAlert =
new javax.swing.JTextField();
535 setPreferredSize(
new java.awt.Dimension(1022, 488));
537 jScrollPane1.setBorder(null);
538 jScrollPane1.setPreferredSize(
new java.awt.Dimension(1022, 407));
540 jPanel1.setPreferredSize(
new java.awt.Dimension(1022, 407));
542 logoPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.logoPanel.border.title")));
543 logoPanel.setPreferredSize(
new java.awt.Dimension(533, 87));
545 agencyLogoPathField.setText(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.agencyLogoPathField.text"));
547 org.openide.awt.Mnemonics.setLocalizedText(browseLogosButton,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.browseLogosButton.text"));
548 browseLogosButton.addActionListener(
new java.awt.event.ActionListener() {
549 public void actionPerformed(java.awt.event.ActionEvent evt) {
550 browseLogosButtonActionPerformed(evt);
554 agencyLogoPreview.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
555 org.openide.awt.Mnemonics.setLocalizedText(agencyLogoPreview,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.agencyLogoPreview.text"));
556 agencyLogoPreview.setBorder(javax.swing.BorderFactory.createEtchedBorder());
557 agencyLogoPreview.setMaximumSize(
new java.awt.Dimension(64, 64));
558 agencyLogoPreview.setMinimumSize(
new java.awt.Dimension(64, 64));
559 agencyLogoPreview.setPreferredSize(
new java.awt.Dimension(64, 64));
561 logoSourceButtonGroup.add(defaultLogoRB);
562 org.openide.awt.Mnemonics.setLocalizedText(defaultLogoRB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.defaultLogoRB.text"));
563 defaultLogoRB.addActionListener(
new java.awt.event.ActionListener() {
564 public void actionPerformed(java.awt.event.ActionEvent evt) {
565 defaultLogoRBActionPerformed(evt);
569 logoSourceButtonGroup.add(specifyLogoRB);
570 org.openide.awt.Mnemonics.setLocalizedText(specifyLogoRB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.specifyLogoRB.text"));
571 specifyLogoRB.addActionListener(
new java.awt.event.ActionListener() {
572 public void actionPerformed(java.awt.event.ActionEvent evt) {
573 specifyLogoRBActionPerformed(evt);
577 agencyLogoPathFieldValidationLabel.setForeground(
new java.awt.Color(255, 0, 0));
578 org.openide.awt.Mnemonics.setLocalizedText(agencyLogoPathFieldValidationLabel,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.agencyLogoPathFieldValidationLabel.text"));
580 javax.swing.GroupLayout logoPanelLayout =
new javax.swing.GroupLayout(logoPanel);
581 logoPanel.setLayout(logoPanelLayout);
582 logoPanelLayout.setHorizontalGroup(
583 logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
584 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logoPanelLayout.createSequentialGroup()
586 .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
587 .addComponent(specifyLogoRB)
588 .addComponent(defaultLogoRB))
589 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
590 .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
591 .addGroup(logoPanelLayout.createSequentialGroup()
592 .addComponent(agencyLogoPathField, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)
593 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
594 .addComponent(browseLogosButton))
595 .addComponent(agencyLogoPathFieldValidationLabel))
596 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
597 .addComponent(agencyLogoPreview, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
598 .addContainerGap(479, Short.MAX_VALUE))
600 logoPanelLayout.setVerticalGroup(
601 logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
602 .addGroup(logoPanelLayout.createSequentialGroup()
604 .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
605 .addComponent(defaultLogoRB)
606 .addComponent(agencyLogoPathFieldValidationLabel))
607 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
608 .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
609 .addComponent(specifyLogoRB)
610 .addComponent(agencyLogoPathField)
611 .addComponent(browseLogosButton)))
612 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logoPanelLayout.createSequentialGroup()
613 .addComponent(agencyLogoPreview, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
614 .addGap(0, 0, Short.MAX_VALUE))
617 runtimePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.runtimePanel.border.title")));
619 org.openide.awt.Mnemonics.setLocalizedText(maxMemoryLabel,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.maxMemoryLabel.text"));
621 org.openide.awt.Mnemonics.setLocalizedText(maxMemoryUnitsLabel,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.maxMemoryUnitsLabel.text"));
623 org.openide.awt.Mnemonics.setLocalizedText(totalMemoryLabel,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.totalMemoryLabel.text"));
625 systemMemoryTotal.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
627 restartNecessaryWarning.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/warning16.png")));
628 org.openide.awt.Mnemonics.setLocalizedText(restartNecessaryWarning,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.restartNecessaryWarning.text"));
630 memField.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
631 memField.addKeyListener(
new java.awt.event.KeyAdapter() {
632 public void keyReleased(java.awt.event.KeyEvent evt) {
633 memFieldKeyReleased(evt);
637 memFieldValidationLabel.setForeground(
new java.awt.Color(255, 0, 0));
639 org.openide.awt.Mnemonics.setLocalizedText(maxMemoryUnitsLabel1,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.maxMemoryUnitsLabel.text"));
641 org.openide.awt.Mnemonics.setLocalizedText(maxLogFileCount,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.maxLogFileCount.text"));
643 logFileCount.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
644 logFileCount.addKeyListener(
new java.awt.event.KeyAdapter() {
645 public void keyReleased(java.awt.event.KeyEvent evt) {
646 logFileCountKeyReleased(evt);
650 logNumAlert.setEditable(
false);
651 logNumAlert.setFont(logNumAlert.getFont().deriveFont(logNumAlert.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
652 logNumAlert.setForeground(
new java.awt.Color(255, 0, 0));
653 logNumAlert.setText(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.logNumAlert.text"));
654 logNumAlert.setBorder(null);
656 javax.swing.GroupLayout runtimePanelLayout =
new javax.swing.GroupLayout(runtimePanel);
657 runtimePanel.setLayout(runtimePanelLayout);
658 runtimePanelLayout.setHorizontalGroup(
659 runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
660 .addGroup(runtimePanelLayout.createSequentialGroup()
662 .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
663 .addGroup(runtimePanelLayout.createSequentialGroup()
664 .addComponent(totalMemoryLabel)
665 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
666 .addComponent(systemMemoryTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
668 .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
669 .addGroup(runtimePanelLayout.createSequentialGroup()
670 .addComponent(maxMemoryUnitsLabel1)
671 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
672 .addComponent(restartNecessaryWarning, javax.swing.GroupLayout.DEFAULT_SIZE, 783, Short.MAX_VALUE))
673 .addGroup(runtimePanelLayout.createSequentialGroup()
674 .addComponent(maxMemoryUnitsLabel)
675 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
676 .addComponent(memFieldValidationLabel)
677 .addGap(0, 0, Short.MAX_VALUE))))
678 .addGroup(runtimePanelLayout.createSequentialGroup()
679 .addComponent(maxMemoryLabel)
680 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
681 .addComponent(memField, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
682 .addGap(0, 0, Short.MAX_VALUE))
683 .addGroup(runtimePanelLayout.createSequentialGroup()
684 .addComponent(maxLogFileCount)
685 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
686 .addComponent(logFileCount, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
688 .addComponent(logNumAlert)))
692 runtimePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {maxLogFileCount, maxMemoryLabel, totalMemoryLabel});
694 runtimePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {logFileCount, memField});
696 runtimePanelLayout.setVerticalGroup(
697 runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
698 .addGroup(runtimePanelLayout.createSequentialGroup()
700 .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
701 .addComponent(totalMemoryLabel)
702 .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
703 .addComponent(restartNecessaryWarning)
704 .addComponent(maxMemoryUnitsLabel1))
705 .addComponent(systemMemoryTotal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
706 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
707 .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
708 .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
709 .addComponent(maxMemoryLabel)
710 .addComponent(memField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
711 .addComponent(maxMemoryUnitsLabel))
712 .addComponent(memFieldValidationLabel))
713 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
714 .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
715 .addComponent(maxLogFileCount)
716 .addComponent(logFileCount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
717 .addComponent(logNumAlert, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
718 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
721 javax.swing.GroupLayout jPanel1Layout =
new javax.swing.GroupLayout(jPanel1);
722 jPanel1.setLayout(jPanel1Layout);
723 jPanel1Layout.setHorizontalGroup(
724 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
725 .addGroup(jPanel1Layout.createSequentialGroup()
727 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
728 .addComponent(runtimePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
729 .addComponent(logoPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 1002, Short.MAX_VALUE))
732 jPanel1Layout.setVerticalGroup(
733 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
734 .addGroup(jPanel1Layout.createSequentialGroup()
736 .addComponent(runtimePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
737 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
738 .addComponent(logoPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
739 .addContainerGap(185, Short.MAX_VALUE))
742 jScrollPane1.setViewportView(jPanel1);
744 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
745 this.setLayout(layout);
746 layout.setHorizontalGroup(
747 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
748 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
750 layout.setVerticalGroup(
751 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
752 .addGroup(layout.createSequentialGroup()
753 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
754 .addGap(0, 0, Short.MAX_VALUE))
758 private void logFileCountKeyReleased(java.awt.event.KeyEvent evt) {
759 String count = logFileCount.getText();
760 if (count.equals(String.valueOf(UserPreferences.getDefaultLogFileCount()))) {
764 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
767 private void memFieldKeyReleased(java.awt.event.KeyEvent evt) {
768 String memText = memField.getText();
769 if (memText.equals(initialMemValue)) {
773 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
776 private void specifyLogoRBActionPerformed(java.awt.event.ActionEvent evt) {
777 agencyLogoPathField.setEnabled(
true);
778 browseLogosButton.setEnabled(
true);
780 if (agencyLogoPathField.getText().isEmpty()) {
781 String path = ModuleSettings.getConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP);
782 if (path != null && !path.isEmpty()) {
783 updateAgencyLogo(path);
786 }
catch (IOException ex) {
787 logger.log(Level.WARNING,
"Error loading image from previously saved agency logo path.", ex);
789 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
792 private void defaultLogoRBActionPerformed(java.awt.event.ActionEvent evt) {
793 agencyLogoPathField.setEnabled(
false);
794 browseLogosButton.setEnabled(
false);
796 updateAgencyLogo(
"");
797 }
catch (IOException ex) {
799 logger.log(Level.SEVERE,
"Unexpected error occurred while updating the agency logo.", ex);
801 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
804 private void browseLogosButtonActionPerformed(java.awt.event.ActionEvent evt) {
805 String oldLogoPath = agencyLogoPathField.getText();
806 int returnState = fileChooser.showOpenDialog(
this);
807 if (returnState == JFileChooser.APPROVE_OPTION) {
808 String path = fileChooser.getSelectedFile().getPath();
810 updateAgencyLogo(path);
811 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
812 }
catch (IOException | IndexOutOfBoundsException ex) {
813 JOptionPane.showMessageDialog(
this,
814 NbBundle.getMessage(
this.getClass(),
815 "AutopsyOptionsPanel.invalidImageFile.msg"),
816 NbBundle.getMessage(
this.getClass(),
"AutopsyOptionsPanel.invalidImageFile.title"),
817 JOptionPane.ERROR_MESSAGE);
819 updateAgencyLogo(oldLogoPath);
820 }
catch (IOException ex1) {
821 logger.log(Level.WARNING,
"Error loading image from previously saved agency logo path", ex1);
828 private javax.swing.JTextField agencyLogoPathField;
829 private javax.swing.JLabel agencyLogoPathFieldValidationLabel;
830 private javax.swing.JLabel agencyLogoPreview;
831 private javax.swing.JButton browseLogosButton;
832 private javax.swing.JRadioButton defaultLogoRB;
833 private javax.swing.ButtonGroup displayTimesButtonGroup;
834 private javax.swing.ButtonGroup fileSelectionButtonGroup;
835 private javax.swing.JPanel jPanel1;
836 private javax.swing.JScrollPane jScrollPane1;
837 private javax.swing.JTextField logFileCount;
838 private javax.swing.JTextField logNumAlert;
839 private javax.swing.JPanel logoPanel;
840 private javax.swing.ButtonGroup logoSourceButtonGroup;
841 private javax.swing.JLabel maxLogFileCount;
842 private javax.swing.JLabel maxMemoryLabel;
843 private javax.swing.JLabel maxMemoryUnitsLabel;
844 private javax.swing.JLabel maxMemoryUnitsLabel1;
845 private javax.swing.JTextField memField;
846 private javax.swing.JLabel memFieldValidationLabel;
847 private javax.swing.JLabel restartNecessaryWarning;
848 private javax.swing.JPanel runtimePanel;
849 private javax.swing.JRadioButton specifyLogoRB;
850 private javax.swing.JLabel systemMemoryTotal;
851 private javax.swing.JLabel totalMemoryLabel;
void insertUpdate(DocumentEvent e)
void removeUpdate(DocumentEvent e)
void changedUpdate(DocumentEvent e)