Autopsy  4.19.3
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 final AccountsBrowser accountsBrowser = new AccountsBrowser(relationshipBrowser);
59  private CommunicationsFilter currentFilter;
60  private final VisualizationPanel vizPanel = new VisualizationPanel(relationshipBrowser);
61  private final FiltersPanel filtersPane = new FiltersPanel();
62 
64  public CVTTopComponent() {
65  initComponents();
66 
67  splitPane.setRightComponent(relationshipBrowser);
68  splitPane.setDividerLocation(0.25);
69 
70  setName(Bundle.CVTTopComponent_name());
71 
72  /*
73  * Associate a Lookup with the GlobalActionContext (GAC) so that
74  * selections in the sub views can be exposed to context-sensitive
75  * actions.
76  */
77  final ModifiableProxyLookup proxyLookup = new ModifiableProxyLookup(accountsBrowser.getLookup());
78  associateLookup(proxyLookup);
79  // Make sure the Global Actions Context is proxying the selection of the active tab.
80  browseVisualizeTabPane.addChangeListener(changeEvent -> {
81  Component selectedComponent = browseVisualizeTabPane.getSelectedComponent();
82  if (selectedComponent instanceof Lookup.Provider) {
83  Lookup lookup = ((Lookup.Provider) selectedComponent).getLookup();
84  proxyLookup.setNewLookups(lookup);
85  }
86 
87  relationshipBrowser.setSelectionInfo(new SelectionInfo(new HashSet<>(), new HashSet<>(), currentFilter));
88  });
89 
90  filterTabPanel.setLayout(new BorderLayout());
91  filterTabPanel.add(filtersPane, BorderLayout.CENTER);
92  browseVisualizeTabPane.addTab(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.accountsBrowser.TabConstraints.tabTitle_1"), new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/table.png")), accountsBrowser); // NOI18N
93  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
94  /*
95  * Connect the filtersPane to the accountsBrowser and visualizaionPanel
96  * via an Eventbus
97  */
98  CVTEvents.getCVTEventBus().register(this);
99  CVTEvents.getCVTEventBus().register(vizPanel);
100  CVTEvents.getCVTEventBus().register(accountsBrowser);
101  CVTEvents.getCVTEventBus().register(filtersPane);
102 
103  filterTabbedPane.setIconAt(0, new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/arrow-left.png")));
104  filterTabbedPane.setTitleAt(0, "");
105 
106  }
107 
108  @Subscribe
109  void pinAccount(CVTEvents.PinAccountsEvent pinEvent) {
110  browseVisualizeTabPane.setSelectedIndex(1);
111  }
112 
113  @Subscribe
114  void handle(final CVTEvents.FilterChangeEvent filterChangeEvent) {
115  currentFilter = filterChangeEvent.getNewFilter();
116  }
117 
123  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
124  private void initComponents() {
125 
126  filterTabbedPane = new JTabbedPane();
127  filterTabPanel = new JPanel();
128  splitPane = new JSplitPane();
129  browseVisualizeTabPane = new JTabbedPane();
130 
131  setLayout(new BorderLayout());
132 
133  filterTabbedPane.addMouseListener(new MouseAdapter() {
134  public void mouseClicked(MouseEvent evt) {
135  filterTabbedPaneMouseClicked(evt);
136  }
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(browseVisualizeTabPane.getFont().deriveFont(browseVisualizeTabPane.getFont().getSize()+7f));
146  splitPane.setLeftComponent(browseVisualizeTabPane);
147  browseVisualizeTabPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.browseVisualizeTabPane.AccessibleContext.accessibleName")); // NOI18N
148 
149  add(splitPane, BorderLayout.CENTER);
150  }// </editor-fold>//GEN-END:initComponents
151 
152  private void filterTabbedPaneMouseClicked(MouseEvent evt) {//GEN-FIRST:event_filterTabPaneMouseClicked
153  int index = filterTabbedPane.indexAtLocation(evt.getX(), evt.getY());
154  if (index != -1) {
155  if (filtersVisible) {
156  filterTabbedPane.setIconAt(0, new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/arrow-right.png")));
157  filterTabPanel.removeAll();
158  filterTabPanel.revalidate();
159  filtersVisible = false;
160  } else {
161  filterTabbedPane.setIconAt(0, new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/arrow-left.png")));
162  filterTabPanel.add(filtersPane, BorderLayout.CENTER);
163  filterTabPanel.revalidate();
164  filtersVisible = true;
165  }
166  }
167  }//GEN-LAST:event_filterTabPaneMouseClicked
168 
169 
170  // Variables declaration - do not modify//GEN-BEGIN:variables
171  private JTabbedPane browseVisualizeTabPane;
172  private JPanel filterTabPanel;
173  private JTabbedPane filterTabbedPane;
174  private JSplitPane splitPane;
175  // End of variables declaration//GEN-END:variables
176 
177  @Override
178  public void componentOpened() {
179  super.componentOpened();
180  WindowManager.getDefault().setTopComponentFloating(this, true);
181  }
182 
183  @Override
184  public void open() {
185  super.open();
186  /*
187  * when the window is (re)opened make sure the filters and accounts are
188  * in an up to date and consistent state.
189  *
190  * Re-applying the filters means we will lose the selection...
191  */
192  filtersPane.initalizeFilters();
193  }
194 
195  @Override
196  public List<Mode> availableModes(List<Mode> modes) {
197  /*
198  * This looks like the right thing to do, but online discussions seems
199  * to indicate this method is effectively deprecated. A break point
200  * placed here was never hit.
201  */
202  return modes.stream().filter(mode -> mode.getName().equals("cvt"))
203  .collect(Collectors.toList());
204  }
205 }

Copyright © 2012-2022 Basis Technology. Generated on: Wed Dec 7 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.