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 @SuppressWarnings(
"PMD.SingularField")
45 public final class
MessageBrowser extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
47 private static final long serialVersionUID = 1L;
52 private final ModifiableProxyLookup proxyLookup =
new ModifiableProxyLookup();
54 private final PropertyChangeListener focusPropertyListener =
new PropertyChangeListener() {
78 public void propertyChange(
final PropertyChangeEvent focusEvent) {
79 if (focusEvent.getPropertyName().equalsIgnoreCase(
"focusOwner")) {
80 final Component newFocusOwner = (Component) focusEvent.getNewValue();
82 if (newFocusOwner == null) {
85 if (isDescendingFrom(newFocusOwner, messageDataContent)) {
87 proxyLookup.setNewLookups(createLookup(messageDataContent.getExplorerManager(), getActionMap()));
88 }
else if (isDescendingFrom(newFocusOwner, messagesResultPanel)) {
90 proxyLookup.setNewLookups(createLookup(gacExplorerManager, getActionMap()));
108 @NbBundle.Messages({
"MessageBrowser.DataResultViewerTable.title=Messages"})
109 MessageBrowser(
final ExplorerManager tableEM,
final ExplorerManager gacExplorerManager) {
110 this.tableEM = tableEM;
111 this.gacExplorerManager = gacExplorerManager;
115 splitPane.setTopComponent(messagesResultPanel);
116 splitPane.setBottomComponent(messageDataContent);
117 messagesResultPanel.
addResultViewer(
new DataResultViewerTable(gacExplorerManager,
118 Bundle.MessageBrowser_DataResultViewerTable_title()));
119 messagesResultPanel.
open();
121 this.tableEM.addPropertyChangeListener(
new PropertyChangeListener() {
129 public void propertyChange(PropertyChangeEvent pce) {
130 if (pce.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
131 final Node[] selectedNodes = MessageBrowser.this.tableEM.getSelectedNodes();
133 messagesResultPanel.
setNode(null);
134 messagesResultPanel.
setPath(
"");
135 if (selectedNodes.length > 0) {
137 final Node selectedNode = selectedNodes[0];
139 if (selectedNode instanceof AccountDeviceInstanceNode) {
140 rootNode = makeRootNodeFromAccountDeviceInstanceNodes(selectedNodes);
142 rootNode = selectedNode;
144 messagesResultPanel.
setPath(rootNode.getDisplayName());
145 messagesResultPanel.
setNode(
new TableFilterNode(
new DataResultFilterNode(rootNode, gacExplorerManager),
true));
150 private Node makeRootNodeFromAccountDeviceInstanceNodes(
final Node[] selectedNodes) {
152 final AccountDeviceInstanceNode adiNode = (AccountDeviceInstanceNode) selectedNodes[0];
154 final Set<AccountDeviceInstanceKey> accountDeviceInstances =
new HashSet<>();
155 for (
final Node n : selectedNodes) {
157 accountDeviceInstances.add(((AccountDeviceInstanceNode) n).getAccountDeviceInstanceKey());
159 return SelectionNode.createFromAccounts(accountDeviceInstances, adiNode.getFilter(), adiNode.getCommsManager());
167 return gacExplorerManager;
179 KeyboardFocusManager.getCurrentKeyboardFocusManager()
180 .addPropertyChangeListener(
"focusOwner", focusPropertyListener);
185 super.removeNotify();
186 KeyboardFocusManager.getCurrentKeyboardFocusManager()
187 .removePropertyChangeListener(
"focusOwner", focusPropertyListener);
195 @SuppressWarnings(
"unchecked")
197 private
void initComponents() {
199 splitPane =
new javax.swing.JSplitPane();
202 splitPane.setDividerLocation(400);
203 splitPane.setDividerSize(10);
204 splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
205 splitPane.setResizeWeight(0.5);
206 splitPane.setBottomComponent(messageDataContent);
208 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
209 this.setLayout(layout);
210 layout.setHorizontalGroup(
211 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
212 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
214 .addComponent(splitPane))
216 layout.setVerticalGroup(
217 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
218 .addGroup(layout.createSequentialGroup()
220 .addComponent(splitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1083, Short.MAX_VALUE)
void setNumberOfChildNodes(Integer numberOfChildNodes)
final DataResultPanel messagesResultPanel
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()