Merge branch 'develop' of https://github.com/sleuthkit/autopsy into develop

This commit is contained in:
Eugene Livis 2017-03-15 14:44:13 -04:00
commit 417815a1c2
2 changed files with 46 additions and 16 deletions

View File

@ -80,7 +80,16 @@ final class LocalDiskPanel extends JPanel {
NbBundle.getMessage(this.getClass(), "LocalDiskPanel.moduleErr.msg"), NbBundle.getMessage(this.getClass(), "LocalDiskPanel.moduleErr.msg"),
MessageNotifyUtil.MessageType.ERROR); MessageNotifyUtil.MessageType.ERROR);
} }
} else { //The selection changed to nothing valid being selected, such as with ctrl+click
enableNext = false;
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);
}
} }
} }
}); });
@ -261,7 +270,7 @@ final class LocalDiskPanel extends JPanel {
// 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
File currentFile = new File(oldText); File currentFile = new File(oldText);
if ((currentFile.getParentFile() != null) && (currentFile.getParentFile().exists())) { if ((currentFile.getParentFile() != null) && (currentFile.getParentFile().exists())) {
fc.setCurrentDirectory(currentFile.getParentFile()); fc.setSelectedFile(currentFile);
} }
int retval = fc.showOpenDialog(this); int retval = fc.showOpenDialog(this);
@ -335,13 +344,29 @@ final class LocalDiskPanel extends JPanel {
subDirectory.mkdirs(); subDirectory.mkdirs();
} }
String path = disk.getName().replaceAll("[:]", ""); String path = disk.getName();
// Remove all non-ASCII characters
path = path.replaceAll("[^\\p{ASCII}]", ""); //NON-NLS
// Remove all control characters
path = path.replaceAll("[\\p{Cntrl}]", ""); //NON-NLS
// Remove / \ : ? ' "
path = path.replaceAll("[/?:'\"\\\\]", ""); //NON-NLS
path += " " + System.currentTimeMillis(); path += " " + System.currentTimeMillis();
path += ".vhd"; path += ".vhd";
pathTextField.setText(Paths.get(getDefaultImageWriterFolder(), path).toString()); pathTextField.setText(Paths.get(getDefaultImageWriterFolder(), path).toString());
} }
private boolean imageWriterPathIsValid() { private boolean imageWriterPathIsValid() {
if((! copyImageCheckbox.isSelected()) || ! (diskTable.getSelectedRow() >= 0 && diskTable.getSelectedRow() < disks.size())){
imageWriterErrorLabel.setVisible(false);
imageWriterErrorLabel.setText("");
return true;
}
if (pathTextField.getText().isEmpty()) { if (pathTextField.getText().isEmpty()) {
imageWriterErrorLabel.setVisible(true); imageWriterErrorLabel.setVisible(true);
imageWriterErrorLabel.setText(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.imageWriterEmptyPathError.text")); imageWriterErrorLabel.setText(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.imageWriterEmptyPathError.text"));
@ -385,8 +410,7 @@ final class LocalDiskPanel extends JPanel {
* @return true if panel is valid * @return true if panel is valid
*/ */
boolean validatePanel() { boolean validatePanel() {
if (copyImageCheckbox.isSelected() if (!imageWriterPathIsValid()) {
&& !imageWriterPathIsValid()) {
return false; return false;
} }
return enableNext; return enableNext;
@ -433,6 +457,7 @@ final class LocalDiskPanel extends JPanel {
// set the selected timezone // set the selected timezone
timeZoneComboBox.setSelectedItem(formatted); timeZoneComboBox.setSelectedItem(formatted);
} }
/** /**
@ -608,6 +633,10 @@ final class LocalDiskPanel extends JPanel {
diskTable.setEnabled(true); diskTable.setEnabled(true);
diskTable.clearSelection(); diskTable.clearSelection();
} }
pathTextField.setText("");
errorLabel.setText("");
errorLabel.setVisible(false);
fireUpdateEvent();
ready = true; ready = true;
} else { } else {
logger.log(Level.INFO, "Loading local disks was canceled, which should not be possible."); //NON-NLS logger.log(Level.INFO, "Loading local disks was canceled, which should not be possible."); //NON-NLS

View File

@ -98,29 +98,30 @@ class DirectoryTreeFilterNode extends FilterNode {
/** /**
* This method gets the number of visible children. Depending on the user * This method gets the number of visible children. Depending on the user
* preferences, slack files will either be included or purged in the count. * preferences, known and/or slack files will either be included or purged
* in the count.
* *
* @param file The AbstractFile object whose children will be counted. * @param file The AbstractFile object whose children will be counted.
* *
* @return The number of visible children. * @return The number of visible children.
*/ */
private int getVisibleChildCount(AbstractFile file) throws TskCoreException { private int getVisibleChildCount(AbstractFile file) throws TskCoreException {
int numVisibleChildren = 0;
List<Content> childList = file.getChildren(); List<Content> childList = file.getChildren();
if(UserPreferences.hideSlackFilesInDataSourcesTree()) { int numVisibleChildren = file.getChildrenCount();
// Purge slack files from the file count boolean purgeKnownFiles = UserPreferences.hideKnownFilesInDataSourcesTree();
boolean purgeSlackFiles = UserPreferences.hideSlackFilesInDataSourcesTree();
if(purgeKnownFiles || purgeSlackFiles) {
// Purge known and/or slack files from the file count
for(int i=0; i < childList.size(); i++) { for(int i=0; i < childList.size(); i++) {
AbstractFile childFile = (AbstractFile)childList.get(i); AbstractFile childFile = (AbstractFile)childList.get(i);
if(childFile.getType() != TskData.TSK_DB_FILES_TYPE_ENUM.SLACK) { if((purgeKnownFiles && childFile.getKnown() == TskData.FileKnown.KNOWN)
numVisibleChildren++; || (purgeSlackFiles && childFile.getType() == TskData.TSK_DB_FILES_TYPE_ENUM.SLACK)) {
numVisibleChildren--;
} }
} }
} }
else {
// Include slack files in the file count
numVisibleChildren = file.getChildrenCount();
}
return numVisibleChildren; return numVisibleChildren;
} }