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;
78 protected void addTag(TagName tagName, String comment) {
87 final Collection<AbstractFile> selectedFiles =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
90 for (AbstractFile file : selectedFiles) {
93 if (file.getName().equals(
".")) {
94 Content parentFile = file.getParent();
95 if (parentFile instanceof AbstractFile) {
96 file = (AbstractFile) parentFile;
98 SwingUtilities.invokeLater(() -> {
99 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
100 NbBundle.getMessage(this.getClass(),
101 "AddContentTagAction.unableToTag.msg",
102 parentFile.getName()),
103 NbBundle.getMessage(
this.getClass(),
104 "AddContentTagAction.cannotApplyTagErr"),
105 JOptionPane.WARNING_MESSAGE);
109 }
else if (file.getName().equals(
"..")) {
110 Content parentFile = file.getParent();
111 if (parentFile instanceof AbstractFile) {
112 parentFile = (AbstractFile) ((AbstractFile) parentFile).getParent();
113 if (parentFile instanceof AbstractFile) {
114 file = (AbstractFile) parentFile;
116 final Content parentFileCopy = parentFile;
117 SwingUtilities.invokeLater(() -> {
118 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
119 NbBundle.getMessage(this.getClass(),
120 "AddContentTagAction.unableToTag.msg",
121 parentFileCopy.getName()),
122 NbBundle.getMessage(
this.getClass(),
123 "AddContentTagAction.cannotApplyTagErr"),
124 JOptionPane.WARNING_MESSAGE);
129 final Content parentFileCopy = parentFile;
130 SwingUtilities.invokeLater(() -> {
131 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
132 NbBundle.getMessage(this.getClass(),
133 "AddContentTagAction.unableToTag.msg",
134 parentFileCopy.getName()),
135 NbBundle.getMessage(
this.getClass(),
136 "AddContentTagAction.cannotApplyTagErr"),
137 JOptionPane.WARNING_MESSAGE);
146 AbstractFile fileCopy = file;
147 SwingUtilities.invokeLater(() -> {
148 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
149 NbBundle.getMessage(this.getClass(),
150 "AddContentTagAction.unableToTag.msg2",
152 NbBundle.getMessage(
this.getClass(),
"AddContentTagAction.taggingErr"),
153 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()