Autopsy  4.9.1
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.Dimension;
23 import java.awt.Font;
24 import java.util.List;
25 import java.util.stream.Collectors;
26 import javax.swing.GroupLayout;
27 import javax.swing.ImageIcon;
28 import javax.swing.JTabbedPane;
29 import javax.swing.LayoutStyle;
30 import org.openide.util.Lookup;
31 import org.openide.util.NbBundle;
32 import org.openide.windows.Mode;
33 import org.openide.windows.RetainLocation;
34 import org.openide.windows.TopComponent;
35 import org.openide.windows.WindowManager;
37 
41 @TopComponent.Description(preferredID = "CVTTopComponent", persistenceType = TopComponent.PERSISTENCE_NEVER)
42 @TopComponent.Registration(mode = "cvt", openAtStartup = false)
43 @RetainLocation("cvt")
44 @NbBundle.Messages("CVTTopComponent.name= Communications Visualization")
45 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
46 public final class CVTTopComponent extends TopComponent {
47 
48  private static final long serialVersionUID = 1L;
49 
51  public CVTTopComponent() {
52  initComponents();
53  setName(Bundle.CVTTopComponent_name());
54 
55  /*
56  * Associate a Lookup with the GlobalActionContext (GAC) so that
57  * selections in the sub views can be exposed to context-sensitive
58  * actions.
59  */
60  final ModifiableProxyLookup proxyLookup = new ModifiableProxyLookup(accountsBrowser.getLookup());
61  associateLookup(proxyLookup);
62  // Make sure the Global Actions Context is proxying the selection of the active tab.
63  browseVisualizeTabPane.addChangeListener(changeEvent -> {
64  Lookup.Provider selectedComponent = (Lookup.Provider) browseVisualizeTabPane.getSelectedComponent();
65  proxyLookup.setNewLookups(selectedComponent.getLookup());
66  filtersPane.setDeviceAccountTypeEnabled(browseVisualizeTabPane.getSelectedIndex() != 0);
67  });
68 
69 
70  /*
71  * Connect the filtersPane to the accountsBrowser and visualizaionPanel
72  * via an Eventbus
73  */
74  CVTEvents.getCVTEventBus().register(this);
75  CVTEvents.getCVTEventBus().register(vizPanel);
76  CVTEvents.getCVTEventBus().register(accountsBrowser);
77  }
78 
79  @Subscribe
80  void pinAccount(CVTEvents.PinAccountsEvent pinEvent) {
81  browseVisualizeTabPane.setSelectedIndex(1);
82  }
83 
89  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
90  private void initComponents() {
91 
92  browseVisualizeTabPane = new JTabbedPane();
93  accountsBrowser = new AccountsBrowser();
94  vizPanel = new VisualizationPanel();
95  filtersPane = new FiltersPanel();
96 
97  browseVisualizeTabPane.setFont(new Font("Tahoma", 0, 18)); // NOI18N
98  browseVisualizeTabPane.addTab(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.accountsBrowser.TabConstraints.tabTitle_1"), new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/table.png")), accountsBrowser); // NOI18N
99  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
100 
101  filtersPane.setMinimumSize(new Dimension(256, 495));
102 
103  GroupLayout layout = new GroupLayout(this);
104  this.setLayout(layout);
105  layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
106  .addGroup(layout.createSequentialGroup()
107  .addGap(6, 6, 6)
108  .addComponent(filtersPane, GroupLayout.PREFERRED_SIZE, 265, GroupLayout.PREFERRED_SIZE)
109  .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
110  .addComponent(browseVisualizeTabPane, GroupLayout.PREFERRED_SIZE, 786, Short.MAX_VALUE)
111  .addContainerGap())
112  );
113  layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
114  .addGroup(layout.createSequentialGroup()
115  .addGap(6, 6, 6)
116  .addComponent(filtersPane, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
117  .addGap(5, 5, 5))
118  .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
119  .addComponent(browseVisualizeTabPane)
120  .addContainerGap())
121  );
122 
123  browseVisualizeTabPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.browseVisualizeTabPane.AccessibleContext.accessibleName")); // NOI18N
124  }// </editor-fold>//GEN-END:initComponents
125 
126 
127  // Variables declaration - do not modify//GEN-BEGIN:variables
129  private JTabbedPane browseVisualizeTabPane;
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: Tue Dec 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.