Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DropdownListSearchPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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.keywordsearch;
20 
21 import java.awt.Component;
22 import java.awt.Cursor;
23 import java.awt.EventQueue;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
26 import java.beans.PropertyChangeEvent;
27 import java.beans.PropertyChangeListener;
28 import java.util.ArrayList;
29 import java.util.HashSet;
30 import java.util.Iterator;
31 import java.util.List;
32 import java.util.Set;
33 import java.util.logging.Level;
34 import javax.swing.JCheckBox;
35 import javax.swing.JTable;
36 import javax.swing.ListSelectionModel;
37 import javax.swing.event.ListSelectionEvent;
38 import javax.swing.event.ListSelectionListener;
39 import javax.swing.table.AbstractTableModel;
40 import javax.swing.table.TableCellRenderer;
41 import javax.swing.table.TableColumn;
42 import org.openide.util.NbBundle;
43 import org.openide.util.actions.SystemAction;
46 
51 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
52 class DropdownListSearchPanel extends AdHocSearchPanel {
53 
54  private static final Logger logger = Logger.getLogger(DropdownListSearchPanel.class.getName());
55  private static DropdownListSearchPanel instance;
56  private XmlKeywordSearchList loader;
57  private final KeywordListsTableModel listsTableModel;
58  private final KeywordsTableModel keywordsTableModel;
59  private ActionListener searchAddListener;
60  private boolean ingestRunning;
61 
65  private DropdownListSearchPanel() {
66  listsTableModel = new KeywordListsTableModel();
67  keywordsTableModel = new KeywordsTableModel();
68  initComponents();
69  customizeComponents();
70  dataSourceList.setModel(getDataSourceListModel());
71 
72  dataSourceList.addListSelectionListener((ListSelectionEvent evt) -> {
73  firePropertyChange(Bundle.DropdownSingleTermSearchPanel_selected(), null, null);
74  });
75  }
76 
77  static synchronized DropdownListSearchPanel getDefault() {
78  if (instance == null) {
79  instance = new DropdownListSearchPanel();
80  }
81  return instance;
82  }
83 
84  private void customizeComponents() {
85  listsTable.setTableHeader(null);
86  listsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
87  //customize column witdhs
88  final int leftWidth = leftPane.getPreferredSize().width;
89  TableColumn column;
90  for (int i = 0; i < listsTable.getColumnCount(); i++) {
91  column = listsTable.getColumnModel().getColumn(i);
92  if (i == 0) {
93  column.setPreferredWidth(((int) (leftWidth * 0.10)));
94  column.setCellRenderer(new LeftCheckBoxRenderer());
95  } else {
96  column.setPreferredWidth(((int) (leftWidth * 0.89)));
97  }
98  }
99  final int rightWidth = rightPane.getPreferredSize().width;
100  for (int i = 0; i < keywordsTable.getColumnCount(); i++) {
101  column = keywordsTable.getColumnModel().getColumn(i);
102  if (i == 0) {
103  column.setPreferredWidth(((int) (rightWidth * 0.60)));
104  } else {
105  column.setPreferredWidth(((int) (rightWidth * 0.38)));
106  }
107  }
108 
109  loader = XmlKeywordSearchList.getCurrent();
110  listsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
111  @Override
112  public void valueChanged(ListSelectionEvent e) {
113  ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
114  if (!listSelectionModel.isSelectionEmpty()) {
115  int index = listSelectionModel.getMinSelectionIndex();
116  KeywordList list = listsTableModel.getListAt(index);
117  keywordsTableModel.resync(list);
118  } else {
119  keywordsTableModel.deleteAll();
120  }
121  }
122  });
123 
124  ingestRunning = IngestManager.getInstance().isIngestRunning();
125  updateComponents();
126 
127  IngestManager.getInstance().addIngestJobEventListener(new PropertyChangeListener() {
128  @Override
129  public void propertyChange(PropertyChangeEvent evt) {
130  Object source = evt.getSource();
131  if (source instanceof String && ((String) source).equals("LOCAL")) { //NON-NLS
132  EventQueue.invokeLater(() -> {
133  ingestRunning = IngestManager.getInstance().isIngestRunning();
134  updateComponents();
135  });
136  }
137  }
138  });
139 
140  searchAddListener = new ActionListener() {
141  @Override
142  public void actionPerformed(ActionEvent e) {
143  if (ingestRunning) {
144  IngestSearchRunner.getInstance().addKeywordListsToAllJobs(listsTableModel.getSelectedLists());
145  logger.log(Level.INFO, "Submitted enqueued lists to ingest"); //NON-NLS
146  } else {
147  searchAction(e);
148  }
149  }
150  };
151 
152  searchAddButton.addActionListener(searchAddListener);
153  }
154 
155  private void updateComponents() {
156  ingestRunning = IngestManager.getInstance().isIngestRunning();
157  if (ingestRunning) {
158  searchAddButton.setText(NbBundle.getMessage(this.getClass(), "KeywordSearchListsViewerPanel.initIngest.addIngestTitle"));
159  searchAddButton.setToolTipText(NbBundle.getMessage(this.getClass(), "KeywordSearchListsViewerPanel.initIngest.addIngestMsg"));
160 
161  } else {
162  searchAddButton.setText(NbBundle.getMessage(this.getClass(), "KeywordSearchListsViewerPanel.initIngest.searchIngestTitle"));
163  searchAddButton.setToolTipText(NbBundle.getMessage(this.getClass(), "KeywordSearchListsViewerPanel.initIngest.addIdxSearchMsg"));
164  }
165  listsTableModel.resync();
166  updateIngestIndexLabel();
167 
168  jSaveSearchResults.setSelected(true);
169  }
170 
171  private void updateIngestIndexLabel() {
172  if (ingestRunning) {
173  ingestIndexLabel.setText(NbBundle.getMessage(this.getClass(), "KeywordSearchListsViewerPanel.initIngest.ongoingIngestMsg", filesIndexed));
174  } else {
175  ingestIndexLabel.setText(NbBundle.getMessage(this.getClass(), "KeywordSearchListsViewerPanel.initIngest.fileIndexCtMsg", filesIndexed));
176  }
177  }
178 
179  @Override
180  protected void postFilesIndexedChange() {
181  updateIngestIndexLabel();
182  }
183 
187  void resync() {
188  listsTableModel.resync();
189  }
190 
196  @SuppressWarnings("unchecked")
197  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
198  private void initComponents() {
199 
200  jSplitPane1 = new javax.swing.JSplitPane();
201  leftPane = new javax.swing.JScrollPane();
202  listsTable = new javax.swing.JTable();
203  rightPane = new javax.swing.JScrollPane();
204  keywordsTable = new javax.swing.JTable();
205  manageListsButton = new javax.swing.JButton();
206  searchAddButton = new javax.swing.JButton();
207  ingestIndexLabel = new javax.swing.JLabel();
208  dataSourceCheckBox = new javax.swing.JCheckBox();
209  jScrollPane1 = new javax.swing.JScrollPane();
210  dataSourceList = new javax.swing.JList<>();
211  jSaveSearchResults = new javax.swing.JCheckBox();
212 
213  leftPane.setMinimumSize(new java.awt.Dimension(150, 23));
214  leftPane.setOpaque(false);
215 
216  listsTable.setBackground(new java.awt.Color(240, 240, 240));
217  listsTable.setModel(listsTableModel);
218  listsTable.setShowHorizontalLines(false);
219  listsTable.setShowVerticalLines(false);
220  listsTable.getTableHeader().setReorderingAllowed(false);
221  leftPane.setViewportView(listsTable);
222 
223  jSplitPane1.setLeftComponent(leftPane);
224 
225  rightPane.setOpaque(false);
226 
227  keywordsTable.setBackground(new java.awt.Color(240, 240, 240));
228  keywordsTable.setModel(keywordsTableModel);
229  keywordsTable.setGridColor(new java.awt.Color(153, 153, 153));
230  rightPane.setViewportView(keywordsTable);
231 
232  jSplitPane1.setRightComponent(rightPane);
233 
234  manageListsButton.setText(org.openide.util.NbBundle.getMessage(DropdownListSearchPanel.class, "KeywordSearchListsViewerPanel.manageListsButton.text")); // NOI18N
235  manageListsButton.setToolTipText(org.openide.util.NbBundle.getMessage(DropdownListSearchPanel.class, "KeywordSearchListsViewerPanel.manageListsButton.toolTipText")); // NOI18N
236  manageListsButton.addActionListener(new java.awt.event.ActionListener() {
237  public void actionPerformed(java.awt.event.ActionEvent evt) {
238  manageListsButtonActionPerformed(evt);
239  }
240  });
241 
242  searchAddButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/search-icon.png"))); // NOI18N
243  searchAddButton.setText(org.openide.util.NbBundle.getMessage(DropdownListSearchPanel.class, "KeywordSearchListsViewerPanel.searchAddButton.text")); // NOI18N
244  searchAddButton.addActionListener(new java.awt.event.ActionListener() {
245  public void actionPerformed(java.awt.event.ActionEvent evt) {
246  searchAddButtonActionPerformed(evt);
247  }
248  });
249 
250  ingestIndexLabel.setFont(ingestIndexLabel.getFont().deriveFont(ingestIndexLabel.getFont().getSize()-1f));
251  ingestIndexLabel.setText(org.openide.util.NbBundle.getMessage(DropdownListSearchPanel.class, "KeywordSearchListsViewerPanel.ingestIndexLabel.text")); // NOI18N
252 
253  dataSourceCheckBox.setText(org.openide.util.NbBundle.getMessage(DropdownListSearchPanel.class, "DropdownListSearchPanel.dataSourceCheckBox.text")); // NOI18N
254  dataSourceCheckBox.addActionListener(new java.awt.event.ActionListener() {
255  public void actionPerformed(java.awt.event.ActionEvent evt) {
256  dataSourceCheckBoxActionPerformed(evt);
257  }
258  });
259 
260  dataSourceList.setMinimumSize(new java.awt.Dimension(0, 200));
261  jScrollPane1.setViewportView(dataSourceList);
262 
263  jSaveSearchResults.setText(org.openide.util.NbBundle.getMessage(DropdownListSearchPanel.class, "DropdownListSearchPanel.jSaveSearchResults.text")); // NOI18N
264  jSaveSearchResults.setToolTipText(org.openide.util.NbBundle.getMessage(DropdownListSearchPanel.class, "DropdownListSearchPanel.jSaveSearchResults.toolTipText")); // NOI18N
265 
266  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
267  this.setLayout(layout);
268  layout.setHorizontalGroup(
269  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
270  .addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
271  .addComponent(jScrollPane1)
272  .addGroup(layout.createSequentialGroup()
273  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
274  .addComponent(dataSourceCheckBox)
275  .addComponent(jSaveSearchResults)
276  .addGroup(layout.createSequentialGroup()
277  .addComponent(searchAddButton)
278  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
279  .addComponent(manageListsButton)
280  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
281  .addComponent(ingestIndexLabel)))
282  .addGap(0, 120, Short.MAX_VALUE))
283  );
284 
285  layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {manageListsButton, searchAddButton});
286 
287  layout.setVerticalGroup(
288  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
289  .addGroup(layout.createSequentialGroup()
290  .addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
291  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
292  .addComponent(dataSourceCheckBox)
293  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
294  .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
295  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
296  .addComponent(jSaveSearchResults)
297  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
298  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
299  .addComponent(manageListsButton)
300  .addComponent(searchAddButton)
301  .addComponent(ingestIndexLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE))
302  .addGap(23, 23, 23))
303  );
304  }// </editor-fold>//GEN-END:initComponents
305 
306  private void manageListsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manageListsButtonActionPerformed
307  SystemAction.get(KeywordSearchConfigurationAction.class).performAction();
308  }//GEN-LAST:event_manageListsButtonActionPerformed
309 
310  private void dataSourceCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dataSourceCheckBoxActionPerformed
311  updateDataSourceListModel();
312  }//GEN-LAST:event_dataSourceCheckBoxActionPerformed
313 
314  private void searchAddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchAddButtonActionPerformed
315  // TODO add your handling code here:
316  }//GEN-LAST:event_searchAddButtonActionPerformed
317 
318  // Variables declaration - do not modify//GEN-BEGIN:variables
319  private javax.swing.JCheckBox dataSourceCheckBox;
320  private javax.swing.JList<String> dataSourceList;
321  private javax.swing.JLabel ingestIndexLabel;
322  private javax.swing.JCheckBox jSaveSearchResults;
323  private javax.swing.JScrollPane jScrollPane1;
324  private javax.swing.JSplitPane jSplitPane1;
325  private javax.swing.JTable keywordsTable;
326  private javax.swing.JScrollPane leftPane;
327  private javax.swing.JTable listsTable;
328  private javax.swing.JButton manageListsButton;
329  private javax.swing.JScrollPane rightPane;
330  private javax.swing.JButton searchAddButton;
331  // End of variables declaration//GEN-END:variables
332 
333  private void searchAction(ActionEvent e) {
334  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
335 
336  try {
337  search(jSaveSearchResults.isSelected());
338  } finally {
339  setCursor(null);
340  }
341  }
342 
343  @Override
344  List<KeywordList> getKeywordLists() {
345  return listsTableModel.getSelectedListsL();
346  }
347 
348  void addSearchButtonActionListener(ActionListener al) {
349  searchAddButton.addActionListener(al);
350  }
351 
356  @Override
357  Set<Long> getDataSourcesSelected() {
358  Set<Long> dataSourceObjIdSet = new HashSet<>();
359  for (Long key : getDataSourceMap().keySet()) {
360  String value = getDataSourceMap().get(key);
361  for (String dataSource : this.dataSourceList.getSelectedValuesList()) {
362  if (value.equals(dataSource)) {
363  dataSourceObjIdSet.add(key);
364  }
365  }
366  }
367  return dataSourceObjIdSet;
368  }
369 
370  private class KeywordListsTableModel extends AbstractTableModel {
371  //data
372 
373  private final XmlKeywordSearchList listsHandle = XmlKeywordSearchList.getCurrent();
374  private final List<ListTableEntry> listData = new ArrayList<>();
375 
376  @Override
377  public int getColumnCount() {
378  return 2;
379  }
380 
381  @Override
382  public int getRowCount() {
383  return listData.size();
384  }
385 
386  @Override
387  public String getColumnName(int column) {
388  String ret = null;
389  switch (column) {
390  case 0:
391  ret = NbBundle.getMessage(this.getClass(), "KeywordSearch.selectedColLbl");
392  break;
393  case 1:
394  ret = NbBundle.getMessage(this.getClass(), "KeywordSearch.nameColLbl");
395  break;
396  default:
397  break;
398  }
399  return ret;
400  }
401 
402  @Override
403  public Object getValueAt(int rowIndex, int columnIndex) {
404  Object ret = null;
405  ListTableEntry entry = null;
406  //iterate until row
407  Iterator<ListTableEntry> it = listData.iterator();
408  for (int i = 0; i <= rowIndex; ++i) {
409  entry = it.next();
410  }
411  if (null != entry) {
412  switch (columnIndex) {
413  case 0:
414  ret = (Object) entry.selected;
415  break;
416  case 1:
417  ret = (Object) entry.name;
418  break;
419  default:
420  break;
421  }
422  }
423  return ret;
424  }
425 
426  @Override
427  public boolean isCellEditable(int rowIndex, int columnIndex) {
428  return (columnIndex == 0 && !ingestRunning);
429  }
430 
431  @Override
432  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
433  if (columnIndex == 0) {
434  ListTableEntry entry = null;
435  Iterator<ListTableEntry> it = listData.iterator();
436  for (int i = 0; i <= rowIndex; i++) {
437  entry = it.next();
438  }
439  if (entry != null) {
440  entry.selected = (Boolean) aValue;
441  if (ingestRunning) {
442  //updateUseForIngest(getListAt(rowIndex), (Boolean) aValue);
443  }
444  }
445 
446  }
447  }
448 
449  @Override
450  public Class<?> getColumnClass(int c) {
451  return getValueAt(0, c).getClass();
452  }
453 
454  List<String> getAllLists() {
455  List<String> ret = new ArrayList<>();
456  for (ListTableEntry e : listData) {
457  ret.add(e.name);
458  }
459  return ret;
460  }
461 
462  KeywordList getListAt(int rowIndex) {
463  return listsHandle.getList((String) getValueAt(rowIndex, 1));
464  }
465 
466  List<String> getSelectedLists() {
467  List<String> ret = new ArrayList<>();
468  for (ListTableEntry e : listData) {
469  if (e.selected) {
470  ret.add(e.name);
471  }
472  }
473  return ret;
474  }
475 
476  List<KeywordList> getSelectedListsL() {
477  List<KeywordList> ret = new ArrayList<>();
478  for (String s : getSelectedLists()) {
479  ret.add(listsHandle.getList(s));
480  }
481  return ret;
482  }
483 
484  boolean listExists(String list) {
485  List<String> all = getAllLists();
486  return all.contains(list);
487  }
488 
489  //resync model from handle, then update table
490  void resync() {
491  listData.clear();
492  addLists(listsHandle.getListsL());
493  fireTableDataChanged();
494  }
495 
496  //add lists to the model
497  private void addLists(List<KeywordList> lists) {
498  for (KeywordList list : lists) {
499  if (!listExists(list.getName())) {
500  listData.add(new ListTableEntry(list, ingestRunning));
501  }
502  }
503  }
504 
505  //single model entry
506  private class ListTableEntry implements Comparable<ListTableEntry> {
507 
508  String name;
509  Boolean selected;
510 
511  ListTableEntry(KeywordList list, boolean ingestRunning) {
512  this.name = list.getName();
513  if (ingestRunning) {
514  this.selected = list.getUseForIngest();
515  } else {
516  this.selected = false;
517  }
518  }
519 
520  @Override
521  public int compareTo(ListTableEntry e) {
522  return this.name.compareTo(e.name);
523  }
524  }
525  }
526 
527  private class KeywordsTableModel extends AbstractTableModel {
528 
529  List<KeywordTableEntry> listData = new ArrayList<>();
530 
531  @Override
532  public int getRowCount() {
533  return listData.size();
534  }
535 
536  @Override
537  public int getColumnCount() {
538  return 2;
539  }
540 
541  @Override
542  public String getColumnName(int column) {
543  String ret = null;
544  switch (column) {
545  case 0:
546  ret = NbBundle.getMessage(this.getClass(), "KeywordSearch.nameColLbl");
547  break;
548  case 1:
549  ret = NbBundle.getMessage(this.getClass(), "KeywordSearch.typeColLbl");
550  break;
551  default:
552  break;
553  }
554  return ret;
555  }
556 
557  @Override
558  public Object getValueAt(int rowIndex, int columnIndex) {
559  Object ret = null;
560  KeywordTableEntry entry = null;
561  //iterate until row
562  Iterator<KeywordTableEntry> it = listData.iterator();
563  for (int i = 0; i <= rowIndex; ++i) {
564  entry = it.next();
565  }
566  if (null != entry) {
567  switch (columnIndex) {
568  case 0:
569  ret = (Object) entry.name;
570  break;
571  case 1:
572  ret = (Object) entry.keywordType;
573  break;
574  default:
575  break;
576  }
577  }
578  return ret;
579  }
580 
581  @Override
582  public boolean isCellEditable(int rowIndex, int columnIndex) {
583  return false;
584  }
585 
586  @Override
587  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
588  }
589 
590  @Override
591  public Class<?> getColumnClass(int c) {
592  return getValueAt(0, c).getClass();
593  }
594 
595  void resync(KeywordList list) {
596  listData.clear();
597  for (Keyword k : list.getKeywords()) {
598  listData.add(new KeywordTableEntry(k));
599  }
600  fireTableDataChanged();
601  }
602 
603  void deleteAll() {
604  listData.clear();
605  fireTableDataChanged();
606  }
607 
608  //single model entry
609  private class KeywordTableEntry implements Comparable<KeywordTableEntry> {
610 
611  String name;
612  String keywordType;
613 
614  KeywordTableEntry(Keyword keyword) {
615  this.name = keyword.getSearchTerm();
616  this.keywordType = keyword.getSearchTermType();
617  }
618 
619  @Override
620  public int compareTo(KeywordTableEntry e) {
621  return this.name.compareTo(e.name);
622  }
623  }
624  }
625 
626  private class LeftCheckBoxRenderer extends JCheckBox implements TableCellRenderer {
627 
628  @Override
630  JTable table, Object value,
631  boolean isSelected, boolean hasFocus,
632  int row, int column) {
633 
634  this.setHorizontalAlignment(JCheckBox.CENTER);
635  this.setVerticalAlignment(JCheckBox.CENTER);
636 
637  setEnabled(!ingestRunning);
638 
639  boolean selected = (Boolean) table.getModel().getValueAt(row, 0);
640  setSelected(selected);
641 
642  if (isSelected) {
643  setBackground(listsTable.getSelectionBackground());
644  } else {
645  setBackground(listsTable.getBackground());
646  }
647 
648  return this;
649  }
650  }
651 
655  @NbBundle.Messages({"DropdownListSearchPanel.selected=Ad Hoc Search data source filter is selected"})
656  void updateDataSourceListModel() {
657  getDataSourceListModel().removeAllElements();
658  for (String dsName : getDataSourceArray()) {
659  getDataSourceListModel().addElement(dsName);
660  }
661  setComponentsEnabled();
662  firePropertyChange(Bundle.DropdownListSearchPanel_selected(), null, null);
663 
664  }
665 
669  private void setComponentsEnabled() {
670 
671  if (getDataSourceListModel().size() > 1) {
672  this.dataSourceCheckBox.setEnabled(true);
673 
674  boolean enabled = this.dataSourceCheckBox.isSelected();
675  this.dataSourceList.setEnabled(enabled);
676  if (enabled) {
677  this.dataSourceList.setSelectionInterval(0, this.dataSourceList.getModel().getSize()-1);
678  } else {
679  this.dataSourceList.setSelectedIndices(new int[0]);
680  }
681  } else {
682  this.dataSourceCheckBox.setEnabled(false);
683  this.dataSourceCheckBox.setSelected(false);
684  this.dataSourceList.setEnabled(false);
685  this.dataSourceList.setSelectedIndices(new int[0]);
686  }
687  }
688 
689 }
Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.