19 package org.sleuthkit.autopsy.discovery;
21 import com.google.common.eventbus.Subscribe;
22 import java.awt.BorderLayout;
23 import java.awt.Color;
24 import java.awt.Graphics;
25 import java.util.List;
26 import java.util.stream.Collectors;
27 import javax.swing.JSplitPane;
28 import javax.swing.plaf.basic.BasicSplitPaneDivider;
29 import javax.swing.plaf.basic.BasicSplitPaneUI;
30 import org.openide.util.NbBundle;
31 import org.openide.util.NbBundle.Messages;
32 import org.openide.windows.Mode;
33 import org.openide.windows.RetainLocation;
34 import org.openide.windows.TopComponent;
35 import org.openide.windows.WindowManager;
42 @TopComponent.Description(preferredID =
"DiscoveryTopComponent", persistenceType = TopComponent.PERSISTENCE_NEVER)
43 @TopComponent.Registration(mode =
"discovery", openAtStartup =
false)
44 @RetainLocation(
"discovery")
45 @NbBundle.Messages(
"DiscoveryTopComponent.name= Discovery")
49 private static final String
PREFERRED_ID =
"DiscoveryTopComponent";
66 setName(Bundle.DiscoveryTopComponent_name());
67 groupListPanel =
new GroupListPanel();
68 resultsPanel =
new ResultsPanel();
69 detailsPanel =
new DetailsPanel();
76 public BasicSplitPaneDivider createDefaultDivider() {
96 this.setLayout(
new BorderLayout());
97 this.add(
new ResultsSplitPaneDivider());
100 private static final long serialVersionUID = 1L;
116 resultsPanel.resetResultViewer();
117 groupListPanel.resetGroupList();
122 super.componentOpened();
123 WindowManager.getDefault().setTopComponentFloating(
this,
true);
124 DiscoveryEventUtils.getDiscoveryEventBus().register(
this);
125 DiscoveryEventUtils.getDiscoveryEventBus().register(resultsPanel);
126 DiscoveryEventUtils.getDiscoveryEventBus().register(groupListPanel);
127 DiscoveryEventUtils.getDiscoveryEventBus().register(detailsPanel);
132 DiscoveryDialog.getDiscoveryDialogInstance().cancelSearch();
133 DiscoveryEventUtils.getDiscoveryEventBus().unregister(
this);
134 DiscoveryEventUtils.getDiscoveryEventBus().unregister(groupListPanel);
135 DiscoveryEventUtils.getDiscoveryEventBus().unregister(resultsPanel);
136 DiscoveryEventUtils.getDiscoveryEventBus().unregister(detailsPanel);
137 super.componentClosed();
145 @SuppressWarnings(
"unchecked")
151 javax.swing.JPanel searchDetailsPanel =
new javax.swing.JPanel();
153 javax.swing.JScrollPane progressMessageScrollPane =
new javax.swing.JScrollPane();
156 setMinimumSize(
new java.awt.Dimension(199, 200));
157 setPreferredSize(
new java.awt.Dimension(1100, 700));
158 setLayout(
new java.awt.BorderLayout());
161 mainSplitPane.setPreferredSize(
new java.awt.Dimension(1100, 700));
164 rightSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
166 rightSplitPane.setPreferredSize(
new java.awt.Dimension(800, 700));
175 newSearchButton.addActionListener(
new java.awt.event.ActionListener() {
176 public void actionPerformed(java.awt.event.ActionEvent evt) {
181 progressMessageScrollPane.setBorder(null);
191 javax.swing.GroupLayout searchDetailsPanelLayout =
new javax.swing.GroupLayout(searchDetailsPanel);
192 searchDetailsPanel.setLayout(searchDetailsPanelLayout);
193 searchDetailsPanelLayout.setHorizontalGroup(
194 searchDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
195 .addGroup(searchDetailsPanelLayout.createSequentialGroup()
197 .addComponent(
newSearchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
198 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
199 .addComponent(progressMessageScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 954, Short.MAX_VALUE)
202 searchDetailsPanelLayout.setVerticalGroup(
203 searchDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
204 .addGroup(searchDetailsPanelLayout.createSequentialGroup()
205 .addGroup(searchDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
206 .addGroup(searchDetailsPanelLayout.createSequentialGroup()
208 .addComponent(progressMessageScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
209 .addGroup(searchDetailsPanelLayout.createSequentialGroup()
211 .addComponent(
newSearchButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
215 add(searchDetailsPanel, java.awt.BorderLayout.PAGE_START);
220 final DiscoveryDialog discDialog = DiscoveryDialog.getDiscoveryDialogInstance();
221 discDialog.cancelSearch();
222 discDialog.setVisible(
true);
223 discDialog.validateDialog();
233 return modes.stream().filter(mode -> mode.getName().equals(
"discovery"))
234 .collect(Collectors.toList());
245 void handleDetailsVisibleEvent(DiscoveryEventUtils.DetailsVisibleEvent detailsVisibleEvent) {
246 if (animator != null && animator.isRunning()) {
250 if (detailsVisibleEvent.isShowDetailsArea()) {
251 animator =
new SwingAnimator(
new ShowDetailsAreaCallback());
253 animator =
new SwingAnimator(
new HideDetailsAreaCallback());
264 @Messages({
"DiscoveryTopComponent.cancelButton.text=Cancel Search",
265 "# {0} - searchType",
266 "DiscoveryTopComponent.searchInProgress.text=Performing search for results of type {0}. Please wait."})
268 void handleSearchStartedEvent(DiscoveryEventUtils.SearchStartedEvent searchStartedEvent) {
269 newSearchButton.setText(Bundle.DiscoveryTopComponent_cancelButton_text());
271 progressMessageTextArea.setText(Bundle.DiscoveryTopComponent_searchInProgress_text(searchStartedEvent.getType().name()));
281 @Messages({
"DiscoveryTopComponent.newSearch.text=New Search",
283 "DiscoveryTopComponent.searchComplete.text=Results with {0}"})
284 void handleSearchCompleteEvent(DiscoveryEventUtils.SearchCompleteEvent searchCompleteEvent) {
285 newSearchButton.setText(Bundle.DiscoveryTopComponent_newSearch_text());
287 progressMessageTextArea.setText(Bundle.DiscoveryTopComponent_searchComplete_text(searchCompleteEvent.getFilters().stream().map(FileFilter::getDesc).collect(Collectors.joining(
"; "))));
297 @Messages({
"DiscoveryTopComponent.searchCancelled.text=Search has been cancelled."})
299 void handleSearchCancelledEvent(DiscoveryEventUtils.SearchCancelledEvent searchCancelledEvent) {
300 newSearchButton.setText(Bundle.DiscoveryTopComponent_newSearch_text());
319 if (dividerLocation != JSplitPane.UNDEFINED_CONDITION && dividerLocation < RESULTS_AREA_SMALL_SIZE) {
341 if (dividerLocation >
rightSplitPane.getHeight() || dividerLocation == JSplitPane.UNDEFINED_CONDITION) {
361 private static final long serialVersionUID = 1L;
368 super.paintComponent(g);
void newSearchButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JButton newSearchButton
javax.swing.JSplitPane mainSplitPane
final DetailsPanel detailsPanel
List< Mode > availableModes(List< Mode > modes)
static final int ANIMATION_INCREMENT
static final long serialVersionUID
javax.swing.JSplitPane rightSplitPane
static DiscoveryTopComponent getTopComponent()
static final int RESULTS_AREA_SMALL_SIZE
static final String PREFERRED_ID
void callback(Object caller)
javax.swing.JTextArea progressMessageTextArea
final GroupListPanel groupListPanel
final ResultsPanel resultsPanel
void paintComponent(Graphics g)
void callback(Object caller)