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) {
79 final Collection<AbstractFile> selectedFiles =
new HashSet<>();
81 if (getContentToTag().isEmpty()) {
91 selectedFiles.addAll(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
93 for (Content content : getContentToTag()) {
94 if (content instanceof AbstractFile) {
95 selectedFiles.add((AbstractFile) content);
100 for (AbstractFile file : selectedFiles) {
103 if (file.getName().equals(
".")) {
104 Content parentFile = file.getParent();
105 if (parentFile instanceof AbstractFile) {
106 file = (AbstractFile) parentFile;
108 SwingUtilities.invokeLater(() -> {
109 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
110 NbBundle.getMessage(this.getClass(),
111 "AddContentTagAction.unableToTag.msg",
112 parentFile.getName()),
113 NbBundle.getMessage(
this.getClass(),
114 "AddContentTagAction.cannotApplyTagErr"),
115 JOptionPane.WARNING_MESSAGE);
119 }
else if (file.getName().equals(
"..")) {
120 Content parentFile = file.getParent();
121 if (parentFile instanceof AbstractFile) {
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",
131 parentFileCopy.getName()),
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",
144 parentFileCopy.getName()),
145 NbBundle.getMessage(
this.getClass(),
146 "AddContentTagAction.cannotApplyTagErr"),
147 JOptionPane.WARNING_MESSAGE);
156 AbstractFile fileCopy = file;
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()