Autopsy  4.6.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-18 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 public final class CVTTopComponent extends TopComponent {
46 
47  private static final long serialVersionUID = 1L;
48 
50  public CVTTopComponent() {
52  setName(Bundle.CVTTopComponent_name());
53 
54  /*
55  * Associate a Lookup with the GlobalActionContext (GAC) so that
56  * selections in the sub views can be exposed to context-sensitive
57  * actions.
58  */
59  final ModifiableProxyLookup proxyLookup = new ModifiableProxyLookup(accountsBrowser.getLookup());
60  associateLookup(proxyLookup);
61  // Make sure the Global Actions Context is proxying the selection of the active tab.
62  browseVisualizeTabPane.addChangeListener(changeEvent -> {
63  Lookup.Provider selectedComponent = (Lookup.Provider) browseVisualizeTabPane.getSelectedComponent();
64  proxyLookup.setNewLookups(selectedComponent.getLookup());
65  filtersPane.setDeviceAccountTypeEnabled(browseVisualizeTabPane.getSelectedIndex() != 0);
66  });
67 
68 
69  /*
70  * Connect the filtersPane to the accountsBrowser and visualizaionPanel
71  * via an Eventbus
72  */
73  CVTEvents.getCVTEventBus().register(this);
74  CVTEvents.getCVTEventBus().register(vizPanel);
75  CVTEvents.getCVTEventBus().register(accountsBrowser);
76  }
77 
78  @Subscribe
79  void pinAccount(CVTEvents.PinAccountsEvent pinEvent) {
80  browseVisualizeTabPane.setSelectedIndex(1);
81  }
82 
88  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
89  private void initComponents() {
90 
91  browseVisualizeTabPane = new JTabbedPane();
94  filtersPane = new FiltersPanel();
95 
96  browseVisualizeTabPane.setFont(new Font("Tahoma", 0, 18)); // NOI18N
97  browseVisualizeTabPane.addTab(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.accountsBrowser.TabConstraints.tabTitle_1"), new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/table.png")), accountsBrowser); // NOI18N
98  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
99 
100  filtersPane.setMinimumSize(new Dimension(256, 495));
101 
102  GroupLayout layout = new GroupLayout(this);
103  this.setLayout(layout);
104  layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
105  .addGroup(layout.createSequentialGroup()
106  .addGap(6, 6, 6)
107  .addComponent(filtersPane, GroupLayout.PREFERRED_SIZE, 265, GroupLayout.PREFERRED_SIZE)
108  .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
109  .addComponent(browseVisualizeTabPane, GroupLayout.PREFERRED_SIZE, 786, Short.MAX_VALUE)
110  .addContainerGap())
111  );
112  layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
113  .addGroup(layout.createSequentialGroup()
114  .addGap(6, 6, 6)
115  .addComponent(filtersPane, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
116  .addGap(5, 5, 5))
117  .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
118  .addComponent(browseVisualizeTabPane)
119  .addContainerGap())
120  );
121 
122  browseVisualizeTabPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.browseVisualizeTabPane.AccessibleContext.accessibleName")); // NOI18N
123  }// </editor-fold>//GEN-END:initComponents
124 
125 
126  // Variables declaration - do not modify//GEN-BEGIN:variables
128  private JTabbedPane browseVisualizeTabPane;
131  // End of variables declaration//GEN-END:variables
132 
133  @Override
134  public void componentOpened() {
135  super.componentOpened();
136  WindowManager.getDefault().setTopComponentFloating(this, true);
137  }
138 
139  @Override
140  public void open() {
141  super.open();
142  /*
143  * when the window is (re)opened make sure the filters and accounts are
144  * in an up to date and consistent state.
145  *
146  * Re-applying the filters means we will lose the selection...
147  */
148  filtersPane.updateAndApplyFilters(true);
149  }
150 
151  @Override
152  public List<Mode> availableModes(List<Mode> modes) {
153  /*
154  * This looks like the right thing to do, but online discussions seems
155  * to indicate this method is effectively deprecated. A break point
156  * placed here was never hit.
157  */
158  return modes.stream().filter(mode -> mode.getName().equals("cvt"))
159  .collect(Collectors.toList());
160  }
161 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.