19 package org.sleuthkit.autopsy.discovery.ui;
22 import com.google.common.eventbus.Subscribe;
23 import java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Graphics;
26 import java.beans.PropertyChangeEvent;
27 import java.beans.PropertyChangeListener;
28 import java.util.List;
29 import java.util.stream.Collectors;
30 import javax.swing.JPanel;
31 import javax.swing.JSplitPane;
32 import javax.swing.SwingUtilities;
33 import javax.swing.plaf.basic.BasicSplitPaneDivider;
34 import javax.swing.plaf.basic.BasicSplitPaneUI;
35 import org.openide.util.NbBundle;
36 import org.openide.util.NbBundle.Messages;
37 import org.openide.windows.Mode;
38 import org.openide.windows.RetainLocation;
39 import org.openide.windows.TopComponent;
40 import org.openide.windows.WindowManager;
46 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
51 @TopComponent.Description(preferredID =
"DiscoveryTc", persistenceType = TopComponent.PERSISTENCE_NEVER)
52 @TopComponent.Registration(mode =
"discovery", openAtStartup =
false)
53 @RetainLocation(
"discovery")
54 @NbBundle.Messages(
"DiscoveryTopComponent.name= Discovery")
76 setName(Bundle.DiscoveryTopComponent_name());
77 groupListPanel =
new GroupListPanel();
78 resultsPanel =
new ResultsPanel();
83 public BasicSplitPaneDivider createDefaultDivider() {
90 rightSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
new PropertyChangeListener() {
92 public void propertyChange(PropertyChangeEvent evt) {
93 if (evt.getPropertyName().equalsIgnoreCase(JSplitPane.DIVIDER_LOCATION_PROPERTY)
94 && ((animator == null || !animator.isRunning())
95 && evt.getNewValue() instanceof Integer
96 && evt.getOldValue() instanceof Integer
98 && (JSplitPane.UNDEFINED_CONDITION != (
int) evt.getNewValue())
99 && ((
int) evt.getOldValue() != JSplitPane.UNDEFINED_CONDITION))) {
101 previousDividerLocation = (int) evt.getNewValue();
123 this.setLayout(
new BorderLayout());
124 this.add(
new ResultsSplitPaneDivider());
127 private static final long serialVersionUID = 1L;
137 return discoveryTopComp;
145 resultsPanel.resetResultViewer();
146 groupListPanel.resetGroupList();
152 super.componentOpened();
153 WindowManager.getDefault().setTopComponentFloating(
this,
true);
161 rightSplitPane.setDividerLocation(JSplitPane.UNDEFINED_CONDITION);
167 DiscoveryDialog.getDiscoveryDialogInstance().cancelSearch();
174 if (detailsPanel instanceof DomainDetailsPanel) {
175 ((DomainDetailsPanel) detailsPanel).unregister();
176 selectedDomainTabName = ((DomainDetailsPanel) detailsPanel).getSelectedTabName();
179 super.componentClosed();
187 @SuppressWarnings(
"unchecked")
193 javax.swing.JPanel searchDetailsPanel =
new javax.swing.JPanel();
195 javax.swing.JScrollPane progressMessageScrollPane =
new javax.swing.JScrollPane();
198 setMinimumSize(
new java.awt.Dimension(199, 200));
199 setPreferredSize(
new java.awt.Dimension(1100, 700));
200 setLayout(
new java.awt.BorderLayout());
203 mainSplitPane.setPreferredSize(
new java.awt.Dimension(1100, 700));
206 rightSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
208 rightSplitPane.setPreferredSize(
new java.awt.Dimension(800, 700));
213 org.openide.awt.Mnemonics.setLocalizedText(
newSearchButton, Bundle.DiscoveryTopComponent_cancelButton_text());
217 newSearchButton.addActionListener(
new java.awt.event.ActionListener() {
218 public void actionPerformed(java.awt.event.ActionEvent evt) {
223 progressMessageScrollPane.setBorder(null);
233 javax.swing.GroupLayout searchDetailsPanelLayout =
new javax.swing.GroupLayout(searchDetailsPanel);
234 searchDetailsPanel.setLayout(searchDetailsPanelLayout);
235 searchDetailsPanelLayout.setHorizontalGroup(
236 searchDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
237 .addGroup(searchDetailsPanelLayout.createSequentialGroup()
239 .addComponent(
newSearchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
240 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
241 .addComponent(progressMessageScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 954, Short.MAX_VALUE)
244 searchDetailsPanelLayout.setVerticalGroup(
245 searchDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
246 .addGroup(searchDetailsPanelLayout.createSequentialGroup()
247 .addGroup(searchDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
248 .addGroup(searchDetailsPanelLayout.createSequentialGroup()
250 .addComponent(progressMessageScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
251 .addGroup(searchDetailsPanelLayout.createSequentialGroup()
253 .addComponent(
newSearchButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
257 add(searchDetailsPanel, java.awt.BorderLayout.PAGE_START);
262 final DiscoveryDialog discDialog = DiscoveryDialog.getDiscoveryDialogInstance();
263 discDialog.setVisible(
true);
264 discDialog.validateDialog();
274 return modes.stream().filter(mode -> mode.getName().equals(
"discovery"))
275 .collect(Collectors.toList());
287 SwingUtilities.invokeLater(() -> {
288 if (animator != null && animator.isRunning()) {
293 if (detailsVisibleEvent.isShowDetailsArea()) {
294 animator =
new SwingAnimator(
new ShowDetailsAreaCallback());
296 animator =
new SwingAnimator(
new HideDetailsAreaCallback());
308 @Messages({
"DiscoveryTopComponent.cancelButton.text=Cancel Search",
309 "# {0} - searchType",
310 "DiscoveryTopComponent.searchInProgress.text=Performing search for results of type {0}. Please wait.",
311 "DiscoveryTopComponent.searchError.text=Error no type specified for search."})
313 void handleSearchStartedEvent(DiscoveryEventUtils.SearchStartedEvent searchStartedEvent) {
314 SwingUtilities.invokeLater(() -> {
315 newSearchButton.setText(Bundle.DiscoveryTopComponent_cancelButton_text());
317 searchType = searchStartedEvent.getType();
329 @Messages({
"DiscoveryTopComponent.newSearch.text=New Search",
331 "DiscoveryTopComponent.searchComplete.text=Results with {0}",
332 "DiscoveryTopComponent.domainSearch.text=Type: Domain",
333 "DiscoveryTopComponent.additionalFilters.text=; "})
334 void handleSearchCompleteEvent(DiscoveryEventUtils.SearchCompleteEvent searchCompleteEvent) {
335 SwingUtilities.invokeLater(() -> {
336 newSearchButton.setText(Bundle.DiscoveryTopComponent_newSearch_text());
338 String descriptionText =
"";
339 if (searchType == DOMAIN) {
341 descriptionText = Bundle.DiscoveryTopComponent_domainSearch_text();
342 if (!searchCompleteEvent.getFilters().isEmpty()) {
343 descriptionText += Bundle.DiscoveryTopComponent_additionalFilters_text();
346 DomainDetailsPanel domainDetailsPanel =
new DomainDetailsPanel();
347 domainDetailsPanel.configureArtifactTabs(selectedDomainTabName);
348 detailsPanel = domainDetailsPanel;
350 detailsPanel =
new FileDetailsPanel();
353 DiscoveryEventUtils.getDiscoveryEventBus().register(detailsPanel);
354 descriptionText += searchCompleteEvent.getFilters().stream().map(
AbstractFilter::getDesc).collect(Collectors.joining(
"; "));
368 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
374 for (ARTIFACT_TYPE type : ((ArtifactTypeFilter) filter).getTypes()) {
375 typeFilteredOn = type.getDisplayName();
376 if (selectedDomainTabName == null || typeFilteredOn.equalsIgnoreCase(selectedDomainTabName)) {
383 return typeFilteredOn;
392 @Messages({
"DiscoveryTopComponent.searchCancelled.text=Search has been cancelled."})
394 void handleSearchCancelledEvent(DiscoveryEventUtils.SearchCancelledEvent searchCancelledEvent) {
395 SwingUtilities.invokeLater(() -> {
396 newSearchButton.setText(Bundle.DiscoveryTopComponent_newSearch_text());
418 if (dividerLocation != JSplitPane.UNDEFINED_CONDITION && dividerLocation < previousDividerLocation) {
443 if (dividerLocation >
rightSplitPane.getHeight() || dividerLocation == JSplitPane.UNDEFINED_CONDITION) {
464 private static final long serialVersionUID = 1L;
469 if (animator != null && animator.isRunning() && (dividerLocation == JSplitPane.UNDEFINED_CONDITION
471 setDividerLocation(dividerLocation);
473 super.paintComponent(g);
javax.swing.JSplitPane mainSplitPane
final ResultsPanel resultsPanel
static volatile int previousDividerLocation
void newSearchButtonActionPerformed(java.awt.event.ActionEvent evt)
abstract String getDesc()
void callback(Object caller)
javax.swing.JTextArea progressMessageTextArea
static EventBus getDiscoveryEventBus()
void callback(Object caller)
void paintComponent(Graphics g)
javax.swing.JSplitPane rightSplitPane
void resetBottomComponent()
static final String PREFERRED_ID
String validateLastSelectedType(DiscoveryEventUtils.SearchCompleteEvent searchCompleteEvent)
static final long serialVersionUID
final GroupListPanel groupListPanel
static DiscoveryTopComponent getTopComponent()
String selectedDomainTabName
List< Mode > availableModes(List< Mode > modes)
static final int ANIMATION_INCREMENT
javax.swing.JButton newSearchButton