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 Logger LOGGER = Logger.getLogger(ContentTagNode.class.getName());
47 private static final String ICON_PATH =
"org/sleuthkit/autopsy/images/blue-tag-icon-16.png";
48 private final ContentTag tag;
50 public ContentTagNode(ContentTag tag) {
51 super(Children.LEAF, Lookups.fixed(tag, tag.getContent()));
52 super.setName(tag.getContent().getName());
53 super.setDisplayName(tag.getContent().getName());
54 this.setIconBaseWithExtension(ICON_PATH);
59 protected Sheet createSheet() {
60 Content content = tag.getContent();
63 contentPath = content.getUniquePath();
64 }
catch (TskCoreException ex) {
65 LOGGER.log(Level.SEVERE,
"Failed to get path for content (id = " + content.getId() +
")", ex);
66 contentPath = NbBundle.getMessage(this.getClass(),
"ContentTagNode.createSheet.unavail.path");
68 AbstractFile file = content instanceof AbstractFile ? (AbstractFile) content : null;
70 Sheet propertySheet = super.createSheet();
71 Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES);
72 if (properties == null) {
73 properties = Sheet.createPropertiesSet();
74 propertySheet.put(properties);
76 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.name"),
77 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.displayName"),
80 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.name"),
81 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.displayName"),
84 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.name"),
85 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.displayName"),
88 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.name"),
89 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.displayName"),
91 file != null ? ContentUtils.getStringTime(file.getMtime(), file) :
""));
92 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.name"),
93 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.displayName"),
95 file != null ? ContentUtils.getStringTime(file.getCtime(), file) :
""));
96 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.name"),
97 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.displayName"),
99 file != null ? ContentUtils.getStringTime(file.getAtime(), file) :
""));
100 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.name"),
101 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.displayName"),
103 file != null ? ContentUtils.getStringTime(file.getCrtime(), file) :
""));
104 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.name"),
105 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.displayName"),
109 return propertySheet;
113 public Action[] getActions(
boolean context) {
114 List<Action> actions = DataModelActionsFactory.getActions(tag.getContent(),
false);
115 actions.addAll(Arrays.asList(super.getActions(context)));
117 AbstractFile file = getLookup().lookup(AbstractFile.class);
119 actions.add(ViewFileInTimelineAction.createViewFileAction(file));
122 actions.add(DeleteContentTagAction.getInstance());
123 return actions.toArray(
new Action[actions.size()]);
127 public <T> T accept(DisplayableItemNodeVisitor<T> v) {
128 return v.visit(
this);
132 public boolean isLeafTypeNode() {
137 public String getItemType() {
138 return getClass().getName();