Autopsy  4.7.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
CommonFilesPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2018 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.commonfilesearch;
20 
21 import java.sql.SQLException;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Map;
25 import java.util.Map.Entry;
26 import java.util.concurrent.ExecutionException;
27 import java.util.logging.Level;
28 import javax.swing.ComboBoxModel;
29 import javax.swing.SwingUtilities;
30 import javax.swing.SwingWorker;
31 import org.openide.explorer.ExplorerManager;
32 import org.openide.util.NbBundle;
41 import org.sleuthkit.datamodel.TskCoreException;
42 
47 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
48 public final class CommonFilesPanel extends javax.swing.JPanel {
49 
50  private static final long serialVersionUID = 1L;
51 
52  private static final Long NO_DATA_SOURCE_SELECTED = -1L;
53 
54  private ComboBoxModel<String> dataSourcesList = new DataSourceComboBoxModel();
55  private Map<Long, String> dataSourceMap;
56 
57  private static final Logger LOGGER = Logger.getLogger(CommonFilesPanel.class.getName());
58  private boolean singleDataSource = false;
59  private String selectedDataSource = "";
60  private boolean pictureViewCheckboxState;
61  private boolean documentsCheckboxState;
62 
66  @NbBundle.Messages({
67  "CommonFilesPanel.title=Common Files Panel",
68  "CommonFilesPanel.exception=Unexpected Exception loading DataSources."})
69  public CommonFilesPanel() {
70  initComponents();
71 
72  this.setupDataSources();
73 
74  this.errorText.setVisible(false);
75  }
76 
83  @NbBundle.Messages({
84  "CommonFilesPanel.buildDataSourceMap.done.tskCoreException=Unable to run query against DB.",
85  "CommonFilesPanel.buildDataSourceMap.done.noCurrentCaseException=Unable to open case file.",
86  "CommonFilesPanel.buildDataSourceMap.done.exception=Unexpected exception building data sources map.",
87  "CommonFilesPanel.buildDataSourceMap.done.interupted=Something went wrong building the Common Files Search dialog box.",
88  "CommonFilesPanel.buildDataSourceMap.done.sqlException=Unable to query db for data sources.",
89  "CommonFilesPanel.buildDataSourcesMap.updateUi.noDataSources=No data sources were found."})
90  private void setupDataSources() {
91 
92  new SwingWorker<Map<Long, String>, Void>() {
93 
94  private void updateUi() {
95 
96  String[] dataSourcesNames = new String[CommonFilesPanel.this.dataSourceMap.size()];
97 
98  //only enable all this stuff if we actually have datasources
99  if (dataSourcesNames.length > 0) {
100  dataSourcesNames = CommonFilesPanel.this.dataSourceMap.values().toArray(dataSourcesNames);
101  CommonFilesPanel.this.dataSourcesList = new DataSourceComboBoxModel(dataSourcesNames);
103 
104  boolean multipleDataSources = this.caseHasMultipleSources();
105  CommonFilesPanel.this.allDataSourcesRadioButton.setEnabled(multipleDataSources);
106  CommonFilesPanel.this.allDataSourcesRadioButton.setSelected(multipleDataSources);
107 
108  if (!multipleDataSources) {
109  CommonFilesPanel.this.withinDataSourceRadioButton.setSelected(true);
110  withinDataSourceSelected(true);
111  }
112 
113  CommonFilesPanel.this.searchButton.setEnabled(true);
114  } else {
115  MessageNotifyUtil.Message.info(Bundle.CommonFilesPanel_buildDataSourcesMap_updateUi_noDataSources());
117  }
118  }
119 
120  private boolean caseHasMultipleSources() {
121  return CommonFilesPanel.this.dataSourceMap.size() >= 2;
122  }
123 
124  @Override
125  protected Map<Long, String> doInBackground() throws NoCurrentCaseException, TskCoreException, SQLException {
126  DataSourceLoader loader = new DataSourceLoader();
127  return loader.getDataSourceMap();
128  }
129 
130  @Override
131  protected void done() {
132 
133  try {
134  CommonFilesPanel.this.dataSourceMap = this.get();
135 
136  updateUi();
137 
138  } catch (InterruptedException ex) {
139  LOGGER.log(Level.SEVERE, "Interrupted while building Common Files Search dialog.", ex);
140  MessageNotifyUtil.Message.error(Bundle.CommonFilesPanel_buildDataSourceMap_done_interupted());
141  } catch (ExecutionException ex) {
142  String errorMessage;
143  Throwable inner = ex.getCause();
144  if (inner instanceof TskCoreException) {
145  LOGGER.log(Level.SEVERE, "Failed to load data sources from database.", ex);
146  errorMessage = Bundle.CommonFilesPanel_buildDataSourceMap_done_tskCoreException();
147  } else if (inner instanceof NoCurrentCaseException) {
148  LOGGER.log(Level.SEVERE, "Current case has been closed.", ex);
149  errorMessage = Bundle.CommonFilesPanel_buildDataSourceMap_done_noCurrentCaseException();
150  } else if (inner instanceof SQLException) {
151  LOGGER.log(Level.SEVERE, "Unable to query db for data sources.", ex);
152  errorMessage = Bundle.CommonFilesPanel_buildDataSourceMap_done_sqlException();
153  } else {
154  LOGGER.log(Level.SEVERE, "Unexpected exception while building Common Files Search dialog panel.", ex);
155  errorMessage = Bundle.CommonFilesPanel_buildDataSourceMap_done_exception();
156  }
157  MessageNotifyUtil.Message.error(errorMessage);
158  }
159  }
160  }.execute();
161  }
162 
163  @NbBundle.Messages({
164  "CommonFilesPanel.search.results.titleAll=Common Files (All Data Sources)",
165  "CommonFilesPanel.search.results.titleSingle=Common Files (Match Within Data Source: %s)",
166  "CommonFilesPanel.search.results.pathText=Common Files Search Results",
167  "CommonFilesPanel.search.done.tskCoreException=Unable to run query against DB.",
168  "CommonFilesPanel.search.done.noCurrentCaseException=Unable to open case file.",
169  "CommonFilesPanel.search.done.exception=Unexpected exception running Common Files Search.",
170  "CommonFilesPanel.search.done.interupted=Something went wrong finding common files.",
171  "CommonFilesPanel.search.done.sqlException=Unable to query db for files or data sources."})
172  private void search() {
173  String pathText = Bundle.CommonFilesPanel_search_results_pathText();
174 
175  new SwingWorker<CommonFilesMetadata, Void>() {
176 
177  private String tabTitle;
178 
179  private void setTitleForAllDataSources() {
180  this.tabTitle = Bundle.CommonFilesPanel_search_results_titleAll();
181  }
182 
183  private void setTitleForSingleSource(Long dataSourceId) {
184  final String CommonFilesPanel_search_results_titleSingle = Bundle.CommonFilesPanel_search_results_titleSingle();
185  final Object[] dataSourceName = new Object[]{dataSourceMap.get(dataSourceId)};
186 
187  this.tabTitle = String.format(CommonFilesPanel_search_results_titleSingle, dataSourceName);
188  }
189 
190  private Long determineDataSourceId() {
191  Long selectedObjId = CommonFilesPanel.NO_DATA_SOURCE_SELECTED;
193  for (Entry<Long, String> dataSource : CommonFilesPanel.this.dataSourceMap.entrySet()) {
194  if (dataSource.getValue().equals(CommonFilesPanel.this.selectedDataSource)) {
195  selectedObjId = dataSource.getKey();
196  break;
197  }
198  }
199  }
200  return selectedObjId;
201  }
202 
203  @Override
204  @SuppressWarnings({"BoxedValueEquality", "NumberEquality"})
205  protected CommonFilesMetadata doInBackground() throws TskCoreException, NoCurrentCaseException, SQLException {
206  Long dataSourceId = determineDataSourceId();
207 
209  boolean filterByMedia = false;
210  boolean filterByDocuments = false;
211  if (selectedFileCategoriesButton.isSelected()) {
212  if (pictureVideoCheckbox.isSelected()) {
213  filterByMedia = true;
214  }
215  if (documentsCheckbox.isSelected()) {
216  filterByDocuments = true;
217  }
218  }
219  if (dataSourceId == CommonFilesPanel.NO_DATA_SOURCE_SELECTED) {
220  builder = new AllDataSourcesCommonFilesAlgorithm(CommonFilesPanel.this.dataSourceMap, filterByMedia, filterByDocuments);
221 
222  setTitleForAllDataSources();
223  } else {
224  builder = new SingleDataSource(dataSourceId, CommonFilesPanel.this.dataSourceMap, filterByMedia, filterByDocuments);
225 
226  setTitleForSingleSource(dataSourceId);
227  }
228 
229  this.tabTitle = builder.buildTabTitle();
230 
231  CommonFilesMetadata metadata = builder.findCommonFiles();
232 
233  return metadata;
234  }
235 
236  @Override
237  protected void done() {
238  try {
239  super.done();
240 
241  CommonFilesMetadata metadata = get();
242 
243  CommonFilesNode commonFilesNode = new CommonFilesNode(metadata);
244 
245  DataResultFilterNode dataResultFilterNode = new DataResultFilterNode(commonFilesNode, ExplorerManager.find(CommonFilesPanel.this));
246 
247  TableFilterNode tableFilterWithDescendantsNode = new TableFilterNode(dataResultFilterNode);
248 
250 
251  Collection<DataResultViewer> viewers = new ArrayList<>(1);
252  viewers.add(table);
253 
254  DataResultTopComponent.createInstance(tabTitle, pathText, tableFilterWithDescendantsNode, metadata.size(), viewers);
255 
256  } catch (InterruptedException ex) {
257  LOGGER.log(Level.SEVERE, "Interrupted while loading Common Files", ex);
258  MessageNotifyUtil.Message.error(Bundle.CommonFilesPanel_search_done_interupted());
259  } catch (ExecutionException ex) {
260  String errorMessage;
261  Throwable inner = ex.getCause();
262  if (inner instanceof TskCoreException) {
263  LOGGER.log(Level.SEVERE, "Failed to load files from database.", ex);
264  errorMessage = Bundle.CommonFilesPanel_search_done_tskCoreException();
265  } else if (inner instanceof NoCurrentCaseException) {
266  LOGGER.log(Level.SEVERE, "Current case has been closed.", ex);
267  errorMessage = Bundle.CommonFilesPanel_search_done_noCurrentCaseException();
268  } else if (inner instanceof SQLException) {
269  LOGGER.log(Level.SEVERE, "Unable to query db for files.", ex);
270  errorMessage = Bundle.CommonFilesPanel_search_done_sqlException();
271  } else {
272  LOGGER.log(Level.SEVERE, "Unexpected exception while running Common Files Search.", ex);
273  errorMessage = Bundle.CommonFilesPanel_search_done_exception();
274  }
275  MessageNotifyUtil.Message.error(errorMessage);
276  }
277  }
278  }.execute();
279  }
280 
286  @SuppressWarnings("unchecked")
287  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
288  private void initComponents() {
289 
290  dataSourcesButtonGroup = new javax.swing.ButtonGroup();
291  fileTypeFilterButtonGroup = new javax.swing.ButtonGroup();
292  searchButton = new javax.swing.JButton();
293  allDataSourcesRadioButton = new javax.swing.JRadioButton();
294  withinDataSourceRadioButton = new javax.swing.JRadioButton();
295  selectDataSourceComboBox = new javax.swing.JComboBox<>();
296  commonFilesSearchLabel = new javax.swing.JLabel();
297  cancelButton = new javax.swing.JButton();
298  allFileCategoriesRadioButton = new javax.swing.JRadioButton();
299  selectedFileCategoriesButton = new javax.swing.JRadioButton();
300  pictureVideoCheckbox = new javax.swing.JCheckBox();
301  documentsCheckbox = new javax.swing.JCheckBox();
302  dataSourceLabel = new javax.swing.JLabel();
303  categoriesLabel = new javax.swing.JLabel();
304  errorText = new javax.swing.JLabel();
305 
306  org.openide.awt.Mnemonics.setLocalizedText(searchButton, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.searchButton.text")); // NOI18N
307  searchButton.setEnabled(false);
308  searchButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
309  searchButton.addActionListener(new java.awt.event.ActionListener() {
310  public void actionPerformed(java.awt.event.ActionEvent evt) {
311  searchButtonActionPerformed(evt);
312  }
313  });
314 
315  dataSourcesButtonGroup.add(allDataSourcesRadioButton);
316  allDataSourcesRadioButton.setSelected(true);
317  org.openide.awt.Mnemonics.setLocalizedText(allDataSourcesRadioButton, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.allDataSourcesRadioButton.text")); // NOI18N
318  allDataSourcesRadioButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
319  allDataSourcesRadioButton.addActionListener(new java.awt.event.ActionListener() {
320  public void actionPerformed(java.awt.event.ActionEvent evt) {
321  allDataSourcesRadioButtonActionPerformed(evt);
322  }
323  });
324 
325  dataSourcesButtonGroup.add(withinDataSourceRadioButton);
326  org.openide.awt.Mnemonics.setLocalizedText(withinDataSourceRadioButton, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.withinDataSourceRadioButton.text")); // NOI18N
327  withinDataSourceRadioButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
328  withinDataSourceRadioButton.addActionListener(new java.awt.event.ActionListener() {
329  public void actionPerformed(java.awt.event.ActionEvent evt) {
330  withinDataSourceRadioButtonActionPerformed(evt);
331  }
332  });
333 
334  selectDataSourceComboBox.setModel(dataSourcesList);
335  selectDataSourceComboBox.setEnabled(false);
336  selectDataSourceComboBox.addActionListener(new java.awt.event.ActionListener() {
337  public void actionPerformed(java.awt.event.ActionEvent evt) {
338  selectDataSourceComboBoxActionPerformed(evt);
339  }
340  });
341 
342  org.openide.awt.Mnemonics.setLocalizedText(commonFilesSearchLabel, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.commonFilesSearchLabel.text")); // NOI18N
343  commonFilesSearchLabel.setFocusable(false);
344 
345  org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.cancelButton.text")); // NOI18N
346  cancelButton.setActionCommand(org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.cancelButton.actionCommand")); // NOI18N
347  cancelButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
348  cancelButton.addActionListener(new java.awt.event.ActionListener() {
349  public void actionPerformed(java.awt.event.ActionEvent evt) {
350  cancelButtonActionPerformed(evt);
351  }
352  });
353 
354  fileTypeFilterButtonGroup.add(allFileCategoriesRadioButton);
355  org.openide.awt.Mnemonics.setLocalizedText(allFileCategoriesRadioButton, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.allFileCategoriesRadioButton.text")); // NOI18N
356  allFileCategoriesRadioButton.setToolTipText(org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.allFileCategoriesRadioButton.toolTipText")); // NOI18N
357  allFileCategoriesRadioButton.addActionListener(new java.awt.event.ActionListener() {
358  public void actionPerformed(java.awt.event.ActionEvent evt) {
359  allFileCategoriesRadioButtonActionPerformed(evt);
360  }
361  });
362 
363  fileTypeFilterButtonGroup.add(selectedFileCategoriesButton);
364  selectedFileCategoriesButton.setSelected(true);
365  org.openide.awt.Mnemonics.setLocalizedText(selectedFileCategoriesButton, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.selectedFileCategoriesButton.text")); // NOI18N
366  selectedFileCategoriesButton.setToolTipText(org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.selectedFileCategoriesButton.toolTipText")); // NOI18N
367  selectedFileCategoriesButton.addActionListener(new java.awt.event.ActionListener() {
368  public void actionPerformed(java.awt.event.ActionEvent evt) {
369  selectedFileCategoriesButtonActionPerformed(evt);
370  }
371  });
372 
373  pictureVideoCheckbox.setSelected(true);
374  org.openide.awt.Mnemonics.setLocalizedText(pictureVideoCheckbox, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.pictureVideoCheckbox.text")); // NOI18N
375  pictureVideoCheckbox.addActionListener(new java.awt.event.ActionListener() {
376  public void actionPerformed(java.awt.event.ActionEvent evt) {
377  pictureVideoCheckboxActionPerformed(evt);
378  }
379  });
380 
381  documentsCheckbox.setSelected(true);
382  org.openide.awt.Mnemonics.setLocalizedText(documentsCheckbox, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.documentsCheckbox.text")); // NOI18N
383  documentsCheckbox.addActionListener(new java.awt.event.ActionListener() {
384  public void actionPerformed(java.awt.event.ActionEvent evt) {
385  documentsCheckboxActionPerformed(evt);
386  }
387  });
388 
389  org.openide.awt.Mnemonics.setLocalizedText(dataSourceLabel, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.text")); // NOI18N
390  dataSourceLabel.setName(""); // NOI18N
391 
392  org.openide.awt.Mnemonics.setLocalizedText(categoriesLabel, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.categoriesLabel.text")); // NOI18N
393  categoriesLabel.setName(""); // NOI18N
394 
395  errorText.setForeground(new java.awt.Color(255, 0, 0));
396  org.openide.awt.Mnemonics.setLocalizedText(errorText, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.errorText.text")); // NOI18N
397 
398  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
399  this.setLayout(layout);
400  layout.setHorizontalGroup(
401  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
402  .addGroup(layout.createSequentialGroup()
403  .addContainerGap()
404  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
405  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
406  .addComponent(errorText)
407  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
408  .addComponent(searchButton)
409  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
410  .addComponent(cancelButton)
411  .addContainerGap())
412  .addGroup(layout.createSequentialGroup()
413  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
414  .addComponent(categoriesLabel)
415  .addComponent(commonFilesSearchLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
416  .addComponent(dataSourceLabel)
417  .addGroup(layout.createSequentialGroup()
418  .addGap(6, 6, 6)
419  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
420  .addGroup(layout.createSequentialGroup()
421  .addGap(29, 29, 29)
422  .addComponent(selectDataSourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE))
423  .addComponent(withinDataSourceRadioButton)
424  .addComponent(allDataSourcesRadioButton)
425  .addComponent(allFileCategoriesRadioButton)
426  .addComponent(selectedFileCategoriesButton)
427  .addGroup(layout.createSequentialGroup()
428  .addGap(21, 21, 21)
429  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
430  .addComponent(pictureVideoCheckbox)
431  .addComponent(documentsCheckbox))))))
432  .addGap(19, 19, 19))))
433  );
434  layout.setVerticalGroup(
435  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
436  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
437  .addContainerGap()
438  .addComponent(commonFilesSearchLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
439  .addGap(18, 18, 18)
440  .addComponent(dataSourceLabel)
441  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
442  .addComponent(allDataSourcesRadioButton)
443  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
444  .addComponent(withinDataSourceRadioButton)
445  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
446  .addComponent(selectDataSourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
447  .addGap(18, 18, 18)
448  .addComponent(categoriesLabel)
449  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
450  .addComponent(selectedFileCategoriesButton)
451  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
452  .addComponent(pictureVideoCheckbox)
453  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
454  .addComponent(documentsCheckbox)
455  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
456  .addComponent(allFileCategoriesRadioButton)
457  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
458  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
459  .addComponent(cancelButton)
460  .addComponent(searchButton)
461  .addComponent(errorText)))
462  );
463  }// </editor-fold>//GEN-END:initComponents
464 
465  private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed
466  search();
467  SwingUtilities.windowForComponent(this).dispose();
468  }//GEN-LAST:event_searchButtonActionPerformed
469 
470  private void allDataSourcesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allDataSourcesRadioButtonActionPerformed
471  selectDataSourceComboBox.setEnabled(!allDataSourcesRadioButton.isSelected());
472  singleDataSource = false;
473  }//GEN-LAST:event_allDataSourcesRadioButtonActionPerformed
474 
475  private void selectDataSourceComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectDataSourceComboBoxActionPerformed
476  final Object selectedItem = selectDataSourceComboBox.getSelectedItem();
477  if (selectedItem != null) {
478  selectedDataSource = selectedItem.toString();
479  } else {
480  selectedDataSource = "";
481  }
482  }//GEN-LAST:event_selectDataSourceComboBoxActionPerformed
483 
484  private void withinDataSourceRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_withinDataSourceRadioButtonActionPerformed
485  withinDataSourceSelected(withinDataSourceRadioButton.isSelected());
486  }//GEN-LAST:event_withinDataSourceRadioButtonActionPerformed
487 
488  private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
489  SwingUtilities.windowForComponent(this).dispose();
490  }//GEN-LAST:event_cancelButtonActionPerformed
491 
492  private void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allFileCategoriesRadioButtonActionPerformed
493  this.manageCheckBoxState();
494  this.toggleErrorTextAndSearchBox();
495  }//GEN-LAST:event_allFileCategoriesRadioButtonActionPerformed
496 
497  private void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectedFileCategoriesButtonActionPerformed
498  this.manageCheckBoxState();
499  }//GEN-LAST:event_selectedFileCategoriesButtonActionPerformed
500 
501  private void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pictureVideoCheckboxActionPerformed
502  this.toggleErrorTextAndSearchBox();
503  }//GEN-LAST:event_pictureVideoCheckboxActionPerformed
504 
505  private void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_documentsCheckboxActionPerformed
506  this.toggleErrorTextAndSearchBox();
507  }//GEN-LAST:event_documentsCheckboxActionPerformed
508 
510  if (!this.pictureVideoCheckbox.isSelected() && !this.documentsCheckbox.isSelected() && !this.allFileCategoriesRadioButton.isSelected()) {
511  this.searchButton.setEnabled(false);
512  this.errorText.setVisible(true);
513  } else {
514  this.searchButton.setEnabled(true);
515  this.errorText.setVisible(false);
516  }
517  }
518 
519  private void withinDataSourceSelected(boolean selected) {
520  selectDataSourceComboBox.setEnabled(selected);
521  if (selectDataSourceComboBox.isEnabled()) {
522  selectDataSourceComboBox.setSelectedIndex(0);
523  singleDataSource = true;
524  }
525  }
526 
527  private void manageCheckBoxState() {
528 
529  if (this.allFileCategoriesRadioButton.isSelected()) {
530 
531  this.pictureViewCheckboxState = this.pictureVideoCheckbox.isSelected();
532  this.documentsCheckboxState = this.documentsCheckbox.isSelected();
533 
534  this.pictureVideoCheckbox.setEnabled(false);
535  this.documentsCheckbox.setEnabled(false);
536  }
537 
538  if (this.selectedFileCategoriesButton.isSelected()) {
539 
540  this.pictureVideoCheckbox.setSelected(this.pictureViewCheckboxState);
541  this.documentsCheckbox.setSelected(this.documentsCheckboxState);
542 
543  this.pictureVideoCheckbox.setEnabled(true);
544  this.documentsCheckbox.setEnabled(true);
545 
546  this.toggleErrorTextAndSearchBox();
547  }
548  }
549 
550  // Variables declaration - do not modify//GEN-BEGIN:variables
551  private javax.swing.JRadioButton allDataSourcesRadioButton;
552  private javax.swing.JRadioButton allFileCategoriesRadioButton;
553  private javax.swing.JButton cancelButton;
554  private javax.swing.JLabel categoriesLabel;
555  private javax.swing.JLabel commonFilesSearchLabel;
556  private javax.swing.JLabel dataSourceLabel;
557  private javax.swing.ButtonGroup dataSourcesButtonGroup;
558  private javax.swing.JCheckBox documentsCheckbox;
559  private javax.swing.JLabel errorText;
560  private javax.swing.ButtonGroup fileTypeFilterButtonGroup;
561  private javax.swing.JCheckBox pictureVideoCheckbox;
562  private javax.swing.JButton searchButton;
563  private javax.swing.JComboBox<String> selectDataSourceComboBox;
564  private javax.swing.JRadioButton selectedFileCategoriesButton;
565  private javax.swing.JRadioButton withinDataSourceRadioButton;
566  // End of variables declaration//GEN-END:variables
567 }
void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void searchButtonActionPerformed(java.awt.event.ActionEvent evt)
void selectDataSourceComboBoxActionPerformed(java.awt.event.ActionEvent evt)
void withinDataSourceRadioButtonActionPerformed(java.awt.event.ActionEvent evt)
void allDataSourcesRadioButtonActionPerformed(java.awt.event.ActionEvent evt)
static DataResultTopComponent createInstance(String title, String description, Node node, int childNodeCount)
void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt)
void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void cancelButtonActionPerformed(java.awt.event.ActionEvent evt)

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