Suppressed some compiler warnings with annotations.

This commit is contained in:
Jeff Wallace 2013-11-27 13:46:35 -05:00
parent 757e1ffa97
commit 341db41da6
5 changed files with 34 additions and 18 deletions

View File

@ -60,6 +60,10 @@
<StringArray count="0"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JComboBox&lt;&gt;()"/>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;LocalDisk&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="errorLabel">
<Properties>

View File

@ -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<LocalDisk> disks = new ArrayList<LocalDisk>();
private List<LocalDisk> 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<LocalDisk>();
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 {
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox diskComboBox;
private javax.swing.JComboBox<LocalDisk> 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<LocalDisk>, ListCellRenderer<LocalDisk> {
private LocalDisk selected;
private boolean ready = false;
List<LocalDisk> physical = new ArrayList<LocalDisk>();
List<LocalDisk> partitions = new ArrayList<LocalDisk>();
List<LocalDisk> physical = new ArrayList<>();
List<LocalDisk> 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<LocalDisk>();
physical = new ArrayList<LocalDisk>();
partitions = new ArrayList<LocalDisk>();
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<? extends LocalDisk> 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));

View File

@ -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<WizardDescriptor>[] getPanels() {
if (panels == null) {
panels = new WizardDescriptor.Panel[]{

View File

@ -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;

View File

@ -58,6 +58,7 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer;
public class DataResultViewerTable extends AbstractDataResultViewer {
private String firstColumnLabel = "Name";
@SuppressWarnings("rawtypes")
private Set<Property> propertiesAcc = new LinkedHashSet<>();
private static final Logger logger = Logger.getLogger(DataResultViewerTable.class.getName());
private final DummyNodeListener dummyNodeListener = new DummyNodeListener();