Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AddBlackboardArtifactTagAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013 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.util.Collection;
22 import java.util.logging.Level;
23 import javax.swing.JOptionPane;
24 
25 import org.openide.util.NbBundle;
26 import org.openide.util.Utilities;
32 
36 public class AddBlackboardArtifactTagAction extends AddTagAction {
37  // This class is a singleton to support multi-selection of nodes, since
38  // org.openide.nodes.NodeOp.findActions(Node[] nodes) will only pick up an Action if every
39  // node in the array returns a reference to the same action object from Node.getActions(boolean).
41 
42  public static synchronized AddBlackboardArtifactTagAction getInstance() {
43  if (null == instance) {
44  instance = new AddBlackboardArtifactTagAction();
45  }
46  return instance;
47  }
48 
50  super("");
51  }
52 
53  @Override
54  protected String getActionDisplayName() {
55  String singularTagResult = NbBundle.getMessage(this.getClass(),
56  "AddBlackboardArtifactTagAction.singularTagResult");
57  String pluralTagResult = NbBundle.getMessage(this.getClass(),
58  "AddBlackboardArtifactTagAction.pluralTagResult");
59  return Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class).size() > 1 ? pluralTagResult : singularTagResult;
60  }
61 
62  @Override
63  protected void addTag(TagName tagName, String comment) {
64  Collection<? extends BlackboardArtifact> selectedArtifacts = Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class);
65  for (BlackboardArtifact artifact : selectedArtifacts) {
66  try {
67  Case.getCurrentCase().getServices().getTagsManager().addBlackboardArtifactTag(artifact, tagName, comment);
68  }
69  catch (TskCoreException ex) {
70  Logger.getLogger(AddBlackboardArtifactTagAction.class.getName()).log(Level.SEVERE, "Error tagging result", ex); //NON-NLS
71  JOptionPane.showMessageDialog(null,
72  NbBundle.getMessage(this.getClass(),
73  "AddBlackboardArtifactTagAction.unableToTag.msg",
74  artifact.getDisplayName()),
75  NbBundle.getMessage(this.getClass(),
76  "AddBlackboardArtifactTagAction.taggingErr"),
77  JOptionPane.ERROR_MESSAGE);
78  }
79  }
80  }
81 }
static synchronized AddBlackboardArtifactTagAction getInstance()
BlackboardArtifactTag addBlackboardArtifactTag(BlackboardArtifact artifact, TagName tagName)
static Logger getLogger(String name)
Definition: Logger.java:131

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