19 package org.sleuthkit.autopsy.keywordsearch;
 
   21 import java.awt.EventQueue;
 
   22 import java.awt.event.ActionListener;
 
   23 import java.beans.PropertyChangeEvent;
 
   24 import java.beans.PropertyChangeListener;
 
   26 import java.util.ArrayList;
 
   27 import java.util.Arrays;
 
   28 import java.util.List;
 
   29 import java.util.logging.Level;
 
   30 import java.util.regex.Pattern;
 
   31 import java.util.regex.PatternSyntaxException;
 
   32 import javax.swing.JFileChooser;
 
   33 import javax.swing.JTable;
 
   34 import javax.swing.ListSelectionModel;
 
   35 import javax.swing.event.ListSelectionEvent;
 
   36 import javax.swing.event.ListSelectionListener;
 
   37 import javax.swing.filechooser.FileNameExtensionFilter;
 
   38 import javax.swing.table.AbstractTableModel;
 
   39 import javax.swing.table.TableColumn;
 
   40 import org.netbeans.spi.options.OptionsPanelController;
 
   41 import org.openide.util.NbBundle;
 
   45 import java.awt.Component;
 
   46 import java.awt.Dimension;
 
   47 import java.awt.FlowLayout;
 
   48 import javax.swing.ImageIcon;
 
   49 import javax.swing.JCheckBox;
 
   50 import javax.swing.JLabel;
 
   51 import javax.swing.JOptionPane;
 
   52 import javax.swing.JPanel;
 
   53 import javax.swing.JTextField;
 
   54 import static javax.swing.SwingConstants.CENTER;
 
   55 import javax.swing.table.DefaultTableCellRenderer;
 
   56 import org.openide.util.NbBundle.Messages;
 
   61 class GlobalEditListPanel 
extends javax.swing.JPanel implements ListSelectionListener, OptionsPanel {
 
   63     private static final Logger logger = Logger.getLogger(GlobalEditListPanel.class.getName());
 
   64     private static final long serialVersionUID = 1L;
 
   65     private final KeywordTableModel tableModel;
 
   66     private KeywordList currentKeywordList;
 
   71     GlobalEditListPanel() {
 
   72         tableModel = 
new KeywordTableModel();
 
   74         customizeComponents();
 
   77     private void customizeComponents() {
 
   78         newWordButton.setToolTipText((NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.customizeComponents.addWordToolTip")));
 
   79         exportButton.setToolTipText(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.customizeComponents.exportToFile"));
 
   80         saveListButton.setToolTipText(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.customizeComponents.saveCurrentWIthNewNameToolTip"));
 
   81         deleteWordButton.setToolTipText(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.customizeComponents.removeSelectedMsg"));
 
   83         keywordTable.getParent().setBackground(keywordTable.getBackground());
 
   84         final int width = jScrollPane1.getPreferredSize().width;
 
   85         keywordTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
 
   87         for (
int i = 0; i < keywordTable.getColumnCount(); i++) {
 
   88             column = keywordTable.getColumnModel().getColumn(i);
 
   90                 column.setPreferredWidth(((
int) (width * 0.90)));
 
   92                 column.setPreferredWidth(((
int) (width * 0.10)));
 
   93                 column.setCellRenderer(
new CheckBoxRenderer());
 
   96         keywordTable.setCellSelectionEnabled(
false);
 
   97         keywordTable.setRowSelectionAllowed(
true);
 
   99         final ListSelectionModel lsm = keywordTable.getSelectionModel();
 
  100         lsm.addListSelectionListener(
new ListSelectionListener() {
 
  102             public void valueChanged(ListSelectionEvent e) {
 
  103                 if (lsm.isSelectionEmpty() || currentKeywordList.isEditable() || IngestManager.getInstance().isIngestRunning()) {
 
  104                     deleteWordButton.setEnabled(
false);
 
  106                     deleteWordButton.setEnabled(
true);
 
  115         IngestManager.getInstance().addIngestJobEventListener(
new PropertyChangeListener() {
 
  117             public void propertyChange(PropertyChangeEvent evt) {
 
  118                 Object source = evt.getSource();
 
  119                 if (source instanceof String && ((String) source).equals(
"LOCAL")) { 
 
  120                     EventQueue.invokeLater(
new Runnable() {
 
  131     void setButtonStates() {
 
  132         boolean isIngestRunning = IngestManager.getInstance().isIngestRunning();
 
  133         boolean isListSelected = currentKeywordList != null;
 
  136         boolean canEditList = ((isListSelected == 
true) && (isIngestRunning == 
false));
 
  137         ingestMessagesCheckbox.setEnabled(canEditList);
 
  138         ingestMessagesCheckbox.setSelected(currentKeywordList != null && currentKeywordList.getIngestMessages());
 
  139         listOptionsLabel.setEnabled(canEditList);
 
  140         listOptionsSeparator.setEnabled(canEditList);
 
  143         boolean isListLocked = ((isListSelected == 
false) || (currentKeywordList.isEditable()));
 
  144         boolean canAddWord = isListSelected && !isIngestRunning && !isListLocked;
 
  145         newWordButton.setEnabled(canAddWord);
 
  146         keywordOptionsLabel.setEnabled(canAddWord);
 
  147         keywordOptionsSeparator.setEnabled(canAddWord);
 
  148         deleteListButton.setEnabled(canAddWord);
 
  151         if ((currentKeywordList == null) || (currentKeywordList.getKeywords().isEmpty())) {
 
  152             saveListButton.setEnabled(
false);
 
  153             exportButton.setEnabled(
false);
 
  154             deleteWordButton.setEnabled(
false);
 
  156             saveListButton.setEnabled(
true);
 
  157             exportButton.setEnabled(
true);
 
  167     @SuppressWarnings(
"unchecked")
 
  169     private 
void initComponents() {
 
  171         listEditorPanel = 
new javax.swing.JPanel();
 
  172         jScrollPane1 = 
new javax.swing.JScrollPane();
 
  173         keywordTable = 
new javax.swing.JTable();
 
  174         addKeywordPanel = 
new javax.swing.JPanel();
 
  175         newWordButton = 
new javax.swing.JButton();
 
  176         deleteWordButton = 
new javax.swing.JButton();
 
  177         ingestMessagesCheckbox = 
new javax.swing.JCheckBox();
 
  178         keywordsLabel = 
new javax.swing.JLabel();
 
  179         keywordOptionsLabel = 
new javax.swing.JLabel();
 
  180         listOptionsLabel = 
new javax.swing.JLabel();
 
  181         keywordOptionsSeparator = 
new javax.swing.JSeparator();
 
  182         listOptionsSeparator = 
new javax.swing.JSeparator();
 
  183         deleteListButton = 
new javax.swing.JButton();
 
  184         saveListButton = 
new javax.swing.JButton();
 
  185         exportButton = 
new javax.swing.JButton();
 
  187         setMinimumSize(
new java.awt.Dimension(0, 0));
 
  189         listEditorPanel.setMinimumSize(
new java.awt.Dimension(0, 0));
 
  191         jScrollPane1.setPreferredSize(
new java.awt.Dimension(340, 300));
 
  193         keywordTable.setModel(tableModel);
 
  194         keywordTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
 
  195         keywordTable.setGridColor(
new java.awt.Color(153, 153, 153));
 
  196         keywordTable.setMaximumSize(
new java.awt.Dimension(30000, 30000));
 
  197         keywordTable.getTableHeader().setReorderingAllowed(
false);
 
  198         jScrollPane1.setViewportView(keywordTable);
 
  200         newWordButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/new16.png"))); 
 
  201         newWordButton.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.addWordButton.text")); 
 
  202         newWordButton.addActionListener(
new java.awt.event.ActionListener() {
 
  203             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  204                 newWordButtonActionPerformed(evt);
 
  208         deleteWordButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/delete16.png"))); 
 
  209         deleteWordButton.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.deleteWordButton.text")); 
 
  210         deleteWordButton.addActionListener(
new java.awt.event.ActionListener() {
 
  211             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  212                 deleteWordButtonActionPerformed(evt);
 
  216         javax.swing.GroupLayout addKeywordPanelLayout = 
new javax.swing.GroupLayout(addKeywordPanel);
 
  217         addKeywordPanel.setLayout(addKeywordPanelLayout);
 
  218         addKeywordPanelLayout.setHorizontalGroup(
 
  219             addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  220             .addGroup(addKeywordPanelLayout.createSequentialGroup()
 
  221                 .addComponent(newWordButton)
 
  222                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  223                 .addComponent(deleteWordButton)
 
  224                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  226         addKeywordPanelLayout.setVerticalGroup(
 
  227             addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  228             .addGroup(addKeywordPanelLayout.createSequentialGroup()
 
  230                 .addGroup(addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  231                     .addComponent(newWordButton)
 
  232                     .addComponent(deleteWordButton))
 
  236         ingestMessagesCheckbox.setSelected(
true);
 
  237         ingestMessagesCheckbox.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.ingestMessagesCheckbox.text")); 
 
  238         ingestMessagesCheckbox.setToolTipText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.ingestMessagesCheckbox.toolTipText")); 
 
  239         ingestMessagesCheckbox.addActionListener(
new java.awt.event.ActionListener() {
 
  240             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  241                 ingestMessagesCheckboxActionPerformed(evt);
 
  245         keywordsLabel.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.keywordsLabel.text")); 
 
  247         keywordOptionsLabel.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.keywordOptionsLabel.text")); 
 
  249         listOptionsLabel.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.listOptionsLabel.text")); 
 
  251         deleteListButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/delete16.png"))); 
 
  252         deleteListButton.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.deleteListButton.text")); 
 
  253         deleteListButton.addActionListener(
new java.awt.event.ActionListener() {
 
  254             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  255                 deleteListButtonActionPerformed(evt);
 
  259         saveListButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/save16.png"))); 
 
  260         saveListButton.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.saveListButton.text")); 
 
  262         exportButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/export16.png"))); 
 
  263         exportButton.setText(
org.openide.util.NbBundle.getMessage(GlobalEditListPanel.class, 
"KeywordSearchEditListPanel.exportButton.text")); 
 
  264         exportButton.addActionListener(
new java.awt.event.ActionListener() {
 
  265             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  266                 exportButtonActionPerformed(evt);
 
  270         javax.swing.GroupLayout listEditorPanelLayout = 
new javax.swing.GroupLayout(listEditorPanel);
 
  271         listEditorPanel.setLayout(listEditorPanelLayout);
 
  272         listEditorPanelLayout.setHorizontalGroup(
 
  273             listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  274             .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  276                 .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  277                     .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  279                         .addComponent(addKeywordPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  280                     .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  281                         .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  282                             .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  283                                 .addComponent(listOptionsLabel)
 
  284                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  285                                 .addComponent(listOptionsSeparator))
 
  286                             .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  287                                 .addComponent(keywordOptionsLabel)
 
  288                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  289                                 .addComponent(keywordOptionsSeparator))
 
  290                             .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  292                                 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE))
 
  293                             .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  294                                 .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  295                                     .addComponent(keywordsLabel)
 
  296                                     .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  298                                         .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  299                                             .addComponent(ingestMessagesCheckbox)
 
  300                                             .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  301                                                 .addComponent(exportButton)
 
  302                                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  303                                                 .addComponent(saveListButton)
 
  304                                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  305                                                 .addComponent(deleteListButton)))))
 
  306                                 .addGap(0, 0, Short.MAX_VALUE)))
 
  307                         .addContainerGap())))
 
  309         listEditorPanelLayout.setVerticalGroup(
 
  310             listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  311             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, listEditorPanelLayout.createSequentialGroup()
 
  313                 .addComponent(keywordsLabel)
 
  314                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  315                 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
 
  317                 .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  318                     .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  319                         .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 
  320                             .addComponent(keywordOptionsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  321                             .addComponent(keywordOptionsLabel))
 
  323                         .addComponent(addKeywordPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  325                         .addComponent(listOptionsLabel))
 
  326                     .addGroup(listEditorPanelLayout.createSequentialGroup()
 
  327                         .addGap(123, 123, 123)
 
  328                         .addComponent(listOptionsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)))
 
  329                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  330                 .addComponent(ingestMessagesCheckbox)
 
  331                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  332                 .addGroup(listEditorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  333                     .addComponent(exportButton)
 
  334                     .addComponent(saveListButton)
 
  335                     .addComponent(deleteListButton))
 
  339         javax.swing.GroupLayout layout = 
new javax.swing.GroupLayout(
this);
 
  340         this.setLayout(layout);
 
  341         layout.setHorizontalGroup(
 
  342             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  343             .addComponent(listEditorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  345         layout.setVerticalGroup(
 
  346             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  347             .addGroup(layout.createSequentialGroup()
 
  348                 .addComponent(listEditorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  353     private void newWordButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  354         JCheckBox chRegex = 
new JCheckBox(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.chRegex.text"));
 
  355         chRegex.setToolTipText(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.customizeComponents.kwReToolTip"));
 
  356         JTextField addWordField = 
new JTextField(25);
 
  357         addWordField.setToolTipText(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.customizeComponents.enterNewWordToolTip"));
 
  359         JPanel addKeywordPanel = 
new JPanel(
new FlowLayout(FlowLayout.LEFT));
 
  360         addKeywordPanel.add(
new JLabel(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.addKeyword.message")));
 
  361         addKeywordPanel.add(addWordField);
 
  362         addKeywordPanel.add(chRegex);
 
  364         addKeywordPanel.setPreferredSize(
new Dimension(250, 80));
 
  366         int result = JOptionPane.showConfirmDialog(null, addKeywordPanel,
 
  367                 NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.addKeyword.title"),
 
  368                 JOptionPane.OK_CANCEL_OPTION);
 
  370         if (result == JOptionPane.OK_OPTION) {
 
  371             String newWord = addWordField.getText().trim();
 
  372             boolean isLiteral = !chRegex.isSelected();
 
  373             final Keyword keyword = 
new Keyword(newWord, isLiteral);
 
  375             if (newWord.equals(
"")) {
 
  377             } 
else if (currentKeywordList.hasKeyword(keyword)) {
 
  378                 KeywordSearchUtil.displayDialog(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.newKwTitle"),
 
  379                         NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.addWordButtonAction.kwAlreadyExistsMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
 
  384             boolean valid = 
true;
 
  386                 Pattern.compile(newWord);
 
  387             } 
catch (PatternSyntaxException ex1) {
 
  389             } 
catch (IllegalArgumentException ex2) {
 
  393                 KeywordSearchUtil.displayDialog(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.newKwTitle"),
 
  394                         NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.invalidKwMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
 
  399             tableModel.addKeyword(keyword);
 
  400             XmlKeywordSearchList.getCurrent().addList(currentKeywordList);
 
  401             firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  402             setFocusOnKeywordTextBox();
 
  409     private void deleteWordButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  410         if (KeywordSearchUtil.displayConfirmDialog(NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.removeKwMsg"), NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.deleteWordButtonActionPerformed.delConfirmMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN)) {
 
  412             tableModel.deleteSelected(keywordTable.getSelectedRows());
 
  413             XmlKeywordSearchList.getCurrent().addList(currentKeywordList);
 
  415             firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  419     private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  421         final String FEATURE_NAME = NbBundle.getMessage(this.getClass(),
 
  422                 "KeywordSearchEditListPanel.exportButtonAction.featureName.text");
 
  424         JFileChooser chooser = 
new JFileChooser();
 
  425         final String EXTENSION = 
"xml"; 
 
  426         FileNameExtensionFilter filter = 
new FileNameExtensionFilter(
 
  427                 NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.exportButtonActionPerformed.fileFilterLabel"), EXTENSION);
 
  428         chooser.setFileFilter(filter);
 
  429         chooser.setSelectedFile(
new File(currentKeywordList.getName()));
 
  430         chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
 
  432         int returnVal = chooser.showSaveDialog(
this);
 
  433         if (returnVal == JFileChooser.APPROVE_OPTION) {
 
  434             File selFile = chooser.getSelectedFile();
 
  435             if (selFile == null) {
 
  440             String fileAbs = selFile.getAbsolutePath();
 
  441             if (!fileAbs.endsWith(
"." + EXTENSION)) {
 
  442                 fileAbs = fileAbs + 
"." + EXTENSION;
 
  443                 selFile = 
new File(fileAbs);
 
  446             boolean shouldWrite = 
true;
 
  447             if (selFile.exists()) {
 
  448                 shouldWrite = KeywordSearchUtil.displayConfirmDialog(FEATURE_NAME,
 
  449                         NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.exportButtonActionPerformed.fileExistPrompt",
 
  450                                 selFile.getName()), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);
 
  456             XmlKeywordSearchList reader = XmlKeywordSearchList.getCurrent();
 
  458             List<KeywordList> toWrite = 
new ArrayList<>();
 
  459             toWrite.add(reader.getList(currentKeywordList.getName()));
 
  460             final XmlKeywordSearchList exporter = 
new XmlKeywordSearchList(fileAbs);
 
  461             boolean written = exporter.saveLists(toWrite);
 
  463                 KeywordSearchUtil.displayDialog(FEATURE_NAME,
 
  464                         NbBundle.getMessage(
this.getClass(), 
"KeywordSearchEditListPanel.exportButtonActionPerformed.kwListExportedMsg"),
 
  465                         KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
 
  470     private void ingestMessagesCheckboxActionPerformed(java.awt.event.ActionEvent evt) {
 
  471         currentKeywordList.setIngestMessages(ingestMessagesCheckbox.isSelected());
 
  472         XmlKeywordSearchList updater = XmlKeywordSearchList.getCurrent();
 
  473         updater.addList(currentKeywordList);
 
  474         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  477     private void deleteListButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  478         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  482     private javax.swing.JPanel addKeywordPanel;
 
  483     private javax.swing.JButton deleteListButton;
 
  484     private javax.swing.JButton deleteWordButton;
 
  485     private javax.swing.JButton exportButton;
 
  486     private javax.swing.JCheckBox ingestMessagesCheckbox;
 
  487     private javax.swing.JScrollPane jScrollPane1;
 
  488     private javax.swing.JLabel keywordOptionsLabel;
 
  489     private javax.swing.JSeparator keywordOptionsSeparator;
 
  490     private javax.swing.JTable keywordTable;
 
  491     private javax.swing.JLabel keywordsLabel;
 
  492     private javax.swing.JPanel listEditorPanel;
 
  493     private javax.swing.JLabel listOptionsLabel;
 
  494     private javax.swing.JSeparator listOptionsSeparator;
 
  495     private javax.swing.JButton newWordButton;
 
  496     private javax.swing.JButton saveListButton;
 
  500     public void valueChanged(ListSelectionEvent e) {
 
  502         ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
 
  503         if (!listSelectionModel.isSelectionEmpty()) {
 
  504             int index = listSelectionModel.getMinSelectionIndex();
 
  506             listSelectionModel.setSelectionInterval(index, index);
 
  507             XmlKeywordSearchList loader = XmlKeywordSearchList.getCurrent();
 
  509             currentKeywordList = loader.getListsL(
false).get(index);
 
  513             currentKeywordList = null;
 
  520     public void store() {
 
  529     KeywordList getCurrentKeywordList() {
 
  530         return currentKeywordList;
 
  533     void setCurrentKeywordList(KeywordList list) {
 
  534         currentKeywordList = list;
 
  537     void addDeleteButtonActionPerformed(ActionListener l) {
 
  538         deleteListButton.addActionListener(l);
 
  541     void addSaveButtonActionPerformed(ActionListener l) {
 
  542         saveListButton.addActionListener(l);
 
  554             return currentKeywordList == null ? 0 : currentKeywordList.getKeywords().size();
 
  559             String colName = null;
 
  563                     colName = NbBundle.getMessage(this.getClass(), 
"KeywordSearchEditListPanel.kwColName");
 
  566                     colName = NbBundle.getMessage(this.getClass(), 
"KeywordSearchEditListPanel.exportButtonActionPerformed.regExColName");
 
  578             if (currentKeywordList == null) {
 
  581             Keyword word = currentKeywordList.getKeywords().get(rowIndex);
 
  582             switch (columnIndex) {
 
  584                     ret = (Object) word.getSearchTerm();
 
  587                     ret = (Object) !word.searchTermIsLiteral();
 
  590                     logger.log(Level.SEVERE, 
"Invalid table column index: {0}", columnIndex); 
 
  602         public void setValueAt(Object aValue, 
int rowIndex, 
int columnIndex) {
 
  610         void addKeyword(Keyword keyword) {
 
  611             if (!currentKeywordList.hasKeyword(keyword)) {
 
  612                 currentKeywordList.getKeywords().add(keyword);
 
  614             fireTableDataChanged();
 
  618             fireTableDataChanged();
 
  622         void deleteSelected(
int[] selected) {
 
  623             List<Keyword> words = currentKeywordList.getKeywords();
 
  624             Arrays.sort(selected);
 
  625             for (
int arrayi = selected.length - 1; arrayi >= 0; arrayi--) {
 
  626                 words.remove(selected[arrayi]);
 
  638         private static final long serialVersionUID = 1L;
 
  639         final ImageIcon theCheck = 
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/checkmark.png")); 
 
  642             setHorizontalAlignment(CENTER);
 
  646         @Messages(
"IsRegularExpression=Keyword is a regular expression")
 
  649             if ((value instanceof Boolean)) {
 
  650                 if ((Boolean) value) {
 
  652                     setToolTipText(Bundle.IsRegularExpression());
 
  655                     setToolTipText(null);
 
  665     void setFocusOnKeywordTextBox() {
 
  666         newWordButton.requestFocus();
 
Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
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)