mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
Merge remote-tracking branch 'upstream/develop' into events_tags_categories_rework
Conflicts: ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/AddTagAction.java
This commit is contained in:
commit
334bd901cd
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2014 Basis Technology Corp.
|
* Copyright 2014-15 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");
|
||||||
@ -257,7 +257,7 @@ public class TimeLineController {
|
|||||||
LOGGER.log(Level.INFO, "Beginning generation of timeline"); // NON-NLS
|
LOGGER.log(Level.INFO, "Beginning generation of timeline"); // NON-NLS
|
||||||
try {
|
try {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
if (mainFrame != null) {
|
if (isWindowOpen()) {
|
||||||
mainFrame.close();
|
mainFrame.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -311,7 +311,8 @@ public class TimeLineController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** show the timeline window and prompt for rebuilding database */
|
/** show the timeline window and prompt for rebuilding database if
|
||||||
|
* necessary. */
|
||||||
synchronized void openTimeLine() {
|
synchronized void openTimeLine() {
|
||||||
|
|
||||||
// listen for case changes (specifically images being added, and case changes).
|
// listen for case changes (specifically images being added, and case changes).
|
||||||
@ -636,12 +637,21 @@ public class TimeLineController {
|
|||||||
/**
|
/**
|
||||||
* prompt the user to rebuild and then rebuild if the user chooses to
|
* prompt the user to rebuild and then rebuild if the user chooses to
|
||||||
*/
|
*/
|
||||||
synchronized public boolean outOfDatePromptAndRebuild() {
|
synchronized private boolean outOfDatePromptAndRebuild() {
|
||||||
return showOutOfDateConfirmation() == JOptionPane.YES_OPTION
|
return showOutOfDateConfirmation() == JOptionPane.YES_OPTION
|
||||||
? rebuildRepo()
|
? rebuildRepo()
|
||||||
: false;
|
: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is the timeline window open.
|
||||||
|
*
|
||||||
|
* @return true if the timeline window is open
|
||||||
|
*/
|
||||||
|
synchronized private boolean isWindowOpen() {
|
||||||
|
return mainFrame != null && mainFrame.isOpened() && mainFrame.isVisible();
|
||||||
|
}
|
||||||
|
|
||||||
synchronized int showLastPopulatedWhileIngestingConfirmation() {
|
synchronized int showLastPopulatedWhileIngestingConfirmation() {
|
||||||
return JOptionPane.showConfirmDialog(mainFrame,
|
return JOptionPane.showConfirmDialog(mainFrame,
|
||||||
DO_REPOPULATE_MESSAGE,
|
DO_REPOPULATE_MESSAGE,
|
||||||
@ -703,7 +713,9 @@ public class TimeLineController {
|
|||||||
case CANCELLED:
|
case CANCELLED:
|
||||||
case COMPLETED:
|
case COMPLETED:
|
||||||
//if we are doing incremental updates, drop this
|
//if we are doing incremental updates, drop this
|
||||||
outOfDatePromptAndRebuild();
|
if (isWindowOpen()) {
|
||||||
|
outOfDatePromptAndRebuild();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -718,7 +730,9 @@ public class TimeLineController {
|
|||||||
case DATA_SOURCE_ADDED:
|
case DATA_SOURCE_ADDED:
|
||||||
// Content content = (Content) evt.getNewValue();
|
// Content content = (Content) evt.getNewValue();
|
||||||
//if we are doing incremental updates, drop this
|
//if we are doing incremental updates, drop this
|
||||||
outOfDatePromptAndRebuild();
|
if (isWindowOpen()) {
|
||||||
|
outOfDatePromptAndRebuild();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CURRENT_CASE:
|
case CURRENT_CASE:
|
||||||
OpenTimelineAction.invalidateController();
|
OpenTimelineAction.invalidateController();
|
||||||
|
@ -119,28 +119,29 @@ public enum ThumbnailCache {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* load a thumbnail from the disk based cache for the given file, or
|
* load a thumbnail from the disk based cache for the given file, or
|
||||||
* generate and save a new thumnbail if one doesn't already exist
|
* generate and save a new thumbnail if one doesn't already exist
|
||||||
*
|
*
|
||||||
* @param file the file to load a thumbnail of
|
* @param file the DrawableFile to load a thumbnail of
|
||||||
*
|
*
|
||||||
* @return an optional containing a thumbnail, or null if a thumbnail
|
* @return an (possibly empty) optional containing a thumbnail
|
||||||
* couldn't be loaded or generated
|
|
||||||
*/
|
*/
|
||||||
private Optional<Image> load(DrawableFile<?> file) {
|
private Optional<Image> load(DrawableFile<?> file) {
|
||||||
Image thumbnail = null;
|
Image thumbnail;
|
||||||
File cacheFile;
|
|
||||||
try {// try to load the thumbnail from disk
|
|
||||||
cacheFile = getCacheFile(file.getId());
|
|
||||||
|
|
||||||
if (cacheFile.exists()) {
|
try {
|
||||||
// If a thumbnail file is already saved locally, load it
|
thumbnail = getCacheFile(file.getId()).map((File cachFile) -> {
|
||||||
try {
|
if (cachFile.exists()) {
|
||||||
int dim = iconSize.get();
|
// If a thumbnail file is already saved locally, load it
|
||||||
thumbnail = new Image(Utilities.toURI(cacheFile).toURL().toString(), dim, dim, true, false, true);
|
try {
|
||||||
} catch (MalformedURLException ex) {
|
int dim = iconSize.get();
|
||||||
Exceptions.printStackTrace(ex);
|
return new Image(Utilities.toURI(cachFile).toURL().toString(), dim, dim, true, false, true);
|
||||||
|
} catch (MalformedURLException ex) {
|
||||||
|
LOGGER.log(Level.WARNING, "Unable to parse cache file path..");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return null;
|
||||||
|
}).orElse(null);
|
||||||
|
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
LOGGER.log(Level.WARNING, "can't load icon when no case is open");
|
LOGGER.log(Level.WARNING, "can't load icon when no case is open");
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
@ -153,9 +154,23 @@ public enum ThumbnailCache {
|
|||||||
return Optional.ofNullable(thumbnail); //return icon, or null if generation failed
|
return Optional.ofNullable(thumbnail); //return icon, or null if generation failed
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File getCacheFile(long id) {
|
/**
|
||||||
// @@@ should use ImageUtils.getFile();
|
* get a File to store the cached icon in.
|
||||||
return new File(Case.getCurrentCase().getCacheDirectory() + File.separator + id + ".png");
|
*
|
||||||
|
* @param id the obj id of the file to get a cache file for
|
||||||
|
*
|
||||||
|
* @return a Optional containing a File to store the cahced icon in or an
|
||||||
|
* empty optional if there was a
|
||||||
|
* problem.
|
||||||
|
*/
|
||||||
|
private static Optional<File> getCacheFile(long id) {
|
||||||
|
try {
|
||||||
|
// @@@ should use ImageUtils.getFile();
|
||||||
|
return Optional.of(new File(Case.getCurrentCase().getCacheDirectory() + File.separator + id + ".png"));
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
LOGGER.log(Level.WARNING, "Failed to create cache file.{0}", e.getLocalizedMessage());
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -255,15 +270,15 @@ public enum ThumbnailCache {
|
|||||||
* @param bi the thumbnail to save for the given DrawableFile
|
* @param bi the thumbnail to save for the given DrawableFile
|
||||||
*/
|
*/
|
||||||
private void saveIcon(final DrawableFile<?> file, final Image bi) {
|
private void saveIcon(final DrawableFile<?> file, final Image bi) {
|
||||||
try {
|
if (bi != null) {
|
||||||
if (bi != null) {
|
getCacheFile(file.getId()).ifPresent((File cacheFile) -> {
|
||||||
File f = getCacheFile(file.getId());
|
try {
|
||||||
//convert back to swing to save
|
//convert back to swing to save
|
||||||
ImageIO.write(SwingFXUtils.fromFXImage(bi, null), FORMAT, f);
|
ImageIO.write(SwingFXUtils.fromFXImage(bi, null), FORMAT, cacheFile);
|
||||||
}
|
} catch (IllegalArgumentException | IOException ex) {
|
||||||
} catch (IllegalArgumentException | IOException ex) {
|
LOGGER.log(Level.WARNING, "failed to save generated icon");
|
||||||
//LOGGER.log(Level.WARNING, "failed to save generated icon ", ex);
|
}
|
||||||
LOGGER.log(Level.WARNING, "failed to save generated icon");
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user