Autopsy  4.13.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DeleteContentTagAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.actions;
20 
21 import java.awt.event.ActionEvent;
22 import java.util.Collection;
23 import java.util.logging.Level;
24 import javax.swing.AbstractAction;
25 import javax.swing.JOptionPane;
26 import javax.swing.SwingUtilities;
27 import org.openide.util.NbBundle;
28 import org.openide.util.Utilities;
29 import org.openide.windows.WindowManager;
33 import org.sleuthkit.datamodel.ContentTag;
34 import org.sleuthkit.datamodel.TskCoreException;
35 
39 @NbBundle.Messages({
40  "DeleteContentTagAction.deleteTag=Remove Selected Tag(s)",
41  "# {0} - tagName",
42  "DeleteContentTagAction.unableToDelTag.msg=Unable to delete tag {0}.",
43  "DeleteContentTagAction.tagDelErr=Tag Deletion Error"
44 })
45 public class DeleteContentTagAction extends AbstractAction {
46 
47  private static final Logger logger = Logger.getLogger(DeleteContentTagAction.class.getName());
48 
49  private static final long serialVersionUID = 1L;
50  private static final String MENU_TEXT = NbBundle.getMessage(DeleteContentTagAction.class,
51  "DeleteContentTagAction.deleteTag");
52 
53  // This class is a singleton to support multi-selection of nodes, since
54  // org.openide.nodes.NodeOp.findActions(Node[] nodes) will only pick up an Action if every
55  // node in the array returns a reference to the same action object from Node.getActions(boolean).
57 
58  public static synchronized DeleteContentTagAction getInstance() {
59  if (null == instance) {
60  instance = new DeleteContentTagAction();
61  }
62  return instance;
63  }
64 
66  super(MENU_TEXT);
67  }
68 
69  @Override
70  public void actionPerformed(ActionEvent e) {
71  final Collection<? extends ContentTag> selectedTags = Utilities.actionsGlobalContext().lookupAll(ContentTag.class);
72  new Thread(() -> {
73  for (ContentTag tag : selectedTags) {
74  try {
76  } catch (TskCoreException | NoCurrentCaseException ex) {
77  Logger.getLogger(DeleteContentTagAction.class.getName()).log(Level.SEVERE, "Error deleting tag", ex); //NON-NLS
78  SwingUtilities.invokeLater(() -> {
79  JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
80  NbBundle.getMessage(this.getClass(),
81  "DeleteContentTagAction.unableToDelTag.msg",
82  tag.getName()),
83  NbBundle.getMessage(this.getClass(), "DeleteContentTagAction.tagDelErr"),
84  JOptionPane.ERROR_MESSAGE);
85  });
86  break;
87  }
88  }
89  }).start();
90  }
91 
99  @Deprecated
100  protected void doAction(ActionEvent event) {
101  actionPerformed(event);
102  }
103 
112  @Deprecated
113  protected void refreshDirectoryTree() {
114  }
115 
116 }
static synchronized DeleteContentTagAction getInstance()
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2019 Basis Technology. Generated on: Tue Jan 7 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.