19 package org.sleuthkit.autopsy.actions;
21 import java.util.Collection;
22 import java.util.HashSet;
23 import java.util.logging.Level;
24 import javax.swing.JOptionPane;
25 import javax.swing.SwingUtilities;
26 import org.openide.util.NbBundle;
27 import org.openide.util.Utilities;
39 "AddContentTagAction.singularTagFile=Tag File",
40 "AddContentTagAction.pluralTagFile=Tag Files",
42 "AddContentTagAction.unableToTag.msg=Unable to tag {0}, not a regular file.",
43 "AddContentTagAction.cannotApplyTagErr=Cannot Apply Tag",
45 "AddContentTagAction.unableToTag.msg2=Unable to tag {0}.",
46 "AddContentTagAction.taggingErr=Tagging Error",
47 "# {0} - fileName",
"# {1} - tagName",
48 "AddContentTagAction.tagExists={0} has been tagged as {1}. Cannot reapply the same tag."
58 if (null == instance) {
70 String singularTagFile = NbBundle.getMessage(this.getClass(),
"AddContentTagAction.singularTagFile");
71 String pluralTagFile = NbBundle.getMessage(this.getClass(),
"AddContentTagAction.pluralTagFile");
72 return Utilities.actionsGlobalContext().lookupAll(AbstractFile.class).size() > 1 ? pluralTagFile : singularTagFile;
76 protected void addTag(TagName tagName, String comment) {
85 final Collection<AbstractFile> selectedFiles =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
88 for (AbstractFile file : selectedFiles) {
91 if (file.getName().equals(
".")) {
92 Content parentFile = file.getParent();
93 if (parentFile instanceof AbstractFile) {
94 file = (AbstractFile) parentFile;
96 SwingUtilities.invokeLater(() -> {
97 JOptionPane.showMessageDialog(null,
98 NbBundle.getMessage(
this.getClass(),
99 "AddContentTagAction.unableToTag.msg",
100 parentFile.getName()),
101 NbBundle.getMessage(
this.getClass(),
102 "AddContentTagAction.cannotApplyTagErr"),
103 JOptionPane.WARNING_MESSAGE);
107 }
else if (file.getName().equals(
"..")) {
108 Content parentFile = file.getParent();
109 if (parentFile instanceof AbstractFile) {
110 parentFile = (AbstractFile) ((AbstractFile) parentFile).getParent();
111 if (parentFile instanceof AbstractFile) {
112 file = (AbstractFile) parentFile;
114 final Content parentFileCopy = parentFile;
115 SwingUtilities.invokeLater(() -> {
116 JOptionPane.showMessageDialog(null,
117 NbBundle.getMessage(
this.getClass(),
118 "AddContentTagAction.unableToTag.msg",
119 parentFileCopy.getName()),
120 NbBundle.getMessage(
this.getClass(),
121 "AddContentTagAction.cannotApplyTagErr"),
122 JOptionPane.WARNING_MESSAGE);
127 final Content parentFileCopy = parentFile;
128 SwingUtilities.invokeLater(() -> {
129 JOptionPane.showMessageDialog(null,
130 NbBundle.getMessage(
this.getClass(),
131 "AddContentTagAction.unableToTag.msg",
132 parentFileCopy.getName()),
133 NbBundle.getMessage(
this.getClass(),
134 "AddContentTagAction.cannotApplyTagErr"),
135 JOptionPane.WARNING_MESSAGE);
142 }
catch (TskCoreException ex) {
144 AbstractFile fileCopy = file;
145 SwingUtilities.invokeLater(() -> {
146 JOptionPane.showMessageDialog(null,
147 NbBundle.getMessage(
this.getClass(),
148 "AddContentTagAction.unableToTag.msg2",
150 NbBundle.getMessage(
this.getClass(),
"AddContentTagAction.taggingErr"),
151 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()