suppress warnings

This commit is contained in:
jmillman
2014-08-26 12:45:55 -04:00
parent bb8bfd4167
commit a705f78e2a
3 changed files with 103 additions and 81 deletions
@@ -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<String, DataSourceProcessor> datasourceProcessorsMap = new HashMap<>();
List<String> 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);
@@ -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<LocalDisk> 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<disks.size(); i++) {
if(disks.get(i).getPath().equals(s)) {
for (int i = 0; i < disks.size(); i++) {
if (disks.get(i).getPath().equals(s)) {
diskComboBox.setSelectedIndex(i);
}
}
}
public String getTimeZone() {
String tz = timeZoneComboBox.getSelectedItem().toString();
return tz.substring(tz.indexOf(")") + 2).trim();
}
boolean getNoFatOrphans() {
return noFatOrphansCheckbox.isSelected();
}
@@ -214,54 +220,53 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
/**
* Should we enable the wizard's next button?
* Always return true because we control the possible selections.
*
* @return true
*/
//@Override
public boolean validatePanel() {
return enableNext;
}
//@Override
public void reset() {
//nothing to reset
}
/**
/**
* Set the focus to the diskComboBox and refreshes the list of disks.
*/
// @Override
// @Override
public void select() {
diskComboBox.requestFocusInWindow();
model.loadDisks();
}
@Override
public synchronized void addPropertyChangeListener(PropertyChangeListener pcl) {
super.addPropertyChangeListener(pcl);
model.loadDisks();
if (pcs == null) {
pcs = new PropertyChangeSupport(this);
}
}
@Override
public synchronized void addPropertyChangeListener(PropertyChangeListener pcl) {
super.addPropertyChangeListener(pcl);
if (pcs == null) {
pcs = new PropertyChangeSupport(this);
}
pcs.addPropertyChangeListener(pcl);
}
@Override
public void removePropertyChangeListener(PropertyChangeListener pcl) {
super.removePropertyChangeListener(pcl);
super.removePropertyChangeListener(pcl);
pcs.removePropertyChangeListener(pcl);
}
/**
/**
* Creates the drop down list for the time zones and then makes the local
* machine time zone to be selected.
*/
public void createTimeZoneList() {
public void createTimeZoneList() {
// load and add all timezone
String[] ids = SimpleTimeZone.getAvailableIDs();
for (String id : ids) {
@@ -292,25 +297,32 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
// set the selected timezone
timeZoneComboBox.setSelectedItem(formatted);
}
@SuppressWarnings("rawtypes")
private class LocalDiskModel implements ComboBoxModel, ListCellRenderer {
private Object selected;
private boolean ready = false;
private volatile boolean loadingDisks = false;
List<LocalDisk> physical = new ArrayList<>();
List<LocalDisk> 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<Object,Void> {
class LocalDiskThread extends SwingWorker<Object, Void> {
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);
}
@@ -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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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