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;
28 import org.openide.windows.WindowManager;
41 "AddContentTagAction.singularTagFile=Add File Tag",
42 "AddContentTagAction.pluralTagFile=Add File Tags",
44 "AddContentTagAction.unableToTag.msg=Unable to tag {0}, not a regular file.",
45 "AddContentTagAction.cannotApplyTagErr=Cannot Apply Tag",
47 "AddContentTagAction.unableToTag.msg2=Unable to tag {0}.",
48 "AddContentTagAction.taggingErr=Tagging Error",
49 "# {0} - fileName",
"# {1} - tagName",
50 "AddContentTagAction.tagExists={0} has been tagged as {1}. Cannot reapply the same tag."
60 if (null == instance) {
72 String singularTagFile = NbBundle.getMessage(this.getClass(),
"AddContentTagAction.singularTagFile");
73 String pluralTagFile = NbBundle.getMessage(this.getClass(),
"AddContentTagAction.pluralTagFile");
74 return Utilities.actionsGlobalContext().lookupAll(
AbstractFile.class).size() > 1 ? pluralTagFile : singularTagFile;
79 final Collection<AbstractFile> selectedFiles =
new HashSet<>();
81 if (getContentToTag().isEmpty()) {
91 selectedFiles.addAll(Utilities.actionsGlobalContext().lookupAll(
AbstractFile.class));
93 for (
Content content : getContentToTag()) {
95 selectedFiles.add((AbstractFile) content);
103 if (file.getName().equals(
".")) {
106 file = (AbstractFile) parentFile;
108 SwingUtilities.invokeLater(() -> {
109 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
110 NbBundle.getMessage(this.getClass(),
111 "AddContentTagAction.unableToTag.msg",
113 NbBundle.getMessage(
this.getClass(),
114 "AddContentTagAction.cannotApplyTagErr"),
115 JOptionPane.WARNING_MESSAGE);
119 }
else if (file.getName().equals(
"..")) {
122 parentFile = (AbstractFile) ((AbstractFile) parentFile).getParent();
123 if (parentFile instanceof AbstractFile) {
124 file = (AbstractFile) parentFile;
126 final Content parentFileCopy = parentFile;
127 SwingUtilities.invokeLater(() -> {
128 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
129 NbBundle.getMessage(this.getClass(),
130 "AddContentTagAction.unableToTag.msg",
132 NbBundle.getMessage(
this.getClass(),
133 "AddContentTagAction.cannotApplyTagErr"),
134 JOptionPane.WARNING_MESSAGE);
139 final Content parentFileCopy = parentFile;
140 SwingUtilities.invokeLater(() -> {
141 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
142 NbBundle.getMessage(this.getClass(),
143 "AddContentTagAction.unableToTag.msg",
145 NbBundle.getMessage(
this.getClass(),
146 "AddContentTagAction.cannotApplyTagErr"),
147 JOptionPane.WARNING_MESSAGE);
157 SwingUtilities.invokeLater(() -> {
158 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
159 NbBundle.getMessage(this.getClass(),
160 "AddContentTagAction.unableToTag.msg2",
162 NbBundle.getMessage(
this.getClass(),
"AddContentTagAction.taggingErr"),
163 JOptionPane.ERROR_MESSAGE);
static AddContentTagAction instance
String getActionDisplayName()
TagsManager getTagsManager()
void addTag(TagName tagName, String comment)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
static synchronized AddContentTagAction getInstance()