Autopsy  4.17.0
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 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  nodeFactory.refresh(info);
168  }
169 
170  @Override
171  public Lookup getLookup() {
172  return outlineViewPanel.getLookup();
173  }
174 
175  @Override
176  public void addNotify() {
177  super.addNotify();
178 
179  if (focusPropertyListener == null) {
180  // See org.sleuthkit.autopsy.timeline.TimeLineTopComponent for a detailed
181  // explaination of focusPropertyListener
182  focusPropertyListener = (final PropertyChangeEvent focusEvent) -> {
183  if (focusEvent.getPropertyName().equalsIgnoreCase("focusOwner")) {
184  handleFocusChange((Component) focusEvent.getNewValue());
185 
186  }
187  };
188  }
189 
190  //add listener that maintains correct selection in the Global Actions Context
191  KeyboardFocusManager.getCurrentKeyboardFocusManager()
192  .addPropertyChangeListener("focusOwner", focusPropertyListener); //NON-NLS
193  }
194 
200  private void handleFocusChange(Component newFocusOwner) {
201  if (newFocusOwner == null) {
202  return;
203  }
204  if (isDescendingFrom(newFocusOwner, callLogDataViewer)) {
205  //if the focus owner is within the MessageContentViewer (the attachments table)
206  proxyLookup.setNewLookups(createLookup(callLogDataViewer.getExplorerManager(), getActionMap()));
207  } else if (isDescendingFrom(newFocusOwner, this)) {
208  //... or if it is within the Results table.
209  proxyLookup.setNewLookups(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
210 
211  }
212  }
213 
214  @Override
215  public void removeNotify() {
216  super.removeNotify();
217  if (focusPropertyListener != null) {
218  KeyboardFocusManager.getCurrentKeyboardFocusManager()
219  .removePropertyChangeListener("focusOwner", focusPropertyListener); //NON-NLS
220  }
221  }
222 
223  private void updateOutlineViewPanel() {
224  int nodeCount = outlineViewPanel.getExplorerManager().getRootContext().getChildren().getNodesCount();
225  if (nodeCount == 0) {
226  outlineViewPanel.hideOutlineView(Bundle.ContactsViewer_noContacts_message());
227  } else {
228  outlineViewPanel.showOutlineView();
229  }
230  }
231 
232 
233  // Variables declaration - do not modify//GEN-BEGIN:variables
234  private javax.swing.JScrollPane bottomScrollPane;
236  private javax.swing.JSplitPane splitPane;
237  // End of variables declaration//GEN-END:variables
238 }

Copyright © 2012-2021 Basis Technology. Generated on: Tue Jan 19 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.