Autopsy  4.5.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
MessageBrowser.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2017 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 obt ain 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;
20 
21 import java.util.Collections;
22 import java.util.Set;
23 import java.util.stream.Collectors;
24 import java.util.stream.Stream;
25 import org.openide.explorer.ExplorerManager;
26 import org.openide.nodes.Node;
32 import org.sleuthkit.datamodel.AccountDeviceInstance;
33 import org.sleuthkit.datamodel.CommunicationsFilter;
34 import org.sleuthkit.datamodel.CommunicationsManager;
35 
40 final class MessageBrowser extends javax.swing.JPanel implements ExplorerManager.Provider {
41 
42  private static final long serialVersionUID = 1L;
43  private final ExplorerManager gacExplorerManager;
44  private final DataResultPanel messagesResultPanel;
45  private DataResultViewerTable dataResultViewerTable;
46 
56  MessageBrowser(ExplorerManager gacExplorerManager) {
57  this.gacExplorerManager = gacExplorerManager;
58  initComponents();
59  //create an uninitialized DataResultPanel so we can control the ResultViewers that get added.
60  messagesResultPanel = DataResultPanel.createInstanceUninitialized("Account", "", Node.EMPTY, 0, messageDataContent);
61  splitPane.setTopComponent(messagesResultPanel);
62  splitPane.setBottomComponent(messageDataContent);
63  }
64 
65  @Override
66  public void addNotify() {
67  super.addNotify();
68  ExplorerManager parentExplorerManager = ExplorerManager.find(this);
69  parentExplorerManager.addPropertyChangeListener(pce -> {
70  if (pce.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
71  final Node[] selectedNodes = parentExplorerManager.getSelectedNodes();
72 
73  messagesResultPanel.setNumMatches(0);
74  messagesResultPanel.setNode(null);
75 
76  if (selectedNodes.length == 0) {
77  //reset panel when there is no selection
78  messagesResultPanel.setPath("");
79  } else {
80  AccountDeviceInstanceNode adiNode = (AccountDeviceInstanceNode) selectedNodes[0];
81  CommunicationsFilter filter = adiNode.getFilter();
82  CommunicationsManager commsManager = adiNode.getCommsManager();
83  final Set<AccountDeviceInstance> accountDeviceInstances;
84 
85  if (selectedNodes.length == 1) {
86  final AccountDeviceInstance accountDeviceInstance = adiNode.getAccountDeviceInstance();
87  accountDeviceInstances = Collections.singleton(accountDeviceInstance);
88  messagesResultPanel.setPath(accountDeviceInstance.getAccount().getTypeSpecificID());
89  } else {
90  accountDeviceInstances = Stream.of(selectedNodes)
91  .map(node -> (AccountDeviceInstanceNode) node)
92  .map(AccountDeviceInstanceNode::getAccountDeviceInstance)
93  .collect(Collectors.toSet());
94  messagesResultPanel.setPath(selectedNodes.length + " accounts");
95  }
96  AccountDetailsNode accountDetailsNode
97  = new AccountDetailsNode(accountDeviceInstances, filter, commsManager);
98  TableFilterNode wrappedNode
99  = new TableFilterNode(new DataResultFilterNode(accountDetailsNode, parentExplorerManager), true);
100  messagesResultPanel.setNode(wrappedNode);
101  }
102  }
103  });
104 
105  //add the required result viewers and THEN open the panel
106  if (null == dataResultViewerTable) {
107  dataResultViewerTable = new DataResultViewerTable(gacExplorerManager, "Messages");
108  messagesResultPanel.addResultViewer(dataResultViewerTable);
109  }
110  messagesResultPanel.open();
111  }
112 
113  @Override
114  public ExplorerManager getExplorerManager() {
115  return gacExplorerManager;
116  }
117 
123  @SuppressWarnings("unchecked")
124  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
125  private void initComponents() {
126 
127  splitPane = new javax.swing.JSplitPane();
128  messageDataContent = new org.sleuthkit.autopsy.communications.MessageDataContent();
129 
130  splitPane.setDividerLocation(400);
131  splitPane.setDividerSize(10);
132  splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
133  splitPane.setResizeWeight(0.5);
134  splitPane.setBottomComponent(messageDataContent);
135 
136  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
137  this.setLayout(layout);
138  layout.setHorizontalGroup(
139  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
140  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
141  .addGap(0, 0, 0)
142  .addComponent(splitPane))
143  );
144  layout.setVerticalGroup(
145  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
146  .addGroup(layout.createSequentialGroup()
147  .addGap(0, 0, 0)
148  .addComponent(splitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1083, Short.MAX_VALUE)
149  .addGap(0, 0, 0))
150  );
151  }// </editor-fold>//GEN-END:initComponents
152 
153 
154  // Variables declaration - do not modify//GEN-BEGIN:variables
155  private org.sleuthkit.autopsy.communications.MessageDataContent messageDataContent;
156  private javax.swing.JSplitPane splitPane;
157  // End of variables declaration//GEN-END:variables
158 
159 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Feb 20 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.