Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ContentTagNode.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.datamodel;
20 
21 import java.util.List;
22 import java.util.logging.Level;
23 import javax.swing.Action;
24 import org.openide.nodes.Children;
25 import org.openide.nodes.Sheet;
26 import org.openide.util.NbBundle;
27 import org.openide.util.lookup.Lookups;
30 import org.sleuthkit.datamodel.AbstractFile;
31 import org.sleuthkit.datamodel.Content;
32 import org.sleuthkit.datamodel.ContentTag;
33 import org.sleuthkit.datamodel.TskCoreException;
34 
41 class ContentTagNode extends DisplayableItemNode {
42 
43  private static final String ICON_PATH = "org/sleuthkit/autopsy/images/blue-tag-icon-16.png"; //NON-NLS
44  private final ContentTag tag;
45 
46  public ContentTagNode(ContentTag tag) {
47  super(Children.LEAF, Lookups.fixed(tag, tag.getContent()));
48  super.setName(tag.getContent().getName());
49  super.setDisplayName(tag.getContent().getName());
50  this.setIconBaseWithExtension(ICON_PATH);
51  this.tag = tag;
52  }
53 
54  @Override
55  protected Sheet createSheet() {
56  Content content = tag.getContent();
57  String contentPath;
58  try {
59  contentPath = content.getUniquePath();
60  } catch (TskCoreException ex) {
61  Logger.getLogger(ContentTagNode.class.getName()).log(Level.SEVERE, "Failed to get path for content (id = " + content.getId() + ")", ex); //NON-NLS
62  contentPath = NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.unavail.path");
63  }
64  AbstractFile file = content instanceof AbstractFile ? (AbstractFile) content : null;
65 
66  Sheet propertySheet = super.createSheet();
67  Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES);
68  if (properties == null) {
69  properties = Sheet.createPropertiesSet();
70  propertySheet.put(properties);
71  }
72  properties.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.file.name"),
73  NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.file.displayName"),
74  "",
75  content.getName()));
76  properties.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.filePath.name"),
77  NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.filePath.displayName"),
78  "",
79  contentPath));
80  properties.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.comment.name"),
81  NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.comment.displayName"),
82  "",
83  tag.getComment()));
84  properties.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.fileModifiedTime.name"),
85  NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.fileModifiedTime.displayName"),
86  "",
87  file != null ? ContentUtils.getStringTime(file.getMtime(), file) : ""));
88  properties.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.fileChangedTime.name"),
89  NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.fileChangedTime.displayName"),
90  "",
91  file != null ? ContentUtils.getStringTime(file.getCtime(), file) : ""));
92  properties.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.fileAccessedTime.name"),
93  NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.fileAccessedTime.displayName"),
94  "",
95  file != null ? ContentUtils.getStringTime(file.getAtime(), file) : ""));
96  properties.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.fileCreatedTime.name"),
97  NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.fileCreatedTime.displayName"),
98  "",
99  file != null ? ContentUtils.getStringTime(file.getCrtime(), file) : ""));
100  properties.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.fileSize.name"),
101  NbBundle.getMessage(this.getClass(), "ContentTagNode.createSheet.fileSize.displayName"),
102  "",
103  content.getSize()));
104  return propertySheet;
105  }
106 
107  @Override
108  public Action[] getActions(boolean context) {
109  List<Action> actions = DataModelActionsFactory.getActions(tag.getContent(), false);
110  actions.add(null); // Adds a menu item separator.
111  actions.add(DeleteContentTagAction.getInstance());
112  return actions.toArray(new Action[0]);
113  }
114 
115  @Override
116  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
117  return v.visit(this);
118  }
119 
120  @Override
121  public boolean isLeafTypeNode() {
122  return true;
123  }
124 
125  /*
126  * TODO (AUT-1849): Correct or remove peristent column reordering code
127  *
128  * Added to support this feature.
129  */
130 // @Override
131 // public String getItemType() {
132 // return "ContentTag"; //NON-NLS
133 // }
134 }

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.