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;
40 @ServiceProvider(service = DataContentViewer.class, position = 5)
43 private static final long serialVersionUID = 1L;
54 mainScrollPane.setViewportView(dataPanel);
59 Long osAccountId = null;
61 OsAccount osAccount = node.getLookup().lookup(OsAccount.class);
62 if (osAccount != null) {
63 dataPanel.setOsAccount(osAccount);
67 Optional<Long> optional;
68 AbstractFile file = node.getLookup().lookup(AbstractFile.class);
70 optional = file.getOsAccountObjectId();
71 if (optional.isPresent()) {
72 osAccountId = optional.get();
76 if (osAccountId == null) {
77 DataArtifact dataArtifact = node.getLookup().lookup(DataArtifact.class);
78 if (dataArtifact != null) {
79 optional = dataArtifact.getOsAccountObjectId();
80 if (optional.isPresent()) {
81 osAccountId = optional.get();
86 }
catch (TskCoreException ex) {
87 logger.log(Level.SEVERE, String.format(
"Failed to get OsAccount for node %s", node.getDisplayName()), ex);
90 if (osAccountId != null) {
91 dataPanel.setOsAccountId(osAccountId);
96 "OsAccountViewer_title=OS Account"
100 return Bundle.OsAccountViewer_title();
104 "OsAccountViewer_tooltip=Viewer for Operating System accounts related to the selected node."
108 return Bundle.OsAccountViewer_tooltip();
123 dataPanel.setOsAccount(null);
128 AbstractFile file = node.getLookup().lookup(AbstractFile.class);
129 OsAccount osAccount = node.getLookup().lookup(OsAccount.class);
130 DataArtifact dataArtifact = node.getLookup().lookup(DataArtifact.class);
133 return osAccount != null
134 || (file != null && file.getOsAccountObjectId().isPresent())
135 || (dataArtifact != null && dataArtifact.getOsAccountObjectId().isPresent());
136 }
catch (TskCoreException ex) {
137 logger.log(Level.SEVERE, String.format(
"Failed to determine if node %s is Supported for OsAccountViewer", node.getDisplayName()), ex);
152 @SuppressWarnings(
"unchecked")
154 private
void initComponents() {
155 java.awt.GridBagConstraints gridBagConstraints;
157 mainScrollPane =
new javax.swing.JScrollPane();
159 setLayout(
new java.awt.GridBagLayout());
161 mainScrollPane.setPreferredSize(
new java.awt.Dimension(200, 0));
162 gridBagConstraints =
new java.awt.GridBagConstraints();
163 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
164 gridBagConstraints.weightx = 1.0;
165 gridBagConstraints.weighty = 1.0;
166 add(mainScrollPane, gridBagConstraints);
javax.swing.JScrollPane mainScrollPane
boolean isSupported(Node node)
int isPreferred(Node node)
synchronized static Logger getLogger(String name)
DataContentViewer createInstance()