Autopsy  4.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-2017 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.HashSet;
24 import java.util.concurrent.ExecutionException;
25 import java.util.logging.Level;
26 import javafx.application.Platform;
27 import javafx.scene.control.Alert;
28 import javax.swing.AbstractAction;
29 import javax.swing.JOptionPane;
30 import javax.swing.SwingUtilities;
31 import javax.swing.SwingWorker;
32 import org.openide.util.NbBundle;
33 import org.openide.util.Utilities;
37 import org.sleuthkit.datamodel.AbstractFile;
38 import org.sleuthkit.datamodel.ContentTag;
39 import org.sleuthkit.datamodel.TagName;
40 import org.sleuthkit.datamodel.TskCoreException;
41 
45 @NbBundle.Messages({
46  "DeleteContentTagAction.deleteTag=Delete Tag",
47  "# {0} - tagName",
48  "DeleteContentTagAction.unableToDelTag.msg=Unable to delete tag {0}.",
49  "DeleteContentTagAction.tagDelErr=Tag Deletion Error"
50 })
51 public class DeleteContentTagAction extends AbstractAction {
52 
53  private static final Logger LOGGER = Logger.getLogger(DeleteContentTagAction.class.getName());
54 
55  private static final long serialVersionUID = 1L;
56  private static final String MENU_TEXT = NbBundle.getMessage(DeleteContentTagAction.class,
57  "DeleteContentTagAction.deleteTag");
58 
59  // This class is a singleton to support multi-selection of nodes, since
60  // org.openide.nodes.NodeOp.findActions(Node[] nodes) will only pick up an Action if every
61  // node in the array returns a reference to the same action object from Node.getActions(boolean).
63 
64  public static synchronized DeleteContentTagAction getInstance() {
65  if (null == instance) {
66  instance = new DeleteContentTagAction();
67  }
68  return instance;
69  }
70 
72  super(MENU_TEXT);
73  }
74 
75  @Override
76  public void actionPerformed(ActionEvent e) {
77  final Collection<? extends ContentTag> selectedTags = Utilities.actionsGlobalContext().lookupAll(ContentTag.class);
78  new Thread(() -> {
79  for (ContentTag tag : selectedTags) {
80  try {
82  } catch (TskCoreException ex) {
83  Logger.getLogger(DeleteContentTagAction.class.getName()).log(Level.SEVERE, "Error deleting tag", ex); //NON-NLS
84  SwingUtilities.invokeLater(() -> {
85  JOptionPane.showMessageDialog(null,
86  NbBundle.getMessage(this.getClass(),
87  "DeleteContentTagAction.unableToDelTag.msg",
88  tag.getName()),
89  NbBundle.getMessage(this.getClass(), "DeleteContentTagAction.tagDelErr"),
90  JOptionPane.ERROR_MESSAGE);
91  });
92  break;
93  }
94  }
95  }).start();
96  }
97 
105  @Deprecated
106  protected void doAction(ActionEvent event) {
107  actionPerformed(event);
108  }
109 
118  @Deprecated
119  protected void refreshDirectoryTree() {
120  }
121 
122 }
static synchronized DeleteContentTagAction getInstance()
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

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