Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
DeleteBlackboardArtifactTagAction.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.BlackboardArtifactTag;
34 import org.sleuthkit.datamodel.TskCoreException;
35 
40 @NbBundle.Messages({
41  "DeleteBlackboardArtifactTagAction.deleteTag=Remove Selected Tag(s)",
42  "# {0} - tagName",
43  "DeleteBlackboardArtifactTagAction.unableToDelTag.msg=Unable to delete tag {0}.",
44  "DeleteBlackboardArtifactTagAction.tagDelErr=Tag Deletion Error"
45 })
46 public class DeleteBlackboardArtifactTagAction extends AbstractAction {
47 
48  private static final Logger logger = Logger.getLogger(DeleteBlackboardArtifactTagAction.class.getName());
49 
50  private static final long serialVersionUID = 1L;
51  private static final String MENU_TEXT = NbBundle.getMessage(DeleteBlackboardArtifactTagAction.class,
52  "DeleteBlackboardArtifactTagAction.deleteTag");
53 
54  // This class is a singleton to support multi-selection of nodes, since
55  // org.openide.nodes.NodeOp.findActions(Node[] nodes) will only pick up an Action if every
56  // node in the array returns a reference to the same action object from Node.getActions(boolean).
58 
59  public static synchronized DeleteBlackboardArtifactTagAction getInstance() {
60  if (null == instance) {
61  instance = new DeleteBlackboardArtifactTagAction();
62  }
63  return instance;
64  }
65 
67  super(MENU_TEXT);
68  }
69 
70  @Override
71  public void actionPerformed(ActionEvent event) {
72  final Collection<? extends BlackboardArtifactTag> selectedTags = Utilities.actionsGlobalContext().lookupAll(BlackboardArtifactTag.class);
73  new Thread(() -> {
74  for (BlackboardArtifactTag tag : selectedTags) {
75  try {
77  } catch (TskCoreException | NoCurrentCaseException ex) {
78  Logger.getLogger(DeleteBlackboardArtifactTagAction.class.getName()).log(Level.SEVERE, "Error deleting tag", ex); //NON-NLS
79  SwingUtilities.invokeLater(() -> {
80  JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
81  NbBundle.getMessage(this.getClass(),
82  "DeleteBlackboardArtifactTagAction.unableToDelTag.msg",
83  tag.getName()),
84  NbBundle.getMessage(this.getClass(),
85  "DeleteBlackboardArtifactTagAction.tagDelErr"),
86  JOptionPane.ERROR_MESSAGE);
87  });
88  break;
89  }
90  }
91  }).start();
92  }
93 
94 }
static synchronized DeleteBlackboardArtifactTagAction getInstance()
void deleteBlackboardArtifactTag(BlackboardArtifactTag tag)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2022 Basis Technology. Generated on: Mon Dec 5 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.