Autopsy  4.11.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
GlobalEditListPanel.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.EventQueue;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import java.util.Arrays;
25 import java.util.List;
26 import java.util.logging.Level;
27 import java.util.regex.Pattern;
28 import java.util.regex.PatternSyntaxException;
29 import javax.swing.JTable;
30 import javax.swing.ListSelectionModel;
31 import javax.swing.event.ListSelectionEvent;
32 import javax.swing.event.ListSelectionListener;
33 import javax.swing.table.AbstractTableModel;
34 import javax.swing.table.TableColumn;
35 import org.netbeans.spi.options.OptionsPanelController;
36 import org.openide.util.NbBundle;
40 
44 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
45 class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionListener, OptionsPanel {
46 
47  private static final Logger logger = Logger.getLogger(GlobalEditListPanel.class.getName());
48  private static final long serialVersionUID = 1L;
49  private final KeywordTableModel tableModel;
50  private KeywordList currentKeywordList;
51 
55  GlobalEditListPanel() {
56  tableModel = new KeywordTableModel();
57  initComponents();
58  customizeComponents();
59  }
60 
61  private void customizeComponents() {
62  newKeywordsButton.setToolTipText((NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.customizeComponents.addWordToolTip")));
63  deleteWordButton.setToolTipText(NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.customizeComponents.removeSelectedMsg"));
64 
65  keywordTable.getParent().setBackground(keywordTable.getBackground());
66  final int width = jScrollPane1.getPreferredSize().width;
67  keywordTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
68  TableColumn column;
69  for (int i = 0; i < keywordTable.getColumnCount(); i++) {
70  column = keywordTable.getColumnModel().getColumn(i);
71  if (i == 0) {
72  column.setPreferredWidth(((int) (width * 0.90)));
73  } else {
74  column.setPreferredWidth(((int) (width * 0.10)));
75  }
76  }
77  keywordTable.setCellSelectionEnabled(false);
78  keywordTable.setRowSelectionAllowed(true);
79 
80  final ListSelectionModel lsm = keywordTable.getSelectionModel();
81  lsm.addListSelectionListener(new ListSelectionListener() {
82  @Override
83  public void valueChanged(ListSelectionEvent e) {
84  boolean canDelete = !(lsm.isSelectionEmpty() || currentKeywordList.isEditable() || IngestManager.getInstance().isIngestRunning());
85  boolean canEdit = canDelete && (lsm.getMaxSelectionIndex() == lsm.getMinSelectionIndex()); //edit only enabled with single selection
86  deleteWordButton.setEnabled(canDelete);
87  editWordButton.setEnabled(canEdit);
88  }
89  });
90 
91  setButtonStates();
92 
93  IngestManager.getInstance().addIngestJobEventListener(new PropertyChangeListener() {
94  @Override
95  public void propertyChange(PropertyChangeEvent evt) {
96  Object source = evt.getSource();
97  if (source instanceof String && ((String) source).equals("LOCAL")) { //NON-NLS
98  EventQueue.invokeLater(() -> {
99  setButtonStates();
100  });
101  }
102  }
103  });
104  }
105 
109  void setButtonStates() {
110  boolean isIngestRunning = IngestManager.getInstance().isIngestRunning();
111  boolean isListSelected = currentKeywordList != null;
112 
113  ingestWarningLabel.setVisible(isIngestRunning);
114  // items that only need a selected list
115  boolean canEditList = isListSelected && !isIngestRunning;
116  ingestMessagesCheckbox.setEnabled(canEditList);
117  ingestMessagesCheckbox.setSelected(currentKeywordList != null && currentKeywordList.getIngestMessages());
118 
119  // items that need an unlocked list w/out ingest running
120  boolean canAddWord = canEditList && !currentKeywordList.isEditable();
121  newKeywordsButton.setEnabled(canAddWord);
122 
123  // items that need a non-empty list
124  if ((currentKeywordList == null) || (currentKeywordList.getKeywords().isEmpty())) {
125  deleteWordButton.setEnabled(false);
126  editWordButton.setEnabled(false);
127  }
128  }
129 
130  @NbBundle.Messages({"GlobalEditListPanel.editKeyword.title=Edit Keyword",
131  "GlobalEditListPanel.warning.title=Warning",
132  "GlobalEditListPanel.warning.text=Boundary characters ^ and $ do not match word boundaries. Consider\nreplacing with an explicit list of boundary characters, such as [ \\.,]"})
133 
140  private boolean addKeywordsAction(String existingKeywords, boolean isLiteral, boolean isWholeWord) {
141  String keywordsToRedisplay = existingKeywords;
142  AddKeywordsDialog dialog = new AddKeywordsDialog();
143 
144  int goodCount = 0;
145  int dupeCount = 0;
146  int badCount = 1; // Default to 1 so we enter the loop the first time
147 
148  if (!existingKeywords.isEmpty()) { //if there is an existing keyword then this action was called by the edit button
149  dialog.setTitle(NbBundle.getMessage(GlobalEditListPanel.class, "GlobalEditListPanel.editKeyword.title"));
150  }
151  while (badCount > 0) {
152  dialog.setInitialKeywordList(keywordsToRedisplay, isLiteral, isWholeWord);
153  dialog.display();
154 
155  goodCount = 0;
156  dupeCount = 0;
157  badCount = 0;
158  keywordsToRedisplay = "";
159  boolean displayedBoundaryWarning = false;
160 
161  if (!dialog.getKeywords().isEmpty()) {
162 
163  for (String newWord : dialog.getKeywords()) {
164  if (newWord.isEmpty()) {
165  continue;
166  }
167 
168  final Keyword keyword = new Keyword(newWord, !dialog.isKeywordRegex(), dialog.isKeywordExact(), currentKeywordList.getName(), newWord);
169  if (currentKeywordList.hasKeyword(keyword)) {
170  dupeCount++;
171  continue;
172  }
173 
174  // Check if it is a regex and starts or ends with a boundary character
175  if (( ! displayedBoundaryWarning) && dialog.isKeywordRegex()) {
176  if(newWord.startsWith("^") ||
177  (newWord.endsWith("$") && ! newWord.endsWith("\\$"))) {
178 
179  KeywordSearchUtil.displayDialog(NbBundle.getMessage(this.getClass(), "GlobalEditListPanel.warning.title"),
180  NbBundle.getMessage(this.getClass(), "GlobalEditListPanel.warning.text"),
181  KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);
182  // Only display the warning once
183  displayedBoundaryWarning = true;
184  }
185  }
186 
187  //check if valid
188  boolean valid = true;
189  try {
190  Pattern.compile(newWord);
191  } catch (PatternSyntaxException ex1) {
192  valid = false;
193  } catch (IllegalArgumentException ex2) {
194  valid = false;
195  }
196  if (!valid) {
197 
198  // Invalid keywords will reappear in the UI
199  keywordsToRedisplay += newWord + "\n";
200  badCount++;
201  continue;
202  }
203 
204  // Add the new keyword
205  tableModel.addKeyword(keyword);
206  goodCount++;
207  }
208  XmlKeywordSearchList.getCurrent().addList(currentKeywordList);
209  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
210 
211  if ((badCount > 0) || (dupeCount > 0)) {
212  // Display the error counts to the user
213  // The add keywords dialog will pop up again if any were invalid with any
214  // invalid entries (valid entries and dupes will disappear)
215 
216  String summary = "";
217  KeywordSearchUtil.DIALOG_MESSAGE_TYPE level = KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO;
218  if (goodCount > 0) {
219  if (goodCount > 1) {
220  summary += NbBundle.getMessage(GlobalEditListPanel.class, "GlobalEditListPanel.keywordsAddedPlural.text", goodCount) + "\n";
221  } else {
222  summary += NbBundle.getMessage(GlobalEditListPanel.class, "GlobalEditListPanel.keywordsAdded.text", goodCount) + "\n";
223  }
224  }
225  if (dupeCount > 0) {
226  if (dupeCount > 1) {
227  summary += NbBundle.getMessage(GlobalEditListPanel.class, "GlobalEditListPanel.keywordDupesSkippedPlural.text", dupeCount) + "\n";
228  } else {
229  summary += NbBundle.getMessage(GlobalEditListPanel.class, "GlobalEditListPanel.keywordDupesSkipped.text", dupeCount) + "\n";
230  }
231  level = KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN;
232  }
233  if (badCount > 0) {
234  if (badCount > 1) {
235  summary += NbBundle.getMessage(GlobalEditListPanel.class, "GlobalEditListPanel.keywordErrorsPlural.text", badCount) + "\n";
236  } else {
237  summary += NbBundle.getMessage(GlobalEditListPanel.class, "GlobalEditListPanel.keywordErrors.text", badCount) + "\n";
238  }
239  level = KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR;
240  }
241  KeywordSearchUtil.displayDialog(NbBundle.getMessage(this.getClass(), "GlobalEditListPanel.addKeywordResults.text"),
242  summary, level);
243  }
244  }
245  }
246  setFocusOnKeywordTextBox();
247  setButtonStates();
248  return (goodCount >= 1 && dupeCount == 0);
249  }
250 
257  private void deleteKeywordAction(int[] selectedKeywords) {
258  tableModel.deleteSelected(selectedKeywords);
259  XmlKeywordSearchList.getCurrent().addList(currentKeywordList);
260  setButtonStates();
261  }
262 
268  @SuppressWarnings("unchecked")
269  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
270  private void initComponents() {
271 
272  listEditorPanel = new javax.swing.JPanel();
273  jScrollPane1 = new javax.swing.JScrollPane();
274  keywordTable = new javax.swing.JTable();
275  ingestMessagesCheckbox = new javax.swing.JCheckBox();
276  keywordsLabel = new javax.swing.JLabel();
277  newKeywordsButton = new javax.swing.JButton();
278  deleteWordButton = new javax.swing.JButton();
279  editWordButton = new javax.swing.JButton();
280  ingestWarningLabel = new javax.swing.JLabel();
281 
282  setMinimumSize(new java.awt.Dimension(0, 0));
283 
284  listEditorPanel.setMinimumSize(new java.awt.Dimension(0, 0));
285 
286  jScrollPane1.setPreferredSize(new java.awt.Dimension(340, 300));
287 
288  keywordTable.setModel(tableModel);
289  keywordTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
290  keywordTable.setGridColor(new java.awt.Color(153, 153, 153));
291  keywordTable.setMaximumSize(new java.awt.Dimension(30000, 30000));
292  keywordTable.getTableHeader().setReorderingAllowed(false);
293  jScrollPane1.setViewportView(keywordTable);
294 
295  ingestMessagesCheckbox.setSelected(true);
296  ingestMessagesCheckbox.setText(org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, "KeywordSearchEditListPanel.ingestMessagesCheckbox.text")); // NOI18N
297  ingestMessagesCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, "KeywordSearchEditListPanel.ingestMessagesCheckbox.toolTipText")); // NOI18N
298  ingestMessagesCheckbox.addActionListener(new java.awt.event.ActionListener() {
299  public void actionPerformed(java.awt.event.ActionEvent evt) {
300  ingestMessagesCheckboxActionPerformed(evt);
301  }
302  });
303 
304  keywordsLabel.setText(org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, "KeywordSearchEditListPanel.keywordsLabel.text")); // NOI18N
305 
306  newKeywordsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/add16.png"))); // NOI18N
307  newKeywordsButton.setText(org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, "GlobalEditListPanel.newKeywordsButton.text")); // NOI18N
308  newKeywordsButton.addActionListener(new java.awt.event.ActionListener() {
309  public void actionPerformed(java.awt.event.ActionEvent evt) {
310  newKeywordsButtonActionPerformed(evt);
311  }
312  });
313 
314  deleteWordButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/delete16.png"))); // NOI18N
315  deleteWordButton.setText(org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, "KeywordSearchEditListPanel.deleteWordButton.text")); // NOI18N
316  deleteWordButton.addActionListener(new java.awt.event.ActionListener() {
317  public void actionPerformed(java.awt.event.ActionEvent evt) {
318  deleteWordButtonActionPerformed(evt);
319  }
320  });
321 
322  editWordButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/edit16.png"))); // NOI18N
323  editWordButton.setText(org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, "GlobalEditListPanel.editWordButton.text")); // NOI18N
324  editWordButton.addActionListener(new java.awt.event.ActionListener() {
325  public void actionPerformed(java.awt.event.ActionEvent evt) {
326  editWordButtonActionPerformed(evt);
327  }
328  });
329 
330  ingestWarningLabel.setFont(ingestWarningLabel.getFont().deriveFont(ingestWarningLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
331  ingestWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); // NOI18N
332  ingestWarningLabel.setText(org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, "GlobalEditListPanel.ingestWarningLabel.text")); // NOI18N
333 
334  javax.swing.GroupLayout listEditorPanelLayout = new javax.swing.GroupLayout(listEditorPanel);
335  listEditorPanel.setLayout(listEditorPanelLayout);
336  listEditorPanelLayout.setHorizontalGroup(
337  listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
338  .addGroup(listEditorPanelLayout.createSequentialGroup()
339  .addContainerGap()
340  .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
341  .addGroup(listEditorPanelLayout.createSequentialGroup()
342  .addComponent(keywordsLabel)
343  .addGap(0, 0, Short.MAX_VALUE))
344  .addGroup(listEditorPanelLayout.createSequentialGroup()
345  .addGap(10, 10, 10)
346  .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
347  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 566, Short.MAX_VALUE)
348  .addGroup(listEditorPanelLayout.createSequentialGroup()
349  .addComponent(newKeywordsButton)
350  .addGap(14, 14, 14)
351  .addComponent(editWordButton)
352  .addGap(14, 14, 14)
353  .addComponent(deleteWordButton)
354  .addGap(0, 0, Short.MAX_VALUE))
355  .addGroup(listEditorPanelLayout.createSequentialGroup()
356  .addComponent(ingestMessagesCheckbox)
357  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
358  .addComponent(ingestWarningLabel)))))
359  .addContainerGap())
360  );
361 
362  listEditorPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {deleteWordButton, editWordButton, newKeywordsButton});
363 
364  listEditorPanelLayout.setVerticalGroup(
365  listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
366  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, listEditorPanelLayout.createSequentialGroup()
367  .addContainerGap()
368  .addComponent(keywordsLabel)
369  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
370  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
371  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
372  .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
373  .addComponent(deleteWordButton)
374  .addComponent(newKeywordsButton)
375  .addComponent(editWordButton))
376  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
377  .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
378  .addComponent(ingestMessagesCheckbox)
379  .addComponent(ingestWarningLabel))
380  .addGap(9, 9, 9))
381  );
382 
383  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
384  this.setLayout(layout);
385  layout.setHorizontalGroup(
386  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
387  .addComponent(listEditorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
388  );
389  layout.setVerticalGroup(
390  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
391  .addGroup(layout.createSequentialGroup()
392  .addComponent(listEditorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
393  .addGap(5, 5, 5))
394  );
395  }// </editor-fold>//GEN-END:initComponents
396 
397  private void deleteWordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteWordButtonActionPerformed
398  if (KeywordSearchUtil.displayConfirmDialog(NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.removeKwMsg"),
399  NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.deleteWordButtonActionPerformed.delConfirmMsg"),
400  KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN)) {
401  deleteKeywordAction(keywordTable.getSelectedRows());
402  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
403  }
404  }//GEN-LAST:event_deleteWordButtonActionPerformed
405 
406  private void ingestMessagesCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ingestMessagesCheckboxActionPerformed
407  currentKeywordList.setIngestMessages(ingestMessagesCheckbox.isSelected());
408  XmlKeywordSearchList updater = XmlKeywordSearchList.getCurrent();
409  updater.addList(currentKeywordList);
410  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
411  }//GEN-LAST:event_ingestMessagesCheckboxActionPerformed
412 
413  private void newKeywordsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newKeywordsButtonActionPerformed
414  addKeywordsAction("", true, true);
415  }//GEN-LAST:event_newKeywordsButtonActionPerformed
416 
417  private void editWordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editWordButtonActionPerformed
418  int[] selectedKeywords = keywordTable.getSelectedRows();
419  if (selectedKeywords.length == 1) {
420  Keyword currentKeyword = currentKeywordList.getKeywords().get(selectedKeywords[0]);
421  if (addKeywordsAction(currentKeyword.getSearchTerm(), currentKeyword.searchTermIsLiteral(), currentKeyword.searchTermIsWholeWord())) {
422  deleteKeywordAction(selectedKeywords);
423  }
424  }
425  }//GEN-LAST:event_editWordButtonActionPerformed
426 
427  // Variables declaration - do not modify//GEN-BEGIN:variables
428  private javax.swing.JButton deleteWordButton;
429  private javax.swing.JButton editWordButton;
430  private javax.swing.JCheckBox ingestMessagesCheckbox;
431  private javax.swing.JLabel ingestWarningLabel;
432  private javax.swing.JScrollPane jScrollPane1;
433  private javax.swing.JTable keywordTable;
434  private javax.swing.JLabel keywordsLabel;
435  private javax.swing.JPanel listEditorPanel;
436  private javax.swing.JButton newKeywordsButton;
437  // End of variables declaration//GEN-END:variables
438 
439  @Override
440  public void valueChanged(ListSelectionEvent e) {
441  //respond to list selection changes in KeywordSearchListManagementPanel
442  ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
443  currentKeywordList = null;
444  if (!listSelectionModel.isSelectionEmpty()) {
445  XmlKeywordSearchList loader = XmlKeywordSearchList.getCurrent();
446  if (listSelectionModel.getMinSelectionIndex() == listSelectionModel.getMaxSelectionIndex()) {
447  currentKeywordList = loader.getListsL(false).get(listSelectionModel.getMinSelectionIndex());
448  }
449  }
450  tableModel.resync();
451  setButtonStates();
452  }
453 
454  @Override
455  public void store() {
456  // Implemented by parent panel
457  }
458 
459  @Override
460  public void load() {
461  // Implemented by parent panel
462  }
463 
464  KeywordList getCurrentKeywordList() {
465  return currentKeywordList;
466  }
467 
468  void setCurrentKeywordList(KeywordList list) {
469  currentKeywordList = list;
470  }
471 
472  private class KeywordTableModel extends AbstractTableModel {
473 
474  @Override
475  public int getColumnCount() {
476  return 2;
477  }
478 
479  @Override
480  public int getRowCount() {
481  return currentKeywordList == null ? 0 : currentKeywordList.getKeywords().size();
482  }
483 
484  @Override
485  public String getColumnName(int column) {
486  String colName = null;
487 
488  switch (column) {
489  case 0:
490  colName = NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.kwColName");
491  break;
492  case 1:
493  colName = NbBundle.getMessage(this.getClass(), "KeywordSearch.typeColLbl");
494  break;
495  default:
496  ;
497  }
498  return colName;
499  }
500 
501  @Override
502  public Object getValueAt(int rowIndex, int columnIndex) {
503  Object ret = null;
504  if (currentKeywordList == null) {
505  return "";
506  }
507  Keyword word = currentKeywordList.getKeywords().get(rowIndex);
508  switch (columnIndex) {
509  case 0:
510  ret = word.getSearchTerm();
511  break;
512  case 1:
513  ret = word.getSearchTermType();
514  break;
515  default:
516  logger.log(Level.SEVERE, "Invalid table column index: {0}", columnIndex); //NON-NLS
517  break;
518  }
519  return ret;
520  }
521 
522  @Override
523  public boolean isCellEditable(int rowIndex, int columnIndex) {
524  return false;
525  }
526 
527  @Override
528  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
529  }
530 
531  @Override
532  public Class<?> getColumnClass(int c) {
533  return getValueAt(0, c).getClass();
534  }
535 
536  void addKeyword(Keyword keyword) {
537  if (!currentKeywordList.hasKeyword(keyword)) {
538  currentKeywordList.getKeywords().add(keyword);
539  }
540  fireTableDataChanged();
541  }
542 
543  void resync() {
544  fireTableDataChanged();
545  }
546 
547  //delete selected from handle, events are fired from the handle
548  void deleteSelected(int[] selected) {
549  List<Keyword> words = currentKeywordList.getKeywords();
550  Arrays.sort(selected);
551  for (int arrayi = selected.length - 1; arrayi >= 0; arrayi--) {
552  words.remove(selected[arrayi]);
553  }
554  resync();
555  }
556  }
557 
561  void setFocusOnKeywordTextBox() {
562  newKeywordsButton.requestFocus();
563  }
564 }

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