diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java index 77ff4f2860..b4c15cc0e2 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java @@ -19,9 +19,9 @@ package org.sleuthkit.autopsy.casemodule; import java.awt.BorderLayout; +import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.Component; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; @@ -30,15 +30,15 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Level; -import javax.swing.JPanel; import javax.swing.JList; +import javax.swing.JPanel; import javax.swing.JSeparator; -import javax.swing.event.DocumentEvent; import javax.swing.ListCellRenderer; +import javax.swing.event.DocumentEvent; import org.openide.util.Lookup; import org.openide.util.NbBundle; -import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; +import org.sleuthkit.autopsy.coreutils.Logger; /** * visual component for the first panel of add image wizard. Allows the user to @@ -48,9 +48,13 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; final class AddImageWizardChooseDataSourceVisual extends JPanel { static final Logger logger = Logger.getLogger(AddImageWizardChooseDataSourceVisual.class.getName()); + private AddImageWizardChooseDataSourcePanel wizPanel; + private JPanel currentPanel; + private Map datasourceProcessorsMap = new HashMap<>(); + List coreDSPTypes = new ArrayList<>(); /** @@ -65,6 +69,7 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { customInit(); } + @SuppressWarnings({"rawtypes", "unchecked"}) private void customInit() { typePanel.setLayout(new BorderLayout()); @@ -94,6 +99,7 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { } typeComboBox.setRenderer(new ComboboxSeparatorRenderer(typeComboBox.getRenderer()) { + @Override protected boolean addSeparatorAfter(JList list, Object value, int index) { return (index == coreDSPTypes.size() - 1); @@ -159,7 +165,7 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { * Returns the currently selected DS Processor * * @return DataSourceProcessor the DataSourceProcessor corresponding to the - * data source type selected in the combobox + * data source type selected in the combobox */ protected DataSourceProcessor getCurrentDSProcessor() { // get the type of the currently selected panel and then look up @@ -297,16 +303,20 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { this.wizPanel.enableNextButton(getCurrentDSProcessor().isPanelValid()); } + @SuppressWarnings("rawtypes") public abstract class ComboboxSeparatorRenderer implements ListCellRenderer { private ListCellRenderer delegate; + private JPanel separatorPanel = new JPanel(new BorderLayout()); + private JSeparator separator = new JSeparator(); public ComboboxSeparatorRenderer(ListCellRenderer delegate) { this.delegate = delegate; } + @SuppressWarnings("unchecked") @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component comp = delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index 41aee09d6d..ce3d427c20 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -18,7 +18,6 @@ */ package org.sleuthkit.autopsy.casemodule; -import org.sleuthkit.autopsy.coreutils.LocalDisk; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -41,22 +40,29 @@ import javax.swing.ListCellRenderer; import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; import javax.swing.event.ListDataListener; - import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; +import org.sleuthkit.autopsy.coreutils.LocalDisk; import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; +import org.sleuthkit.autopsy.coreutils.PlatformUtil; + /** - * ImageTypePanel for adding a local disk or partition such as PhysicalDrive0 or C:. + * ImageTypePanel for adding a local disk or partition such as PhysicalDrive0 or + * C:. */ - final class LocalDiskPanel extends JPanel { +final class LocalDiskPanel extends JPanel { + private static final Logger logger = Logger.getLogger(LocalDiskPanel.class.getName()); - + private static LocalDiskPanel instance; + private PropertyChangeSupport pcs = null; + private List disks; + private LocalDiskModel model; + private boolean enableNext = false; /** @@ -66,11 +72,11 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; this.disks = new ArrayList<>(); initComponents(); customInit(); - + createTimeZoneList(); - + } - + /** * Get the default instance of this panel. */ @@ -80,16 +86,16 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; } return instance; } - - + + @SuppressWarnings("unchecked") private void customInit() { model = new LocalDiskModel(); diskComboBox.setModel(model); diskComboBox.setRenderer(model); - + errorLabel.setText(""); diskComboBox.setEnabled(false); - + } /** @@ -176,15 +182,15 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; /** * Return the currently selected disk path. + * * @return String selected disk path */ //@Override public String getContentPaths() { - if(disks.size() > 0) { + if (disks.size() > 0) { LocalDisk selected = (LocalDisk) diskComboBox.getSelectedItem(); return selected.getPath(); - } - else { + } else { return ""; } } @@ -192,21 +198,21 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; /** * Set the selected disk. */ - // @Override + // @Override public void setContentPath(String s) { - for(int i=0; i physical = new ArrayList<>(); + List partitions = new ArrayList<>(); - + //private String SELECT = "Select a local disk:"; private String LOADING = NbBundle.getMessage(this.getClass(), "LocalDiskPanel.localDiskModel.loading.msg"); + LocalDiskThread worker = null; - + private void loadDisks() { - + // if there is a worker already building the lists, then cancel it first. - if (loadingDisks && worker != null) { + if (loadingDisks && worker != null) { worker.cancel(false); } - + // Clear the lists errorLabel.setText(""); disks = new ArrayList<>(); @@ -323,20 +335,18 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; worker = new LocalDiskThread(); worker.execute(); - - + } @Override public void setSelectedItem(Object anItem) { - if(ready) { + if (ready) { selected = (LocalDisk) anItem; enableNext = true; - + try { pcs.firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.UPDATE_UI.toString(), false, true); - } - catch (Exception e) { + } catch (Exception e) { logger.log(Level.SEVERE, "LocalDiskPanel listener threw exception", e); //NON-NLS MessageNotifyUtil.Notify.show(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.moduleErr"), NbBundle.getMessage(this.getClass(), "LocalDiskPanel.moduleErr.msg"), @@ -367,15 +377,16 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; @Override public void removeListDataListener(ListDataListener l) { } - + + @SuppressWarnings("rawtypes") @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel(); - if(index == physical.size() - 1) { + if (index == physical.size() - 1) { panel.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH); } - + if (isSelected) { label.setBackground(list.getSelectionBackground()); label.setForeground(list.getSelectionForeground()); @@ -383,9 +394,9 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; label.setBackground(list.getBackground()); label.setForeground(list.getForeground()); } - + String localDiskString = value.toString(); - if(localDiskString.equals(LOADING)) { + if (localDiskString.equals(LOADING)) { label.setText(LOADING); label.setFont(label.getFont().deriveFont(Font.ITALIC)); label.setBackground(Color.GRAY); @@ -394,12 +405,13 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; } label.setOpaque(true); label.setBorder(new EmptyBorder(2, 2, 2, 2)); - + panel.add(label, BorderLayout.CENTER); return panel; } - - class LocalDiskThread extends SwingWorker { + + class LocalDiskThread extends SwingWorker { + private Logger logger = Logger.getLogger(LocalDiskThread.class.getName()); @Override @@ -407,13 +419,13 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; // Populate the lists physical = PlatformUtil.getPhysicalDrives(); partitions = PlatformUtil.getPartitions(); - + return null; } - + private void displayErrors() { - if(physical.isEmpty() && partitions.isEmpty()) { - if(PlatformUtil.isWindowsOS()) { + if (physical.isEmpty() && partitions.isEmpty()) { + if (PlatformUtil.isWindowsOS()) { errorLabel.setText( NbBundle.getMessage(this.getClass(), "LocalDiskPanel.errLabel.disksNotDetected.text")); errorLabel.setToolTipText(NbBundle.getMessage(this.getClass(), @@ -425,14 +437,14 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; "LocalDiskPanel.errLabel.drivesNotDetected.toolTipText")); } diskComboBox.setEnabled(false); - } else if(physical.isEmpty()) { + } else if (physical.isEmpty()) { errorLabel.setText( NbBundle.getMessage(this.getClass(), "LocalDiskPanel.errLabel.someDisksNotDetected.text")); errorLabel.setToolTipText(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.errLabel.someDisksNotDetected.toolTipText")); } } - + @Override protected void done() { try { @@ -450,11 +462,11 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; ready = true; worker = null; loadingDisks = false; - - disks.addAll(physical); - disks.addAll(partitions); - - if(disks.size() > 0) { + + disks.addAll(physical); + disks.addAll(partitions); + + if (disks.size() > 0) { diskComboBox.setEnabled(true); diskComboBox.setSelectedIndex(0); } diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbSearchPanel.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbSearchPanel.java index ca5f05251e..fcce2b58df 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbSearchPanel.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbSearchPanel.java @@ -131,7 +131,7 @@ import org.sleuthkit.autopsy.ingest.IngestManager; * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") // //GEN-BEGIN:initComponents private void initComponents() { @@ -172,7 +172,7 @@ import org.sleuthkit.autopsy.ingest.IngestManager; } }); jScrollPane1.setViewportView(hashTable); - hashTable.getColumnModel().getColumn(0).setHeaderValue(org.openide.util.NbBundle.getMessage(HashDbSearchPanel.class, "HashDbSearchPanel.hashTable.columnModel.title0")); // NOI18N + hashTable.getColumnModel().getColumn(0).setHeaderValue(org.openide.util.NbBundle.getMessage(HashDbSearchPanel.class, "HashDbSearchPanel.hashTable.columnModel.title0")); // NOI18N hashField.setText(org.openide.util.NbBundle.getMessage(HashDbSearchPanel.class, "HashDbSearchPanel.hashField.text")); // NOI18N