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

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.