19 package org.sleuthkit.autopsy.communications;
21 import com.google.common.eventbus.Subscribe;
22 import java.awt.BorderLayout;
23 import java.awt.Component;
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;
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")
55 private static final long serialVersionUID = 1L;
56 private boolean filtersVisible =
true;
67 splitPane.setRightComponent(relationshipBrowser);
68 splitPane.setDividerLocation(0.25);
70 setName(Bundle.CVTTopComponent_name());
78 associateLookup(proxyLookup);
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);
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);
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);
98 CVTEvents.getCVTEventBus().register(
this);
99 CVTEvents.getCVTEventBus().register(vizPanel);
100 CVTEvents.getCVTEventBus().register(accountsBrowser);
101 CVTEvents.getCVTEventBus().register(filtersPane);
103 filterTabbedPane.setIconAt(0,
new ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/communications/images/arrow-left.png")));
104 filterTabbedPane.setTitleAt(0,
"");
109 void pinAccount(CVTEvents.PinAccountsEvent pinEvent) {
110 browseVisualizeTabPane.setSelectedIndex(1);
114 void handle(
final CVTEvents.FilterChangeEvent filterChangeEvent) {
115 currentFilter = filterChangeEvent.getNewFilter();
126 filterTabbedPane =
new JTabbedPane();
127 filterTabPanel =
new JPanel();
128 splitPane =
new JSplitPane();
129 browseVisualizeTabPane =
new JTabbedPane();
131 setLayout(
new BorderLayout());
133 filterTabbedPane.addMouseListener(
new MouseAdapter() {
134 public void mouseClicked(MouseEvent evt) {
135 filterTabbedPaneMouseClicked(evt);
138 filterTabbedPane.addTab(NbBundle.getMessage(
CVTTopComponent.class,
"CVTTopComponent.filterTabPanel.TabConstraints.tabTitle"), filterTabPanel);
140 add(filterTabbedPane, BorderLayout.WEST);
142 splitPane.setDividerLocation(1);
143 splitPane.setResizeWeight(0.25);
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"));
149 add(splitPane, BorderLayout.CENTER);
153 int index = filterTabbedPane.indexAtLocation(evt.getX(), evt.getY());
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;
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;
179 super.componentOpened();
180 WindowManager.getDefault().setTopComponentFloating(
this,
true);
192 filtersPane.initalizeFilters();
202 return modes.stream().filter(mode -> mode.getName().equals(
"cvt"))
203 .collect(Collectors.toList());
void setSelectionInfo(SelectionInfo info)
CommunicationsFilter currentFilter
JTabbedPane browseVisualizeTabPane
void filterTabbedPaneMouseClicked(MouseEvent evt)
List< Mode > availableModes(List< Mode > modes)
JTabbedPane filterTabbedPane