19 package org.sleuthkit.autopsy.datamodel;
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;
41 class ContentTagNode
extends DisplayableItemNode {
43 private static final String ICON_PATH =
"org/sleuthkit/autopsy/images/blue-tag-icon-16.png";
44 private final ContentTag tag;
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);
55 protected Sheet createSheet() {
56 Content content = tag.getContent();
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);
62 contentPath = NbBundle.getMessage(this.getClass(),
"ContentTagNode.createSheet.unavail.path");
64 AbstractFile file = content instanceof AbstractFile ? (AbstractFile)content : null;
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);
72 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.name"),
73 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.displayName"),
76 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.name"),
77 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.displayName"),
80 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.name"),
81 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.displayName"),
84 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.name"),
85 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.displayName"),
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"),
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"),
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"),
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"),
104 return propertySheet;
108 public Action[] getActions(
boolean context) {
109 List<Action> actions = DataModelActionsFactory.getActions(tag.getContent(),
false);
111 actions.add(DeleteContentTagAction.getInstance());
112 return actions.toArray(
new Action[0]);
116 public <T> T accept(DisplayableItemNodeVisitor<T> v) {
117 return v.visit(
this);
121 public boolean isLeafTypeNode() {