Autopsy  4.14.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.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); // NOI18N
331  ingestWarningLabel.setText(org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, "GlobalEditListPanel.ingestWarningLabel.text")); // NOI18N
332 
333  javax.swing.GroupLayout listEditorPanelLayout = new javax.swing.GroupLayout(listEditorPanel);
334  listEditorPanel.setLayout(listEditorPanelLayout);
335  listEditorPanelLayout.setHorizontalGroup(
336  listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
337  .addGroup(listEditorPanelLayout.createSequentialGroup()
338  .addContainerGap()
339  .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
340  .addGroup(listEditorPanelLayout.createSequentialGroup()
341  .addComponent(keywordsLabel)
342  .addGap(0, 0, Short.MAX_VALUE))
343  .addGroup(listEditorPanelLayout.createSequentialGroup()
344  .addGap(10, 10, 10)
345  .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
346  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 566, Short.MAX_VALUE)
347  .addGroup(listEditorPanelLayout.createSequentialGroup()
348  .addComponent(newKeywordsButton)
349  .addGap(14, 14, 14)
350  .addComponent(editWordButton)
351  .addGap(14, 14, 14)
352  .addComponent(deleteWordButton)
353  .addGap(0, 0, Short.MAX_VALUE))
354  .addGroup(listEditorPanelLayout.createSequentialGroup()
355  .addComponent(ingestMessagesCheckbox)
356  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
357  .addComponent(ingestWarningLabel)))))
358  .addContainerGap())
359  );
360 
361  listEditorPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {deleteWordButton, editWordButton, newKeywordsButton});
362 
363  listEditorPanelLayout.setVerticalGroup(
364  listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
365  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, listEditorPanelLayout.createSequentialGroup()
366  .addContainerGap()
367  .addComponent(keywordsLabel)
368  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
369  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
370  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
371  .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
372  .addComponent(deleteWordButton)
373  .addComponent(newKeywordsButton)
374  .addComponent(editWordButton))
375  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
376  .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
377  .addComponent(ingestMessagesCheckbox)
378  .addComponent(ingestWarningLabel))
379  .addGap(9, 9, 9))
380  );
381 
382  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
383  this.setLayout(layout);
384  layout.setHorizontalGroup(
385  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
386  .addComponent(listEditorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
387  );
388  layout.setVerticalGroup(
389  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
390  .addGroup(layout.createSequentialGroup()
391  .addComponent(listEditorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
392  .addGap(5, 5, 5))
393  );
394  }// </editor-fold>//GEN-END:initComponents
395 
396  private void deleteWordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteWordButtonActionPerformed
397  if (KeywordSearchUtil.displayConfirmDialog(NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.removeKwMsg"),
398  NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.deleteWordButtonActionPerformed.delConfirmMsg"),
399  KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN)) {
400  deleteKeywordAction(keywordTable.getSelectedRows());
401  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
402  }
403  }//GEN-LAST:event_deleteWordButtonActionPerformed
404 
405  private void ingestMessagesCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ingestMessagesCheckboxActionPerformed
406  currentKeywordList.setIngestMessages(ingestMessagesCheckbox.isSelected());
407  XmlKeywordSearchList updater = XmlKeywordSearchList.getCurrent();
408  updater.addList(currentKeywordList);
409  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
410  }//GEN-LAST:event_ingestMessagesCheckboxActionPerformed
411 
412  private void newKeywordsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newKeywordsButtonActionPerformed
413  addKeywordsAction("", true, true);
414  }//GEN-LAST:event_newKeywordsButtonActionPerformed
415 
416  private void editWordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editWordButtonActionPerformed
417  int[] selectedKeywords = keywordTable.getSelectedRows();
418  if (selectedKeywords.length == 1) {
419  Keyword currentKeyword = currentKeywordList.getKeywords().get(selectedKeywords[0]);
420  if (addKeywordsAction(currentKeyword.getSearchTerm(), currentKeyword.searchTermIsLiteral(), currentKeyword.searchTermIsWholeWord())) {
421  deleteKeywordAction(selectedKeywords);
422  }
423  }
424  }//GEN-LAST:event_editWordButtonActionPerformed
425 
426  // Variables declaration - do not modify//GEN-BEGIN:variables
427  private javax.swing.JButton deleteWordButton;
428  private javax.swing.JButton editWordButton;
429  private javax.swing.JCheckBox ingestMessagesCheckbox;
430  private javax.swing.JLabel ingestWarningLabel;
431  private javax.swing.JScrollPane jScrollPane1;
432  private javax.swing.JTable keywordTable;
433  private javax.swing.JLabel keywordsLabel;
434  private javax.swing.JPanel listEditorPanel;
435  private javax.swing.JButton newKeywordsButton;
436  // End of variables declaration//GEN-END:variables
437 
438  @Override
439  public void valueChanged(ListSelectionEvent e) {
440  //respond to list selection changes in KeywordSearchListManagementPanel
441  ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
442  currentKeywordList = null;
443  if (!listSelectionModel.isSelectionEmpty()) {
444  XmlKeywordSearchList loader = XmlKeywordSearchList.getCurrent();
445  if (listSelectionModel.getMinSelectionIndex() == listSelectionModel.getMaxSelectionIndex()) {
446  currentKeywordList = loader.getListsL(false).get(listSelectionModel.getMinSelectionIndex());
447  }
448  }
449  tableModel.resync();
450  setButtonStates();
451  }
452 
453  @Override
454  public void store() {
455  // Implemented by parent panel
456  }
457 
458  @Override
459  public void load() {
460  // Implemented by parent panel
461  }
462 
463  KeywordList getCurrentKeywordList() {
464  return currentKeywordList;
465  }
466 
467  void setCurrentKeywordList(KeywordList list) {
468  currentKeywordList = list;
469  }
470 
471  private class KeywordTableModel extends AbstractTableModel {
472 
473  @Override
474  public int getColumnCount() {
475  return 2;
476  }
477 
478  @Override
479  public int getRowCount() {
480  return currentKeywordList == null ? 0 : currentKeywordList.getKeywords().size();
481  }
482 
483  @Override
484  public String getColumnName(int column) {
485  String colName = null;
486 
487  switch (column) {
488  case 0:
489  colName = NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.kwColName");
490  break;
491  case 1:
492  colName = NbBundle.getMessage(this.getClass(), "KeywordSearch.typeColLbl");
493  break;
494  default:
495  ;
496  }
497  return colName;
498  }
499 
500  @Override
501  public Object getValueAt(int rowIndex, int columnIndex) {
502  Object ret = null;
503  if (currentKeywordList == null) {
504  return "";
505  }
506  Keyword word = currentKeywordList.getKeywords().get(rowIndex);
507  switch (columnIndex) {
508  case 0:
509  ret = word.getSearchTerm();
510  break;
511  case 1:
512  ret = word.getSearchTermType();
513  break;
514  default:
515  logger.log(Level.SEVERE, "Invalid table column index: {0}", columnIndex); //NON-NLS
516  break;
517  }
518  return ret;
519  }
520 
521  @Override
522  public boolean isCellEditable(int rowIndex, int columnIndex) {
523  return false;
524  }
525 
526  @Override
527  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
528  }
529 
530  @Override
531  public Class<?> getColumnClass(int c) {
532  return getValueAt(0, c).getClass();
533  }
534 
535  void addKeyword(Keyword keyword) {
536  if (!currentKeywordList.hasKeyword(keyword)) {
537  currentKeywordList.getKeywords().add(keyword);
538  }
539  fireTableDataChanged();
540  }
541 
542  void resync() {
543  fireTableDataChanged();
544  }
545 
546  //delete selected from handle, events are fired from the handle
547  void deleteSelected(int[] selected) {
548  List<Keyword> words = currentKeywordList.getKeywords();
549  Arrays.sort(selected);
550  for (int arrayi = selected.length - 1; arrayi >= 0; arrayi--) {
551  words.remove(selected[arrayi]);
552  }
553  resync();
554  }
555  }
556 
560  void setFocusOnKeywordTextBox() {
561  newKeywordsButton.requestFocus();
562  }
563 }

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.