Autopsy  4.13.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
CVTTopComponent.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2017-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.communications;
20 
21 import com.google.common.eventbus.Subscribe;
22 import java.awt.BorderLayout;
23 import java.awt.Component;
24 import java.awt.Font;
25 import java.awt.event.MouseAdapter;
26 import java.awt.event.MouseEvent;
27 import java.util.HashSet;
28 import java.util.List;
29 import java.util.stream.Collectors;
30 import javax.swing.ImageIcon;
31 import javax.swing.JPanel;
32 import javax.swing.JSplitPane;
33 import javax.swing.JTabbedPane;
34 import org.openide.util.Lookup;
35 import org.openide.util.NbBundle;
36 import org.openide.windows.Mode;
37 import org.openide.windows.RetainLocation;
38 import org.openide.windows.TopComponent;
39 import org.openide.windows.WindowManager;
43 import org.sleuthkit.datamodel.CommunicationsFilter;
44 
48 @TopComponent.Description(preferredID = "CVTTopComponent", persistenceType = TopComponent.PERSISTENCE_NEVER)
49 @TopComponent.Registration(mode = "cvt", openAtStartup = false)
50 @RetainLocation("cvt")
51 @NbBundle.Messages("CVTTopComponent.name= Communications Visualization")
52 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
53 public final class CVTTopComponent extends TopComponent {
54 
55  private static final long serialVersionUID = 1L;
56  private boolean filtersVisible = true;
57  private final RelationshipBrowser relationshipBrowser = new RelationshipBrowser();
58  private CommunicationsFilter currentFilter;
59 
61  public CVTTopComponent() {
62  initComponents();
63 
64  splitPane.setRightComponent(relationshipBrowser);
65  splitPane.setDividerLocation(0.25);
66 
67  setName(Bundle.CVTTopComponent_name());
68 
69  /*
70  * Associate a Lookup with the GlobalActionContext (GAC) so that
71  * selections in the sub views can be exposed to context-sensitive
72  * actions.
73  */
74  final ModifiableProxyLookup proxyLookup = new ModifiableProxyLookup(accountsBrowser.getLookup());
75  associateLookup(proxyLookup);
76  // Make sure the Global Actions Context is proxying the selection of the active tab.
77  browseVisualizeTabPane.addChangeListener(changeEvent -> {
78  Component selectedComponent = browseVisualizeTabPane.getSelectedComponent();
79  if(selectedComponent instanceof Lookup.Provider) {
80  Lookup lookup = ((Lookup.Provider)selectedComponent).getLookup();
81  proxyLookup.setNewLookups(lookup);
82  }
83 
84  relationshipBrowser.setSelectionInfo(new SelectionInfo(new HashSet<>(), new HashSet<>(), currentFilter));
85  });
86 
87 
88  /*
89  * Connect the filtersPane to the accountsBrowser and visualizaionPanel
90  * via an Eventbus
91  */
92  CVTEvents.getCVTEventBus().register(this);
93  CVTEvents.getCVTEventBus().register(vizPanel);
94  CVTEvents.getCVTEventBus().register(accountsBrowser);
95  CVTEvents.getCVTEventBus().register(filtersPane);
96 
97  filterTabbedPane.setIconAt(0, new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/arrow-left.png")));
98  filterTabbedPane.setTitleAt(0, "");
99  }
100 
101  @Subscribe
102  void pinAccount(CVTEvents.PinAccountsEvent pinEvent) {
103  browseVisualizeTabPane.setSelectedIndex(1);
104  }
105 
106  @Subscribe
107  void handle(final CVTEvents.FilterChangeEvent filterChangeEvent) {
108  currentFilter = filterChangeEvent.getNewFilter();
109  }
110 
116  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
117  private void initComponents() {
118 
119  filterTabbedPane = new JTabbedPane();
120  filterTabPanel = new JPanel();
121  filtersPane = new FiltersPanel();
122  splitPane = new JSplitPane();
123  browseVisualizeTabPane = new JTabbedPane();
124  accountsBrowser = new AccountsBrowser(relationshipBrowser);
125  vizPanel = new VisualizationPanel(relationshipBrowser);
126 
127  setLayout(new BorderLayout());
128 
129  filterTabbedPane.addMouseListener(new MouseAdapter() {
130  public void mouseClicked(MouseEvent evt) {
131  filterTabbedPaneMouseClicked(evt);
132  }
133  });
134 
135  filterTabPanel.setLayout(new BorderLayout());
136  filterTabPanel.add(filtersPane, BorderLayout.CENTER);
137 
138  filterTabbedPane.addTab(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.filterTabPanel.TabConstraints.tabTitle"), filterTabPanel); // NOI18N
139 
140  add(filterTabbedPane, BorderLayout.WEST);
141 
142  splitPane.setDividerLocation(1);
143  splitPane.setResizeWeight(0.25);
144 
145  browseVisualizeTabPane.setFont(new Font("Tahoma", 0, 18)); // NOI18N
146  browseVisualizeTabPane.addTab(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.accountsBrowser.TabConstraints.tabTitle_1"), new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/table.png")), accountsBrowser); // NOI18N
147  browseVisualizeTabPane.addTab(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.vizPanel.TabConstraints.tabTitle_1"), new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/emblem-web.png")), vizPanel); // NOI18N
148 
149  splitPane.setLeftComponent(browseVisualizeTabPane);
150  browseVisualizeTabPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.browseVisualizeTabPane.AccessibleContext.accessibleName")); // NOI18N
151 
152  add(splitPane, BorderLayout.CENTER);
153  }// </editor-fold>//GEN-END:initComponents
154 
155  private void filterTabbedPaneMouseClicked(MouseEvent evt) {//GEN-FIRST:event_filterTabPaneMouseClicked
156  int index = filterTabbedPane.indexAtLocation(evt.getX(), evt.getY());
157  if(index != -1) {
158  if(filtersVisible) {
159  filterTabbedPane.setIconAt(0, new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/arrow-right.png")));
160  filterTabPanel.removeAll();
161  filterTabPanel.revalidate();
162  filtersVisible = false;
163  } else {
164  filterTabbedPane.setIconAt(0, new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/arrow-left.png")));
165  filterTabPanel.add(filtersPane, BorderLayout.CENTER);
166  filterTabPanel.revalidate();
167  filtersVisible = true;
168  }
169  }
170  }//GEN-LAST:event_filterTabPaneMouseClicked
171 
172 
173  // Variables declaration - do not modify//GEN-BEGIN:variables
175  private JTabbedPane browseVisualizeTabPane;
176  private JTabbedPane filterTabbedPane;
177  private JPanel filterTabPanel;
179  private JSplitPane splitPane;
181  // End of variables declaration//GEN-END:variables
182 
183  @Override
184  public void componentOpened() {
185  super.componentOpened();
186  WindowManager.getDefault().setTopComponentFloating(this, true);
187  }
188 
189  @Override
190  public void open() {
191  super.open();
192  /*
193  * when the window is (re)opened make sure the filters and accounts are
194  * in an up to date and consistent state.
195  *
196  * Re-applying the filters means we will lose the selection...
197  */
198  filtersPane.updateAndApplyFilters(true);
199  }
200 
201  @Override
202  public List<Mode> availableModes(List<Mode> modes) {
203  /*
204  * This looks like the right thing to do, but online discussions seems
205  * to indicate this method is effectively deprecated. A break point
206  * placed here was never hit.
207  */
208  return modes.stream().filter(mode -> mode.getName().equals("cvt"))
209  .collect(Collectors.toList());
210  }
211 }

Copyright © 2012-2019 Basis Technology. Generated on: Tue Jan 7 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.