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.JSplitPane;
31 import javax.swing.plaf.basic.BasicSplitPaneDivider;
32 import javax.swing.plaf.basic.BasicSplitPaneUI;
33 import org.openide.util.NbBundle;
34 import org.openide.util.NbBundle.Messages;
35 import org.openide.windows.Mode;
36 import org.openide.windows.RetainLocation;
37 import org.openide.windows.TopComponent;
38 import org.openide.windows.WindowManager;
47 @TopComponent.Description(preferredID =
"DiscoveryTc", persistenceType = TopComponent.PERSISTENCE_NEVER)
48 @TopComponent.Registration(mode =
"discovery", openAtStartup =
false)
49 @RetainLocation(
"discovery")
50 @NbBundle.Messages(
"DiscoveryTopComponent.name= Discovery")
70 setName(Bundle.DiscoveryTopComponent_name());
71 groupListPanel =
new GroupListPanel();
72 resultsPanel =
new ResultsPanel();
73 detailsPanel =
new DetailsPanel();
80 public BasicSplitPaneDivider createDefaultDivider() {
85 rightSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
new PropertyChangeListener() {
87 public void propertyChange(PropertyChangeEvent evt) {
88 if (evt.getPropertyName().equalsIgnoreCase(JSplitPane.DIVIDER_LOCATION_PROPERTY)) {
90 if ((animator == null || !animator.isRunning()) && evt.getNewValue() instanceof Integer
92 resultsAreaSize = (int) evt.getNewValue();
113 this.setLayout(
new BorderLayout());
114 this.add(
new ResultsSplitPaneDivider());
117 private static final long serialVersionUID = 1L;
133 resultsPanel.resetResultViewer();
134 groupListPanel.resetGroupList();
139 super.componentOpened();
140 WindowManager.getDefault().setTopComponentFloating(
this,
true);
149 DiscoveryDialog.getDiscoveryDialogInstance().cancelSearch();
155 super.componentClosed();
163 @SuppressWarnings(
"unchecked")
169 javax.swing.JPanel searchDetailsPanel =
new javax.swing.JPanel();
171 javax.swing.JScrollPane progressMessageScrollPane =
new javax.swing.JScrollPane();
174 setMinimumSize(
new java.awt.Dimension(199, 200));
175 setPreferredSize(
new java.awt.Dimension(1100, 700));
176 setLayout(
new java.awt.BorderLayout());
179 mainSplitPane.setPreferredSize(
new java.awt.Dimension(1100, 700));
182 rightSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
184 rightSplitPane.setPreferredSize(
new java.awt.Dimension(800, 700));
189 org.openide.awt.Mnemonics.setLocalizedText(
newSearchButton, Bundle.DiscoveryTopComponent_cancelButton_text());
193 newSearchButton.addActionListener(
new java.awt.event.ActionListener() {
194 public void actionPerformed(java.awt.event.ActionEvent evt) {
199 progressMessageScrollPane.setBorder(null);
209 javax.swing.GroupLayout searchDetailsPanelLayout =
new javax.swing.GroupLayout(searchDetailsPanel);
210 searchDetailsPanel.setLayout(searchDetailsPanelLayout);
211 searchDetailsPanelLayout.setHorizontalGroup(
212 searchDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
213 .addGroup(searchDetailsPanelLayout.createSequentialGroup()
215 .addComponent(
newSearchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
216 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
217 .addComponent(progressMessageScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 954, Short.MAX_VALUE)
220 searchDetailsPanelLayout.setVerticalGroup(
221 searchDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
222 .addGroup(searchDetailsPanelLayout.createSequentialGroup()
223 .addGroup(searchDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
224 .addGroup(searchDetailsPanelLayout.createSequentialGroup()
226 .addComponent(progressMessageScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
227 .addGroup(searchDetailsPanelLayout.createSequentialGroup()
229 .addComponent(
newSearchButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
233 add(searchDetailsPanel, java.awt.BorderLayout.PAGE_START);
238 final DiscoveryDialog discDialog = DiscoveryDialog.getDiscoveryDialogInstance();
239 discDialog.cancelSearch();
240 discDialog.setVisible(
true);
241 discDialog.validateDialog();
251 return modes.stream().filter(mode -> mode.getName().equals(
"discovery"))
252 .collect(Collectors.toList());
264 if (resultsPanel.getActiveType() != DOMAIN) {
265 if (animator != null && animator.isRunning()) {
270 if (detailsVisibleEvent.isShowDetailsArea()) {
271 animator =
new SwingAnimator(
new ShowDetailsAreaCallback());
273 animator =
new SwingAnimator(
new HideDetailsAreaCallback());
285 @Messages({
"DiscoveryTopComponent.cancelButton.text=Cancel Search",
286 "# {0} - searchType",
287 "DiscoveryTopComponent.searchInProgress.text=Performing search for results of type {0}. Please wait.",
288 "DiscoveryTopComponent.searchError.text=Error no type specified for search."})
290 void handleSearchStartedEvent(DiscoveryEventUtils.SearchStartedEvent searchStartedEvent) {
291 newSearchButton.setText(Bundle.DiscoveryTopComponent_cancelButton_text());
293 searchType = searchStartedEvent.getType();
295 rightSplitPane.getComponent(1).setVisible(searchStartedEvent.getType() != DOMAIN);
296 rightSplitPane.getComponent(2).setVisible(searchStartedEvent.getType() != DOMAIN);
306 @Messages({
"DiscoveryTopComponent.newSearch.text=New Search",
308 "DiscoveryTopComponent.searchComplete.text=Results with {0}",
309 "DiscoveryTopComponent.domainSearch.text=Type: Domain",
310 "DiscoveryTopComponent.additionalFilters.text=; "})
311 void handleSearchCompleteEvent(DiscoveryEventUtils.SearchCompleteEvent searchCompleteEvent) {
312 newSearchButton.setText(Bundle.DiscoveryTopComponent_newSearch_text());
314 String descriptionText =
"";
315 if (searchType == DOMAIN) {
317 descriptionText = Bundle.DiscoveryTopComponent_domainSearch_text();
318 if (!searchCompleteEvent.getFilters().isEmpty()) {
319 descriptionText += Bundle.DiscoveryTopComponent_additionalFilters_text();
322 descriptionText += searchCompleteEvent.getFilters().stream().map(
AbstractFilter::getDesc).collect(Collectors.joining(
"; "));
333 @Messages({
"DiscoveryTopComponent.searchCancelled.text=Search has been cancelled."})
335 void handleSearchCancelledEvent(DiscoveryEventUtils.SearchCancelledEvent searchCancelledEvent) {
336 newSearchButton.setText(Bundle.DiscoveryTopComponent_newSearch_text());
355 if (dividerLocation != JSplitPane.UNDEFINED_CONDITION && dividerLocation < resultsAreaSize) {
378 if (dividerLocation >
rightSplitPane.getHeight() || dividerLocation == JSplitPane.UNDEFINED_CONDITION) {
399 private static final long serialVersionUID = 1L;
403 if (animator != null && animator.isRunning() && (dividerLocation == JSplitPane.UNDEFINED_CONDITION
404 || (dividerLocation <= getHeight() && dividerLocation >=
resultsAreaSize))) {
405 setDividerLocation(dividerLocation);
407 super.paintComponent(g);
javax.swing.JSplitPane mainSplitPane
final ResultsPanel resultsPanel
void newSearchButtonActionPerformed(java.awt.event.ActionEvent evt)
abstract String getDesc()
void callback(Object caller)
static volatile int resultsAreaSize
javax.swing.JTextArea progressMessageTextArea
static EventBus getDiscoveryEventBus()
void callback(Object caller)
void paintComponent(Graphics g)
javax.swing.JSplitPane rightSplitPane
static final String PREFERRED_ID
static final long serialVersionUID
final GroupListPanel groupListPanel
static DiscoveryTopComponent getTopComponent()
List< Mode > availableModes(List< Mode > modes)
static final int ANIMATION_INCREMENT
final DetailsPanel detailsPanel
javax.swing.JButton newSearchButton