From 812aed56e1c8f18344dfb6b88da4920e152ced7e Mon Sep 17 00:00:00 2001 From: "U-BASIS\\dsmyda" Date: Wed, 26 Jun 2019 15:08:16 -0400 Subject: [PATCH] Disabled image tagging for non-windows OS and if OpenCV failed to load. --- .../contentviewers/Bundle.properties-MERGED | 4 ++ .../contentviewers/MediaViewImagePanel.java | 44 +++++++++++++------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/contentviewers/Bundle.properties-MERGED index b9f5986b41..ff3341b60f 100755 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/Bundle.properties-MERGED @@ -42,11 +42,15 @@ MediaFileViewer.toolTip=Displays supported multimedia files (images, videos, aud MediaPlayerPanel.noSupport=File not supported. MediaPlayerPanel.timeFormat=%02d:%02d:%02d MediaPlayerPanel.unknownTime=Unknown +MediaViewImagePanel.createTagOption=Create +MediaViewImagePanel.deleteTagOption=Delete MediaViewImagePanel.errorLabel.OOMText=Could not load file into Media View: insufficent memory. MediaViewImagePanel.errorLabel.text=Could not load file into Media View. MediaViewImagePanel.exportSaveText=Save +MediaViewImagePanel.exportTagOption=Export MediaViewImagePanel.externalViewerButton.text=Open in External Viewer Ctrl+E MediaViewImagePanel.fileChooserTitle=Choose a save location +MediaViewImagePanel.hideTagOption=Hide MediaViewImagePanel.successfulExport=Tagged image was successfully saved. MediaViewImagePanel.unsuccessfulExport=Unable to export tagged image to disk. MediaViewVideoPanel.pauseButton.text=\u25ba diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewImagePanel.java b/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewImagePanel.java index 746c16c4c0..0e1b9c9fb1 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewImagePanel.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewImagePanel.java @@ -83,8 +83,10 @@ import org.sleuthkit.autopsy.contentviewers.imagetagging.ImageTagRegion; import org.sleuthkit.autopsy.contentviewers.imagetagging.ImageTagCreator; import org.sleuthkit.autopsy.contentviewers.imagetagging.ImageTag; import org.sleuthkit.autopsy.contentviewers.imagetagging.ImageTagsGroup; +import org.sleuthkit.autopsy.corelibs.OpenCvLoader; import org.sleuthkit.autopsy.coreutils.ImageUtils; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.datamodel.FileNode; import org.sleuthkit.autopsy.directorytree.ExternalViewerAction; import org.sleuthkit.datamodel.AbstractFile; @@ -116,7 +118,7 @@ class MediaViewImagePanel extends JPanel implements MediaFileViewer.MediaViewPan private final ProgressBar progressBar = new ProgressBar(); private final MaskerPane maskerPane = new MaskerPane(); - private final JPopupMenu popupMenu = new JPopupMenu(); + private final JPopupMenu imageTaggingOptions = new JPopupMenu(); private final JMenuItem createTagMenuItem; private final JMenuItem deleteTagMenuItem; private final JMenuItem hideTagsMenuItem; @@ -158,6 +160,12 @@ class MediaViewImagePanel extends JPanel implements MediaFileViewer.MediaViewPan /** * Creates new form MediaViewImagePanel */ + @NbBundle.Messages({ + "MediaViewImagePanel.createTagOption=Create", + "MediaViewImagePanel.deleteTagOption=Delete", + "MediaViewImagePanel.hideTagOption=Hide", + "MediaViewImagePanel.exportTagOption=Export" + }) public MediaViewImagePanel() { initComponents(); fxInited = org.sleuthkit.autopsy.core.Installer.isJavaFxInited(); @@ -166,29 +174,35 @@ class MediaViewImagePanel extends JPanel implements MediaFileViewer.MediaViewPan exportChooser.setDialogTitle(Bundle.MediaViewImagePanel_fileChooserTitle()); //Build popupMenu when Tags Menu button is pressed. - createTagMenuItem = new JMenuItem("Create"); + createTagMenuItem = new JMenuItem(Bundle.MediaViewImagePanel_createTagOption()); createTagMenuItem.addActionListener((event) -> createTag()); - popupMenu.add(createTagMenuItem); + imageTaggingOptions.add(createTagMenuItem); - popupMenu.add(new JSeparator()); + imageTaggingOptions.add(new JSeparator()); - deleteTagMenuItem = new JMenuItem("Delete"); + deleteTagMenuItem = new JMenuItem(Bundle.MediaViewImagePanel_deleteTagOption()); deleteTagMenuItem.addActionListener((event) -> deleteTag()); - popupMenu.add(deleteTagMenuItem); + imageTaggingOptions.add(deleteTagMenuItem); - popupMenu.add(new JSeparator()); + imageTaggingOptions.add(new JSeparator()); - hideTagsMenuItem = new JMenuItem("Hide"); + hideTagsMenuItem = new JMenuItem(Bundle.MediaViewImagePanel_hideTagOption()); hideTagsMenuItem.addActionListener((event) -> showOrHideTags()); - popupMenu.add(hideTagsMenuItem); + imageTaggingOptions.add(hideTagsMenuItem); - popupMenu.add(new JSeparator()); + imageTaggingOptions.add(new JSeparator()); - exportTagsMenuItem = new JMenuItem("Export"); + exportTagsMenuItem = new JMenuItem(Bundle.MediaViewImagePanel_exportTagOption()); exportTagsMenuItem.addActionListener((event) -> exportTags()); - popupMenu.add(exportTagsMenuItem); + imageTaggingOptions.add(exportTagsMenuItem); - popupMenu.setPopupSize(300, 150); + imageTaggingOptions.setPopupSize(300, 150); + + //Disable image tagging for non-windows users or upon failure to load OpenCV. + if (!PlatformUtil.isWindowsOS() || !OpenCvLoader.hasOpenCvLoaded()) { + tagsMenu.setEnabled(false); + imageTaggingOptions.setEnabled(false); + } if (fxInited) { Platform.runLater(new Runnable() { @@ -893,7 +907,9 @@ class MediaViewImagePanel extends JPanel implements MediaFileViewer.MediaViewPan } private void tagsMenuMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tagsMenuMousePressed - popupMenu.show(tagsMenu, -300 + tagsMenu.getWidth(), tagsMenu.getHeight() + 3); + if (imageTaggingOptions.isEnabled()) { + imageTaggingOptions.show(tagsMenu, -300 + tagsMenu.getWidth(), tagsMenu.getHeight() + 3); + } }//GEN-LAST:event_tagsMenuMousePressed /**