Autopsy  4.19.3
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;
36 import org.sleuthkit.datamodel.ContentTag;
37 import org.sleuthkit.datamodel.TskCoreException;
38 
42 @NbBundle.Messages({
43  "DeleteContentTagAction.deleteTag=Remove Selected Tag(s)",
44  "# {0} - tagName",
45  "DeleteContentTagAction.unableToDelTag.msg=Unable to delete tag {0}.",
46  "DeleteContentTagAction.tagDelErr=Tag Deletion Error"
47 })
48 public class DeleteContentTagAction extends AbstractAction {
49 
50  private static final Logger logger = Logger.getLogger(DeleteContentTagAction.class.getName());
51 
52  private static final long serialVersionUID = 1L;
53  private static final String MENU_TEXT = NbBundle.getMessage(DeleteContentTagAction.class,
54  "DeleteContentTagAction.deleteTag");
55 
56  // This class is a singleton to support multi-selection of nodes, since
57  // org.openide.nodes.NodeOp.findActions(Node[] nodes) will only pick up an Action if every
58  // node in the array returns a reference to the same action object from Node.getActions(boolean).
60 
61  public static synchronized DeleteContentTagAction getInstance() {
62  if (null == instance) {
63  instance = new DeleteContentTagAction();
64  }
65  return instance;
66  }
67 
69  super(MENU_TEXT);
70  }
71 
72  @Override
73  public void actionPerformed(ActionEvent e) {
74  final Collection<? extends ContentTag> selectedTags = Utilities.actionsGlobalContext().lookupAll(ContentTag.class);
75  new Thread(() -> {
76  for (ContentTag tag : selectedTags) {
77  try {
78  // Check if there is an image tag before deleting the content tag.
80  if(imageTag != null) {
82  }
83 
85  } catch (TskCoreException | NoCurrentCaseException ex) {
86  Logger.getLogger(DeleteContentTagAction.class.getName()).log(Level.SEVERE, "Error deleting tag", ex); //NON-NLS
87  SwingUtilities.invokeLater(() -> {
88  JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
89  NbBundle.getMessage(this.getClass(),
90  "DeleteContentTagAction.unableToDelTag.msg",
91  tag.getName()),
92  NbBundle.getMessage(this.getClass(), "DeleteContentTagAction.tagDelErr"),
93  JOptionPane.ERROR_MESSAGE);
94  });
95  break;
96  }
97  }
98  }).start();
99  }
100 
108  @Deprecated
109  protected void doAction(ActionEvent event) {
110  actionPerformed(event);
111  }
112 
121  @Deprecated
122  protected void refreshDirectoryTree() {
123  }
124 
125 }
static synchronized DeleteContentTagAction getInstance()
static< T > ContentViewerTag< T > getTag(ContentTag contentTag, Class< T > clazz)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

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