Autopsy  4.11.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
MessagesPanel.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 static javax.swing.SwingUtilities.isDescendingFrom;
26 import org.netbeans.swing.outline.DefaultOutlineModel;
27 import org.netbeans.swing.outline.Outline;
28 import org.openide.explorer.ExplorerManager;
29 import static org.openide.explorer.ExplorerUtils.createLookup;
30 import org.openide.nodes.AbstractNode;
31 import org.openide.nodes.ChildFactory;
32 import org.openide.nodes.Children;
33 import org.openide.nodes.Node;
34 import org.openide.util.Lookup;
38 
44 public class MessagesPanel extends javax.swing.JPanel implements Lookup.Provider {
45 
46  private final Outline outline;
48  private final PropertyChangeListener focusPropertyListener;
49 
53  public MessagesPanel() {
55 
56  proxyLookup = new ModifiableProxyLookup(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
57 
58  // See org.sleuthkit.autopsy.timeline.TimeLineTopComponent for a detailed
59  // explaination of focusPropertyListener
60  focusPropertyListener = (final PropertyChangeEvent focusEvent) -> {
61  if (focusEvent.getPropertyName().equalsIgnoreCase("focusOwner")) {
62  final Component newFocusOwner = (Component) focusEvent.getNewValue();
63 
64  if (newFocusOwner == null) {
65  return;
66  }
67  if (isDescendingFrom(newFocusOwner, messageContentViewer)) {
68  //if the focus owner is within the MessageContentViewer (the attachments table)
69  proxyLookup.setNewLookups(createLookup(((MessageDataContent) messageContentViewer).getExplorerManager(), getActionMap()));
70  } else if (isDescendingFrom(newFocusOwner, MessagesPanel.this)) {
71  //... or if it is within the Results table.
72  proxyLookup.setNewLookups(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
73 
74  }
75  }
76  };
77 
78  outline = outlineViewPanel.getOutlineView().getOutline();
79  outlineViewPanel.getOutlineView().setPropertyColumns(
80  "From", Bundle.MessageViewer_columnHeader_From(),
81  "To", Bundle.MessageViewer_columnHeader_To(),
82  "Date", Bundle.MessageViewer_columnHeader_Date(),
83  "Subject", Bundle.MessageViewer_columnHeader_Subject(),
84  "Attms", Bundle.MessageViewer_columnHeader_Attms()
85  );
86  outline.setRootVisible(false);
87  ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel("Type");
88 
89  outlineViewPanel.getExplorerManager().addPropertyChangeListener((PropertyChangeEvent evt) -> {
90  if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
91  final Node[] nodes = outlineViewPanel.getExplorerManager().getSelectedNodes();
92 
93  if (nodes != null && nodes.length == 1) {
94  messageContentViewer.setNode(nodes[0]);
95  }
96  else {
98  }
99  }
100  });
101 
102  splitPane.setResizeWeight(0.5);
103  splitPane.setDividerLocation(0.5);
104  outlineViewPanel.setTableColumnsWidth(5,10,10,15,50,10);
105  }
106 
107  public MessagesPanel(ChildFactory<?> nodeFactory) {
108  this();
109  setChildFactory(nodeFactory);
110  }
111 
112  @Override
113  public Lookup getLookup() {
114  return proxyLookup;
115  }
116 
117  @Override
118  public void addNotify() {
119  super.addNotify();
120  //add listener that maintains correct selection in the Global Actions Context
121  KeyboardFocusManager.getCurrentKeyboardFocusManager()
122  .addPropertyChangeListener("focusOwner", focusPropertyListener);
123  }
124 
125  @Override
126  public void removeNotify() {
127  super.removeNotify();
128  KeyboardFocusManager.getCurrentKeyboardFocusManager()
129  .removePropertyChangeListener("focusOwner", focusPropertyListener);
130  }
131 
132  final void setChildFactory(ChildFactory<?> nodeFactory) {
133  outlineViewPanel.getExplorerManager().setRootContext(
134  new TableFilterNode(
136  new AbstractNode(
137  Children.create(nodeFactory, true)),
139  }
140 
146  @SuppressWarnings("unchecked")
147  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
148  private void initComponents() {
149 
150  splitPane = new javax.swing.JSplitPane();
152  messageContentViewer = new MessageDataContent();
153 
154  setLayout(new java.awt.BorderLayout());
155 
156  splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
157  splitPane.setLeftComponent(outlineViewPanel);
158  splitPane.setRightComponent(messageContentViewer);
159 
160  add(splitPane, java.awt.BorderLayout.CENTER);
161  }// </editor-fold>//GEN-END:initComponents
162 
163 
164  // Variables declaration - do not modify//GEN-BEGIN:variables
167  private javax.swing.JSplitPane splitPane;
168  // End of variables declaration//GEN-END:variables
169 }
org.sleuthkit.autopsy.communications.relationships.OutlineViewPanel outlineViewPanel
org.sleuthkit.autopsy.contentviewers.MessageContentViewer messageContentViewer

Copyright © 2012-2018 Basis Technology. Generated on: Fri Jun 21 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.