mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
Populate new menu item from AbstractAbstractFileNode.
This commit is contained in:
parent
3c8daa283a
commit
2c9762cf31
@ -21,12 +21,14 @@ package org.sleuthkit.autopsy.datamodel;
|
|||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import javax.swing.Action;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openide.nodes.Children;
|
import org.openide.nodes.Children;
|
||||||
import org.openide.nodes.Sheet;
|
import org.openide.nodes.Sheet;
|
||||||
@ -36,6 +38,9 @@ import org.sleuthkit.autopsy.casemodule.Case;
|
|||||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||||
import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent;
|
import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent;
|
||||||
import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent;
|
import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent;
|
||||||
|
import org.sleuthkit.autopsy.centralrepository.AddEditCentralRepoCommentAction;
|
||||||
|
import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil;
|
||||||
|
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import static org.sleuthkit.autopsy.datamodel.AbstractAbstractFileNode.AbstractFilePropertyType.*;
|
import static org.sleuthkit.autopsy.datamodel.AbstractAbstractFileNode.AbstractFilePropertyType.*;
|
||||||
import static org.sleuthkit.autopsy.datamodel.Bundle.*;
|
import static org.sleuthkit.autopsy.datamodel.Bundle.*;
|
||||||
@ -253,6 +258,27 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
|
|||||||
map.put(EXTENSION.toString(), content.getNameExtension());
|
map.put(EXTENSION.toString(), content.getNameExtension());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Action[] getActions(boolean context) {
|
||||||
|
List<Action> actionsList = new ArrayList<>();
|
||||||
|
|
||||||
|
actionsList.addAll(Arrays.asList(super.getActions(true)));
|
||||||
|
|
||||||
|
// Create the "Add/Edit Central Repository Comment" menu item if the enabled.
|
||||||
|
AbstractFile file = content;
|
||||||
|
if (EamDbUtil.useCentralRepo() && EamArtifactUtil.isValidCentralRepoFile(file) && file.isFile()) {
|
||||||
|
try {
|
||||||
|
actionsList.add(AddEditCentralRepoCommentAction.createAddEditCentralRepoCommentAction(file));
|
||||||
|
} catch (AddEditCentralRepoCommentAction.AddEditCentralRepoCommentException ex) {
|
||||||
|
logger.log(Level.SEVERE, String.format(
|
||||||
|
"An error occurred while trying to create the 'Add/Edit Central Repository Comment' action for file \"%s\" (objId=%d).",
|
||||||
|
file.getName(), file.getId()), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return actionsList.toArray(new Action[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by subclasses of AbstractAbstractFileNode to add the tags property
|
* Used by subclasses of AbstractAbstractFileNode to add the tags property
|
||||||
* to their sheets.
|
* to their sheets.
|
||||||
|
@ -26,15 +26,10 @@ import java.util.List;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openide.util.Exceptions;
|
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.util.Utilities;
|
import org.openide.util.Utilities;
|
||||||
import org.sleuthkit.autopsy.actions.AddContentTagAction;
|
import org.sleuthkit.autopsy.actions.AddContentTagAction;
|
||||||
import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction;
|
import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction;
|
||||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
|
||||||
import org.sleuthkit.autopsy.centralrepository.AddEditCentralRepoCommentAction;
|
|
||||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
|
||||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
|
||||||
import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
|
import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
|
import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
|
||||||
@ -159,18 +154,6 @@ public class FileNode extends AbstractFsContentNode<AbstractFile> {
|
|||||||
public Action[] getActions(boolean context) {
|
public Action[] getActions(boolean context) {
|
||||||
List<Action> actionsList = new ArrayList<>();
|
List<Action> actionsList = new ArrayList<>();
|
||||||
actionsList.addAll(Arrays.asList(super.getActions(true)));
|
actionsList.addAll(Arrays.asList(super.getActions(true)));
|
||||||
|
|
||||||
// Create the "Add/Edit Central Repository Comment" menu item if the enabled.
|
|
||||||
AbstractFile file = content;
|
|
||||||
if (file != null && file.isFile() && EamDbUtil.useCentralRepo()) {
|
|
||||||
try {
|
|
||||||
actionsList.add(AddEditCentralRepoCommentAction.createAddEditCentralRepoCommentAction(file));
|
|
||||||
} catch (AddEditCentralRepoCommentAction.AddEditCentralRepoCommentException ex) {
|
|
||||||
logger.log(Level.SEVERE, String.format(
|
|
||||||
"An error occurred while trying to create the 'Add/Edit Central Repository Comment' action for file \"%s\" (objId=%d).",
|
|
||||||
file.getName(), file.getId()), ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.getDirectoryBrowseMode()) {
|
if (!this.getDirectoryBrowseMode()) {
|
||||||
actionsList.add(new ViewContextAction(Bundle.FileNode_getActions_viewFileInDir_text(), this));
|
actionsList.add(new ViewContextAction(Bundle.FileNode_getActions_viewFileInDir_text(), this));
|
||||||
|
@ -32,8 +32,6 @@ import org.openide.util.NbBundle;
|
|||||||
import org.openide.util.Utilities;
|
import org.openide.util.Utilities;
|
||||||
import org.sleuthkit.autopsy.actions.AddContentTagAction;
|
import org.sleuthkit.autopsy.actions.AddContentTagAction;
|
||||||
import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction;
|
import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction;
|
||||||
import org.sleuthkit.autopsy.centralrepository.AddEditCentralRepoCommentAction;
|
|
||||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
|
||||||
import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
|
import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
|
import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
|
||||||
@ -98,21 +96,8 @@ public class LocalFileNode extends AbstractAbstractFileNode<AbstractFile> {
|
|||||||
@Override
|
@Override
|
||||||
public Action[] getActions(boolean context) {
|
public Action[] getActions(boolean context) {
|
||||||
List<Action> actionsList = new ArrayList<>();
|
List<Action> actionsList = new ArrayList<>();
|
||||||
|
|
||||||
actionsList.addAll(Arrays.asList(super.getActions(true)));
|
actionsList.addAll(Arrays.asList(super.getActions(true)));
|
||||||
|
|
||||||
// Create the "Add/Edit Central Repository Comment" menu item if the enabled.
|
|
||||||
AbstractFile file = content;
|
|
||||||
if (file != null && file.isFile() && EamDbUtil.useCentralRepo()) {
|
|
||||||
try {
|
|
||||||
actionsList.add(AddEditCentralRepoCommentAction.createAddEditCentralRepoCommentAction(file));
|
|
||||||
} catch (AddEditCentralRepoCommentAction.AddEditCentralRepoCommentException ex) {
|
|
||||||
logger.log(Level.SEVERE, String.format(
|
|
||||||
"An error occurred while trying to create the 'Add/Edit Central Repository Comment' action for file \"%s\" (objId=%d).",
|
|
||||||
file.getName(), file.getId()), ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "LocalFileNode.viewFileInDir.text"), this.content));
|
actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "LocalFileNode.viewFileInDir.text"), this.content));
|
||||||
actionsList.add(null); // creates a menu separator
|
actionsList.add(null); // creates a menu separator
|
||||||
actionsList.add(new NewWindowViewAction(
|
actionsList.add(new NewWindowViewAction(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user