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;
43 class ContentTagNode
extends TagNode {
45 private static final Logger LOGGER = Logger.getLogger(ContentTagNode.class.getName());
46 private static final String ICON_PATH =
"org/sleuthkit/autopsy/images/blue-tag-icon-16.png";
47 private final ContentTag tag;
49 ContentTagNode(ContentTag tag) {
50 super(Lookups.fixed(tag, tag.getContent()), tag.getContent());
51 super.setName(tag.getContent().getName());
52 super.setDisplayName(tag.getContent().getName());
53 this.setIconBaseWithExtension(ICON_PATH);
58 "ContentTagNode.createSheet.origFileName=Original Name",
59 "ContentTagNode.createSheet.artifactMD5.displayName=MD5 Hash",
60 "ContentTagNode.createSheet.artifactMD5.name=MD5 Hash",
61 "ContentTagNode.createSheet.userName.text=User Name"})
63 protected Sheet createSheet() {
64 Content content = tag.getContent();
67 contentPath = content.getUniquePath();
68 }
catch (TskCoreException ex) {
69 LOGGER.log(Level.SEVERE,
"Failed to get path for content (id = " + content.getId() +
")", ex);
70 contentPath = NbBundle.getMessage(this.getClass(),
"ContentTagNode.createSheet.unavail.path");
72 AbstractFile file = content instanceof AbstractFile ? (AbstractFile) content : null;
74 Sheet propertySheet = super.createSheet();
75 Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES);
76 if (properties == null) {
77 properties = Sheet.createPropertiesSet();
78 propertySheet.put(properties);
80 properties.put(
new NodeProperty<>(
81 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.name"),
82 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.displayName"),
85 addOriginalNameProp(properties);
86 properties.put(
new NodeProperty<>(
87 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.name"),
88 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.displayName"),
91 properties.put(
new NodeProperty<>(
92 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.name"),
93 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.displayName"),
96 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.name"),
97 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.displayName"),
99 file != null ? ContentUtils.getStringTime(file.getMtime(), file) :
""));
100 properties.put(
new NodeProperty<>(
101 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.name"),
102 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.displayName"),
104 file != null ? ContentUtils.getStringTime(file.getCtime(), file) :
""));
105 properties.put(
new NodeProperty<>(
106 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.name"),
107 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.displayName"),
109 file != null ? ContentUtils.getStringTime(file.getAtime(), file) :
""));
110 properties.put(
new NodeProperty<>(
111 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.name"),
112 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.displayName"),
114 file != null ? ContentUtils.getStringTime(file.getCrtime(), file) :
""));
115 properties.put(
new NodeProperty<>(
116 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.name"),
117 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.displayName"),
120 properties.put(
new NodeProperty<>(
121 Bundle.ContentTagNode_createSheet_artifactMD5_name(),
122 Bundle.ContentTagNode_createSheet_artifactMD5_displayName(),
124 file != null ? StringUtils.defaultString(file.getMd5Hash()) :
""));
125 properties.put(
new NodeProperty<>(
126 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.userName.text"),
127 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.userName.text"),
130 return propertySheet;
134 public Action[] getActions(
boolean context) {
135 List<Action> actions =
new ArrayList<>();
136 actions.addAll(Arrays.asList(super.getActions(context)));
138 AbstractFile file = getLookup().lookup(AbstractFile.class);
140 actions.add(ViewFileInTimelineAction.createViewFileAction(file));
143 actions.addAll(DataModelActionsFactory.getActions(tag,
false));
145 return actions.toArray(
new Action[actions.size()]);
149 public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
150 return visitor.visit(
this);
154 public String getItemType() {
155 return getClass().getName();