Autopsy  4.4
Graphical digital forensics platform for The Sleuth Kit and other tools.
AddBookmarkTagAction.java
Go to the documentation of this file.
1 /*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2011-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.awt.event.InputEvent;
23 import java.awt.event.KeyEvent;
24 import java.util.Collection;
25 import java.util.HashSet;
26 import java.util.Map;
27 import java.util.logging.Level;
28 import javax.swing.AbstractAction;
29 import javax.swing.KeyStroke;
30 import org.openide.util.NbBundle;
31 import org.openide.util.Utilities;
34 import org.sleuthkit.datamodel.BlackboardArtifact;
35 import org.sleuthkit.datamodel.TagName;
36 import org.sleuthkit.datamodel.TskCoreException;
37 
38 public class AddBookmarkTagAction extends AbstractAction {
39 
40  public static final KeyStroke BOOKMARK_SHORTCUT = KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_MASK);
41  private static final String NO_COMMENT = "";
42  private static final String BOOKMARK = NbBundle.getMessage(AddBookmarkTagAction.class, "AddBookmarkTagAction.bookmark.text");
43 
44  @Override
45  public void actionPerformed(ActionEvent e) {
46  try {
47  Map<String, TagName> tagNamesMap = Case.getCurrentCase().getServices().getTagsManager().getDisplayNamesToTagNamesMap();
48  TagName bookmarkTagName = tagNamesMap.get(BOOKMARK);
49 
50  /*
51  * Both AddContentTagAction.addTag and
52  * AddBlackboardArtifactTagAction.addTag do their own lookup
53  * If the selection is a BlackboardArtifact wrapped around an
54  * AbstractFile, tag the artifact by default.
55  */
56  final Collection<BlackboardArtifact> artifacts = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class));
57  if (!artifacts.isEmpty()) {
58  AddBlackboardArtifactTagAction.getInstance().addTag(bookmarkTagName, NO_COMMENT);
59  } else {
60  AddContentTagAction.getInstance().addTag(bookmarkTagName, NO_COMMENT);
61  }
62 
63  } catch (TskCoreException ex) {
64  Logger.getLogger(AddBookmarkTagAction.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
65  }
66  }
67 }
static synchronized AddBlackboardArtifactTagAction getInstance()
void addTag(TagName tagName, String comment)
synchronized Map< String, TagName > getDisplayNamesToTagNamesMap()
synchronized static Logger getLogger(String name)
Definition: Logger.java:161
static synchronized AddContentTagAction getInstance()

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