19 package org.sleuthkit.autopsy.datamodel;
21 import java.util.Arrays;
22 import java.util.List;
23 import java.util.logging.Level;
24 import javax.swing.Action;
25 import org.openide.nodes.Children;
26 import org.openide.nodes.Sheet;
27 import org.openide.util.NbBundle;
28 import org.openide.util.lookup.Lookups;
43 class ContentTagNode
extends DisplayableItemNode {
45 private static final String ICON_PATH =
"org/sleuthkit/autopsy/images/blue-tag-icon-16.png";
46 private final ContentTag tag;
48 public ContentTagNode(ContentTag tag) {
49 super(Children.LEAF, Lookups.fixed(tag, tag.getContent()));
50 super.setName(tag.getContent().getName());
51 super.setDisplayName(tag.getContent().getName());
52 this.setIconBaseWithExtension(ICON_PATH);
57 protected Sheet createSheet() {
58 Content content = tag.getContent();
61 contentPath = content.getUniquePath();
62 }
catch (TskCoreException ex) {
63 Logger.getLogger(ContentTagNode.class.getName()).log(Level.SEVERE,
"Failed to get path for content (id = " + content.getId() +
")", ex);
64 contentPath = NbBundle.getMessage(this.getClass(),
"ContentTagNode.createSheet.unavail.path");
66 AbstractFile file = content instanceof AbstractFile ? (AbstractFile) content : null;
68 Sheet propertySheet = super.createSheet();
69 Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES);
70 if (properties == null) {
71 properties = Sheet.createPropertiesSet();
72 propertySheet.put(properties);
74 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.name"),
75 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.displayName"),
78 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.name"),
79 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.displayName"),
82 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.name"),
83 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.displayName"),
86 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.name"),
87 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.displayName"),
89 file != null ? ContentUtils.getStringTime(file.getMtime(), file) :
""));
90 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.name"),
91 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.displayName"),
93 file != null ? ContentUtils.getStringTime(file.getCtime(), file) :
""));
94 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.name"),
95 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.displayName"),
97 file != null ? ContentUtils.getStringTime(file.getAtime(), file) :
""));
98 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.name"),
99 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.displayName"),
101 file != null ? ContentUtils.getStringTime(file.getCrtime(), file) :
""));
102 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.name"),
103 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.displayName"),
106 return propertySheet;
110 public Action[] getActions(
boolean context) {
111 List<Action> actions = DataModelActionsFactory.getActions(tag.getContent(),
false);
112 actions.addAll(Arrays.asList(super.getActions(context)));
114 AbstractFile file = getLookup().lookup(AbstractFile.class);
116 actions.add(ViewFileInTimelineAction.createViewFileAction(file));
119 actions.add(DeleteContentTagAction.getInstance());
120 return actions.toArray(
new Action[actions.size()]);
124 public <T> T accept(DisplayableItemNodeVisitor<T> v) {
125 return v.visit(
this);
129 public boolean isLeafTypeNode() {