mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-16 17:57:43 +00:00
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:
parent
5e118737da
commit
de7eb6b519
@ -115,7 +115,6 @@ ImageFilePanel.browseButton.text=Browse
|
||||
ImageFilePanel.pathTextField.text=
|
||||
LocalDiskPanel.diskLabel.text=Select a local disk:
|
||||
MissingImageDialog.selectButton.text=Select Image
|
||||
MissingImageDialog.typeTabel.text=Select input type to add:
|
||||
MissingImageDialog.titleLabel.text=Search for missing image
|
||||
MissingImageDialog.cancelButton.text=Cancel
|
||||
LocalDiskPanel.errorLabel.text=Error Label
|
||||
@ -152,3 +151,5 @@ LocalDiskPanel.timeZoneLabel.text=Please select the input timezone:
|
||||
LocalDiskPanel.noFatOrphansCheckbox.toolTipText=
|
||||
LocalDiskPanel.noFatOrphansCheckbox.text=Ignore orphan files in FAT file systems
|
||||
LocalDiskPanel.descLabel.text=(faster results, although some data will not be searched)
|
||||
MissingImageDialog.browseButton.text=Browse
|
||||
MissingImageDialog.pathNameTextField.text=
|
||||
|
@ -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"
|
||||
+ "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) {
|
||||
/***** RAMAN TBD: MissingImageDialog class needs to be refactored to eliminate ContentTypePanel dependency.
|
||||
|
||||
MissingImageDialog.makeDialog(obj_id, db);
|
||||
* *****************/
|
||||
|
||||
} else {
|
||||
logger.log(Level.WARNING, "Selected image files don't match old files!");
|
||||
}
|
||||
|
@ -110,65 +110,49 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" 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>
|
||||
<Group type="102" alignment="0" 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>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" 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">
|
||||
<Component id="typeTabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="typeComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="pathNameTextField" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="browseButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="typePanel" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace pref="62" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JComboBox" name="typeComboBox">
|
||||
<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">
|
||||
<Component class="javax.swing.JTextField" name="pathNameTextField">
|
||||
<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.typeTabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="MissingImageDialog.pathNameTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</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, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseButtonActionPerformed"/>
|
||||
</Events>
|
||||
</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>
|
||||
</Container>
|
||||
<Component class="javax.swing.JLabel" name="titleLabel">
|
||||
|
@ -18,42 +18,51 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.casemodule;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.JDialog;
|
||||
import java.io.File;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.sleuthkit.autopsy.casemodule.ImageFilePanel;
|
||||
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
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 {
|
||||
private static final Logger logger = Logger.getLogger(MissingImageDialog.class.getName());
|
||||
long obj_id;
|
||||
SleuthkitCase db;
|
||||
ContentTypePanel currentPanel;
|
||||
ImageTypeModel model;
|
||||
|
||||
|
||||
|
||||
|
||||
private JFileChooser fc = new JFileChooser();
|
||||
|
||||
private MissingImageDialog(long obj_id, SleuthkitCase db) {
|
||||
super(new JFrame(), true);
|
||||
this.obj_id = obj_id;
|
||||
this.db = db;
|
||||
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();
|
||||
}
|
||||
|
||||
@ -75,11 +84,8 @@ public class MissingImageDialog extends javax.swing.JDialog {
|
||||
}
|
||||
|
||||
private void customInit() {
|
||||
model = new ImageTypeModel();
|
||||
typeComboBox.setModel(model);
|
||||
typeComboBox.setSelectedIndex(0);
|
||||
typePanel.setLayout(new BorderLayout());
|
||||
updateCurrentPanel(ImageFilePanel.getDefault());
|
||||
|
||||
selectButton.setEnabled(false);
|
||||
}
|
||||
|
||||
private void display() {
|
||||
@ -94,35 +100,6 @@ public class MissingImageDialog extends javax.swing.JDialog {
|
||||
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.
|
||||
//
|
||||
@ -134,7 +111,13 @@ public class MissingImageDialog extends javax.swing.JDialog {
|
||||
// * Enables/disables the select button based off the current panel.
|
||||
//
|
||||
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();
|
||||
cancelButton = new javax.swing.JButton();
|
||||
containerPanel = new javax.swing.JPanel();
|
||||
typeComboBox = new javax.swing.JComboBox();
|
||||
typeTabel = new javax.swing.JLabel();
|
||||
typePanel = new javax.swing.JPanel();
|
||||
pathNameTextField = new javax.swing.JTextField();
|
||||
browseButton = new javax.swing.JButton();
|
||||
titleLabel = new javax.swing.JLabel();
|
||||
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))
|
||||
);
|
||||
|
||||
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);
|
||||
typePanel.setLayout(typePanelLayout);
|
||||
typePanelLayout.setHorizontalGroup(
|
||||
typePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
);
|
||||
typePanelLayout.setVerticalGroup(
|
||||
typePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 57, Short.MAX_VALUE)
|
||||
);
|
||||
org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(MissingImageDialog.class, "MissingImageDialog.browseButton.text")); // NOI18N
|
||||
browseButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
browseButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout containerPanelLayout = new javax.swing.GroupLayout(containerPanel);
|
||||
containerPanel.setLayout(containerPanelLayout);
|
||||
containerPanelLayout.setHorizontalGroup(
|
||||
containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(containerPanelLayout.createSequentialGroup()
|
||||
.addGap(10, 10, 10)
|
||||
.addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(typePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(containerPanelLayout.createSequentialGroup()
|
||||
.addComponent(typeTabel)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(typeComboBox, 0, 298, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
.addContainerGap()
|
||||
.addComponent(pathNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(browseButton)
|
||||
.addContainerGap(83, Short.MAX_VALUE))
|
||||
);
|
||||
containerPanelLayout.setVerticalGroup(
|
||||
containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(containerPanelLayout.createSequentialGroup()
|
||||
.addGap(0, 0, 0)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(typeTabel)
|
||||
.addComponent(typeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(typePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
.addComponent(pathNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(browseButton))
|
||||
.addContainerGap(62, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
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
|
||||
try {
|
||||
String newPath = currentPanel.getContentPaths();
|
||||
String newPath = pathNameTextField.getText();
|
||||
//TODO handle local files
|
||||
db.setImagePaths(obj_id, Arrays.asList(new String[]{newPath}));
|
||||
} catch (TskCoreException ex) {
|
||||
@ -283,16 +261,43 @@ public class MissingImageDialog extends javax.swing.JDialog {
|
||||
cancel();
|
||||
}//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
|
||||
private javax.swing.JButton browseButton;
|
||||
private javax.swing.JPanel buttonPanel;
|
||||
private javax.swing.JButton cancelButton;
|
||||
private javax.swing.JPanel containerPanel;
|
||||
private javax.swing.JTextField pathNameTextField;
|
||||
private javax.swing.JButton selectButton;
|
||||
private javax.swing.JLabel titleLabel;
|
||||
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
|
||||
|
||||
//
|
||||
@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
********************************/
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user