Straightened out the MissingImageDialog class w.r.t. DataSourceProcessor interface.

MissingImageDialog allows the user to directly pick an image/local-disk if its is found to be missing.
This commit is contained in:
raman-bt 2013-10-28 11:03:14 -04:00
parent 5e118737da
commit de7eb6b519
4 changed files with 114 additions and 160 deletions

View File

@ -115,7 +115,6 @@ ImageFilePanel.browseButton.text=Browse
ImageFilePanel.pathTextField.text= ImageFilePanel.pathTextField.text=
LocalDiskPanel.diskLabel.text=Select a local disk: LocalDiskPanel.diskLabel.text=Select a local disk:
MissingImageDialog.selectButton.text=Select Image MissingImageDialog.selectButton.text=Select Image
MissingImageDialog.typeTabel.text=Select input type to add:
MissingImageDialog.titleLabel.text=Search for missing image MissingImageDialog.titleLabel.text=Search for missing image
MissingImageDialog.cancelButton.text=Cancel MissingImageDialog.cancelButton.text=Cancel
LocalDiskPanel.errorLabel.text=Error Label LocalDiskPanel.errorLabel.text=Error Label
@ -152,3 +151,5 @@ LocalDiskPanel.timeZoneLabel.text=Please select the input timezone:
LocalDiskPanel.noFatOrphansCheckbox.toolTipText= LocalDiskPanel.noFatOrphansCheckbox.toolTipText=
LocalDiskPanel.noFatOrphansCheckbox.text=Ignore orphan files in FAT file systems LocalDiskPanel.noFatOrphansCheckbox.text=Ignore orphan files in FAT file systems
LocalDiskPanel.descLabel.text=(faster results, although some data will not be searched) LocalDiskPanel.descLabel.text=(faster results, although some data will not be searched)
MissingImageDialog.browseButton.text=Browse
MissingImageDialog.pathNameTextField.text=

View File

@ -319,9 +319,9 @@ public class Case implements SleuthkitCase.ErrorObserver {
+ "\nPlease note that you will still be able to browse directories and generate reports\n" + "\nPlease note that you will still be able to browse directories and generate reports\n"
+ "if you choose No, but you will not be able to view file content or run the ingest process.", "Missing Image", JOptionPane.YES_NO_OPTION); + "if you choose No, but you will not be able to view file content or run the ingest process.", "Missing Image", JOptionPane.YES_NO_OPTION);
if (ret == JOptionPane.YES_OPTION) { if (ret == JOptionPane.YES_OPTION) {
/***** RAMAN TBD: MissingImageDialog class needs to be refactored to eliminate ContentTypePanel dependency.
MissingImageDialog.makeDialog(obj_id, db); MissingImageDialog.makeDialog(obj_id, db);
* *****************/
} else { } else {
logger.log(Level.WARNING, "Selected image files don't match old files!"); logger.log(Level.WARNING, "Selected image files don't match old files!");
} }

View File

@ -110,65 +110,49 @@
<Layout> <Layout>
<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" alignment="0" attributes="0">
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="typePanel" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="typeTabel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="typeComboBox" pref="298" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="pathNameTextField" min="-2" pref="285" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="browseButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="83" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/> <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="typeTabel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="pathNameTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="typeComboBox" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="browseButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace pref="62" max="32767" attributes="0"/>
<Component id="typePanel" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="javax.swing.JComboBox" name="typeComboBox"> <Component class="javax.swing.JTextField" name="pathNameTextField">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="typeTabel">
<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="MissingImageDialog.typeTabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="MissingImageDialog.pathNameTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pathNameTextFieldActionPerformed"/>
</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="MissingImageDialog.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> </Component>
<Container class="javax.swing.JPanel" name="typePanel">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="57" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="javax.swing.JLabel" name="titleLabel"> <Component class="javax.swing.JLabel" name="titleLabel">

View File

@ -18,42 +18,51 @@
*/ */
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.Dimension; import java.awt.Dimension;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Arrays; import java.util.Arrays;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.ComboBoxModel; import java.io.File;
import javax.swing.JDialog; import javax.swing.JFileChooser;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import org.sleuthkit.autopsy.casemodule.ImageFilePanel;
import javax.swing.event.ListDataListener;
import org.openide.util.Exceptions;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
/**** RAMAN TBD: this class needs to be straightened out. It should not duplicate what the ChooseDataSourceWizard does.
public class MissingImageDialog extends javax.swing.JDialog { public class MissingImageDialog extends javax.swing.JDialog {
private static final Logger logger = Logger.getLogger(MissingImageDialog.class.getName()); private static final Logger logger = Logger.getLogger(MissingImageDialog.class.getName());
long obj_id; long obj_id;
SleuthkitCase db; SleuthkitCase db;
ContentTypePanel currentPanel;
ImageTypeModel model;
private JFileChooser fc = new JFileChooser();
private MissingImageDialog(long obj_id, SleuthkitCase db) { private MissingImageDialog(long obj_id, SleuthkitCase db) {
super(new JFrame(), true); super(new JFrame(), true);
this.obj_id = obj_id; this.obj_id = obj_id;
this.db = db; this.db = db;
initComponents(); initComponents();
fc.setDragEnabled(false);
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setMultiSelectionEnabled(false);
// borrow the filters from ImageFilePanel
fc.addChoosableFileFilter(ImageFilePanel.rawFilter);
fc.addChoosableFileFilter(ImageFilePanel.encaseFilter);
fc.setFileFilter(ImageFilePanel.allFilter);
customInit(); customInit();
} }
@ -75,11 +84,8 @@ public class MissingImageDialog extends javax.swing.JDialog {
} }
private void customInit() { private void customInit() {
model = new ImageTypeModel();
typeComboBox.setModel(model); selectButton.setEnabled(false);
typeComboBox.setSelectedIndex(0);
typePanel.setLayout(new BorderLayout());
updateCurrentPanel(ImageFilePanel.getDefault());
} }
private void display() { private void display() {
@ -94,35 +100,6 @@ public class MissingImageDialog extends javax.swing.JDialog {
this.setVisible(true); this.setVisible(true);
} }
//
// * Refresh this panel.
// * @param panel current typepanel
//
private void updateCurrentPanel(ContentTypePanel panel) {
currentPanel = panel;
typePanel.removeAll();
typePanel.add((JPanel) currentPanel, BorderLayout.CENTER);
typePanel.validate();
typePanel.repaint();
this.validate();
this.repaint();
currentPanel.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if(evt.getPropertyName().equals(AddImageWizardChooseDataSourceVisual.EVENT.UPDATE_UI.toString())) {
updateSelectButton();
}
if(evt.getPropertyName().equals(AddImageWizardChooseDataSourceVisual.EVENT.FOCUS_NEXT.toString())) {
moveFocusToSelect();
}
}
});
currentPanel.select();
updateSelectButton();
}
// //
// * Focuses the select button for easy enter-pressing access. // * Focuses the select button for easy enter-pressing access.
// //
@ -134,7 +111,13 @@ public class MissingImageDialog extends javax.swing.JDialog {
// * Enables/disables the select button based off the current panel. // * Enables/disables the select button based off the current panel.
// //
private void updateSelectButton() { private void updateSelectButton() {
this.selectButton.setEnabled(currentPanel.enableNext());
// Enable this based on whether there is a valid path
if (!pathNameTextField.getText().isEmpty()) {
String filePath = pathNameTextField.getText();
boolean isExist = Case.pathExists(filePath) || Case.driveExists(filePath);
selectButton.setEnabled(isExist);
}
} }
// //
@ -150,9 +133,8 @@ public class MissingImageDialog extends javax.swing.JDialog {
selectButton = new javax.swing.JButton(); selectButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton();
containerPanel = new javax.swing.JPanel(); containerPanel = new javax.swing.JPanel();
typeComboBox = new javax.swing.JComboBox(); pathNameTextField = new javax.swing.JTextField();
typeTabel = new javax.swing.JLabel(); browseButton = new javax.swing.JButton();
typePanel = new javax.swing.JPanel();
titleLabel = new javax.swing.JLabel(); titleLabel = new javax.swing.JLabel();
titleSeparator = new javax.swing.JSeparator(); titleSeparator = new javax.swing.JSeparator();
@ -193,43 +175,39 @@ public class MissingImageDialog extends javax.swing.JDialog {
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
org.openide.awt.Mnemonics.setLocalizedText(typeTabel, org.openide.util.NbBundle.getMessage(MissingImageDialog.class, "MissingImageDialog.typeTabel.text")); // NOI18N pathNameTextField.setText(org.openide.util.NbBundle.getMessage(MissingImageDialog.class, "MissingImageDialog.pathNameTextField.text")); // NOI18N
pathNameTextField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pathNameTextFieldActionPerformed(evt);
}
});
javax.swing.GroupLayout typePanelLayout = new javax.swing.GroupLayout(typePanel); org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(MissingImageDialog.class, "MissingImageDialog.browseButton.text")); // NOI18N
typePanel.setLayout(typePanelLayout); browseButton.addActionListener(new java.awt.event.ActionListener() {
typePanelLayout.setHorizontalGroup( public void actionPerformed(java.awt.event.ActionEvent evt) {
typePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) browseButtonActionPerformed(evt);
.addGap(0, 0, Short.MAX_VALUE) }
); });
typePanelLayout.setVerticalGroup(
typePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 57, Short.MAX_VALUE)
);
javax.swing.GroupLayout containerPanelLayout = new javax.swing.GroupLayout(containerPanel); javax.swing.GroupLayout containerPanelLayout = new javax.swing.GroupLayout(containerPanel);
containerPanel.setLayout(containerPanelLayout); containerPanel.setLayout(containerPanelLayout);
containerPanelLayout.setHorizontalGroup( containerPanelLayout.setHorizontalGroup(
containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(containerPanelLayout.createSequentialGroup() .addGroup(containerPanelLayout.createSequentialGroup()
.addGap(10, 10, 10) .addContainerGap()
.addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(pathNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(typePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(containerPanelLayout.createSequentialGroup() .addComponent(browseButton)
.addComponent(typeTabel) .addContainerGap(83, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addComponent(typeComboBox, 0, 298, Short.MAX_VALUE)))
.addContainerGap())
); );
containerPanelLayout.setVerticalGroup( containerPanelLayout.setVerticalGroup(
containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(containerPanelLayout.createSequentialGroup() .addGroup(containerPanelLayout.createSequentialGroup()
.addGap(0, 0, 0) .addGap(18, 18, 18)
.addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(typeTabel) .addComponent(pathNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(typeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(browseButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addContainerGap(62, Short.MAX_VALUE))
.addComponent(typePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
); );
titleLabel.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N titleLabel.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
@ -270,7 +248,7 @@ public class MissingImageDialog extends javax.swing.JDialog {
private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed
try { try {
String newPath = currentPanel.getContentPaths(); String newPath = pathNameTextField.getText();
//TODO handle local files //TODO handle local files
db.setImagePaths(obj_id, Arrays.asList(new String[]{newPath})); db.setImagePaths(obj_id, Arrays.asList(new String[]{newPath}));
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
@ -283,16 +261,43 @@ public class MissingImageDialog extends javax.swing.JDialog {
cancel(); cancel();
}//GEN-LAST:event_cancelButtonActionPerformed }//GEN-LAST:event_cancelButtonActionPerformed
private void pathNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pathNameTextFieldActionPerformed
// TODO add your handling code here:
updateSelectButton();
}//GEN-LAST:event_pathNameTextFieldActionPerformed
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
String oldText = pathNameTextField.getText();
// set the current directory of the FileChooser if the ImagePath Field is valid
File currentDir = new File(oldText);
if (currentDir.exists()) {
fc.setCurrentDirectory(currentDir);
}
int retval = fc.showOpenDialog(this);
if (retval == JFileChooser.APPROVE_OPTION) {
String path = fc.getSelectedFile().getPath();
pathNameTextField.setText(path);
}
//pcs.firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.FOCUS_NEXT.toString(), false, true);
updateSelectButton();
}//GEN-LAST:event_browseButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton browseButton;
private javax.swing.JPanel buttonPanel; private javax.swing.JPanel buttonPanel;
private javax.swing.JButton cancelButton; private javax.swing.JButton cancelButton;
private javax.swing.JPanel containerPanel; private javax.swing.JPanel containerPanel;
private javax.swing.JTextField pathNameTextField;
private javax.swing.JButton selectButton; private javax.swing.JButton selectButton;
private javax.swing.JLabel titleLabel; private javax.swing.JLabel titleLabel;
private javax.swing.JSeparator titleSeparator; private javax.swing.JSeparator titleSeparator;
private javax.swing.JComboBox typeComboBox;
private javax.swing.JPanel typePanel;
private javax.swing.JLabel typeTabel;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
// //
@ -308,41 +313,5 @@ public class MissingImageDialog extends javax.swing.JDialog {
} }
} }
//
// * ComboBoxModel to control typeComboBox and supply ImageTypePanels.
//
private class ImageTypeModel implements ComboBoxModel {
ContentTypePanel selected;
ContentTypePanel[] types = ContentTypePanel.getPanels();
@Override }
public void setSelectedItem(Object anItem) {
selected = (ContentTypePanel) anItem;
updateCurrentPanel(selected);
}
@Override
public Object getSelectedItem() {
return selected;
}
@Override
public int getSize() {
return types.length;
}
@Override
public Object getElementAt(int index) {
return types[index];
}
@Override
public void addListDataListener(ListDataListener l) {
}
@Override
public void removeListDataListener(ListDataListener l) {
}
}
}
********************************/