2347 Changed Jcombobox for Local disk selection to table

This commit is contained in:
William Schaefer 2017-03-13 11:53:36 -04:00
parent 8a4b78daee
commit 664a591a45
3 changed files with 283 additions and 308 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2013-2016 Basis Technology Corp. * Copyright 2013-2017 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -38,9 +38,9 @@ import org.sleuthkit.autopsy.framework.AutoIngestDataSourceProcessor;
* wizard. It also provides a run method overload to allow it to be used * wizard. It also provides a run method overload to allow it to be used
* independently of the wizard. * independently of the wizard.
*/ */
@ServiceProviders(value={ @ServiceProviders(value = {
@ServiceProvider(service=DataSourceProcessor.class), @ServiceProvider(service = DataSourceProcessor.class),
@ServiceProvider(service=AutoIngestDataSourceProcessor.class)} @ServiceProvider(service = AutoIngestDataSourceProcessor.class)}
) )
public class LocalDiskDSProcessor implements DataSourceProcessor, AutoIngestDataSourceProcessor { public class LocalDiskDSProcessor implements DataSourceProcessor, AutoIngestDataSourceProcessor {
@ -101,7 +101,7 @@ public class LocalDiskDSProcessor implements DataSourceProcessor, AutoIngestData
*/ */
@Override @Override
public JPanel getPanel() { public JPanel getPanel() {
configPanel.select(); configPanel.refreshTable();
return configPanel; return configPanel;
} }
@ -138,7 +138,7 @@ public class LocalDiskDSProcessor implements DataSourceProcessor, AutoIngestData
drivePath = configPanel.getContentPaths(); drivePath = configPanel.getContentPaths();
timeZone = configPanel.getTimeZone(); timeZone = configPanel.getTimeZone();
ignoreFatOrphanFiles = configPanel.getNoFatOrphans(); ignoreFatOrphanFiles = configPanel.getNoFatOrphans();
if(configPanel.getImageWriterEnabled()){ if (configPanel.getImageWriterEnabled()) {
imageWriterPath = configPanel.getImageWriterPath(); imageWriterPath = configPanel.getImageWriterPath();
} }
} }
@ -192,7 +192,6 @@ public class LocalDiskDSProcessor implements DataSourceProcessor, AutoIngestData
*/ */
@Override @Override
public void reset() { public void reset() {
configPanel.reset();
deviceId = null; deviceId = null;
drivePath = null; drivePath = null;
timeZone = null; timeZone = null;
@ -214,7 +213,7 @@ public class LocalDiskDSProcessor implements DataSourceProcessor, AutoIngestData
// ELTODO this needs to be tested more. do these methods actually work correctly? // ELTODO this needs to be tested more. do these methods actually work correctly?
// or should I use PlatformUtil.getPhysicalDrives() and PlatformUtil.getPartitions() instead? // or should I use PlatformUtil.getPhysicalDrives() and PlatformUtil.getPartitions() instead?
String path = dataSourcePath.toString(); String path = dataSourcePath.toString();
if ( (DriveUtils.isPhysicalDrive(path) || DriveUtils.isPartition(path)) && DriveUtils.driveExists(path) ) { if ((DriveUtils.isPhysicalDrive(path) || DriveUtils.isPartition(path)) && DriveUtils.driveExists(path)) {
return 90; return 90;
} }

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> <Form version="1.6" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties> <Properties>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 420]"/> <Dimension value="[0, 65]"/>
</Property> </Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[485, 410]"/> <Dimension value="[485, 65]"/>
</Property> </Property>
</Properties> </Properties>
<AuxValues> <AuxValues>
@ -25,39 +25,41 @@
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="pathTextField" alignment="1" min="-2" pref="362" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="diskLabel" min="-2" max="-2" attributes="0"/> <Component id="diskLabel" min="-2" max="-2" attributes="0"/>
<Component id="diskComboBox" min="-2" pref="345" max="-2" attributes="0"/>
<Component id="errorLabel" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="errorLabel" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="timeZoneLabel" min="-2" max="-2" attributes="0"/> <Component id="timeZoneLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="timeZoneComboBox" min="-2" pref="215" max="-2" attributes="0"/> <Component id="timeZoneComboBox" max="32767" attributes="0"/>
</Group> </Group>
<Component id="noFatOrphansCheckbox" min="-2" max="-2" attributes="0"/> <Component id="noFatOrphansCheckbox" min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane1" alignment="0" min="-2" pref="461" max="-2" attributes="0"/>
<Group type="103" alignment="0" groupAlignment="1" attributes="0">
<Component id="copyImageCheckbox" min="-2" max="-2" attributes="0"/> <Component id="copyImageCheckbox" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace min="21" pref="21" max="-2" attributes="0"/>
<Component id="descLabel" min="-2" max="-2" attributes="0"/> <Component id="descLabel" min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="browseButton" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/> <EmptySpace min="21" pref="21" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" pref="423" max="-2" attributes="0"/>
<Component id="imageWriterErrorLabel" min="-2" max="-2" attributes="0"/> <Component id="imageWriterErrorLabel" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="pathTextField" min="-2" pref="342" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="browseButton" pref="0" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</Group> </Group>
<EmptySpace min="0" pref="29" max="32767" attributes="0"/> </Group>
</Group>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -66,8 +68,8 @@
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="diskLabel" min="-2" max="-2" attributes="0"/> <Component id="diskLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="diskComboBox" min="-2" max="-2" attributes="0"/> <Component id="jScrollPane1" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="13" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="errorLabel" min="-2" max="-2" attributes="0"/> <Component id="errorLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
@ -81,15 +83,15 @@
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="copyImageCheckbox" min="-2" max="-2" attributes="0"/> <Component id="copyImageCheckbox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Component id="pathTextField" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="browseButton" min="-2" max="-2" attributes="0"/>
<Component id="browseButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="pathTextField" min="-2" pref="23" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="imageWriterErrorLabel" min="-2" max="-2" attributes="0"/> <Component id="imageWriterErrorLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="170" max="32767" attributes="0"/> <EmptySpace max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -106,22 +108,11 @@
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.diskLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.diskLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> <AccessibilityProperties>
<Component class="javax.swing.JComboBox" name="diskComboBox"> <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<Properties> <ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.diskLabel.AccessibleContext.accessibleName" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="false" component="diskComboBox" property="font" relativeSize="false" size="11"/>
</FontInfo>
</Property> </Property>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> </AccessibilityProperties>
<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>
<Component class="javax.swing.JLabel" name="errorLabel"> <Component class="javax.swing.JLabel" name="errorLabel">
<Properties> <Properties>
@ -193,16 +184,64 @@
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="diskTable">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="model" type="code"/>
</Property>
<Property name="selectionModel" type="javax.swing.ListSelectionModel" editor="org.netbeans.modules.form.editors2.JTableSelectionModelEditor">
<JTableSelectionModel selectionMode="0"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JCheckBox" name="copyImageCheckbox"> <Component class="javax.swing.JCheckBox" name="copyImageCheckbox">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.copyImageCheckbox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.copyImageCheckbox1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
<AccessibilityProperties>
<Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.copyImageCheckbox.AccessibleContext.accessibleName" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</AccessibilityProperties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="copyImageCheckboxActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="copyImageCheckboxActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JTextField" name="pathTextField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.pathTextField1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="pathTextFieldKeyReleased"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="browseButton">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.browseButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="imageWriterErrorLabel"> <Component class="javax.swing.JLabel" name="imageWriterErrorLabel">
<Properties> <Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
@ -214,37 +253,9 @@
<Color blue="0" green="0" red="ff" type="rgb"/> <Color blue="0" green="0" red="ff" type="rgb"/>
</Property> </Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.imageWriterErrorLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.imageWriterErrorLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="pathTextField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.pathTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="pathTextFieldKeyReleased"/>
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="pathTextFieldKeyTyped"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="browseButton">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="LocalDiskPanel.browseButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseButtonActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2016 Basis Technology Corp. * Copyright 2011-2017 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -18,10 +18,6 @@
*/ */
package org.sleuthkit.autopsy.casemodule; package org.sleuthkit.autopsy.casemodule;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.io.File; import java.io.File;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
@ -31,16 +27,13 @@ import java.util.SimpleTimeZone;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.ComboBoxModel;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.ListCellRenderer;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import javax.swing.border.EmptyBorder; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListDataListener; import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
import org.sleuthkit.autopsy.coreutils.LocalDisk; import org.sleuthkit.autopsy.coreutils.LocalDisk;
@ -58,25 +51,44 @@ final class LocalDiskPanel extends JPanel {
private static LocalDiskPanel instance; private static LocalDiskPanel instance;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private List<LocalDisk> disks; private List<LocalDisk> disks;
private LocalDiskModel model;
private boolean enableNext = false; private boolean enableNext = false;
private final LocalDiskModel model;
private final JFileChooser fc = new JFileChooser(); private final JFileChooser fc = new JFileChooser();
/** /**
* Creates new form LocalDiskPanel * Creates new form LocalDiskPanel
*/ */
public LocalDiskPanel() { LocalDiskPanel() {
this.model = new LocalDiskModel();
this.disks = new ArrayList<>(); this.disks = new ArrayList<>();
initComponents(); initComponents();
customInit(); customInit();
createTimeZoneList(); createTimeZoneList();
refreshTable();
diskTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (diskTable.getSelectedRow() >= 0 && diskTable.getSelectedRow() < disks.size()) {
enableNext = true;
try {
firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.UPDATE_UI.toString(), false, true);
} catch (Exception ex) {
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"),
MessageNotifyUtil.MessageType.ERROR);
}
}
}
});
} }
/** /**
* Get the default instance of this panel. * Get the default instance of this panel.
*/ */
public static synchronized LocalDiskPanel getDefault() { static synchronized LocalDiskPanel getDefault() {
if (instance == null) { if (instance == null) {
instance = new LocalDiskPanel(); instance = new LocalDiskPanel();
} }
@ -85,13 +97,9 @@ final class LocalDiskPanel extends JPanel {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void customInit() { private void customInit() {
model = new LocalDiskModel();
diskComboBox.setModel(model);
diskComboBox.setRenderer(model);
errorLabel.setVisible(false); errorLabel.setVisible(false);
errorLabel.setText(""); errorLabel.setText("");
diskComboBox.setEnabled(false); diskTable.setEnabled(false);
imageWriterErrorLabel.setOpaque(true); imageWriterErrorLabel.setOpaque(true);
imageWriterErrorLabel.setText(""); imageWriterErrorLabel.setText("");
pathTextField.setEnabled(copyImageCheckbox.isSelected()); pathTextField.setEnabled(copyImageCheckbox.isSelected());
@ -108,26 +116,25 @@ final class LocalDiskPanel extends JPanel {
private void initComponents() { private void initComponents() {
diskLabel = new javax.swing.JLabel(); diskLabel = new javax.swing.JLabel();
diskComboBox = new javax.swing.JComboBox<>();
errorLabel = new javax.swing.JLabel(); errorLabel = new javax.swing.JLabel();
timeZoneLabel = new javax.swing.JLabel(); timeZoneLabel = new javax.swing.JLabel();
timeZoneComboBox = new javax.swing.JComboBox<>(); timeZoneComboBox = new javax.swing.JComboBox<>();
noFatOrphansCheckbox = new javax.swing.JCheckBox(); noFatOrphansCheckbox = new javax.swing.JCheckBox();
descLabel = new javax.swing.JLabel(); descLabel = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
diskTable = new javax.swing.JTable();
copyImageCheckbox = new javax.swing.JCheckBox(); copyImageCheckbox = new javax.swing.JCheckBox();
imageWriterErrorLabel = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
pathTextField = new javax.swing.JTextField(); pathTextField = new javax.swing.JTextField();
browseButton = new javax.swing.JButton(); browseButton = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
imageWriterErrorLabel = new javax.swing.JLabel();
setMinimumSize(new java.awt.Dimension(0, 420)); setMinimumSize(new java.awt.Dimension(0, 65));
setPreferredSize(new java.awt.Dimension(485, 410)); setPreferredSize(new java.awt.Dimension(485, 65));
diskLabel.setFont(diskLabel.getFont().deriveFont(diskLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11)); diskLabel.setFont(diskLabel.getFont().deriveFont(diskLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
org.openide.awt.Mnemonics.setLocalizedText(diskLabel, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.diskLabel.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(diskLabel, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.diskLabel.text")); // NOI18N
diskComboBox.setFont(diskComboBox.getFont().deriveFont(diskComboBox.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
errorLabel.setFont(errorLabel.getFont().deriveFont(errorLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11)); errorLabel.setFont(errorLabel.getFont().deriveFont(errorLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
errorLabel.setForeground(new java.awt.Color(255, 0, 0)); errorLabel.setForeground(new java.awt.Color(255, 0, 0));
org.openide.awt.Mnemonics.setLocalizedText(errorLabel, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.errorLabel.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(errorLabel, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.errorLabel.text")); // NOI18N
@ -145,74 +152,76 @@ final class LocalDiskPanel extends JPanel {
descLabel.setFont(descLabel.getFont().deriveFont(descLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11)); descLabel.setFont(descLabel.getFont().deriveFont(descLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
org.openide.awt.Mnemonics.setLocalizedText(descLabel, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.descLabel.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(descLabel, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.descLabel.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(copyImageCheckbox, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.copyImageCheckbox.text")); // NOI18N diskTable.setModel(model);
diskTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane1.setViewportView(diskTable);
org.openide.awt.Mnemonics.setLocalizedText(copyImageCheckbox, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.copyImageCheckbox1.text")); // NOI18N
copyImageCheckbox.addActionListener(new java.awt.event.ActionListener() { copyImageCheckbox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
copyImageCheckboxActionPerformed(evt); copyImageCheckboxActionPerformed(evt);
} }
}); });
imageWriterErrorLabel.setFont(imageWriterErrorLabel.getFont().deriveFont(imageWriterErrorLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11)); pathTextField.setText(org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.pathTextField1.text")); // NOI18N
imageWriterErrorLabel.setForeground(new java.awt.Color(255, 0, 0));
org.openide.awt.Mnemonics.setLocalizedText(imageWriterErrorLabel, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.imageWriterErrorLabel.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.jLabel1.text")); // NOI18N
pathTextField.setText(org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.pathTextField.text")); // NOI18N
pathTextField.addKeyListener(new java.awt.event.KeyAdapter() { pathTextField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) { public void keyReleased(java.awt.event.KeyEvent evt) {
pathTextFieldKeyReleased(evt); pathTextFieldKeyReleased(evt);
} }
public void keyTyped(java.awt.event.KeyEvent evt) {
pathTextFieldKeyTyped(evt);
}
}); });
org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.browseButton.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.browseButton1.text")); // NOI18N
browseButton.addActionListener(new java.awt.event.ActionListener() { browseButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
browseButtonActionPerformed(evt); browseButtonActionPerformed(evt);
} }
}); });
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.jLabel2.text")); // NOI18N
imageWriterErrorLabel.setFont(imageWriterErrorLabel.getFont().deriveFont(imageWriterErrorLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
imageWriterErrorLabel.setForeground(new java.awt.Color(255, 0, 0));
org.openide.awt.Mnemonics.setLocalizedText(imageWriterErrorLabel, org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.imageWriterErrorLabel1.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(diskLabel) .addComponent(diskLabel)
.addComponent(diskComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 345, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(errorLabel) .addComponent(errorLabel)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(timeZoneLabel) .addComponent(timeZoneLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(timeZoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(timeZoneComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(noFatOrphansCheckbox) .addComponent(noFatOrphansCheckbox)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 461, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(copyImageCheckbox) .addComponent(copyImageCheckbox)
.addGroup(layout.createSequentialGroup() .addComponent(descLabel))
.addGap(21, 21, 21)
.addComponent(descLabel))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(browseButton))
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21) .addGap(21, 21, 21)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 423, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(imageWriterErrorLabel)
.addComponent(imageWriterErrorLabel)))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 29, Short.MAX_VALUE)) .addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()
.addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(browseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))))))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(diskLabel) .addComponent(diskLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(diskComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(13, 13, 13) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(errorLabel) .addComponent(errorLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@ -225,17 +234,30 @@ final class LocalDiskPanel extends JPanel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(copyImageCheckbox) .addComponent(copyImageCheckbox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(browseButton)
.addComponent(browseButton)) .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1) .addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(imageWriterErrorLabel) .addComponent(imageWriterErrorLabel)
.addContainerGap(170, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
diskLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.diskLabel.AccessibleContext.accessibleName")); // NOI18N
copyImageCheckbox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(LocalDiskPanel.class, "LocalDiskPanel.copyImageCheckbox.AccessibleContext.accessibleName")); // NOI18N
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void copyImageCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyImageCheckboxActionPerformed
pathTextField.setEnabled(copyImageCheckbox.isSelected());
browseButton.setEnabled(copyImageCheckbox.isSelected());
fireUpdateEvent();
}//GEN-LAST:event_copyImageCheckboxActionPerformed
private void pathTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_pathTextFieldKeyReleased
fireUpdateEvent();
}//GEN-LAST:event_pathTextFieldKeyReleased
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
String oldText = pathTextField.getText(); String oldText = pathTextField.getText();
// set the current directory of the FileChooser if the ImagePath Field is valid // set the current directory of the FileChooser if the ImagePath Field is valid
@ -252,36 +274,23 @@ final class LocalDiskPanel extends JPanel {
fireUpdateEvent(); fireUpdateEvent();
}//GEN-LAST:event_browseButtonActionPerformed }//GEN-LAST:event_browseButtonActionPerformed
private void copyImageCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyImageCheckboxActionPerformed
pathTextField.setEnabled(copyImageCheckbox.isSelected());
browseButton.setEnabled(copyImageCheckbox.isSelected());
fireUpdateEvent();
}//GEN-LAST:event_copyImageCheckboxActionPerformed
private void pathTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_pathTextFieldKeyTyped
}//GEN-LAST:event_pathTextFieldKeyTyped
private void pathTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_pathTextFieldKeyReleased
fireUpdateEvent();
}//GEN-LAST:event_pathTextFieldKeyReleased
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton browseButton; private javax.swing.JButton browseButton;
private javax.swing.JCheckBox copyImageCheckbox; private javax.swing.JCheckBox copyImageCheckbox;
private javax.swing.JLabel descLabel; private javax.swing.JLabel descLabel;
private javax.swing.JComboBox<LocalDisk> diskComboBox;
private javax.swing.JLabel diskLabel; private javax.swing.JLabel diskLabel;
private javax.swing.JTable diskTable;
private javax.swing.JLabel errorLabel; private javax.swing.JLabel errorLabel;
private javax.swing.JLabel imageWriterErrorLabel; private javax.swing.JLabel imageWriterErrorLabel;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JCheckBox noFatOrphansCheckbox; private javax.swing.JCheckBox noFatOrphansCheckbox;
private javax.swing.JTextField pathTextField; private javax.swing.JTextField pathTextField;
private javax.swing.JComboBox<String> timeZoneComboBox; private javax.swing.JComboBox<String> timeZoneComboBox;
private javax.swing.JLabel timeZoneLabel; private javax.swing.JLabel timeZoneLabel;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
private void fireUpdateEvent(){ private void fireUpdateEvent() {
try { try {
firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.UPDATE_UI.toString(), false, true); firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.UPDATE_UI.toString(), false, true);
} catch (Exception e) { } catch (Exception e) {
@ -297,27 +306,17 @@ final class LocalDiskPanel extends JPanel {
* *
* @return String selected disk path * @return String selected disk path
*/ */
public String getContentPaths() { String getContentPaths() {
if (disks.size() > 0) { if (disks.size() > 0) {
LocalDisk selected = (LocalDisk) diskComboBox.getSelectedItem(); int selectedRow = diskTable.getSelectedRow();
LocalDisk selected = disks.get(selectedRow);
return selected.getPath(); return selected.getPath();
} else { } else {
return ""; return "";
} }
} }
/** String getTimeZone() {
* Set the selected disk.
*/
public void setContentPath(String 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(); String tz = timeZoneComboBox.getSelectedItem().toString();
return tz.substring(tz.indexOf(")") + 2).trim(); return tz.substring(tz.indexOf(")") + 2).trim();
@ -327,11 +326,11 @@ final class LocalDiskPanel extends JPanel {
return noFatOrphansCheckbox.isSelected(); return noFatOrphansCheckbox.isSelected();
} }
private static String getDefaultImageWriterFolder(){ private static String getDefaultImageWriterFolder() {
return Paths.get(Case.getCurrentCase().getModuleDirectory(), "Image Writer").toString(); return Paths.get(Case.getCurrentCase().getModuleDirectory(), "Image Writer").toString();
} }
private void setPotentialImageWriterPath(LocalDisk disk){ private void setPotentialImageWriterPath(LocalDisk disk) {
File subDirectory = Paths.get(getDefaultImageWriterFolder()).toFile(); File subDirectory = Paths.get(getDefaultImageWriterFolder()).toFile();
if (!subDirectory.exists()) { if (!subDirectory.exists()) {
@ -344,23 +343,23 @@ final class LocalDiskPanel extends JPanel {
pathTextField.setText(Paths.get(getDefaultImageWriterFolder(), path).toString()); pathTextField.setText(Paths.get(getDefaultImageWriterFolder(), path).toString());
} }
private boolean imageWriterPathIsValid(){ private boolean imageWriterPathIsValid() {
if(pathTextField.getText().isEmpty()){ if (pathTextField.getText().isEmpty()) {
imageWriterErrorLabel.setText(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.imageWriterEmptyPathError.text")); imageWriterErrorLabel.setText(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.imageWriterEmptyPathError.text"));
return false; return false;
} }
File f = new File(pathTextField.getText()); File f = new File(pathTextField.getText());
if(((f.getParentFile() != null) && (! f.getParentFile().exists())) || if (((f.getParentFile() != null) && (!f.getParentFile().exists()))
(f.getParentFile() == null)) { || (f.getParentFile() == null)) {
imageWriterErrorLabel.setText(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.imageWriterDirError.text")); imageWriterErrorLabel.setText(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.imageWriterDirError.text"));
return false; return false;
} }
if(f.isDirectory()){ if (f.isDirectory()) {
imageWriterErrorLabel.setText(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.imageWriterIsDirError.text")); imageWriterErrorLabel.setText(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.imageWriterIsDirError.text"));
return false; return false;
} }
if(f.exists()){ if (f.exists()) {
imageWriterErrorLabel.setText(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.imageWriterFileExistsError.text")); imageWriterErrorLabel.setText(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.imageWriterFileExistsError.text"));
return false; return false;
} }
@ -369,11 +368,11 @@ final class LocalDiskPanel extends JPanel {
return true; return true;
} }
boolean getImageWriterEnabled(){ boolean getImageWriterEnabled() {
return copyImageCheckbox.isSelected(); return copyImageCheckbox.isSelected();
} }
String getImageWriterPath(){ String getImageWriterPath() {
return pathTextField.getText(); return pathTextField.getText();
} }
@ -383,24 +382,18 @@ final class LocalDiskPanel extends JPanel {
* *
* @return true if panel is valid * @return true if panel is valid
*/ */
public boolean validatePanel() { boolean validatePanel() {
if(copyImageCheckbox.isSelected() && if (copyImageCheckbox.isSelected()
! imageWriterPathIsValid()){ && !imageWriterPathIsValid()) {
return false; return false;
} }
return enableNext; return enableNext;
} }
public void reset() {
//nothing to reset
}
/** /**
* Set the focus to the diskComboBox and refreshes the list of disks. * Refreshes the list of disks in the table.
*/ */
public void select() { public void refreshTable() {
diskComboBox.requestFocusInWindow();
model.loadDisks(); model.loadDisks();
} }
@ -440,24 +433,18 @@ final class LocalDiskPanel extends JPanel {
timeZoneComboBox.setSelectedItem(formatted); timeZoneComboBox.setSelectedItem(formatted);
} }
@SuppressWarnings("rawtypes") private class LocalDiskModel implements TableModel {
private class LocalDiskModel implements ComboBoxModel, ListCellRenderer {
private Object selected;
private List<LocalDisk> physicalDrives = new ArrayList<>();
private List<LocalDisk> partitions = new ArrayList<>();
private LocalDiskThread worker = null;
private boolean ready = false; private boolean ready = false;
private volatile boolean loadingDisks = false; private volatile boolean loadingDisks = false;
List<LocalDisk> physicalDrives = new ArrayList<>();
List<LocalDisk> partitions = new ArrayList<>();
//private String SELECT = "Select a local disk:"; //private String SELECT = "Select a local disk:";
private final String LOADING = NbBundle.getMessage(this.getClass(), "LocalDiskPanel.localDiskModel.loading.msg"); private final String LOADING = NbBundle.getMessage(this.getClass(), "LocalDiskPanel.localDiskModel.loading.msg");
private final String NO_DRIVES = NbBundle.getMessage(this.getClass(), "LocalDiskPanel.localDiskModel.nodrives.msg"); private final String NO_DRIVES = NbBundle.getMessage(this.getClass(), "LocalDiskPanel.localDiskModel.nodrives.msg");
LocalDiskThread worker = null;
private void loadDisks() { private void loadDisks() {
// if there is a worker already building the lists, then cancel it first. // if there is a worker already building the lists, then cancel it first.
@ -467,103 +454,82 @@ final class LocalDiskPanel extends JPanel {
// Clear the lists // Clear the lists
errorLabel.setText(""); errorLabel.setText("");
disks = new ArrayList<>(); diskTable.setEnabled(false);
physicalDrives = new ArrayList<>();
partitions = new ArrayList<>();
diskComboBox.setEnabled(false);
ready = false; ready = false;
enableNext = false; enableNext = false;
loadingDisks = true; loadingDisks = true;
worker = new LocalDiskThread(); worker = new LocalDiskThread();
worker.execute(); worker.execute();
} }
@Override @Override
public void setSelectedItem(Object anItem) { public int getRowCount() {
if (ready) {
selected = (LocalDisk) anItem;
enableNext = true;
setPotentialImageWriterPath((LocalDisk) selected);
fireUpdateEvent();
}
}
@Override
public Object getSelectedItem() {
if (ready) {
if (disks.isEmpty()) { if (disks.isEmpty()) {
return NO_DRIVES; return 0;
}
return selected;
} else {
return LOADING;
}
}
@Override
public int getSize() {
if (ready) {
if (disks.isEmpty()) {
return 1;
} }
return disks.size(); return disks.size();
} else { }
return 1;
@Override
public int getColumnCount() {
return 2;
}
@Override
public String getColumnName(int columnIndex) {
switch (columnIndex) {
case 0:
return "Disk Name"; //WJS-TODO
case 1:
return "Disk Size"; //WJS-TODO
default:
return "Unnamed"; //NON-NLS
} }
} }
@Override @Override
public Object getElementAt(int index) { public Class<?> getColumnClass(int columnIndex) {
return String.class;
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
if (ready) { if (ready) {
if (disks.isEmpty()) { if (disks.isEmpty()) {
return NO_DRIVES; return NO_DRIVES;
} }
return disks.get(index); switch (columnIndex) {
case 0:
return disks.get(rowIndex).getName();
case 1:
return disks.get(rowIndex).getReadableSize();
default:
return disks.get(rowIndex).getPath();
}
} else { } else {
return LOADING; return LOADING;
} }
} }
@Override @Override
public void addListDataListener(ListDataListener l) { public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
//setter does nothing they should not be able to modify table
} }
@Override @Override
public void removeListDataListener(ListDataListener l) { public void addTableModelListener(TableModelListener l) {
} }
@SuppressWarnings("rawtypes")
@Override @Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { public void removeTableModelListener(TableModelListener l) {
JPanel panel = new JPanel(new BorderLayout());
JLabel label = new JLabel();
if ((index == physicalDrives.size() - 1) && (physicalDrives.size() > 0)) {
panel.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH);
}
if (isSelected) {
label.setBackground(list.getSelectionBackground());
label.setForeground(list.getSelectionForeground());
} else {
label.setBackground(list.getBackground());
label.setForeground(list.getForeground());
}
if (value != null) {
String localDiskString = value.toString();
label.setText(value.toString());
if ((localDiskString.equals(LOADING)) || (localDiskString.equals(NO_DRIVES))) {
label.setFont(label.getFont().deriveFont(Font.ITALIC));
label.setBackground(Color.GRAY);
}
}
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> {
@ -573,9 +539,10 @@ final class LocalDiskPanel extends JPanel {
@Override @Override
protected Object doInBackground() throws Exception { protected Object doInBackground() throws Exception {
// Populate the lists // Populate the lists
physicalDrives = new ArrayList<>();
partitions = new ArrayList<>();
physicalDrives = PlatformUtil.getPhysicalDrives(); physicalDrives = PlatformUtil.getPhysicalDrives();
partitions = PlatformUtil.getPartitions(); partitions = PlatformUtil.getPartitions();
return null; return null;
} }
@ -592,7 +559,7 @@ final class LocalDiskPanel extends JPanel {
errorLabel.setToolTipText(NbBundle.getMessage(this.getClass(), errorLabel.setToolTipText(NbBundle.getMessage(this.getClass(),
"LocalDiskPanel.errLabel.drivesNotDetected.toolTipText")); "LocalDiskPanel.errLabel.drivesNotDetected.toolTipText"));
} }
diskComboBox.setEnabled(false); diskTable.setEnabled(false);
} else if (physicalDrives.isEmpty()) { } else if (physicalDrives.isEmpty()) {
errorLabel.setText( errorLabel.setText(
NbBundle.getMessage(this.getClass(), "LocalDiskPanel.errLabel.someDisksNotDetected.text")); NbBundle.getMessage(this.getClass(), "LocalDiskPanel.errLabel.someDisksNotDetected.text"));
@ -615,16 +582,14 @@ final class LocalDiskPanel extends JPanel {
if (!this.isCancelled()) { if (!this.isCancelled()) {
enableNext = false; enableNext = false;
displayErrors(); displayErrors();
worker = null; worker = null;
loadingDisks = false; loadingDisks = false;
disks = new ArrayList<>();
disks.addAll(physicalDrives); disks.addAll(physicalDrives);
disks.addAll(partitions); disks.addAll(partitions);
if (disks.size() > 0) { if (disks.size() > 0) {
diskComboBox.setEnabled(true); diskTable.setEnabled(true);
diskComboBox.setSelectedIndex(0); diskTable.clearSelection();
} }
ready = true; ready = true;
} else { } else {