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 javax.swing.JPanel;
 
   26 import static javax.swing.SwingUtilities.isDescendingFrom;
 
   27 import org.netbeans.swing.outline.DefaultOutlineModel;
 
   28 import org.netbeans.swing.outline.Outline;
 
   29 import org.openide.explorer.ExplorerManager;
 
   30 import static org.openide.explorer.ExplorerUtils.createLookup;
 
   31 import org.openide.nodes.AbstractNode;
 
   32 import org.openide.nodes.Children;
 
   33 import org.openide.nodes.Node;
 
   34 import org.openide.nodes.NodeAdapter;
 
   35 import org.openide.nodes.NodeMemberEvent;
 
   36 import org.openide.util.Lookup;
 
   37 import org.openide.util.NbBundle;
 
   38 import org.openide.util.lookup.ServiceProvider;
 
   48 @ServiceProvider(service = RelationshipsViewer.class)
 
   58         "ContactsViewer_tabTitle=Contacts",
 
   59         "ContactsViewer_columnHeader_Name=Name",
 
   60         "ContactsViewer_columnHeader_Phone=Phone",
 
   61         "ContactsViewer_columnHeader_Email=Email",
 
   62         "ContactsViewer_noContacts_message=<No contacts found for selected account>" 
   71         outlineViewPanel.hideOutlineView(Bundle.ContactsViewer_noContacts_message());
 
   73         proxyLookup = 
new ModifiableProxyLookup(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
 
   74         nodeFactory = 
new ContactsChildNodeFactory(null);
 
   78         focusPropertyListener = (
final PropertyChangeEvent focusEvent) -> {
 
   79             if (focusEvent.getPropertyName().equalsIgnoreCase(
"focusOwner")) {
 
   80                 final Component newFocusOwner = (Component) focusEvent.getNewValue();
 
   82                 if (newFocusOwner == null) {
 
   85                 if (isDescendingFrom(newFocusOwner, contactPane)) {
 
   87                     proxyLookup.
setNewLookups(createLookup(contactPane.getExplorerManager(), getActionMap()));
 
   90                     proxyLookup.
setNewLookups(createLookup(outlineViewPanel.getExplorerManager(), getActionMap()));
 
   96         outline = outlineViewPanel.getOutlineView().getOutline();
 
   97         outlineViewPanel.getOutlineView().setPropertyColumns(
 
   98                 "TSK_EMAIL", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL.getDisplayName(),
 
   99                 "TSK_PHONE_NUMBER", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER.getDisplayName()
 
  101         outline.setRootVisible(
false);
 
  102         ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(Bundle.ContactsViewer_columnHeader_Name());
 
  104         outlineViewPanel.hideOutlineView(
"<No contacts for selected account>");
 
  106         outlineViewPanel.getExplorerManager().addPropertyChangeListener((PropertyChangeEvent evt) -> {
 
  107             if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
 
  108                 final Node[] nodes = outlineViewPanel.getExplorerManager().getSelectedNodes();
 
  109                 contactPane.setNode(nodes);
 
  113         outlineViewPanel.getExplorerManager().setRootContext(
new TableFilterNode(
new DataResultFilterNode(
new AbstractNode(Children.create(nodeFactory, 
true)), outlineViewPanel.getExplorerManager()), 
true));
 
  117         outlineViewPanel.getExplorerManager().getRootContext().addNodeListener(
new NodeAdapter(){
 
  119             public void childrenAdded(NodeMemberEvent nme) {
 
  120                 updateOutlineViewPanel();
 
  124             public void childrenRemoved(NodeMemberEvent nme) {
 
  125                 updateOutlineViewPanel();
 
  129         splitPane.setResizeWeight(0.5);
 
  130         splitPane.setDividerLocation(0.5);
 
  135         return Bundle.ContactsViewer_tabTitle();
 
  145         nodeFactory.refresh(info);
 
  157         KeyboardFocusManager.getCurrentKeyboardFocusManager()
 
  158                 .addPropertyChangeListener(
"focusOwner", focusPropertyListener); 
 
  163         super.removeNotify();
 
  164         KeyboardFocusManager.getCurrentKeyboardFocusManager()
 
  165                 .removePropertyChangeListener(
"focusOwner", focusPropertyListener); 
 
  169         int nodeCount = outlineViewPanel.getExplorerManager().getRootContext().getChildren().getNodesCount();
 
  171             outlineViewPanel.hideOutlineView(Bundle.ContactsViewer_noContacts_message());
 
  173             outlineViewPanel.showOutlineView();
 
  182     @SuppressWarnings(
"unchecked")
 
  184     private 
void initComponents() {
 
  185         java.awt.GridBagConstraints gridBagConstraints;
 
  187         splitPane = 
new javax.swing.JSplitPane();
 
  191         setLayout(
new java.awt.GridBagLayout());
 
  193         splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
 
  194         splitPane.setRightComponent(contactPane);
 
  195         splitPane.setLeftComponent(outlineViewPanel);
 
  197         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  198         gridBagConstraints.gridx = 0;
 
  199         gridBagConstraints.gridy = 0;
 
  200         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
 
  201         gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
 
  202         gridBagConstraints.weightx = 1.0;
 
  203         gridBagConstraints.weighty = 1.0;
 
  204         add(splitPane, gridBagConstraints);
 
void setNewLookups(final Lookup...lookups)