Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
CallLogViewer.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019-2021 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.communications.relationships;
20 
21 import java.awt.Component;
22 import java.awt.KeyboardFocusManager;
23 import java.beans.PropertyChangeEvent;
24 import java.beans.PropertyChangeListener;
25 import javax.swing.JPanel;
26 import static javax.swing.SwingUtilities.isDescendingFrom;
27 import javax.swing.table.TableColumn;
28 import org.netbeans.swing.outline.DefaultOutlineModel;
29 import org.netbeans.swing.outline.Outline;
30 import org.openide.explorer.ExplorerManager;
31 import static org.openide.explorer.ExplorerUtils.createLookup;
32 import org.openide.nodes.AbstractNode;
33 import org.openide.nodes.Children;
34 import org.openide.nodes.Node;
35 import org.openide.nodes.NodeAdapter;
36 import org.openide.nodes.NodeMemberEvent;
37 import org.openide.util.Lookup;
38 import org.openide.util.NbBundle.Messages;
42 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER;
43 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START;
44 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION;
45 
50 final class CallLogViewer extends javax.swing.JPanel implements RelationshipsViewer {
51 
52  private static final long serialVersionUID = 1L;
53 
54  private final CallLogsChildNodeFactory nodeFactory;
55 
56  private final CallLogDataViewer callLogDataViewer;
57  private final ModifiableProxyLookup proxyLookup;
58  private PropertyChangeListener focusPropertyListener;
59 
60  @Messages({
61  "CallLogViewer_title=Call Logs",
62  "CallLogViewer_noCallLogs=<No call logs found for selected account>",
63  "CallLogViewer_recipient_label=To/From",
64  "CallLogViewer_duration_label=Duration(seconds)",
65  "CallLogViewer_device_label=Device"
66  })
67 
71  CallLogViewer() {
72  initComponents();
73 
74  callLogDataViewer = new CallLogDataViewer();
75 
76  bottomScrollPane.setViewportView(callLogDataViewer);
77 
78  splitPane.setResizeWeight(0.5);
79  splitPane.setDividerLocation(0.5);
80 
81  nodeFactory = new CallLogsChildNodeFactory(null);
82  proxyLookup = new ModifiableProxyLookup(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
83 
84  outlineViewPanel.hideOutlineView(Bundle.CallLogViewer_noCallLogs());
85 
86  // If changing the order of these columns effects the location of the
87  // phone number column be sure to adjust the renderer code below.
88  outlineViewPanel.getOutlineView().setPropertyColumns(
89  TSK_DIRECTION.getLabel(), TSK_DIRECTION.getDisplayName(),
90  TSK_PHONE_NUMBER.getLabel(), Bundle.CallLogViewer_recipient_label(),
91  TSK_DATETIME_START.getLabel(), TSK_DATETIME_START.getDisplayName(),
92  CallLogNode.DURATION_PROP, Bundle.CallLogViewer_duration_label()
93  );
94 
95  Outline outline = outlineViewPanel.getOutlineView().getOutline();
96  outline.setRootVisible(false);
97  ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(Bundle.CallLogViewer_device_label());
98 
99  outlineViewPanel.getExplorerManager().addPropertyChangeListener((PropertyChangeEvent evt) -> {
100  if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
101  final Node[] nodes = outlineViewPanel.getExplorerManager().getSelectedNodes();
102  callLogDataViewer.setNode(nodes != null && nodes.length > 0 ? nodes[0] : null);
103  }
104  });
105 
106  outlineViewPanel.getExplorerManager().setRootContext(
107  new TableFilterNode(
108  new DataResultFilterNode(
109  new AbstractNode(Children.create(nodeFactory, true)), outlineViewPanel.getExplorerManager()), true));
110 
111  outlineViewPanel.getExplorerManager().getRootContext().addNodeListener(new NodeAdapter() {
112  @Override
113  public void childrenAdded(NodeMemberEvent nme) {
114  updateOutlineViewPanel();
115  }
116 
117  @Override
118  public void childrenRemoved(NodeMemberEvent nme) {
119  updateOutlineViewPanel();
120  }
121  });
122 
123  TableColumn column = outline.getColumnModel().getColumn(2);
124  column.setCellRenderer(new NodeTableCellRenderer());
125 
126  }
127 
133  @SuppressWarnings("unchecked")
134  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
135  private void initComponents() {
136  java.awt.GridBagConstraints gridBagConstraints;
137 
138  splitPane = new javax.swing.JSplitPane();
140  bottomScrollPane = new javax.swing.JScrollPane();
141 
142  setLayout(new java.awt.GridBagLayout());
143 
144  splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
145  splitPane.setLeftComponent(outlineViewPanel);
146  splitPane.setRightComponent(bottomScrollPane);
147 
148  gridBagConstraints = new java.awt.GridBagConstraints();
149  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
150  gridBagConstraints.weightx = 1.0;
151  gridBagConstraints.weighty = 1.0;
152  add(splitPane, gridBagConstraints);
153  }// </editor-fold>//GEN-END:initComponents
154 
155  @Override
156  public String getDisplayName() {
157  return Bundle.CallLogViewer_title();
158  }
159 
160  @Override
161  public JPanel getPanel() {
162  return this;
163  }
164 
165  @Override
166  public void setSelectionInfo(SelectionInfo info) {
167  callLogDataViewer.setNode(null);
168  nodeFactory.refresh(info);
169 
170  }
171 
172  @Override
173  public Lookup getLookup() {
174  return outlineViewPanel.getLookup();
175  }
176 
177  @Override
178  public void addNotify() {
179  super.addNotify();
180 
181  if (focusPropertyListener == null) {
182  // See org.sleuthkit.autopsy.timeline.TimeLineTopComponent for a detailed
183  // explaination of focusPropertyListener
184  focusPropertyListener = (final PropertyChangeEvent focusEvent) -> {
185  if (focusEvent.getPropertyName().equalsIgnoreCase("focusOwner")) {
186  handleFocusChange((Component) focusEvent.getNewValue());
187 
188  }
189  };
190  }
191 
192  //add listener that maintains correct selection in the Global Actions Context
193  KeyboardFocusManager.getCurrentKeyboardFocusManager()
194  .addPropertyChangeListener("focusOwner", focusPropertyListener); //NON-NLS
195  }
196 
202  private void handleFocusChange(Component newFocusOwner) {
203  if (newFocusOwner == null) {
204  return;
205  }
206  if (isDescendingFrom(newFocusOwner, callLogDataViewer)) {
207  //if the focus owner is within the MessageContentViewer (the attachments table)
208  proxyLookup.setNewLookups(createLookup(callLogDataViewer.getExplorerManager(), getActionMap()));
209  } else if (isDescendingFrom(newFocusOwner, this)) {
210  //... or if it is within the Results table.
211  proxyLookup.setNewLookups(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
212 
213  }
214  }
215 
216  @Override
217  public void removeNotify() {
218  super.removeNotify();
219  if (focusPropertyListener != null) {
220  KeyboardFocusManager.getCurrentKeyboardFocusManager()
221  .removePropertyChangeListener("focusOwner", focusPropertyListener); //NON-NLS
222  }
223  }
224 
225  private void updateOutlineViewPanel() {
226  int nodeCount = outlineViewPanel.getExplorerManager().getRootContext().getChildren().getNodesCount();
227  if (nodeCount == 0) {
228  outlineViewPanel.hideOutlineView(Bundle.CallLogViewer_noCallLogs());
229  } else {
230  outlineViewPanel.showOutlineView();
231  }
232  }
233 
234 
235  // Variables declaration - do not modify//GEN-BEGIN:variables
236  private javax.swing.JScrollPane bottomScrollPane;
238  private javax.swing.JSplitPane splitPane;
239  // End of variables declaration//GEN-END:variables
240 }

Copyright © 2012-2022 Basis Technology. Generated on: Mon Dec 5 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.