mirror of
https://github.com/elisspace/autopsy.git
synced 2026-09-06 02:24:30 +00:00
add "undisplayable" icon to DrawableTile.fxml and SlideShow.fxml; show this icon , when we can't display the contents of a drawable file.
This commit is contained in:
@@ -37,7 +37,6 @@ import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.imagegallery.FileTypeUtils;
|
||||
import org.sleuthkit.autopsy.imagegallery.ImageGalleryController;
|
||||
import org.sleuthkit.autopsy.imagegallery.ImageGalleryModule;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
@@ -318,4 +317,6 @@ public abstract class DrawableFile<T extends AbstractFile> extends AbstractFile
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract boolean isDisplayable();
|
||||
}
|
||||
|
||||
@@ -18,11 +18,15 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imagegallery.datamodel;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import javafx.embed.swing.SwingFXUtils;
|
||||
import javafx.scene.image.Image;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.imagegallery.ThumbnailCache;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
@@ -58,27 +62,30 @@ public class ImageFile<T extends AbstractFile> extends DrawableFile<T> {
|
||||
if (image == null) {
|
||||
try (BufferedInputStream readContentInputStream = new BufferedInputStream(new ReadContentInputStream(this.getAbstractFile()))) {
|
||||
image = new Image(readContentInputStream);
|
||||
if (image.errorProperty().get()) {
|
||||
image.getException().printStackTrace();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(ImageFile.class.getName()).log(Level.WARNING, "unable to read file" + getName());
|
||||
Logger.getLogger(ImageFile.class.getName()).log(Level.WARNING, "unable to read file with JavaFX" + getName());
|
||||
}
|
||||
}
|
||||
|
||||
// if (image == null || image.isError()) {
|
||||
// try (ReadContentInputStream readContentInputStream = new ReadContentInputStream(this.getAbstractFile())) {
|
||||
// BufferedImage read = ImageIO.read(readContentInputStream);
|
||||
// image = SwingFXUtils.toFXImage(read, null);
|
||||
// } catch (IOException | NullPointerException ex) {
|
||||
// Logger.getLogger(ImageFile.class.getName()).log(Level.WARNING, "unable to read file" + getName());
|
||||
// return null;
|
||||
// }
|
||||
// imageRef = new SoftReference<>(image);
|
||||
// }
|
||||
if (image == null || image.errorProperty().get()) {
|
||||
try (BufferedInputStream readContentInputStream = new BufferedInputStream(new ReadContentInputStream(this.getAbstractFile()))) {
|
||||
BufferedImage read = ImageIO.read(readContentInputStream);
|
||||
image = SwingFXUtils.toFXImage(read, null);
|
||||
} catch (IOException | NullPointerException ex) {
|
||||
Logger.getLogger(ImageFile.class.getName()).log(Level.WARNING, "unable to read file with Swing" + getName());
|
||||
return null;
|
||||
}
|
||||
imageRef = new SoftReference<>(image);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplayable() {
|
||||
Image fullSizeImage = getFullSizeImage();
|
||||
return Objects.nonNull(fullSizeImage) && fullSizeImage.errorProperty().get() == false;
|
||||
}
|
||||
|
||||
@Override
|
||||
Double getWidth() {
|
||||
final Image fullSizeImage = getFullSizeImage();
|
||||
|
||||
@@ -22,10 +22,13 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.media.Media;
|
||||
import javafx.scene.media.MediaException;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.datamodel.ContentUtils;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
|
||||
@@ -61,19 +64,30 @@ public class VideoFile<T extends AbstractFile> extends DrawableFile<T> {
|
||||
if (cacheFile.exists() == false) {
|
||||
ContentUtils.writeToFile(this.getAbstractFile(), cacheFile);
|
||||
}
|
||||
try {
|
||||
media = new Media(Paths.get(cacheFile.getAbsolutePath()).toUri().toString());
|
||||
mediaRef = new SoftReference<>(media);
|
||||
return media;
|
||||
} catch (MediaException ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
media = new Media(Paths.get(cacheFile.getAbsolutePath()).toUri().toString());
|
||||
mediaRef = new SoftReference<>(media);
|
||||
return media;
|
||||
|
||||
}
|
||||
|
||||
private File getCacheFile(long id) {
|
||||
return new File(Case.getCurrentCase().getCacheDirectory() + File.separator + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplayable() {
|
||||
try {
|
||||
Media media = getMedia();
|
||||
return Objects.nonNull(media) && Objects.isNull(media.getError());
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(VideoFile.class.getName()).log(Level.SEVERE, "failed to write video to cache for playback.", ex);
|
||||
return false;
|
||||
} catch (MediaException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
Double getWidth() {
|
||||
try {
|
||||
|
||||
@@ -90,8 +90,6 @@ public abstract class DrawableTileBase extends DrawableUIBase {
|
||||
private static final Border SELECTED_BORDER = new Border(new BorderStroke(Color.BLUE, BorderStrokeStyle.SOLID, new CornerRadii(2), new BorderWidths(3)));
|
||||
|
||||
//TODO: do this in CSS? -jm
|
||||
protected static final Image videoIcon = new Image("org/sleuthkit/autopsy/imagegallery/images/video-file.png");
|
||||
protected static final Image hashHitIcon = new Image("org/sleuthkit/autopsy/imagegallery/images/hashset_hits.png");
|
||||
protected static final Image followUpIcon = new Image("org/sleuthkit/autopsy/imagegallery/images/flag_red.png");
|
||||
protected static final Image followUpGray = new Image("org/sleuthkit/autopsy/imagegallery/images/flag_gray.png");
|
||||
|
||||
@@ -110,6 +108,8 @@ public abstract class DrawableTileBase extends DrawableUIBase {
|
||||
@FXML
|
||||
protected ImageView hashHitImageView;
|
||||
|
||||
@FXML
|
||||
protected ImageView undisplayableImageView;
|
||||
/**
|
||||
* displays the icon representing follow up tag
|
||||
*/
|
||||
@@ -318,11 +318,16 @@ public abstract class DrawableTileBase extends DrawableUIBase {
|
||||
getFile().ifPresent(file -> {
|
||||
final boolean isVideo = file.isVideo();
|
||||
final boolean hasHashSetHits = hasHashHit();
|
||||
final boolean isUndisplayable = file.isDisplayable() == false;
|
||||
final String text = getTextForLabel();
|
||||
|
||||
Platform.runLater(() -> {
|
||||
fileTypeImageView.setImage(isVideo ? videoIcon : null);
|
||||
hashHitImageView.setImage(hasHashSetHits ? hashHitIcon : null);
|
||||
fileTypeImageView.setManaged(isVideo);
|
||||
hashHitImageView.setManaged(hasHashSetHits);
|
||||
undisplayableImageView.setManaged(isUndisplayable);
|
||||
fileTypeImageView.setVisible(isVideo);
|
||||
hashHitImageView.setVisible(hasHashSetHits);
|
||||
undisplayableImageView.setVisible(isUndisplayable);
|
||||
nameLabel.setText(text);
|
||||
nameLabel.setTooltip(new Tooltip(text));
|
||||
});
|
||||
|
||||
@@ -58,7 +58,10 @@
|
||||
<ToggleButton id="Cat2Toggle" fx:id="cat2Toggle" mnemonicParsing="false" styleClass="button" text="2" HBox.hgrow="ALWAYS" />
|
||||
<ToggleButton fx:id="cat3Toggle" mnemonicParsing="false" styleClass="button" text="3" HBox.hgrow="ALWAYS" />
|
||||
<ToggleButton fx:id="cat4Toggle" mnemonicParsing="false" styleClass="button" text="4" HBox.hgrow="ALWAYS" />
|
||||
<ToggleButton fx:id="cat5Toggle" mnemonicParsing="false" text="5" toggleGroup="$cat" HBox.hgrow="ALWAYS" />
|
||||
<ToggleButton fx:id="cat5Toggle" mnemonicParsing="false" text="5" HBox.hgrow="ALWAYS">
|
||||
<toggleGroup>
|
||||
<ToggleGroup fx:id="cat" />
|
||||
</toggleGroup></ToggleButton>
|
||||
</buttons>
|
||||
|
||||
</org.controlsfx.control.SegmentedButton>
|
||||
@@ -99,6 +102,11 @@
|
||||
<Insets bottom="1.0" left="1.0" right="1.0" top="1.0" />
|
||||
</HBox.margin>
|
||||
</ImageView>
|
||||
<ImageView fx:id="undisplayableImageView" fitHeight="16.0" fitWidth="16.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../../images/prohibition.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="2.0" right="2.0" top="2.0" />
|
||||
|
||||
Reference in New Issue
Block a user