19 package org.sleuthkit.autopsy.contentviewers.osaccount;
21 import java.awt.BorderLayout;
22 import java.awt.Component;
23 import java.beans.PropertyChangeEvent;
24 import java.beans.PropertyChangeListener;
25 import java.util.Optional;
26 import java.util.logging.Level;
27 import org.openide.nodes.Node;
28 import org.openide.util.NbBundle.Messages;
29 import org.openide.util.lookup.ServiceProvider;
41 @ServiceProvider(service = DataContentViewer.class, position = 5)
44 private static final long serialVersionUID = 1L;
55 mainScrollPane.setViewportView(dataPanel);
60 Long osAccountId = null;
62 OsAccount osAccount = node.getLookup().lookup(OsAccount.class);
63 if (osAccount != null) {
64 dataPanel.setOsAccount(osAccount);
68 Optional<Long> optional;
69 AbstractFile file = node.getLookup().lookup(AbstractFile.class);
71 optional = file.getOsAccountObjectId();
72 if (optional.isPresent()) {
73 osAccountId = optional.get();
77 if (osAccountId == null) {
78 DataArtifact dataArtifact = node.getLookup().lookup(DataArtifact.class);
79 if (dataArtifact != null) {
80 optional = dataArtifact.getOsAccountObjectId();
81 if (optional.isPresent()) {
82 osAccountId = optional.get();
87 }
catch (TskCoreException ex) {
88 logger.log(Level.SEVERE, String.format(
"Failed to get OsAccount for node %s", node.getDisplayName()), ex);
91 if (osAccountId != null) {
92 dataPanel.setOsAccountId(osAccountId);
97 "OsAccountViewer_title=OS Account"
101 return Bundle.OsAccountViewer_title();
105 "OsAccountViewer_tooltip=Viewer for Operating System accounts related to the selected node."
109 return Bundle.OsAccountViewer_tooltip();
124 dataPanel.setOsAccount(null);
129 AbstractFile file = node.getLookup().lookup(AbstractFile.class);
130 OsAccount osAccount = node.getLookup().lookup(OsAccount.class);
131 DataArtifact dataArtifact = node.getLookup().lookup(DataArtifact.class);
134 return osAccount != null
135 || (file != null && file.getOsAccountObjectId().isPresent())
136 || (dataArtifact != null && dataArtifact.getOsAccountObjectId().isPresent());
137 }
catch (TskCoreException ex) {
138 logger.log(Level.SEVERE, String.format(
"Failed to determine if node %s is Supported for OsAccountViewer", node.getDisplayName()), ex);
153 @SuppressWarnings(
"unchecked")
155 private
void initComponents() {
156 java.awt.GridBagConstraints gridBagConstraints;
158 mainScrollPane =
new javax.swing.JScrollPane();
160 setLayout(
new java.awt.GridBagLayout());
162 mainScrollPane.setPreferredSize(
new java.awt.Dimension(200, 0));
163 gridBagConstraints =
new java.awt.GridBagConstraints();
164 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
165 gridBagConstraints.weightx = 1.0;
166 gridBagConstraints.weighty = 1.0;
167 add(mainScrollPane, gridBagConstraints);
javax.swing.JScrollPane mainScrollPane
boolean isSupported(Node node)
int isPreferred(Node node)
synchronized static Logger getLogger(String name)
DataContentViewer createInstance()