19 package org.sleuthkit.autopsy.communications;
21 import java.awt.Component;
22 import java.awt.KeyboardFocusManager;
23 import java.beans.PropertyChangeEvent;
24 import java.beans.PropertyChangeListener;
25 import java.util.HashSet;
27 import javax.swing.JPanel;
28 import static javax.swing.SwingUtilities.isDescendingFrom;
29 import org.openide.explorer.ExplorerManager;
30 import static org.openide.explorer.ExplorerUtils.createLookup;
31 import org.openide.nodes.Node;
32 import org.openide.util.Lookup;
33 import org.openide.util.NbBundle;
44 public final class MessageBrowser extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
51 private final ModifiableProxyLookup
proxyLookup =
new ModifiableProxyLookup();
77 public void propertyChange(
final PropertyChangeEvent focusEvent) {
78 if (focusEvent.getPropertyName().equalsIgnoreCase(
"focusOwner")) {
79 final Component newFocusOwner = (Component) focusEvent.getNewValue();
81 if (newFocusOwner == null) {
86 proxyLookup.setNewLookups(createLookup(
messageDataContent.getExplorerManager(), getActionMap()));
87 }
else if (isDescendingFrom(newFocusOwner, messagesResultPanel)) {
89 proxyLookup.setNewLookups(createLookup(gacExplorerManager, getActionMap()));
107 @NbBundle.Messages({
"MessageBrowser.DataResultViewerTable.title=Messages"})
108 MessageBrowser(
final ExplorerManager tableEM,
final ExplorerManager gacExplorerManager) {
114 splitPane.setTopComponent(messagesResultPanel);
116 messagesResultPanel.
addResultViewer(
new DataResultViewerTable(gacExplorerManager,
117 Bundle.MessageBrowser_DataResultViewerTable_title()));
118 messagesResultPanel.
open();
120 this.tableEM.addPropertyChangeListener(
new PropertyChangeListener() {
128 public void propertyChange(PropertyChangeEvent pce) {
129 if (pce.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
130 final Node[] selectedNodes = MessageBrowser.this.tableEM.getSelectedNodes();
132 messagesResultPanel.
setNode(null);
133 messagesResultPanel.
setPath(
"");
134 if (selectedNodes.length > 0) {
136 final Node selectedNode = selectedNodes[0];
138 if (selectedNode instanceof AccountDeviceInstanceNode) {
139 rootNode = makeRootNodeFromAccountDeviceInstanceNodes(selectedNodes);
141 rootNode = selectedNode;
143 messagesResultPanel.
setPath(rootNode.getDisplayName());
144 messagesResultPanel.
setNode(
new TableFilterNode(
new DataResultFilterNode(rootNode, gacExplorerManager),
true));
149 private Node makeRootNodeFromAccountDeviceInstanceNodes(
final Node[] selectedNodes) {
151 final AccountDeviceInstanceNode adiNode = (AccountDeviceInstanceNode) selectedNodes[0];
153 final Set<AccountDeviceInstanceKey> accountDeviceInstances =
new HashSet<>();
154 for (
final Node n : selectedNodes) {
156 accountDeviceInstances.add(((AccountDeviceInstanceNode) n).getAccountDeviceInstanceKey());
158 return SelectionNode.createFromAccounts(accountDeviceInstances, adiNode.getFilter(), adiNode.getCommsManager());
178 KeyboardFocusManager.getCurrentKeyboardFocusManager()
179 .addPropertyChangeListener(
"focusOwner", focusPropertyListener);
184 super.removeNotify();
185 KeyboardFocusManager.getCurrentKeyboardFocusManager()
186 .removePropertyChangeListener(
"focusOwner", focusPropertyListener);
194 @SuppressWarnings(
"unchecked")
198 splitPane =
new javax.swing.JSplitPane();
203 splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
207 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
208 this.setLayout(layout);
209 layout.setHorizontalGroup(
210 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
211 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
215 layout.setVerticalGroup(
216 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
217 .addGroup(layout.createSequentialGroup()
219 .addComponent(
splitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1083, Short.MAX_VALUE)
void setNumberOfChildNodes(Integer numberOfChildNodes)
static final long serialVersionUID
final ModifiableProxyLookup proxyLookup
final DataResultPanel messagesResultPanel
final PropertyChangeListener focusPropertyListener
void setPath(String description)
void setNode(Node rootNode)
static DataResultPanel createInstanceUninitialized(String title, String description, Node currentRootNode, int childNodeCount, DataContent customContentView)
final ExplorerManager gacExplorerManager
javax.swing.JSplitPane splitPane
void addResultViewer(DataResultViewer resultViewer)
final ExplorerManager tableEM
org.sleuthkit.autopsy.communications.MessageDataContent messageDataContent
ExplorerManager getExplorerManager()