diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/AutopsyOptionsPanel.form b/Core/src/org/sleuthkit/autopsy/corecomponents/AutopsyOptionsPanel.form index 00881c2ca7..c1fc384c5e 100755 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/AutopsyOptionsPanel.form +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/AutopsyOptionsPanel.form @@ -2,9 +2,11 @@
- + - + + + @@ -22,10 +24,7 @@ - - - - + @@ -69,7 +68,7 @@ - + @@ -92,13 +91,17 @@ - - - + + + + + + - + + @@ -109,42 +112,31 @@ - - - - - - - - - - - + + + + - + + + + + + + + + + - - - - - - - - - - - - - @@ -179,6 +171,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -276,7 +304,7 @@ - + @@ -292,7 +320,7 @@ - + @@ -369,7 +397,7 @@ - + @@ -382,7 +410,7 @@ - + @@ -427,7 +455,7 @@ - + @@ -442,7 +470,7 @@ - + @@ -503,7 +531,7 @@ - + diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/AutopsyOptionsPanel.java b/Core/src/org/sleuthkit/autopsy/corecomponents/AutopsyOptionsPanel.java index a62ae4400c..a9640f005e 100755 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/AutopsyOptionsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/AutopsyOptionsPanel.java @@ -34,6 +34,8 @@ import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.coreutils.Logger; @@ -58,35 +60,45 @@ import org.sleuthkit.autopsy.report.ReportBranding; "AutopsyOptionsPanel.maxMemoryLabel.text=Maximum JVM Memory:", "AutopsyOptionsPanel.maxMemoryUnitsLabel.text=GB", "AutopsyOptionsPanel.runtimePanel.border.title=Runtime", - "AutopsyOptionsPanel.invalidReasonLabel.not64BitInstall.text=JVM memory settings only enabled for 64 bit version", - "AutopsyOptionsPanel.invalidReasonLabel.noValueEntered.text=No value entered", - "AutopsyOptionsPanel.invalidReasonLabel.invalidCharacters.text=Invalid characters, value must be a positive integer", + "AutopsyOptionsPanel.memFieldValidationLabel.not64BitInstall.text=JVM memory settings only enabled for 64 bit version", + "AutopsyOptionsPanel.memFieldValidationLabel.noValueEntered.text=No value entered", + "AutopsyOptionsPanel.memFieldValidationLabel.invalidCharacters.text=Invalid characters, value must be a positive integer", "# {0} - minimumMemory", - "AutopsyOptionsPanel.invalidReasonLabel.underMinMemory.text=Value must be at least {0}GB", + "AutopsyOptionsPanel.memFieldValidationLabel.underMinMemory.text=Value must be at least {0}GB", "# {0} - systemMemory", - "AutopsyOptionsPanel.invalidReasonLabel.overMaxMemory.text=Value must be less than the total system memory of {0}GB", - "AutopsyOptionsPanel.invalidReasonLabel.developerMode.text=Memory settings are not available while running in developer mode"}) + "AutopsyOptionsPanel.memFieldValidationLabel.overMaxMemory.text=Value must be less than the total system memory of {0}GB", + "AutopsyOptionsPanel.memFieldValidationLabel.developerMode.text=Memory settings are not available while running in developer mode", + "AutopsyOptionsPanel.defaultLogoRB.text=Use default", + "AutopsyOptionsPanel.specifyLogoRB.text=Specify a logo", + "AutopsyOptionsPanel.browseLogosButton.text=Browse", + "AutopsyOptionsPanel.agencyLogoPathFieldValidationLabel.invalidPath.text=Path is not valid.", + "AutopsyOptionsPanel.agencyLogoPathFieldValidationLabel.pathNotSet.text=Agency logo path must be set." +}) final class AutopsyOptionsPanel extends javax.swing.JPanel { private static final long serialVersionUID = 1L; - private final JFileChooser fc; + private final JFileChooser fileChooser; + private final TextFieldListener textFieldListener; private static final String ETC_FOLDER_NAME = "etc"; private static final String CONFIG_FILE_EXTENSION = ".conf"; private static final long ONE_BILLION = 1000000000L; //used to roughly convert system memory from bytes to gigabytes private static final long MEGA_IN_GIGA = 1024; //used to convert memory settings saved as megabytes to gigabytes private static final int MIN_MEMORY_IN_GB = 2; //the enforced minimum memory in gigabytes - private static final Logger logger = Logger.getLogger(AutopsyOptionsPanel.class.getName()); + private static final Logger LOGGER = Logger.getLogger(AutopsyOptionsPanel.class.getName()); private String initialMemValue = Long.toString(Runtime.getRuntime().maxMemory() / ONE_BILLION); + /** + * Instantiate the Autopsy options panel. + */ AutopsyOptionsPanel() { initComponents(); - fc = new JFileChooser(); - fc.setFileSelectionMode(JFileChooser.FILES_ONLY); - fc.setMultiSelectionEnabled(false); - fc.setAcceptAllFileFilterUsed(false); - fc.setFileFilter(new GeneralFilter(GeneralFilter.GRAPHIC_IMAGE_EXTS, GeneralFilter.GRAPHIC_IMG_DECR)); - if (!PlatformUtil.is64BitJVM() || Version.getBuildType() == Version.Type.DEVELOPMENT) { + fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + fileChooser.setMultiSelectionEnabled(false); + fileChooser.setAcceptAllFileFilterUsed(false); + fileChooser.setFileFilter(new GeneralFilter(GeneralFilter.GRAPHIC_IMAGE_EXTS, GeneralFilter.GRAPHIC_IMG_DECR)); + if (!PlatformUtil.is64BitJVM() || Version.getBuildType() == Version.Type.DEVELOPMENT) { //32 bit JVM has a max heap size of 1.4 gb to 4 gb depending on OS //So disabling the setting of heap size when the JVM is not 64 bit //Is the safest course of action @@ -94,6 +106,9 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { memField.setEnabled(false); } systemMemoryTotal.setText(Long.toString(getSystemMemoryInGB())); + + textFieldListener = new TextFieldListener(); + agencyLogoPathField.getDocument().addDocumentListener(textFieldListener); } /** @@ -247,7 +262,7 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { try { lines = Files.readAllLines(filePath, charset); } catch (IOException e) { - logger.log(Level.SEVERE, "Error reading config file contents. {}", configFile.getAbsolutePath()); + LOGGER.log(Level.SEVERE, "Error reading config file contents. {}", configFile.getAbsolutePath()); } } return lines; @@ -273,6 +288,9 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { return new String[]{}; } + /** + * Load the saved user preferences. + */ void load() { boolean keepPreferredViewer = UserPreferences.keepPreferredContentViewer(); keepCurrentViewerRB.setSelected(keepPreferredViewer); @@ -285,23 +303,36 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { useLocalTimeRB.setSelected(useLocalTime); useGMTTimeRB.setSelected(!useLocalTime); String path = ModuleSettings.getConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP); + boolean useDefault = (path == null || path.isEmpty()); + defaultLogoRB.setSelected(useDefault); + specifyLogoRB.setSelected(!useDefault); + agencyLogoPathField.setEnabled(!useDefault); + browseLogosButton.setEnabled(!useDefault); try { updateAgencyLogo(path); } catch (IOException ex) { - logger.log(Level.WARNING, "Error loading image from previously saved agency logo path", ex); + LOGGER.log(Level.WARNING, "Error loading image from previously saved agency logo path", ex); } if (memField.isEnabled()) { try { initialMemValue = Long.toString(getCurrentJvmMaxMemoryInGB()); } catch (IOException ex) { - logger.log(Level.SEVERE, "Can't read current Jvm max memory setting from file", ex); + LOGGER.log(Level.SEVERE, "Can't read current Jvm max memory setting from file", ex); memField.setEnabled(false); } memField.setText(initialMemValue); } - isMemFieldValid(); //ensure the error message is up to date + + valid(); //ensure the error messages are up to date } + /** + * Update the agency logo with the image specified by the path. + * + * @param path The path to the image. + * + * @throws IOException Thrown when there is a problem reading the file. + */ private void updateAgencyLogo(String path) throws IOException { agencyLogoPathField.setText(path); ImageIcon agencyLogoIcon = new ImageIcon(); @@ -321,6 +352,9 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { agencyLogoPreview.repaint(); } + /** + * Store the current user preferences. + */ void store() { UserPreferences.setKeepPreferredContentViewer(keepCurrentViewerRB.isSelected()); UserPreferences.setHideKnownFilesInDataSourcesTree(dataSourcesHideKnownCB.isSelected()); @@ -333,18 +367,124 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { if (file.exists()) { ModuleSettings.setConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP, agencyLogoPathField.getText()); } + } else { + ModuleSettings.setConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP, ""); } if (memField.isEnabled()) { //if the field could of been changed we need to try and save it try { writeEtcConfFile(); } catch (IOException ex) { - logger.log(Level.WARNING, "Unable to save config file to " + PlatformUtil.getUserDirectory() + "\\" + ETC_FOLDER_NAME, ex); + LOGGER.log(Level.WARNING, "Unable to save config file to " + PlatformUtil.getUserDirectory() + "\\" + ETC_FOLDER_NAME, ex); } } } + /** + * Checks to see if the memory and agency logo field inputs are valid. + * + * @return True if valid; false otherwise. + */ boolean valid() { - return isMemFieldValid(); + boolean valid = true; + + if (!isAgencyLogoPathValid()) { + valid = false; + } + if (!isMemFieldValid()) { + valid = false; + } + + return valid; + } + + /** + * Validates the agency logo path to ensure it is valid. + * + * @return True if the default logo is being used or if the path is valid; + * otherwise false. + */ + boolean isAgencyLogoPathValid() { + boolean valid = true; + + if (defaultLogoRB.isSelected()) { + agencyLogoPathFieldValidationLabel.setText(""); + } else { + String agencyLogoPath = agencyLogoPathField.getText(); + if (agencyLogoPath.isEmpty()) { + agencyLogoPathFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_agencyLogoPathFieldValidationLabel_pathNotSet_text()); + valid = false; + } else { + File file = new File(agencyLogoPathField.getText()); + if (file.exists() && file.isFile()) { + agencyLogoPathFieldValidationLabel.setText(""); + } else { + agencyLogoPathFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_agencyLogoPathFieldValidationLabel_invalidPath_text()); + valid = false; + } + } + } + + return valid; + } + + /** + * Checks that if the mem field is enabled it has a valid value. + * + * @return true if the memfield is valid false if it is not + */ + private boolean isMemFieldValid() { + String memText = memField.getText(); + memFieldValidationLabel.setText(""); + if (!PlatformUtil.is64BitJVM()) { + memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_not64BitInstall_text()); + //the panel should be valid when it is a 32 bit jvm because the memfield will be disabled. + return true; + } + if (Version.getBuildType() == Version.Type.DEVELOPMENT) { + memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_developerMode_text()); + //the panel should be valid when you are running in developer mode because the memfield will be disabled + return true; + } + if (memText.length() == 0) { + memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_noValueEntered_text()); + return false; + } + if (memText.replaceAll("[^\\d]", "").length() != memText.length()) { + memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_invalidCharacters_text()); + return false; + } + int parsedInt = Integer.parseInt(memText); + if (parsedInt < MIN_MEMORY_IN_GB) { + memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_underMinMemory_text(MIN_MEMORY_IN_GB)); + return false; + } + if (parsedInt >= getSystemMemoryInGB()) { + memFieldValidationLabel.setText(Bundle.AutopsyOptionsPanel_memFieldValidationLabel_overMaxMemory_text(getSystemMemoryInGB())); + return false; + } + return true; + } + + /** + * Listens for registered text fields that have changed and fires a + * PropertyChangeEvent accordingly. + */ + private class TextFieldListener implements DocumentListener { + + @Override + public void insertUpdate(DocumentEvent e) { + firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null); + } + + @Override + public void removeUpdate(DocumentEvent e) { + firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null); + } + + @Override + public void changedUpdate(DocumentEvent e) { + firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null); + } } /** @@ -355,15 +495,18 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { // //GEN-BEGIN:initComponents private void initComponents() { - buttonGroup1 = new javax.swing.ButtonGroup(); - buttonGroup3 = new javax.swing.ButtonGroup(); + fileSelectionButtonGroup = new javax.swing.ButtonGroup(); + displayTimesButtonGroup = new javax.swing.ButtonGroup(); + logoSourceButtonGroup = new javax.swing.ButtonGroup(); jScrollPane1 = new javax.swing.JScrollPane(); jPanel1 = new javax.swing.JPanel(); logoPanel = new javax.swing.JPanel(); - agencyLogoImageLabel = new javax.swing.JLabel(); agencyLogoPathField = new javax.swing.JTextField(); browseLogosButton = new javax.swing.JButton(); agencyLogoPreview = new javax.swing.JLabel(); + defaultLogoRB = new javax.swing.JRadioButton(); + specifyLogoRB = new javax.swing.JRadioButton(); + agencyLogoPathFieldValidationLabel = new javax.swing.JLabel(); viewPanel = new javax.swing.JPanel(); jLabelSelectFile = new javax.swing.JLabel(); useBestViewerRB = new javax.swing.JRadioButton(); @@ -384,20 +527,14 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { systemMemoryTotal = new javax.swing.JLabel(); restartNecessaryWarning = new javax.swing.JLabel(); memField = new javax.swing.JTextField(); - invalidReasonLabel = new javax.swing.JLabel(); + memFieldValidationLabel = new javax.swing.JLabel(); maxMemoryUnitsLabel1 = new javax.swing.JLabel(); jScrollPane1.setBorder(null); logoPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.logoPanel.border.title"))); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(agencyLogoImageLabel, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.agencyLogoImageLabel.text")); // NOI18N - - agencyLogoPathField.setEditable(false); - agencyLogoPathField.setBackground(new java.awt.Color(255, 255, 255)); agencyLogoPathField.setText(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.agencyLogoPathField.text")); // NOI18N - agencyLogoPathField.setFocusable(false); - agencyLogoPathField.setRequestFocusEnabled(false); org.openide.awt.Mnemonics.setLocalizedText(browseLogosButton, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.browseLogosButton.text")); // NOI18N browseLogosButton.addActionListener(new java.awt.event.ActionListener() { @@ -413,6 +550,25 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { agencyLogoPreview.setMinimumSize(new java.awt.Dimension(64, 64)); agencyLogoPreview.setPreferredSize(new java.awt.Dimension(64, 64)); + logoSourceButtonGroup.add(defaultLogoRB); + org.openide.awt.Mnemonics.setLocalizedText(defaultLogoRB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.defaultLogoRB.text")); // NOI18N + defaultLogoRB.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + defaultLogoRBActionPerformed(evt); + } + }); + + logoSourceButtonGroup.add(specifyLogoRB); + org.openide.awt.Mnemonics.setLocalizedText(specifyLogoRB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.specifyLogoRB.text")); // NOI18N + specifyLogoRB.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + specifyLogoRBActionPerformed(evt); + } + }); + + agencyLogoPathFieldValidationLabel.setForeground(new java.awt.Color(255, 0, 0)); + org.openide.awt.Mnemonics.setLocalizedText(agencyLogoPathFieldValidationLabel, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.agencyLogoPathFieldValidationLabel.text")); // NOI18N + javax.swing.GroupLayout logoPanelLayout = new javax.swing.GroupLayout(logoPanel); logoPanel.setLayout(logoPanelLayout); logoPanelLayout.setHorizontalGroup( @@ -420,12 +576,15 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logoPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(agencyLogoImageLabel) + .addComponent(specifyLogoRB, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(defaultLogoRB, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(logoPanelLayout.createSequentialGroup() - .addGap(10, 10, 10) .addComponent(agencyLogoPathField, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(browseLogosButton))) + .addComponent(browseLogosButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(agencyLogoPathFieldValidationLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(agencyLogoPreview, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) @@ -433,23 +592,25 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { logoPanelLayout.setVerticalGroup( logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(logoPanelLayout.createSequentialGroup() - .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(agencyLogoPreview, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(logoPanelLayout.createSequentialGroup() - .addContainerGap() - .addComponent(agencyLogoImageLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(agencyLogoPathField) - .addComponent(browseLogosButton)))) - .addGap(0, 0, 0)) + .addGap(6, 6, 6) + .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(defaultLogoRB) + .addComponent(agencyLogoPathFieldValidationLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(logoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(specifyLogoRB) + .addComponent(agencyLogoPathField) + .addComponent(browseLogosButton))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logoPanelLayout.createSequentialGroup() + .addComponent(agencyLogoPreview, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) ); viewPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.viewPanel.border.title"))); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(jLabelSelectFile, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.jLabelSelectFile.text")); // NOI18N - buttonGroup1.add(useBestViewerRB); + fileSelectionButtonGroup.add(useBestViewerRB); org.openide.awt.Mnemonics.setLocalizedText(useBestViewerRB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.useBestViewerRB.text")); // NOI18N useBestViewerRB.setToolTipText(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.useBestViewerRB.toolTipText")); // NOI18N useBestViewerRB.addActionListener(new java.awt.event.ActionListener() { @@ -458,7 +619,7 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { } }); - buttonGroup1.add(keepCurrentViewerRB); + fileSelectionButtonGroup.add(keepCurrentViewerRB); org.openide.awt.Mnemonics.setLocalizedText(keepCurrentViewerRB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.keepCurrentViewerRB.text")); // NOI18N keepCurrentViewerRB.setToolTipText(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.keepCurrentViewerRB.toolTipText")); // NOI18N keepCurrentViewerRB.addActionListener(new java.awt.event.ActionListener() { @@ -501,7 +662,7 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { org.openide.awt.Mnemonics.setLocalizedText(jLabelTimeDisplay, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.jLabelTimeDisplay.text")); // NOI18N - buttonGroup3.add(useLocalTimeRB); + displayTimesButtonGroup.add(useLocalTimeRB); org.openide.awt.Mnemonics.setLocalizedText(useLocalTimeRB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.useLocalTimeRB.text")); // NOI18N useLocalTimeRB.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -509,7 +670,7 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { } }); - buttonGroup3.add(useGMTTimeRB); + displayTimesButtonGroup.add(useGMTTimeRB); org.openide.awt.Mnemonics.setLocalizedText(useGMTTimeRB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.useGMTTimeRB.text")); // NOI18N useGMTTimeRB.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -598,7 +759,7 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { } }); - invalidReasonLabel.setForeground(new java.awt.Color(255, 0, 0)); + memFieldValidationLabel.setForeground(new java.awt.Color(255, 0, 0)); org.openide.awt.Mnemonics.setLocalizedText(maxMemoryUnitsLabel1, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.maxMemoryUnitsLabel.text")); // NOI18N @@ -622,7 +783,7 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { .addGap(18, 18, 18) .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(restartNecessaryWarning, javax.swing.GroupLayout.DEFAULT_SIZE, 417, Short.MAX_VALUE) - .addComponent(invalidReasonLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(memFieldValidationLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); runtimePanelLayout.setVerticalGroup( @@ -633,7 +794,7 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(maxMemoryUnitsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(memField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(invalidReasonLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(memFieldValidationLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(maxMemoryLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(runtimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) @@ -665,7 +826,7 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { .addComponent(runtimePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(logoPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, 0)) + .addContainerGap()) ); jScrollPane1.setViewportView(jPanel1); @@ -674,9 +835,7 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jScrollPane1) - .addGap(0, 0, 0)) + .addComponent(jScrollPane1) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -718,9 +877,9 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { private void browseLogosButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLogosButtonActionPerformed String oldLogoPath = agencyLogoPathField.getText(); - int returnState = fc.showOpenDialog(this); + int returnState = fileChooser.showOpenDialog(this); if (returnState == JFileChooser.APPROVE_OPTION) { - String path = fc.getSelectedFile().getPath(); + String path = fileChooser.getSelectedFile().getPath(); try { updateAgencyLogo(path); firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null); @@ -733,7 +892,7 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { try { updateAgencyLogo(oldLogoPath); //restore previous setting if new one is invalid } catch (IOException ex1) { - logger.log(Level.WARNING, "Error loading image from previously saved agency logo path", ex1); + LOGGER.log(Level.WARNING, "Error loading image from previously saved agency logo path", ex1); } } } @@ -748,53 +907,44 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null); }//GEN-LAST:event_memFieldKeyReleased - /** - * Checks that if the mem field is enabled it has a valid value. - * - * @return true if the memfield is valid false if it is not - */ - private boolean isMemFieldValid() { - String memText = memField.getText(); - invalidReasonLabel.setText(""); - if (!PlatformUtil.is64BitJVM()) { - invalidReasonLabel.setText(Bundle.AutopsyOptionsPanel_invalidReasonLabel_not64BitInstall_text()); - //the panel should be valid when it is a 32 bit jvm because the memfield will be disabled. - return true; + private void defaultLogoRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_defaultLogoRBActionPerformed + agencyLogoPathField.setEnabled(false); + browseLogosButton.setEnabled(false); + try { + updateAgencyLogo(""); + } catch (IOException ex) { + // This should never happen since we're not reading from a file. + LOGGER.log(Level.SEVERE, "Unexpected error occurred while updating the agency logo.", ex); } - if (Version.getBuildType() == Version.Type.DEVELOPMENT) { - invalidReasonLabel.setText(Bundle.AutopsyOptionsPanel_invalidReasonLabel_developerMode_text()); - //the panel should be valid when you are running in developer mode because the memfield will be disabled - return true; + firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null); + }//GEN-LAST:event_defaultLogoRBActionPerformed + + private void specifyLogoRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_specifyLogoRBActionPerformed + agencyLogoPathField.setEnabled(true); + browseLogosButton.setEnabled(true); + try { + if (agencyLogoPathField.getText().isEmpty()) { + String path = ModuleSettings.getConfigSetting(ReportBranding.MODULE_NAME, ReportBranding.AGENCY_LOGO_PATH_PROP); + if (path != null && !path.isEmpty()) { + updateAgencyLogo(path); + } + } + } catch (IOException ex) { + LOGGER.log(Level.WARNING, "Error loading image from previously saved agency logo path.", ex); } - if (memText.length() == 0) { - invalidReasonLabel.setText(Bundle.AutopsyOptionsPanel_invalidReasonLabel_noValueEntered_text()); - return false; - } - if (memText.replaceAll("[^\\d]", "").length() != memText.length()) { - invalidReasonLabel.setText(Bundle.AutopsyOptionsPanel_invalidReasonLabel_invalidCharacters_text()); - return false; - } - int parsedInt = Integer.parseInt(memText); - if (parsedInt < MIN_MEMORY_IN_GB) { - invalidReasonLabel.setText(Bundle.AutopsyOptionsPanel_invalidReasonLabel_underMinMemory_text(MIN_MEMORY_IN_GB)); - return false; - } - if (parsedInt >= getSystemMemoryInGB()) { - invalidReasonLabel.setText(Bundle.AutopsyOptionsPanel_invalidReasonLabel_overMaxMemory_text(getSystemMemoryInGB())); - return false; - } - return true; - } + firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null); + }//GEN-LAST:event_specifyLogoRBActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JLabel agencyLogoImageLabel; private javax.swing.JTextField agencyLogoPathField; + private javax.swing.JLabel agencyLogoPathFieldValidationLabel; private javax.swing.JLabel agencyLogoPreview; private javax.swing.JButton browseLogosButton; - private javax.swing.ButtonGroup buttonGroup1; - private javax.swing.ButtonGroup buttonGroup3; private javax.swing.JCheckBox dataSourcesHideKnownCB; private javax.swing.JCheckBox dataSourcesHideSlackCB; - private javax.swing.JLabel invalidReasonLabel; + private javax.swing.JRadioButton defaultLogoRB; + private javax.swing.ButtonGroup displayTimesButtonGroup; + private javax.swing.ButtonGroup fileSelectionButtonGroup; private javax.swing.JLabel jLabelHideKnownFiles; private javax.swing.JLabel jLabelHideSlackFiles; private javax.swing.JLabel jLabelSelectFile; @@ -803,12 +953,15 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel { private javax.swing.JScrollPane jScrollPane1; private javax.swing.JRadioButton keepCurrentViewerRB; private javax.swing.JPanel logoPanel; + private javax.swing.ButtonGroup logoSourceButtonGroup; private javax.swing.JLabel maxMemoryLabel; private javax.swing.JLabel maxMemoryUnitsLabel; private javax.swing.JLabel maxMemoryUnitsLabel1; private javax.swing.JTextField memField; + private javax.swing.JLabel memFieldValidationLabel; private javax.swing.JLabel restartNecessaryWarning; private javax.swing.JPanel runtimePanel; + private javax.swing.JRadioButton specifyLogoRB; private javax.swing.JLabel systemMemoryTotal; private javax.swing.JLabel totalMemoryLabel; private javax.swing.JRadioButton useBestViewerRB; diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties b/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties index 26a2cc03e0..6e9b722d71 100755 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties @@ -192,8 +192,6 @@ AutopsyOptionsPanel.jLabelHideSlackFiles.text=Hide slack files in the: AutopsyOptionsPanel.dataSourcesHideSlackCB.text=Data Sources area (the directory hierarchy) AutopsyOptionsPanel.viewsHideSlackCB.text=Views area AutopsyOptionsPanel.agencyLogoImageLabel.toolTipText= -AutopsyOptionsPanel.agencyLogoImageLabel.text=Image to use as the agency logo for HTML reports: -AutopsyOptionsPanel.browseLogosButton.text=Browse AutopsyOptionsPanel.agencyLogoPathField.text= SortChooserDialog.label=remove SortChooser.addCriteriaButton.text=Add Sort Criteria @@ -201,3 +199,4 @@ DataResultViewerThumbnail.sortButton.text=Sort CriterionChooser.ascendingRadio.text=\u25b2 Ascending\n CriterionChooser.removeButton.text=Remove CriterionChooser.descendingRadio.text=\u25bc Descending +AutopsyOptionsPanel.agencyLogoPathFieldValidationLabel.text=