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 javax.swing.event.TableModelEvent;
27 import javax.swing.event.TableModelListener;
28 import javax.swing.table.TableColumn;
29 import org.netbeans.swing.outline.DefaultOutlineModel;
30 import org.netbeans.swing.outline.Outline;
31 import org.openide.explorer.ExplorerManager;
32 import static org.openide.explorer.ExplorerUtils.createLookup;
33 import org.openide.nodes.AbstractNode;
34 import org.openide.nodes.ChildFactory;
35 import org.openide.nodes.Children;
36 import org.openide.nodes.Node;
37 import org.openide.util.Lookup;
47 class MessagesPanel
extends javax.swing.JPanel implements Lookup.Provider {
49 private static final long serialVersionUID = 1L;
51 private final Outline outline;
52 private final ModifiableProxyLookup proxyLookup;
53 private PropertyChangeListener focusPropertyListener;
55 private final MessageDataContent messageContentViewer;
63 messageContentViewer =
new MessageDataContent();
64 splitPane.setRightComponent(messageContentViewer);
66 proxyLookup =
new ModifiableProxyLookup(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
68 outline = outlineViewPanel.getOutlineView().getOutline();
71 outlineViewPanel.getOutlineView().setPropertyColumns(
72 "From", Bundle.MessageViewer_columnHeader_From(),
73 "To", Bundle.MessageViewer_columnHeader_To(),
74 "Date", Bundle.MessageViewer_columnHeader_Date(),
75 "Subject", Bundle.MessageViewer_columnHeader_Subject(),
76 "Attms", Bundle.MessageViewer_columnHeader_Attms()
78 outline.setRootVisible(
false);
79 ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(
"Type");
81 outlineViewPanel.getExplorerManager().addPropertyChangeListener((PropertyChangeEvent evt) -> {
82 if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
83 final Node[] nodes = outlineViewPanel.getExplorerManager().getSelectedNodes();
85 if (nodes != null && nodes.length == 1) {
86 messageContentViewer.setNode(nodes[0]);
88 messageContentViewer.setNode(null);
96 outlineViewPanel.getOutlineView().getOutline().getOutlineModel().addTableModelListener(
new TableModelListener() {
98 public void tableChanged(TableModelEvent e) {
99 if (e.getType() == TableModelEvent.INSERT) {
100 outline.setRowSelectionInterval(0, 0);
105 TableColumn column = outline.getColumnModel().getColumn(1);
106 column.setCellRenderer(
new NodeTableCellRenderer());
108 column = outline.getColumnModel().getColumn(2);
109 column.setCellRenderer(
new NodeTableCellRenderer());
111 splitPane.setResizeWeight(0.5);
112 splitPane.setDividerLocation(0.5);
113 outlineViewPanel.setTableColumnsWidth(5, 10, 10, 15, 50, 10);
116 MessagesPanel(ChildFactory<?> nodeFactory) {
118 setChildFactory(nodeFactory);
122 public Lookup getLookup() {
131 ExplorerManager getExplorerManager() {
132 return outlineViewPanel.getExplorerManager();
136 public void addNotify() {
139 if (focusPropertyListener == null) {
142 focusPropertyListener = (
final PropertyChangeEvent focusEvent) -> {
143 if (focusEvent.getPropertyName().equalsIgnoreCase(
"focusOwner")) {
144 handleFocusChange((Component) focusEvent.getNewValue());
152 KeyboardFocusManager.getCurrentKeyboardFocusManager()
153 .addPropertyChangeListener(
"focusOwner", focusPropertyListener);
156 private void handleFocusChange(Component newFocusOwner) {
157 if (newFocusOwner == null) {
160 if (isDescendingFrom(newFocusOwner, messageContentViewer)) {
162 proxyLookup.setNewLookups(createLookup((messageContentViewer).getExplorerManager(), getActionMap()));
163 }
else if (isDescendingFrom(newFocusOwner, MessagesPanel.this)) {
165 proxyLookup.setNewLookups(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
171 public void removeNotify() {
172 super.removeNotify();
173 KeyboardFocusManager.getCurrentKeyboardFocusManager()
174 .removePropertyChangeListener(
"focusOwner", focusPropertyListener);
177 final void setChildFactory(ChildFactory<?> nodeFactory) {
178 outlineViewPanel.getExplorerManager().setRootContext(
180 new DataResultFilterNode(
182 Children.create(nodeFactory,
true)),
183 outlineViewPanel.getExplorerManager()),
true));
191 @SuppressWarnings(
"unchecked")
193 private
void initComponents() {
195 splitPane =
new javax.swing.JSplitPane();
198 setLayout(
new java.awt.BorderLayout());
200 splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
201 splitPane.setLeftComponent(outlineViewPanel);
203 add(splitPane, java.awt.BorderLayout.CENTER);
209 private javax.swing.JSplitPane splitPane;