19 package org.sleuthkit.autopsy.communications.relationships;
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;
44 class MessagesPanel
extends javax.swing.JPanel implements Lookup.Provider {
46 private static final long serialVersionUID = 1L;
48 private final Outline outline;
49 private final ModifiableProxyLookup proxyLookup;
50 private PropertyChangeListener focusPropertyListener;
52 private final MessageDataContent messageContentViewer;
60 messageContentViewer =
new MessageDataContent();
61 splitPane.setRightComponent(messageContentViewer);
63 proxyLookup =
new ModifiableProxyLookup(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
65 outline = outlineViewPanel.getOutlineView().getOutline();
66 outlineViewPanel.getOutlineView().setPropertyColumns(
67 "From", Bundle.MessageViewer_columnHeader_From(),
68 "To", Bundle.MessageViewer_columnHeader_To(),
69 "Date", Bundle.MessageViewer_columnHeader_Date(),
70 "Subject", Bundle.MessageViewer_columnHeader_Subject(),
71 "Attms", Bundle.MessageViewer_columnHeader_Attms()
73 outline.setRootVisible(
false);
74 ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(
"Type");
76 outlineViewPanel.getExplorerManager().addPropertyChangeListener((PropertyChangeEvent evt) -> {
77 if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
78 final Node[] nodes = outlineViewPanel.getExplorerManager().getSelectedNodes();
80 if (nodes != null && nodes.length == 1) {
81 messageContentViewer.setNode(nodes[0]);
83 messageContentViewer.setNode(null);
88 splitPane.setResizeWeight(0.5);
89 splitPane.setDividerLocation(0.5);
90 outlineViewPanel.setTableColumnsWidth(5, 10, 10, 15, 50, 10);
93 public MessagesPanel(ChildFactory<?> nodeFactory) {
95 setChildFactory(nodeFactory);
99 public Lookup getLookup() {
104 public void addNotify() {
107 if (focusPropertyListener == null) {
110 focusPropertyListener = (
final PropertyChangeEvent focusEvent) -> {
111 if (focusEvent.getPropertyName().equalsIgnoreCase(
"focusOwner")) {
112 handleFocusChange((Component) focusEvent.getNewValue());
120 KeyboardFocusManager.getCurrentKeyboardFocusManager()
121 .addPropertyChangeListener(
"focusOwner", focusPropertyListener);
124 private void handleFocusChange(Component newFocusOwner) {
125 if (newFocusOwner == null) {
128 if (isDescendingFrom(newFocusOwner, messageContentViewer)) {
130 proxyLookup.setNewLookups(createLookup((messageContentViewer).getExplorerManager(), getActionMap()));
131 }
else if (isDescendingFrom(newFocusOwner, MessagesPanel.this)) {
133 proxyLookup.setNewLookups(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
139 public void removeNotify() {
140 super.removeNotify();
141 KeyboardFocusManager.getCurrentKeyboardFocusManager()
142 .removePropertyChangeListener(
"focusOwner", focusPropertyListener);
145 final void setChildFactory(ChildFactory<?> nodeFactory) {
146 outlineViewPanel.getExplorerManager().setRootContext(
148 new DataResultFilterNode(
150 Children.create(nodeFactory,
true)),
151 outlineViewPanel.getExplorerManager()),
true));
159 @SuppressWarnings(
"unchecked")
161 private
void initComponents() {
163 splitPane =
new javax.swing.JSplitPane();
166 setLayout(
new java.awt.BorderLayout());
168 splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
169 splitPane.setLeftComponent(outlineViewPanel);
171 add(splitPane, java.awt.BorderLayout.CENTER);
177 private javax.swing.JSplitPane splitPane;