Autopsy  4.11.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.Component;
23 import java.awt.Dimension;
24 import java.awt.Font;
25 import java.awt.GridBagConstraints;
26 import java.awt.GridBagLayout;
27 import java.awt.Insets;
28 import java.util.List;
29 import java.util.stream.Collectors;
30 import javax.swing.ImageIcon;
31 import javax.swing.JTabbedPane;
32 import org.openide.util.Lookup;
33 import org.openide.util.NbBundle;
34 import org.openide.windows.Mode;
35 import org.openide.windows.RetainLocation;
36 import org.openide.windows.TopComponent;
37 import org.openide.windows.WindowManager;
39 
43 @TopComponent.Description(preferredID = "CVTTopComponent", persistenceType = TopComponent.PERSISTENCE_NEVER)
44 @TopComponent.Registration(mode = "cvt", openAtStartup = false)
45 @RetainLocation("cvt")
46 @NbBundle.Messages("CVTTopComponent.name= Communications Visualization")
47 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
48 public final class CVTTopComponent extends TopComponent {
49 
50  private static final long serialVersionUID = 1L;
51 
53  public CVTTopComponent() {
54  initComponents();
55  setName(Bundle.CVTTopComponent_name());
56 
57  /*
58  * Associate a Lookup with the GlobalActionContext (GAC) so that
59  * selections in the sub views can be exposed to context-sensitive
60  * actions.
61  */
62  final ModifiableProxyLookup proxyLookup = new ModifiableProxyLookup(accountsBrowser.getLookup());
63  associateLookup(proxyLookup);
64  // Make sure the Global Actions Context is proxying the selection of the active tab.
65  browseVisualizeTabPane.addChangeListener(changeEvent -> {
66  Component selectedComponent = browseVisualizeTabPane.getSelectedComponent();
67  if(selectedComponent instanceof Lookup.Provider) {
68  Lookup lookup = ((Lookup.Provider)selectedComponent).getLookup();
69  proxyLookup.setNewLookups(lookup);
70  }
71  filtersPane.setDeviceAccountTypeEnabled(browseVisualizeTabPane.getSelectedIndex() != 0);
72  });
73 
74 
75  /*
76  * Connect the filtersPane to the accountsBrowser and visualizaionPanel
77  * via an Eventbus
78  */
79  CVTEvents.getCVTEventBus().register(this);
80  CVTEvents.getCVTEventBus().register(vizPanel);
81  CVTEvents.getCVTEventBus().register(accountsBrowser);
82  CVTEvents.getCVTEventBus().register(filtersPane);
83  }
84 
85  @Subscribe
86  void pinAccount(CVTEvents.PinAccountsEvent pinEvent) {
87  browseVisualizeTabPane.setSelectedIndex(1);
88  }
89 
95  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
96  private void initComponents() {
97  GridBagConstraints gridBagConstraints;
98 
99  browseVisualizeTabPane = new JTabbedPane();
100  accountsBrowser = new AccountsBrowser();
101  vizPanel = new VisualizationPanel();
102  filtersPane = new FiltersPanel();
103 
104  setLayout(new GridBagLayout());
105 
106  browseVisualizeTabPane.setFont(new Font("Tahoma", 0, 18)); // NOI18N
107  browseVisualizeTabPane.addTab(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.accountsBrowser.TabConstraints.tabTitle_1"), new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/table.png")), accountsBrowser); // NOI18N
108  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
109 
110  gridBagConstraints = new GridBagConstraints();
111  gridBagConstraints.gridx = 1;
112  gridBagConstraints.gridy = 0;
113  gridBagConstraints.fill = GridBagConstraints.BOTH;
114  gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
115  gridBagConstraints.weightx = 0.75;
116  gridBagConstraints.weighty = 1.0;
117  gridBagConstraints.insets = new Insets(15, 0, 15, 15);
118  add(browseVisualizeTabPane, gridBagConstraints);
119  browseVisualizeTabPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.browseVisualizeTabPane.AccessibleContext.accessibleName")); // NOI18N
120 
121  gridBagConstraints = new GridBagConstraints();
122  gridBagConstraints.gridx = 0;
123  gridBagConstraints.gridy = 0;
124  gridBagConstraints.fill = GridBagConstraints.BOTH;
125  gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
126  gridBagConstraints.weightx = 0.25;
127  gridBagConstraints.weighty = 1.0;
128  gridBagConstraints.insets = new Insets(15, 15, 15, 5);
129  add(filtersPane, gridBagConstraints);
130  }// </editor-fold>//GEN-END:initComponents
131 
132 
133  // Variables declaration - do not modify//GEN-BEGIN:variables
135  private JTabbedPane browseVisualizeTabPane;
138  // End of variables declaration//GEN-END:variables
139 
140  @Override
141  public void componentOpened() {
142  super.componentOpened();
143  WindowManager.getDefault().setTopComponentFloating(this, true);
144  }
145 
146  @Override
147  public void open() {
148  super.open();
149  /*
150  * when the window is (re)opened make sure the filters and accounts are
151  * in an up to date and consistent state.
152  *
153  * Re-applying the filters means we will lose the selection...
154  */
155  filtersPane.updateAndApplyFilters(true);
156  }
157 
158  @Override
159  public List<Mode> availableModes(List<Mode> modes) {
160  /*
161  * This looks like the right thing to do, but online discussions seems
162  * to indicate this method is effectively deprecated. A break point
163  * placed here was never hit.
164  */
165  return modes.stream().filter(mode -> mode.getName().equals("cvt"))
166  .collect(Collectors.toList());
167  }
168 }

Copyright © 2012-2018 Basis Technology. Generated on: Fri Jun 21 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.