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

Copyright © 2012-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.