19 package org.sleuthkit.autopsy.actions;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.Collections;
24 import java.util.List;
25 import java.util.logging.Level;
26 import javax.swing.JMenu;
27 import javax.swing.JMenuItem;
29 import org.openide.util.NbBundle;
30 import org.openide.util.actions.Presenter;
41 abstract class AddTagAction
extends TagAction implements Presenter.Popup {
42 private static final String NO_COMMENT =
"";
44 AddTagAction(String menuText) {
49 public JMenuItem getPopupPresenter() {
54 protected void doAction(ActionEvent event) {
61 abstract protected String getActionDisplayName();
67 abstract protected void addTag(TagName tagName, String comment);
78 super(getActionDisplayName());
82 List<TagName> tagNames = null;
85 Collections.sort(tagNames);
92 JMenu quickTagMenu =
new JMenu(NbBundle.getMessage(
this.getClass(),
"AddTagAction.quickTag"));
98 if (null != tagNames && !tagNames.isEmpty()) {
99 for (
final TagName tagName : tagNames) {
100 JMenuItem tagNameItem =
new JMenuItem(tagName.getDisplayName());
101 tagNameItem.addActionListener(
new ActionListener() {
103 public void actionPerformed(ActionEvent e) {
104 addTag(tagName, NO_COMMENT);
105 refreshDirectoryTree();
108 quickTagMenu.add(tagNameItem);
112 JMenuItem empty =
new JMenuItem(NbBundle.getMessage(
this.getClass(),
"AddTagAction.noTags"));
113 empty.setEnabled(
false);
114 quickTagMenu.add(empty);
117 quickTagMenu.addSeparator();
122 JMenuItem newTagMenuItem =
new JMenuItem(NbBundle.getMessage(
this.getClass(),
"AddTagAction.newTag"));
123 newTagMenuItem.addActionListener(
new ActionListener() {
125 public void actionPerformed(ActionEvent e) {
127 if (tagName != null) {
128 addTag(tagName, NO_COMMENT);
129 refreshDirectoryTree();
133 quickTagMenu.add(newTagMenuItem);
138 JMenuItem tagAndCommentItem =
new JMenuItem(
139 NbBundle.getMessage(
this.getClass(),
"AddTagAction.tagAndComment"));
140 tagAndCommentItem.addActionListener(
new ActionListener() {
142 public void actionPerformed(ActionEvent e) {
144 if (null != tagNameAndComment) {
145 addTag(tagNameAndComment.getTagName(), tagNameAndComment.getComment());
146 refreshDirectoryTree();
150 add(tagAndCommentItem);
TagsManager getTagsManager()
static Case getCurrentCase()
static TagName doDialog()
static Logger getLogger(String name)