19 package org.sleuthkit.autopsy.datamodel;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.List;
24 import java.util.logging.Level;
25 import javax.swing.Action;
26 import org.openide.nodes.Children;
27 import org.openide.nodes.Sheet;
28 import org.openide.util.NbBundle;
29 import org.openide.util.lookup.Lookups;
44 class ContentTagNode
extends DisplayableItemNode {
46 private static final Logger LOGGER = Logger.getLogger(ContentTagNode.class.getName());
48 private static final String ICON_PATH =
"org/sleuthkit/autopsy/images/blue-tag-icon-16.png";
49 private final ContentTag tag;
51 public ContentTagNode(ContentTag tag) {
52 super(Children.LEAF, Lookups.fixed(tag, tag.getContent()));
53 super.setName(tag.getContent().getName());
54 super.setDisplayName(tag.getContent().getName());
55 this.setIconBaseWithExtension(ICON_PATH);
60 protected Sheet createSheet() {
61 Content content = tag.getContent();
64 contentPath = content.getUniquePath();
65 }
catch (TskCoreException ex) {
66 LOGGER.log(Level.SEVERE,
"Failed to get path for content (id = " + content.getId() +
")", ex);
67 contentPath = NbBundle.getMessage(this.getClass(),
"ContentTagNode.createSheet.unavail.path");
69 AbstractFile file = content instanceof AbstractFile ? (AbstractFile) content : null;
71 Sheet propertySheet = super.createSheet();
72 Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES);
73 if (properties == null) {
74 properties = Sheet.createPropertiesSet();
75 propertySheet.put(properties);
77 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.name"),
78 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.displayName"),
81 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.name"),
82 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.displayName"),
85 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.name"),
86 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.displayName"),
89 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.name"),
90 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.displayName"),
92 file != null ? ContentUtils.getStringTime(file.getMtime(), file) :
""));
93 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.name"),
94 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.displayName"),
96 file != null ? ContentUtils.getStringTime(file.getCtime(), file) :
""));
97 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.name"),
98 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.displayName"),
100 file != null ? ContentUtils.getStringTime(file.getAtime(), file) :
""));
101 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.name"),
102 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.displayName"),
104 file != null ? ContentUtils.getStringTime(file.getCrtime(), file) :
""));
105 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.name"),
106 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.displayName"),
110 return propertySheet;
114 public Action[] getActions(
boolean context) {
115 List<Action> actions =
new ArrayList<>();
116 actions.addAll(Arrays.asList(super.getActions(context)));
118 AbstractFile file = getLookup().lookup(AbstractFile.class);
120 actions.add(ViewFileInTimelineAction.createViewFileAction(file));
122 actions.addAll(DataModelActionsFactory.getActions(tag.getContent(),
false));
123 actions.add(DeleteContentTagAction.getInstance());
124 return actions.toArray(
new Action[actions.size()]);
128 public <T> T accept(DisplayableItemNodeVisitor<T> v) {
129 return v.visit(
this);
133 public boolean isLeafTypeNode() {
138 public String getItemType() {
139 return getClass().getName();