Autopsy  4.1
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-2015 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;
31 import org.sleuthkit.datamodel.ContentTag;
32 import org.sleuthkit.datamodel.TskCoreException;
33 
37 public class DeleteContentTagAction extends AbstractAction {
38 
39  private static final long serialVersionUID = 1L;
40  private static final String MENU_TEXT = NbBundle.getMessage(DeleteContentTagAction.class,
41  "DeleteContentTagAction.deleteTags");
42 
43  // This class is a singleton to support multi-selection of nodes, since
44  // org.openide.nodes.NodeOp.findActions(Node[] nodes) will only pick up an Action if every
45  // node in the array returns a reference to the same action object from Node.getActions(boolean).
47 
48  public static synchronized DeleteContentTagAction getInstance() {
49  if (null == instance) {
50  instance = new DeleteContentTagAction();
51  }
52  return instance;
53  }
54 
56  super(MENU_TEXT);
57  }
58 
59  @Override
60  public void actionPerformed(ActionEvent e) {
61  final Collection<? extends ContentTag> selectedTags = Utilities.actionsGlobalContext().lookupAll(ContentTag.class);
62  new Thread(() -> {
63  for (ContentTag tag : selectedTags) {
64  try {
66  } catch (TskCoreException ex) {
67  Logger.getLogger(AddContentTagAction.class.getName()).log(Level.SEVERE, "Error deleting tag", ex); //NON-NLS
68  SwingUtilities.invokeLater(() -> {
69  JOptionPane.showMessageDialog(null,
70  NbBundle.getMessage(this.getClass(),
71  "DeleteContentTagAction.unableToDelTag.msg",
72  tag.getName()),
73  NbBundle.getMessage(this.getClass(), "DeleteContentTagAction.tagDelErr"),
74  JOptionPane.ERROR_MESSAGE);
75  });
76  break;
77  }
78  }
79  }).start();
80  }
81 
89  @Deprecated
90  protected void doAction(ActionEvent event) {
91  actionPerformed(event);
92  }
93 
102  @Deprecated
103  protected void refreshDirectoryTree() {
104  }
105 
106 }
static synchronized DeleteContentTagAction getInstance()
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jan 2 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.