19 package org.sleuthkit.autopsy.corecomponents;
21 import java.awt.CardLayout;
22 import java.awt.Component;
23 import java.awt.Dimension;
24 import java.util.Arrays;
26 import java.util.SortedSet;
27 import java.util.TreeSet;
28 import java.util.logging.Level;
29 import org.openide.nodes.Node;
30 import org.openide.util.NbBundle;
31 import org.openide.util.lookup.ServiceProvider;
32 import org.openide.util.lookup.ServiceProviders;
43 @ServiceProviders(value = {
44 @ServiceProvider(service = DataContentViewer.class, position = 5)
48 private static final Set<String> AUDIO_EXTENSIONS =
new TreeSet<>(Arrays.asList(
".mp3",
".wav",
".wma"));
60 private static final String IMAGE_VIEWER_LAYER =
"IMAGE";
61 private static final String VIDEO_VIEWER_LAYER =
"VIDEO";
72 videoPanelInited = videoPanel.
isInited();
73 videoExtensions =
new TreeSet<>(Arrays.asList(videoPanel.
getExtensions()));
77 imagePanelInited = imagePanel.isInited();
78 imageMimes =
new TreeSet<>(imagePanel.getMimeTypes());
79 imageExtensions =
new TreeSet<>(imagePanel.getExtensions());
81 customizeComponents();
82 logger.log(Level.INFO,
"Created MediaView instance: " +
this);
86 add(imagePanel, IMAGE_VIEWER_LAYER);
87 add(videoPanel, VIDEO_VIEWER_LAYER);
89 showVideoPanel(
false);
97 @SuppressWarnings(
"unchecked")
99 private
void initComponents() {
101 setLayout(
new java.awt.CardLayout());
102 getAccessibleContext().setAccessibleDescription(
org.openide.util.NbBundle.getMessage(
DataContentViewerMedia.class,
"DataContentViewerMedia.AccessibleContext.accessibleDescription"));
110 if (selectedNode == null) {
121 if (file.
equals(lastFile)) {
129 if (imagePanelInited && isImageSupported(file)) {
130 imagePanel.showImageFx(file, dims);
131 this.showVideoPanel(
false);
132 }
else if (videoPanelInited && isVideoSupported(file)) {
133 videoPanel.setupVideo(file, dims);
134 this.showVideoPanel(
true);
136 }
catch (Exception e) {
137 logger.log(Level.SEVERE,
"Exception while setting node", e);
147 CardLayout layout = (CardLayout) this.getLayout();
149 layout.show(
this, VIDEO_VIEWER_LAYER);
151 layout.show(
this, IMAGE_VIEWER_LAYER);
157 return NbBundle.getMessage(this.getClass(),
"DataContentViewerMedia.title");
162 return NbBundle.getMessage(this.getClass(),
"DataContentViewerMedia.toolTip");
188 String name = file.
getName().toLowerCase();
190 if ((containsExt(name, AUDIO_EXTENSIONS) || containsExt(name, videoExtensions)) &&
203 String name = file.
getName().toLowerCase();
206 if (!imageMimes.isEmpty()) {
217 if (containsExt(name, imageExtensions)) {
248 if (imagePanelInited) {
249 if (isImageSupported(file))
253 if (videoPanelInited && videoPanel.
isInited()) {
254 if (isVideoSupported(file))
268 String name = file.
getName().toLowerCase();
271 if (containsExt(name, videoExtensions) && deleted) {
280 private static boolean containsExt(String name, Set<String> exts) {
281 int extStart = name.lastIndexOf(
".");
283 if (extStart != -1) {
284 ext = name.substring(extStart, name.length()).toLowerCase();
286 return exts.contains(ext);
boolean isVideoSupported(AbstractFile file)
final MediaViewVideoPanel videoPanel
void showVideoPanel(boolean showVideo)
boolean isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM flag)
boolean isImageSupported(AbstractFile file)
static boolean isPngFileHeader(AbstractFile file)
static boolean containsExt(String name, Set< String > exts)
DataContentViewer createInstance()
MimeMatchEnum isMimeType(SortedSet< String > mimeTypes)
void customizeComponents()
boolean isSupported(Node node)
static boolean isJpegFileHeader(AbstractFile file)
final SortedSet< String > imageMimes
int isPreferred(Node node)
final SortedSet< String > videoExtensions
boolean equals(Object obj)
final MediaViewImagePanel imagePanel
void setNode(Node selectedNode)
final SortedSet< String > videoMimes
final SortedSet< String > imageExtensions
static Logger getLogger(String name)