Autopsy  4.8.0
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-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.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;
35 import org.sleuthkit.datamodel.BlackboardArtifact;
36 import org.sleuthkit.datamodel.TagName;
37 import org.sleuthkit.datamodel.TskCoreException;
38 
39 public class AddBookmarkTagAction extends AbstractAction {
40 
41  public static final KeyStroke BOOKMARK_SHORTCUT = KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_MASK);
42  private static final String NO_COMMENT = "";
43  private static final String BOOKMARK = NbBundle.getMessage(AddBookmarkTagAction.class, "AddBookmarkTagAction.bookmark.text");
44 
45  @Override
46  public void actionPerformed(ActionEvent e) {
47  try {
48  Map<String, TagName> tagNamesMap = Case.getCurrentCaseThrows().getServices().getTagsManager().getDisplayNamesToTagNamesMap();
49  TagName bookmarkTagName = tagNamesMap.get(BOOKMARK);
50 
51  /*
52  * Both AddContentTagAction.addTag and
53  * AddBlackboardArtifactTagAction.addTag do their own lookup
54  * If the selection is a BlackboardArtifact wrapped around an
55  * AbstractFile, tag the artifact by default.
56  */
57  final Collection<BlackboardArtifact> artifacts = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class));
58  if (!artifacts.isEmpty()) {
59  AddBlackboardArtifactTagAction.getInstance().addTag(bookmarkTagName, NO_COMMENT);
60  } else {
61  AddContentTagAction.getInstance().addTag(bookmarkTagName, NO_COMMENT);
62  }
63 
64  } catch (TskCoreException | NoCurrentCaseException ex) {
65  Logger.getLogger(AddBookmarkTagAction.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
66  }
67  }
68 }
static synchronized AddBlackboardArtifactTagAction getInstance()
void addTag(TagName tagName, String comment)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static synchronized AddContentTagAction getInstance()

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