19 package org.sleuthkit.autopsy.actions;
21 import java.util.Collection;
22 import java.util.logging.Level;
23 import javax.swing.JOptionPane;
24 import javax.swing.SwingUtilities;
25 import org.openide.util.NbBundle;
26 import org.openide.util.Utilities;
47 if (null == instance) {
59 String singularTagFile = NbBundle.getMessage(this.getClass(),
"AddContentTagAction.singularTagFile");
60 String pluralTagFile = NbBundle.getMessage(this.getClass(),
"AddContentTagAction.pluralTagFile");
61 return Utilities.actionsGlobalContext().lookupAll(AbstractFile.class).size() > 1 ? pluralTagFile : singularTagFile;
65 protected void addTag(TagName tagName, String comment) {
66 final Collection<? extends AbstractFile> selectedFiles = Utilities.actionsGlobalContext().lookupAll(AbstractFile.class);
69 for (AbstractFile file : selectedFiles) {
72 if (file.getName().equals(
".")) {
73 Content parentFile = file.getParent();
74 if (parentFile instanceof AbstractFile) {
75 file = (AbstractFile) parentFile;
77 SwingUtilities.invokeLater(() -> {
78 JOptionPane.showMessageDialog(null,
79 NbBundle.getMessage(
this.getClass(),
80 "AddContentTagAction.unableToTag.msg",
81 parentFile.getName()),
82 NbBundle.getMessage(
this.getClass(),
83 "AddContentTagAction.cannotApplyTagErr"),
84 JOptionPane.WARNING_MESSAGE);
88 }
else if (file.getName().equals(
"..")) {
89 Content parentFile = file.getParent();
90 if (parentFile instanceof AbstractFile) {
91 parentFile = (AbstractFile) ((AbstractFile) parentFile).getParent();
92 if (parentFile instanceof AbstractFile) {
93 file = (AbstractFile) parentFile;
95 final Content parentFileCopy = parentFile;
96 SwingUtilities.invokeLater(() -> {
97 JOptionPane.showMessageDialog(null,
98 NbBundle.getMessage(
this.getClass(),
99 "AddContentTagAction.unableToTag.msg",
100 parentFileCopy.getName()),
101 NbBundle.getMessage(
this.getClass(),
102 "AddContentTagAction.cannotApplyTagErr"),
103 JOptionPane.WARNING_MESSAGE);
108 final Content parentFileCopy = parentFile;
109 SwingUtilities.invokeLater(() -> {
110 JOptionPane.showMessageDialog(null,
111 NbBundle.getMessage(
this.getClass(),
112 "AddContentTagAction.unableToTag.msg",
113 parentFileCopy.getName()),
114 NbBundle.getMessage(
this.getClass(),
115 "AddContentTagAction.cannotApplyTagErr"),
116 JOptionPane.WARNING_MESSAGE);
123 }
catch (TskCoreException ex) {
125 AbstractFile fileCopy = file;
126 SwingUtilities.invokeLater(() -> {
127 JOptionPane.showMessageDialog(null,
128 NbBundle.getMessage(
this.getClass(),
129 "AddContentTagAction.unableToTag.msg2",
131 NbBundle.getMessage(
this.getClass(),
"AddContentTagAction.taggingErr"),
132 JOptionPane.ERROR_MESSAGE);
static AddContentTagAction instance
String getActionDisplayName()
TagsManager getTagsManager()
void addTag(TagName tagName, String comment)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
static synchronized AddContentTagAction getInstance()