19 package org.sleuthkit.autopsy.keywordsearch;
 
   21 import java.awt.EventQueue;
 
   22 import java.awt.event.ActionEvent;
 
   23 import java.awt.event.ActionListener;
 
   24 import java.beans.PropertyChangeEvent;
 
   25 import java.beans.PropertyChangeListener;
 
   27 import java.util.ArrayList;
 
   28 import java.util.Arrays;
 
   29 import java.util.List;
 
   30 import java.util.logging.Level;
 
   31 import org.openide.util.NbBundle;
 
   33 import java.util.regex.Pattern;
 
   34 import java.util.regex.PatternSyntaxException;
 
   35 import javax.swing.JFileChooser;
 
   36 import javax.swing.JMenuItem;
 
   37 import javax.swing.JTable;
 
   38 import javax.swing.ListSelectionModel;
 
   39 import javax.swing.event.ListSelectionEvent;
 
   40 import javax.swing.event.ListSelectionListener;
 
   41 import javax.swing.filechooser.FileNameExtensionFilter;
 
   42 import javax.swing.table.AbstractTableModel;
 
   43 import javax.swing.table.TableColumn;
 
   51 class GlobalEditListPanel 
extends javax.swing.JPanel implements ListSelectionListener, OptionsPanel {
 
   53     private static Logger logger = Logger.getLogger(GlobalEditListPanel.class.getName());
 
   54     private KeywordTableModel tableModel;
 
   55     private KeywordList currentKeywordList;
 
   60     GlobalEditListPanel() {
 
   61         tableModel = 
new KeywordTableModel();
 
   63         customizeComponents();
 
   66     private void customizeComponents() {
 
   67         chRegex.setToolTipText(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.customizeComponents.kwReToolTip"));
 
   68         addWordButton.setToolTipText((NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.customizeComponents.addWordToolTip")));
 
   69         addWordField.setToolTipText(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.customizeComponents.enterNewWordToolTip"));
 
   70         exportButton.setToolTipText(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.customizeComponents.exportToFile"));
 
   71         saveListButton.setToolTipText(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.customizeComponents.saveCurrentWIthNewNameToolTip"));
 
   72         deleteWordButton.setToolTipText(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.customizeComponents.removeSelectedMsg"));
 
   74         keywordTable.setShowHorizontalLines(
false);
 
   75         keywordTable.setShowVerticalLines(
false);
 
   76         keywordTable.getParent().setBackground(keywordTable.getBackground());
 
   77         final int width = jScrollPane1.getPreferredSize().width;
 
   78         keywordTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
 
   80         for (
int i = 0; i < keywordTable.getColumnCount(); i++) {
 
   81             column = keywordTable.getColumnModel().getColumn(i);
 
   83                 column.setPreferredWidth(((
int) (width * 0.90)));
 
   85                 column.setPreferredWidth(((
int) (width * 0.10)));
 
   89         keywordTable.setCellSelectionEnabled(
false);
 
   90         keywordTable.setRowSelectionAllowed(
true);
 
   92         final ListSelectionModel lsm = keywordTable.getSelectionModel();
 
   93         lsm.addListSelectionListener(
new ListSelectionListener() {
 
   95             public void valueChanged(ListSelectionEvent e) {
 
   96                 if (lsm.isSelectionEmpty() || currentKeywordList.isLocked() || IngestManager.getInstance().isIngestRunning() ) {
 
   97                     deleteWordButton.setEnabled(
false);
 
   99                     deleteWordButton.setEnabled(
true);
 
  106         addWordField.setComponentPopupMenu(rightClickMenu);
 
  107         ActionListener actList = 
new ActionListener() {
 
  109             public void actionPerformed(ActionEvent e) {
 
  110                 JMenuItem jmi = (JMenuItem) e.getSource();
 
  111                 if (jmi.equals(cutMenuItem)) {
 
  113                 } 
else if (jmi.equals(copyMenuItem)) {
 
  115                 } 
else if (jmi.equals(pasteMenuItem)) {
 
  116                     addWordField.paste();
 
  117                 } 
else if (jmi.equals(selectAllMenuItem)) {
 
  118                     addWordField.selectAll();
 
  122         cutMenuItem.addActionListener(actList);
 
  123         copyMenuItem.addActionListener(actList);
 
  124         pasteMenuItem.addActionListener(actList);
 
  125         selectAllMenuItem.addActionListener(actList);
 
  129         IngestManager.getInstance().addIngestJobEventListener(
new PropertyChangeListener() {
 
  131             public void propertyChange(PropertyChangeEvent evt) {
 
  132                 String changed = evt.getPropertyName();
 
  133                 if (changed.equals(IngestJobEvent.STARTED.toString())
 
  134                         || changed.equals(IngestJobEvent.COMPLETED.toString())
 
  135                         || changed.equals(IngestJobEvent.CANCELLED.toString())) {
 
  136                     EventQueue.invokeLater(
new Runnable() {
 
  147     void setButtonStates() {
 
  148         boolean isIngestRunning = IngestManager.getInstance().isIngestRunning();
 
  149         boolean isListSelected = currentKeywordList != null;
 
  152         boolean canEditList = ((isListSelected == 
true) && (isIngestRunning == 
false));
 
  153         ingestMessagesCheckbox.setEnabled(canEditList);
 
  154         ingestMessagesCheckbox.setSelected(currentKeywordList != null && currentKeywordList.getIngestMessages());
 
  155         listOptionsLabel.setEnabled(canEditList);
 
  156         listOptionsSeparator.setEnabled(canEditList);
 
  159         boolean isListLocked = ((isListSelected == 
false) || (currentKeywordList.isLocked()));
 
  160         boolean canAddWord = isListSelected && !isIngestRunning && !isListLocked;
 
  161         addWordButton.setEnabled(canAddWord);
 
  162         addWordField.setEnabled(canAddWord);
 
  163         chRegex.setEnabled(canAddWord);
 
  164         keywordOptionsLabel.setEnabled(canAddWord);
 
  165         keywordOptionsSeparator.setEnabled(canAddWord);
 
  166         deleteListButton.setEnabled(canAddWord);
 
  170         if ((currentKeywordList == null) || (currentKeywordList.getKeywords().isEmpty())) {
 
  171             saveListButton.setEnabled(
false);
 
  172             exportButton.setEnabled(
false);
 
  173             deleteWordButton.setEnabled(
false);
 
  175             saveListButton.setEnabled(
true);
 
  176             exportButton.setEnabled(
true);
 
  186     @SuppressWarnings(
"unchecked")
 
  188     private 
void initComponents() {
 
  190         rightClickMenu = 
new javax.swing.JPopupMenu();
 
  191         cutMenuItem = 
new javax.swing.JMenuItem();
 
  192         copyMenuItem = 
new javax.swing.JMenuItem();
 
  193         pasteMenuItem = 
new javax.swing.JMenuItem();
 
  194         selectAllMenuItem = 
new javax.swing.JMenuItem();
 
  195         listEditorPanel = 
new javax.swing.JPanel();
 
  196         jScrollPane1 = 
new javax.swing.JScrollPane();
 
  197         keywordTable = 
new javax.swing.JTable();
 
  198         addKeywordPanel = 
new javax.swing.JPanel();
 
  199         addWordButton = 
new javax.swing.JButton();
 
  200         addWordField = 
new javax.swing.JTextField();
 
  201         chRegex = 
new javax.swing.JCheckBox();
 
  202         deleteWordButton = 
new javax.swing.JButton();
 
  203         ingestMessagesCheckbox = 
new javax.swing.JCheckBox();
 
  204         keywordsLabel = 
new javax.swing.JLabel();
 
  205         keywordOptionsLabel = 
new javax.swing.JLabel();
 
  206         listOptionsLabel = 
new javax.swing.JLabel();
 
  207         keywordOptionsSeparator = 
new javax.swing.JSeparator();
 
  208         listOptionsSeparator = 
new javax.swing.JSeparator();
 
  209         deleteListButton = 
new javax.swing.JButton();
 
  210         saveListButton = 
new javax.swing.JButton();
 
  211         exportButton = 
new javax.swing.JButton();
 
  213         cutMenuItem.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.cutMenuItem.text")); 
 
  214         rightClickMenu.add(cutMenuItem);
 
  216         copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.copyMenuItem.text")); 
 
  217         rightClickMenu.add(copyMenuItem);
 
  219         pasteMenuItem.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.pasteMenuItem.text")); 
 
  220         rightClickMenu.add(pasteMenuItem);
 
  222         selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.selectAllMenuItem.text")); 
 
  223         rightClickMenu.add(selectAllMenuItem);
 
  225         jScrollPane1.setPreferredSize(
new java.awt.Dimension(340, 300));
 
  227         keywordTable.setModel(tableModel);
 
  228         keywordTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
 
  229         keywordTable.setShowHorizontalLines(
false);
 
  230         keywordTable.setShowVerticalLines(
false);
 
  231         keywordTable.getTableHeader().setReorderingAllowed(
false);
 
  232         jScrollPane1.setViewportView(keywordTable);
 
  234         addWordButton.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.addWordButton.text")); 
 
  235         addWordButton.addActionListener(
new java.awt.event.ActionListener() {
 
  236             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  237                 addWordButtonActionPerformed(evt);
 
  241         addWordField.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.addWordField.text")); 
 
  242         addWordField.addActionListener(
new java.awt.event.ActionListener() {
 
  243             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  244                 addWordFieldActionPerformed(evt);
 
  248         chRegex.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.chRegex.text")); 
 
  250         deleteWordButton.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.deleteWordButton.text")); 
 
  251         deleteWordButton.addActionListener(
new java.awt.event.ActionListener() {
 
  252             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  253                 deleteWordButtonActionPerformed(evt);
 
  257         javax.swing.GroupLayout addKeywordPanelLayout = 
new javax.swing.GroupLayout(addKeywordPanel);
 
  258         addKeywordPanel.setLayout(addKeywordPanelLayout);
 
  259         addKeywordPanelLayout.setHorizontalGroup(
 
  260             addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  261             .addGroup(addKeywordPanelLayout.createSequentialGroup()
 
  262                 .addGroup(addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 
  263                     .addGroup(addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  264                         .addGroup(addKeywordPanelLayout.createSequentialGroup()
 
  265                             .addComponent(addWordField, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  266                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  267                             .addComponent(addWordButton))
 
  268                         .addComponent(deleteWordButton))
 
  269                     .addComponent(chRegex, javax.swing.GroupLayout.Alignment.LEADING))
 
  270                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  272         addKeywordPanelLayout.setVerticalGroup(
 
  273             addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  274             .addGroup(addKeywordPanelLayout.createSequentialGroup()
 
  276                 .addGroup(addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  277                     .addComponent(addWordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  278                     .addComponent(addWordButton))
 
  280                 .addComponent(chRegex)
 
  282                 .addComponent(deleteWordButton)
 
  283                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  286         ingestMessagesCheckbox.setSelected(
true);
 
  287         ingestMessagesCheckbox.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.ingestMessagesCheckbox.text")); 
 
  288         ingestMessagesCheckbox.setToolTipText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.ingestMessagesCheckbox.toolTipText")); 
 
  289         ingestMessagesCheckbox.addActionListener(
new java.awt.event.ActionListener() {
 
  290             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  291                 ingestMessagesCheckboxActionPerformed(evt);
 
  295         keywordsLabel.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.keywordsLabel.text")); 
 
  297         keywordOptionsLabel.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.keywordOptionsLabel.text")); 
 
  299         listOptionsLabel.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.listOptionsLabel.text")); 
 
  301         deleteListButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/delete16.png"))); 
 
  302         deleteListButton.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.deleteListButton.text")); 
 
  304         saveListButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/save16.png"))); 
 
  305         saveListButton.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.saveListButton.text")); 
 
  307         exportButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/export16.png"))); 
 
  308         exportButton.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.exportButton.text")); 
 
  309         exportButton.addActionListener(
new java.awt.event.ActionListener() {
 
  310             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  311                 exportButtonActionPerformed(evt);
 
  315         javax.swing.GroupLayout listEditorPanelLayout = 
new javax.swing.GroupLayout(listEditorPanel);
 
  316         listEditorPanel.setLayout(listEditorPanelLayout);
 
  317         listEditorPanelLayout.setHorizontalGroup(
 
  318             listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  319             .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  321                 .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  322                     .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  324                         .addComponent(addKeywordPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  325                     .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  326                         .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  327                             .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  328                                 .addComponent(listOptionsLabel)
 
  329                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  330                                 .addComponent(listOptionsSeparator))
 
  331                             .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  332                                 .addComponent(keywordOptionsLabel)
 
  333                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  334                                 .addComponent(keywordOptionsSeparator))
 
  335                             .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  336                             .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  337                                 .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  338                                     .addComponent(keywordsLabel)
 
  339                                     .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  341                                         .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  342                                             .addComponent(ingestMessagesCheckbox)
 
  343                                             .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  344                                                 .addComponent(exportButton)
 
  345                                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  346                                                 .addComponent(saveListButton)
 
  347                                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  348                                                 .addComponent(deleteListButton)))))
 
  349                                 .addGap(0, 0, Short.MAX_VALUE)))
 
  350                         .addContainerGap())))
 
  352         listEditorPanelLayout.setVerticalGroup(
 
  353             listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  354             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, listEditorPanelLayout.createSequentialGroup()
 
  356                 .addComponent(keywordsLabel)
 
  357                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  358                 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  360                 .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  361                     .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  362                         .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 
  363                             .addComponent(keywordOptionsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  364                             .addComponent(keywordOptionsLabel))
 
  366                         .addComponent(addKeywordPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  368                         .addComponent(listOptionsLabel))
 
  369                     .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  370                         .addGap(123, 123, 123)
 
  371                         .addComponent(listOptionsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)))
 
  372                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  373                 .addComponent(ingestMessagesCheckbox)
 
  374                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  375                 .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  376                     .addComponent(exportButton)
 
  377                     .addComponent(saveListButton)
 
  378                     .addComponent(deleteListButton))
 
  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)
 
  388         layout.setVerticalGroup(
 
  389             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  390             .addGroup(layout.createSequentialGroup()
 
  391                 .addComponent(listEditorPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  392                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  396     private void addWordButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  397         String newWord = addWordField.getText().trim();
 
  398         boolean isLiteral = !chRegex.isSelected();
 
  399         final Keyword keyword = 
new Keyword(newWord, isLiteral);
 
  401         if (newWord.equals(
"")) {
 
  403         } 
else if (currentKeywordList.hasKeyword(keyword)) {
 
  404             KeywordSearchUtil.displayDialog(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.newKwTitle"),
 
  405                     NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.addWordButtonAction.kwAlreadyExistsMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
 
  410         boolean valid = 
true;
 
  412             Pattern.compile(newWord);
 
  413         } 
catch (PatternSyntaxException ex1) {
 
  415         } 
catch (IllegalArgumentException ex2) {
 
  419             KeywordSearchUtil.displayDialog(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.newKwTitle"),
 
  420                     NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.invalidKwMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
 
  425         tableModel.addKeyword(keyword);
 
  426         XmlKeywordSearchList.getCurrent().addList(currentKeywordList);
 
  427         chRegex.setSelected(
false);
 
  428         addWordField.setText(
"");
 
  433     private void deleteWordButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  434         if (KeywordSearchUtil.displayConfirmDialog(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.removeKwMsg"), NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.deleteWordButtonActionPerformed.delConfirmMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN)) {
 
  436             tableModel.deleteSelected(keywordTable.getSelectedRows());
 
  437             XmlKeywordSearchList.getCurrent().addList(currentKeywordList);
 
  442     private void addWordFieldActionPerformed(java.awt.event.ActionEvent evt) {
 
  443         addWordButtonActionPerformed(evt);
 
  446     private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  448         final String FEATURE_NAME = NbBundle.getMessage(this.getClass(),
 
  449                                                         "KeywordSearchEditListPanel.exportButtonAction.featureName.text");
 
  451         JFileChooser chooser = 
new JFileChooser();
 
  452         final String EXTENSION = 
"xml"; 
 
  453         FileNameExtensionFilter filter = 
new FileNameExtensionFilter(
 
  454                 NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.exportButtonActionPerformed.fileFilterLabel"), EXTENSION);
 
  455         chooser.setFileFilter(filter);
 
  456         chooser.setSelectedFile(
new File(currentKeywordList.getName()));
 
  457         chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
 
  459         int returnVal = chooser.showSaveDialog(
this);
 
  460         if (returnVal == JFileChooser.APPROVE_OPTION) {
 
  461             File selFile = chooser.getSelectedFile();
 
  462             if (selFile == null) {
 
  467             String fileAbs = selFile.getAbsolutePath();
 
  468             if (!fileAbs.endsWith(
"." + EXTENSION)) {
 
  469                 fileAbs = fileAbs + 
"." + EXTENSION;
 
  470                 selFile = 
new File(fileAbs);
 
  473             boolean shouldWrite = 
true;
 
  474             if (selFile.exists()) {
 
  475                 shouldWrite = KeywordSearchUtil.displayConfirmDialog(FEATURE_NAME,
 
  476                         NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.exportButtonActionPerformed.fileExistPrompt",
 
  477                         selFile.getName()), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);
 
  483             XmlKeywordSearchList reader = XmlKeywordSearchList.getCurrent();
 
  485             List<KeywordList> toWrite = 
new ArrayList<>();
 
  486             toWrite.add(reader.getList(currentKeywordList.getName()));
 
  487             final XmlKeywordSearchList exporter = 
new XmlKeywordSearchList(fileAbs);
 
  488             boolean written = exporter.saveLists(toWrite);
 
  490                 KeywordSearchUtil.displayDialog(FEATURE_NAME,
 
  491                         NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.exportButtonActionPerformed.kwListExportedMsg"),
 
  492                         KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
 
  497     private void ingestMessagesCheckboxActionPerformed(java.awt.event.ActionEvent evt) {
 
  498         currentKeywordList.setIngestMessages(ingestMessagesCheckbox.isSelected());
 
  499         XmlKeywordSearchList updater = XmlKeywordSearchList.getCurrent();
 
  500         updater.addList(currentKeywordList);
 
  503     private javax.swing.JPanel addKeywordPanel;
 
  504     private javax.swing.JButton addWordButton;
 
  505     private javax.swing.JTextField addWordField;
 
  506     private javax.swing.JCheckBox chRegex;
 
  507     private javax.swing.JMenuItem copyMenuItem;
 
  508     private javax.swing.JMenuItem cutMenuItem;
 
  509     private javax.swing.JButton deleteListButton;
 
  510     private javax.swing.JButton deleteWordButton;
 
  511     private javax.swing.JButton exportButton;
 
  512     private javax.swing.JCheckBox ingestMessagesCheckbox;
 
  513     private javax.swing.JScrollPane jScrollPane1;
 
  514     private javax.swing.JLabel keywordOptionsLabel;
 
  515     private javax.swing.JSeparator keywordOptionsSeparator;
 
  516     private javax.swing.JTable keywordTable;
 
  517     private javax.swing.JLabel keywordsLabel;
 
  518     private javax.swing.JPanel listEditorPanel;
 
  519     private javax.swing.JLabel listOptionsLabel;
 
  520     private javax.swing.JSeparator listOptionsSeparator;
 
  521     private javax.swing.JMenuItem pasteMenuItem;
 
  522     private javax.swing.JPopupMenu rightClickMenu;
 
  523     private javax.swing.JButton saveListButton;
 
  524     private javax.swing.JMenuItem selectAllMenuItem;
 
  528     public void valueChanged(ListSelectionEvent e) {
 
  530         ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
 
  531         if (!listSelectionModel.isSelectionEmpty()) {
 
  532             int index = listSelectionModel.getMinSelectionIndex();
 
  534             listSelectionModel.setSelectionInterval(index, index);
 
  535             XmlKeywordSearchList loader = XmlKeywordSearchList.getCurrent();
 
  537             currentKeywordList = loader.getListsL(
false).get(index);
 
  541             currentKeywordList = null;
 
  548     public void store() {
 
  557     KeywordList getCurrentKeywordList() {
 
  558         return currentKeywordList;
 
  561     void setCurrentKeywordList(KeywordList list) {
 
  562         currentKeywordList = list;
 
  565     void addDeleteButtonActionPerformed(ActionListener l) {
 
  566         deleteListButton.addActionListener(l);
 
  569     void addSaveButtonActionPerformed(ActionListener l) {
 
  570         saveListButton.addActionListener(l);
 
  582             return currentKeywordList == null ? 0 : currentKeywordList.getKeywords().size();
 
  587             String colName = null;
 
  591                     colName = NbBundle.getMessage(this.getClass(), 
"KeywordSearchEditListPanel.kwColName");
 
  594                     colName = NbBundle.getMessage(this.getClass(), 
"KeywordSearchEditListPanel.exportButtonActionPerformed.regExColName");
 
  606             if (currentKeywordList == null) {
 
  609             Keyword word = currentKeywordList.getKeywords().get(rowIndex);
 
  610             switch (columnIndex) {
 
  612                     ret = (Object) word.getQuery();
 
  615                     ret = (Object) !word.isLiteral();
 
  618                     logger.log(Level.SEVERE, 
"Invalid table column index: {0}", columnIndex); 
 
  630         public void setValueAt(Object aValue, 
int rowIndex, 
int columnIndex) {
 
  638         void addKeyword(Keyword keyword) {
 
  639             if (!currentKeywordList.hasKeyword(keyword)) {
 
  640                 currentKeywordList.getKeywords().add(keyword);
 
  642             fireTableDataChanged();
 
  646             fireTableDataChanged();
 
  650         void deleteSelected(
int[] selected) {
 
  651             List<Keyword> words = currentKeywordList.getKeywords();
 
  652             Arrays.sort(selected);
 
  653             for (
int arrayi = selected.length - 1; arrayi >= 0; arrayi--) {
 
  654                 words.remove(selected[arrayi]);
 
boolean isCellEditable(int rowIndex, int columnIndex)
 
void setValueAt(Object aValue, int rowIndex, int columnIndex)
 
String getColumnName(int column)
 
Class<?> getColumnClass(int c)
 
Object getValueAt(int rowIndex, int columnIndex)