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.apache.commons.lang3.StringUtils;
27 import org.openide.nodes.Sheet;
28 import org.openide.util.NbBundle;
29 import org.openide.util.NbBundle.Messages;
30 import org.openide.util.lookup.Lookups;
44 class ContentTagNode
extends TagNode {
46 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 ContentTagNode(ContentTag tag) {
51 super(Lookups.fixed(tag, tag.getContent()), tag.getContent());
52 super.setName(tag.getContent().getName());
53 super.setDisplayName(tag.getContent().getName());
54 this.setIconBaseWithExtension(ICON_PATH);
59 "ContentTagNode.createSheet.origFileName=Original Name",
60 "ContentTagNode.createSheet.artifactMD5.displayName=MD5 Hash",
61 "ContentTagNode.createSheet.artifactMD5.name=MD5 Hash",
62 "ContentTagNode.createSheet.userName.text=User Name"})
64 protected Sheet createSheet() {
65 Content content = tag.getContent();
68 contentPath = content.getUniquePath();
69 }
catch (TskCoreException ex) {
70 LOGGER.log(Level.SEVERE,
"Failed to get path for content (id = " + content.getId() +
")", ex);
71 contentPath = NbBundle.getMessage(this.getClass(),
"ContentTagNode.createSheet.unavail.path");
73 AbstractFile file = content instanceof AbstractFile ? (AbstractFile) content : null;
75 Sheet propertySheet = super.createSheet();
76 Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES);
77 if (properties == null) {
78 properties = Sheet.createPropertiesSet();
79 propertySheet.put(properties);
81 properties.put(
new NodeProperty<>(
82 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.name"),
83 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.displayName"),
86 addOriginalNameProp(properties);
87 properties.put(
new NodeProperty<>(
88 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.name"),
89 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.displayName"),
92 properties.put(
new NodeProperty<>(
93 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.name"),
94 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.displayName"),
97 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.name"),
98 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.displayName"),
100 file != null ? TimeZoneUtils.getFormattedTime(file.getMtime()) :
""));
101 properties.put(
new NodeProperty<>(
102 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.name"),
103 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.displayName"),
105 file != null ? TimeZoneUtils.getFormattedTime(file.getCtime()) :
""));
106 properties.put(
new NodeProperty<>(
107 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.name"),
108 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.displayName"),
110 file != null ? TimeZoneUtils.getFormattedTime(file.getAtime()) :
""));
111 properties.put(
new NodeProperty<>(
112 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.name"),
113 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.displayName"),
115 file != null ? TimeZoneUtils.getFormattedTime(file.getCrtime()) :
""));
116 properties.put(
new NodeProperty<>(
117 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.name"),
118 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.displayName"),
121 properties.put(
new NodeProperty<>(
122 Bundle.ContentTagNode_createSheet_artifactMD5_name(),
123 Bundle.ContentTagNode_createSheet_artifactMD5_displayName(),
125 file != null ? StringUtils.defaultString(file.getMd5Hash()) :
""));
126 properties.put(
new NodeProperty<>(
127 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.userName.text"),
128 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.userName.text"),
131 return propertySheet;
135 public Action[] getActions(
boolean context) {
136 List<Action> actions =
new ArrayList<>();
137 actions.addAll(Arrays.asList(super.getActions(context)));
139 AbstractFile file = getLookup().lookup(AbstractFile.class);
141 actions.add(ViewFileInTimelineAction.createViewFileAction(file));
144 actions.addAll(DataModelActionsFactory.getActions(tag,
false));
146 return actions.toArray(
new Action[actions.size()]);
150 public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
151 return visitor.visit(
this);
155 public String getItemType() {
156 return getClass().getName();