Disabled image tagging for non-windows OS and if OpenCV failed to load.

This commit is contained in:
U-BASIS\dsmyda 2019-06-26 15:08:16 -04:00
parent 357c70fcee
commit 812aed56e1
2 changed files with 34 additions and 14 deletions

View File

@ -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

View File

@ -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
/**