From 341db41da6f815b6211ac4bf4a7ff1d5459c6fb2 Mon Sep 17 00:00:00 2001 From: Jeff Wallace Date: Wed, 27 Nov 2013 13:46:35 -0500 Subject: [PATCH] Suppressed some compiler warnings with annotations. --- .../autopsy/casemodule/LocalDiskPanel.form | 4 ++ .../autopsy/casemodule/LocalDiskPanel.java | 44 ++++++++++++------- .../casemodule/NewCaseWizardAction.java | 2 +- .../autopsy/contentviewers/Utilities.java | 1 + .../corecomponents/DataResultViewerTable.java | 1 + 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.form b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.form index a0b5f3f431..4f56ea00f8 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.form +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.form @@ -60,6 +60,10 @@ + + + + diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index 6a51382940..cf9d0fa06a 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -46,7 +46,7 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil; public class LocalDiskPanel extends ContentTypePanel { private static LocalDiskPanel instance; private PropertyChangeSupport pcs = null; - private List disks = new ArrayList(); + private List disks; private LocalDiskModel model; private boolean enableNext = false; @@ -54,6 +54,7 @@ public class LocalDiskPanel extends ContentTypePanel { * Creates new form LocalDiskPanel */ public LocalDiskPanel() { + this.disks = new ArrayList(); initComponents(); customInit(); } @@ -87,7 +88,7 @@ public class LocalDiskPanel extends ContentTypePanel { private void initComponents() { diskLabel = new javax.swing.JLabel(); - diskComboBox = new javax.swing.JComboBox(); + diskComboBox = new javax.swing.JComboBox<>(); errorLabel = new javax.swing.JLabel(); setMinimumSize(new java.awt.Dimension(0, 65)); @@ -120,7 +121,7 @@ public class LocalDiskPanel extends ContentTypePanel { ); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JComboBox diskComboBox; + private javax.swing.JComboBox diskComboBox; private javax.swing.JLabel diskLabel; private javax.swing.JLabel errorLabel; // End of variables declaration//GEN-END:variables @@ -207,21 +208,29 @@ public class LocalDiskPanel extends ContentTypePanel { pcs.removePropertyChangeListener(pcl); } - private class LocalDiskModel implements ComboBoxModel, ListCellRenderer { - private Object selected; + private class LocalDiskModel implements ComboBoxModel, ListCellRenderer { + private LocalDisk selected; private boolean ready = false; - List physical = new ArrayList(); - List partitions = new ArrayList(); + List physical = new ArrayList<>(); + List partitions = new ArrayList<>(); //private String SELECT = "Select a local disk:"; - private String LOADING = "Loading local disks..."; + private String LOADING_STR = "Loading local disks..."; + + // Dummy local disk that will be displayed as a loading message + private LocalDisk LOADING = new LocalDisk("", "", 0L) { + @Override + public String toString() { + return LOADING_STR; + } + }; private void loadDisks() { // Clear the lists errorLabel.setText(""); - disks = new ArrayList(); - physical = new ArrayList(); - partitions = new ArrayList(); + disks = new ArrayList<>(); + physical = new ArrayList<>(); + partitions = new ArrayList<>(); diskComboBox.setEnabled(false); ready = false; @@ -232,7 +241,7 @@ public class LocalDiskPanel extends ContentTypePanel { @Override public void setSelectedItem(Object anItem) { if(ready) { - selected = anItem; + selected = (LocalDisk) anItem; enableNext = true; pcs.firePropertyChange(AddImageWizardChooseDataSourceVisual.EVENT.UPDATE_UI.toString(), false, true); } @@ -249,7 +258,7 @@ public class LocalDiskPanel extends ContentTypePanel { } @Override - public Object getElementAt(int index) { + public LocalDisk getElementAt(int index) { return ready ? disks.get(index) : LOADING; } @@ -262,7 +271,7 @@ public class LocalDiskPanel extends ContentTypePanel { } @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(JList list, LocalDisk value, int index, boolean isSelected, boolean cellHasFocus) { JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel(); if(index == physical.size() - 1) { @@ -277,13 +286,14 @@ public class LocalDiskPanel extends ContentTypePanel { label.setForeground(list.getForeground()); } - if(value !=null && value.equals(LOADING)) { + String localDiskString = value.toString(); + if(localDiskString.equals(LOADING_STR)) { Font font = new Font(label.getFont().getName(), Font.ITALIC, label.getFont().getSize()); - label.setText(LOADING); + label.setText(LOADING_STR); label.setFont(font); label.setBackground(Color.GRAY); } else { - label.setText(value != null ? value.toString() : ""); + label.setText(value.toString()); } label.setOpaque(true); label.setBorder(new EmptyBorder(2, 2, 2, 2)); diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java index b57632a603..f3c5e63009 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java @@ -115,7 +115,7 @@ public final class NewCaseWizardAction extends CallableSystemAction { * Initialize panels representing individual wizard's steps and sets * various properties for them influencing wizard appearance. */ - @SuppressWarnings({"unchecked"}) + @SuppressWarnings({"unchecked", "rawtypes"}) private WizardDescriptor.Panel[] getPanels() { if (panels == null) { panels = new WizardDescriptor.Panel[]{ diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/Utilities.java b/Core/src/org/sleuthkit/autopsy/contentviewers/Utilities.java index 6a3c40dfd5..458c348e26 100755 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/Utilities.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/Utilities.java @@ -37,6 +37,7 @@ public class Utilities { * * @return true if jpeg file, false otherwise */ + @SuppressWarnings("cast") public static boolean isJpegFileHeader(AbstractFile file) { if (file.getSize() < 100) { return false; diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java index 45c87e0752..3fdbdc32cb 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java @@ -58,6 +58,7 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer; public class DataResultViewerTable extends AbstractDataResultViewer { private String firstColumnLabel = "Name"; + @SuppressWarnings("rawtypes") private Set propertiesAcc = new LinkedHashSet<>(); private static final Logger logger = Logger.getLogger(DataResultViewerTable.class.getName()); private final DummyNodeListener dummyNodeListener = new DummyNodeListener();