Autopsy  4.16.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 org.netbeans.swing.outline.DefaultOutlineModel;
28 import org.netbeans.swing.outline.Outline;
29 import org.openide.explorer.ExplorerManager;
30 import static org.openide.explorer.ExplorerUtils.createLookup;
31 import org.openide.nodes.AbstractNode;
32 import org.openide.nodes.Children;
33 import org.openide.nodes.Node;
34 import org.openide.nodes.NodeAdapter;
35 import org.openide.nodes.NodeMemberEvent;
36 import org.openide.util.Lookup;
37 import org.openide.util.NbBundle.Messages;
41 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER;
42 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START;
43 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION;
44 
49 final class CallLogViewer extends javax.swing.JPanel implements RelationshipsViewer {
50 
51  private static final long serialVersionUID = 1L;
52 
53  private final CallLogsChildNodeFactory nodeFactory;
54 
55  private final CallLogDataViewer callLogDataViewer;
56  private final ModifiableProxyLookup proxyLookup;
57  private PropertyChangeListener focusPropertyListener;
58 
59  @Messages({
60  "CallLogViewer_title=Call Logs",
61  "CallLogViewer_noCallLogs=<No call logs found for selected account>",
62  "CallLogViewer_recipient_label=To/From",
63  "CallLogViewer_duration_label=Duration(seconds)",
64  "CallLogViewer_device_label=Device"
65  })
66 
70  CallLogViewer() {
71  initComponents();
72 
73  callLogDataViewer = new CallLogDataViewer();
74 
75  bottomScrollPane.setViewportView(callLogDataViewer);
76 
77  splitPane.setResizeWeight(0.5);
78  splitPane.setDividerLocation(0.5);
79 
80  nodeFactory = new CallLogsChildNodeFactory(null);
81  proxyLookup = new ModifiableProxyLookup(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
82 
83  outlineViewPanel.hideOutlineView(Bundle.CallLogViewer_noCallLogs());
84 
85  outlineViewPanel.getOutlineView().setPropertyColumns(
86  TSK_DIRECTION.getLabel(), TSK_DIRECTION.getDisplayName(),
87  TSK_PHONE_NUMBER.getLabel(), Bundle.CallLogViewer_recipient_label(),
88  TSK_DATETIME_START.getLabel(), TSK_DATETIME_START.getDisplayName(),
89  CallLogNode.DURATION_PROP, Bundle.CallLogViewer_duration_label()
90  );
91 
92  Outline outline = outlineViewPanel.getOutlineView().getOutline();
93  outline.setRootVisible(false);
94  ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(Bundle.CallLogViewer_device_label());
95 
96  outlineViewPanel.getExplorerManager().addPropertyChangeListener((PropertyChangeEvent evt) -> {
97  if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
98  final Node[] nodes = outlineViewPanel.getExplorerManager().getSelectedNodes();
99  callLogDataViewer.setNode(nodes != null && nodes.length > 0 ? nodes[0] : null);
100  }
101  });
102 
103  outlineViewPanel.getExplorerManager().setRootContext(
104  new TableFilterNode(
105  new DataResultFilterNode(
106  new AbstractNode(Children.create(nodeFactory, true)), outlineViewPanel.getExplorerManager()), true));
107 
108  outlineViewPanel.getExplorerManager().getRootContext().addNodeListener(new NodeAdapter() {
109  @Override
110  public void childrenAdded(NodeMemberEvent nme) {
111  updateOutlineViewPanel();
112  }
113 
114  @Override
115  public void childrenRemoved(NodeMemberEvent nme) {
116  updateOutlineViewPanel();
117  }
118  });
119 
120  }
121 
127  @SuppressWarnings("unchecked")
128  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
129  private void initComponents() {
130  java.awt.GridBagConstraints gridBagConstraints;
131 
132  splitPane = new javax.swing.JSplitPane();
134  bottomScrollPane = new javax.swing.JScrollPane();
135 
136  setLayout(new java.awt.GridBagLayout());
137 
138  splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
139  splitPane.setLeftComponent(outlineViewPanel);
140  splitPane.setRightComponent(bottomScrollPane);
141 
142  gridBagConstraints = new java.awt.GridBagConstraints();
143  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
144  gridBagConstraints.weightx = 1.0;
145  gridBagConstraints.weighty = 1.0;
146  add(splitPane, gridBagConstraints);
147  }// </editor-fold>//GEN-END:initComponents
148 
149  @Override
150  public String getDisplayName() {
151  return Bundle.CallLogViewer_title();
152  }
153 
154  @Override
155  public JPanel getPanel() {
156  return this;
157  }
158 
159  @Override
160  public void setSelectionInfo(SelectionInfo info) {
161  nodeFactory.refresh(info);
162  }
163 
164  @Override
165  public Lookup getLookup() {
166  return outlineViewPanel.getLookup();
167  }
168 
169  @Override
170  public void addNotify() {
171  super.addNotify();
172 
173  if (focusPropertyListener == null) {
174  // See org.sleuthkit.autopsy.timeline.TimeLineTopComponent for a detailed
175  // explaination of focusPropertyListener
176  focusPropertyListener = (final PropertyChangeEvent focusEvent) -> {
177  if (focusEvent.getPropertyName().equalsIgnoreCase("focusOwner")) {
178  handleFocusChange((Component) focusEvent.getNewValue());
179 
180  }
181  };
182  }
183 
184  //add listener that maintains correct selection in the Global Actions Context
185  KeyboardFocusManager.getCurrentKeyboardFocusManager()
186  .addPropertyChangeListener("focusOwner", focusPropertyListener); //NON-NLS
187  }
188 
194  private void handleFocusChange(Component newFocusOwner) {
195  if (newFocusOwner == null) {
196  return;
197  }
198  if (isDescendingFrom(newFocusOwner, callLogDataViewer)) {
199  //if the focus owner is within the MessageContentViewer (the attachments table)
200  proxyLookup.setNewLookups(createLookup(callLogDataViewer.getExplorerManager(), getActionMap()));
201  } else if (isDescendingFrom(newFocusOwner, this)) {
202  //... or if it is within the Results table.
203  proxyLookup.setNewLookups(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
204 
205  }
206  }
207 
208  @Override
209  public void removeNotify() {
210  super.removeNotify();
211  if (focusPropertyListener != null) {
212  KeyboardFocusManager.getCurrentKeyboardFocusManager()
213  .removePropertyChangeListener("focusOwner", focusPropertyListener); //NON-NLS
214  }
215  }
216 
217  private void updateOutlineViewPanel() {
218  int nodeCount = outlineViewPanel.getExplorerManager().getRootContext().getChildren().getNodesCount();
219  if (nodeCount == 0) {
220  outlineViewPanel.hideOutlineView(Bundle.ContactsViewer_noContacts_message());
221  } else {
222  outlineViewPanel.showOutlineView();
223  }
224  }
225 
226 
227  // Variables declaration - do not modify//GEN-BEGIN:variables
228  private javax.swing.JScrollPane bottomScrollPane;
230  private javax.swing.JSplitPane splitPane;
231  // End of variables declaration//GEN-END:variables
232 }

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