Autopsy  4.12.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.Font;
24 import java.awt.GridBagConstraints;
25 import java.awt.GridBagLayout;
26 import java.awt.Insets;
27 import java.util.List;
28 import java.util.stream.Collectors;
29 import javax.swing.ImageIcon;
30 import javax.swing.JSplitPane;
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  });
72 
73 
74  /*
75  * Connect the filtersPane to the accountsBrowser and visualizaionPanel
76  * via an Eventbus
77  */
78  CVTEvents.getCVTEventBus().register(this);
79  CVTEvents.getCVTEventBus().register(vizPanel);
80  CVTEvents.getCVTEventBus().register(accountsBrowser);
81  CVTEvents.getCVTEventBus().register(filtersPane);
82 
83  mainSplitPane.setResizeWeight(0.5);
84  mainSplitPane.setDividerLocation(0.25);
85  }
86 
87  @Subscribe
88  void pinAccount(CVTEvents.PinAccountsEvent pinEvent) {
89  browseVisualizeTabPane.setSelectedIndex(1);
90  }
91 
97  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
98  private void initComponents() {
99  GridBagConstraints gridBagConstraints;
100 
101  mainSplitPane = new JSplitPane();
102  filtersPane = new FiltersPanel();
103  browseVisualizeTabPane = new JTabbedPane();
104  accountsBrowser = new AccountsBrowser();
105  vizPanel = new VisualizationPanel();
106 
107  setLayout(new GridBagLayout());
108 
109  mainSplitPane.setLeftComponent(filtersPane);
110 
111  browseVisualizeTabPane.setFont(new Font("Tahoma", 0, 18)); // NOI18N
112  browseVisualizeTabPane.addTab(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.accountsBrowser.TabConstraints.tabTitle_1"), new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/table.png")), accountsBrowser); // NOI18N
113  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
114 
115  mainSplitPane.setRightComponent(browseVisualizeTabPane);
116  browseVisualizeTabPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.browseVisualizeTabPane.AccessibleContext.accessibleName")); // NOI18N
117 
118  gridBagConstraints = new GridBagConstraints();
119  gridBagConstraints.fill = GridBagConstraints.BOTH;
120  gridBagConstraints.weightx = 1.0;
121  gridBagConstraints.weighty = 1.0;
122  add(mainSplitPane, gridBagConstraints);
123  }// </editor-fold>//GEN-END:initComponents
124 
125 
126  // Variables declaration - do not modify//GEN-BEGIN:variables
128  private JTabbedPane browseVisualizeTabPane;
130  private JSplitPane mainSplitPane;
132  // End of variables declaration//GEN-END:variables
133 
134  @Override
135  public void componentOpened() {
136  super.componentOpened();
137  WindowManager.getDefault().setTopComponentFloating(this, true);
138  }
139 
140  @Override
141  public void open() {
142  super.open();
143  /*
144  * when the window is (re)opened make sure the filters and accounts are
145  * in an up to date and consistent state.
146  *
147  * Re-applying the filters means we will lose the selection...
148  */
149  filtersPane.updateAndApplyFilters(true);
150  }
151 
152  @Override
153  public List<Mode> availableModes(List<Mode> modes) {
154  /*
155  * This looks like the right thing to do, but online discussions seems
156  * to indicate this method is effectively deprecated. A break point
157  * placed here was never hit.
158  */
159  return modes.stream().filter(mode -> mode.getName().equals("cvt"))
160  .collect(Collectors.toList());
161  }
162 }

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