Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
WebCategoriesOptionsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2021 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.url.analytics.domaincategorization;
20 
21 import java.awt.Cursor;
22 import java.beans.PropertyChangeListener;
23 import java.io.File;
24 import java.io.IOException;
25 import java.sql.SQLException;
26 import java.util.Arrays;
27 import java.util.HashSet;
28 import java.util.List;
29 import java.util.Set;
30 import java.util.logging.Level;
31 import java.util.logging.Logger;
32 import java.util.stream.Collectors;
33 import javax.swing.JFileChooser;
34 import javax.swing.JFrame;
35 import javax.swing.JOptionPane;
36 import javax.swing.SwingUtilities;
37 import javax.swing.filechooser.FileNameExtensionFilter;
38 import org.apache.commons.collections.CollectionUtils;
39 import org.apache.commons.lang.StringUtils;
40 import org.openide.util.NbBundle.Messages;
41 import org.openide.util.WeakListeners;
52 
57 @Messages({
58  "WebCategoriesOptionsPanel_categoryTable_suffixColumnName=Domain Suffix",
59  "WebCategoriesOptionsPanel_categoryTable_categoryColumnName=Category",})
60 public class WebCategoriesOptionsPanel extends IngestModuleGlobalSettingsPanel implements OptionsPanel, AutoCloseable {
61 
62  private static final Logger logger = Logger.getLogger(WebCategoriesOptionsPanel.class.getName());
63  private static final String DEFAULT_EXTENSION = "json";
64  private static final FileNameExtensionFilter DB_FILTER = new FileNameExtensionFilter("JSON", DEFAULT_EXTENSION);
65 
66  private final JFileChooser fileChooser = new JFileChooser();
67  private final WebCategoriesDataModel dataModel;
68 
69  private final JTablePanel<DomainCategory> categoryTable
70  = JTablePanel.getJTablePanel(Arrays.asList(
72  Bundle.WebCategoriesOptionsPanel_categoryTable_suffixColumnName(),
73  (domCat) -> new DefaultCellModel<>(domCat.getHostSuffix())
74  .setTooltip(domCat.getHostSuffix()),
75  300
76  ),
77  new ColumnModel<>(
78  Bundle.WebCategoriesOptionsPanel_categoryTable_categoryColumnName(),
79  (domCat) -> new DefaultCellModel<>(domCat.getCategory())
80  .setTooltip(domCat.getCategory()),
81  200
82  )
83  )).setKeyFunction((domCat) -> domCat.getHostSuffix());
84 
85  private final PropertyChangeListener ingestListener = (evt) -> refreshComponentStates();
86  private final PropertyChangeListener weakIngestListener = WeakListeners.propertyChange(ingestListener, this);
87  private Set<String> domainSuffixes = new HashSet<>();
88  private boolean isRefreshing = false;
89 
95  public WebCategoriesOptionsPanel(WebCategoriesDataModel dataModel) {
96  initComponents();
97  this.dataModel = dataModel;
98 
99  fileChooser.addChoosableFileFilter(DB_FILTER);
100  fileChooser.setFileFilter(DB_FILTER);
101  categoryTable.setCellListener((evt) -> refreshComponentStates());
103  setDefaultCursor();
104  refresh();
105  }
106 
112  private List<DomainCategory> getSelected() {
113  return categoryTable.getSelectedItems();
114  }
115 
119  void refresh() {
120  isRefreshing = true;
121  refreshComponentStates();
122  categoryTable.showDefaultLoadingMessage();
124  (noVal) -> this.dataModel.getRecords(),
125  (data) -> onRefreshedData(data),
126  null).execute();
127  }
128 
135  private void onRefreshedData(DataFetchResult<List<DomainCategory>> categoriesResult) {
136  categoryTable.showDataFetchResult(categoriesResult);
137  if (categoriesResult.getResultType() == ResultType.SUCCESS && categoriesResult.getData() != null) {
138  domainSuffixes = categoriesResult.getData().stream()
139  .map((dc) -> dc.getHostSuffix())
140  .collect(Collectors.toSet());
141  } else {
142  domainSuffixes = new HashSet<>();
143  }
144  isRefreshing = false;
145  refreshComponentStates();
146  }
147 
153  private void refreshComponentStates() {
154  List<DomainCategory> selectedItems = getSelected();
155  int selectedCount = CollectionUtils.isEmpty(selectedItems) ? 0 : selectedItems.size();
156  boolean isIngestRunning = IngestManager.getInstance().isIngestRunning();
157  boolean operationsPermitted = !isIngestRunning && !isRefreshing;
158 
159  deleteEntryButton.setEnabled(selectedCount > 0 && operationsPermitted);
160  editEntryButton.setEnabled(selectedCount == 1 && operationsPermitted);
161 
162  newEntryButton.setEnabled(operationsPermitted);
163  exportSetButton.setEnabled(operationsPermitted);
164  importSetButton.setEnabled(operationsPermitted);
165 
166  ingestRunningWarning.setVisible(isIngestRunning);
167  }
168 
178  JFrame parent = (this.getRootPane() != null && this.getRootPane().getParent() instanceof JFrame)
179  ? (JFrame) this.getRootPane().getParent()
180  : null;
181 
182  AddEditCategoryDialog addEditDialog = new AddEditCategoryDialog(parent, domainSuffixes, original);
183  addEditDialog.setResizable(false);
184  addEditDialog.setLocationRelativeTo(parent);
185  addEditDialog.setVisible(true);
186  addEditDialog.toFront();
187 
188  if (addEditDialog.isChanged()) {
189  return addEditDialog.getValue();
190  } else {
191  return null;
192  }
193  }
194 
198  private void setWaitingCursor() {
199  SwingUtilities.invokeLater(() -> this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)));
200  }
201 
205  private void setDefaultCursor() {
206  SwingUtilities.invokeLater(() -> this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)));
207  }
208 
212  private interface UpdateAction {
213 
221  void run() throws IllegalArgumentException, IOException, SQLException;
222  }
223 
233  private void runUpdateAction(UpdateAction runnable) throws IllegalArgumentException, IOException, SQLException {
234  setWaitingCursor();
235  runnable.run();
236  setDefaultCursor();
237  refresh();
238  }
239 
245  @SuppressWarnings("unchecked")
246  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
247  private void initComponents() {
248  java.awt.GridBagConstraints gridBagConstraints;
249 
250  javax.swing.JLabel panelDescription = new javax.swing.JLabel();
251  javax.swing.JLabel categoriesTitle = new javax.swing.JLabel();
252  javax.swing.JPanel categoryTablePanel = categoryTable;
253  newEntryButton = new javax.swing.JButton();
254  editEntryButton = new javax.swing.JButton();
255  deleteEntryButton = new javax.swing.JButton();
256  importSetButton = new javax.swing.JButton();
257  exportSetButton = new javax.swing.JButton();
258  javax.swing.JPanel bottomStrut = new javax.swing.JPanel();
259  ingestRunningWarning = new javax.swing.JLabel();
260 
261  setLayout(new java.awt.GridBagLayout());
262 
263  panelDescription.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
264  panelDescription.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.panelDescription.text")); // NOI18N
265  panelDescription.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(), javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)));
266  gridBagConstraints = new java.awt.GridBagConstraints();
267  gridBagConstraints.gridwidth = 3;
268  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
269  gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
270  gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 0);
271  add(panelDescription, gridBagConstraints);
272 
273  categoriesTitle.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.categoriesTitle.text")); // NOI18N
274  gridBagConstraints = new java.awt.GridBagConstraints();
275  gridBagConstraints.gridx = 0;
276  gridBagConstraints.gridy = 1;
277  gridBagConstraints.gridwidth = 3;
278  gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
279  gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
280  add(categoriesTitle, gridBagConstraints);
281 
282  categoryTablePanel.setAutoscrolls(true);
283  categoryTablePanel.setMaximumSize(new java.awt.Dimension(400, 32767));
284  categoryTablePanel.setMinimumSize(new java.awt.Dimension(400, 300));
285  categoryTablePanel.setPreferredSize(new java.awt.Dimension(400, 600));
286  gridBagConstraints = new java.awt.GridBagConstraints();
287  gridBagConstraints.gridx = 0;
288  gridBagConstraints.gridy = 2;
289  gridBagConstraints.gridwidth = 3;
290  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
291  gridBagConstraints.weighty = 1.0;
292  gridBagConstraints.insets = new java.awt.Insets(2, 10, 10, 0);
293  add(categoryTablePanel, gridBagConstraints);
294 
295  newEntryButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/add16.png"))); // NOI18N
296  newEntryButton.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.newEntryButton.text")); // NOI18N
297  newEntryButton.addActionListener(new java.awt.event.ActionListener() {
298  public void actionPerformed(java.awt.event.ActionEvent evt) {
299  newEntryButtonActionPerformed(evt);
300  }
301  });
302  gridBagConstraints = new java.awt.GridBagConstraints();
303  gridBagConstraints.gridx = 0;
304  gridBagConstraints.gridy = 3;
305  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
306  gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
307  gridBagConstraints.insets = new java.awt.Insets(0, 10, 5, 5);
308  add(newEntryButton, gridBagConstraints);
309 
310  editEntryButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/edit16.png"))); // NOI18N
311  editEntryButton.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.editEntryButton.text")); // NOI18N
312  editEntryButton.addActionListener(new java.awt.event.ActionListener() {
313  public void actionPerformed(java.awt.event.ActionEvent evt) {
314  editEntryButtonActionPerformed(evt);
315  }
316  });
317  gridBagConstraints = new java.awt.GridBagConstraints();
318  gridBagConstraints.gridx = 1;
319  gridBagConstraints.gridy = 3;
320  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
321  gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
322  gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 5);
323  add(editEntryButton, gridBagConstraints);
324 
325  deleteEntryButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete16.png"))); // NOI18N
326  deleteEntryButton.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.deleteEntryButton.text")); // NOI18N
327  deleteEntryButton.addActionListener(new java.awt.event.ActionListener() {
328  public void actionPerformed(java.awt.event.ActionEvent evt) {
329  deleteEntryButtonActionPerformed(evt);
330  }
331  });
332  gridBagConstraints = new java.awt.GridBagConstraints();
333  gridBagConstraints.gridx = 2;
334  gridBagConstraints.gridy = 3;
335  gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
336  gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 5);
337  add(deleteEntryButton, gridBagConstraints);
338 
339  importSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/import16.png"))); // NOI18N
340  importSetButton.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.importSetButton.text")); // NOI18N
341  importSetButton.addActionListener(new java.awt.event.ActionListener() {
342  public void actionPerformed(java.awt.event.ActionEvent evt) {
343  importSetButtonActionPerformed(evt);
344  }
345  });
346  gridBagConstraints = new java.awt.GridBagConstraints();
347  gridBagConstraints.gridx = 0;
348  gridBagConstraints.gridy = 4;
349  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
350  gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
351  gridBagConstraints.insets = new java.awt.Insets(0, 10, 5, 5);
352  add(importSetButton, gridBagConstraints);
353 
354  exportSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/export16.png"))); // NOI18N
355  exportSetButton.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.exportSetButton.text")); // NOI18N
356  exportSetButton.addActionListener(new java.awt.event.ActionListener() {
357  public void actionPerformed(java.awt.event.ActionEvent evt) {
358  exportSetButtonActionPerformed(evt);
359  }
360  });
361  gridBagConstraints = new java.awt.GridBagConstraints();
362  gridBagConstraints.gridx = 1;
363  gridBagConstraints.gridy = 4;
364  gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
365  gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 5);
366  add(exportSetButton, gridBagConstraints);
367 
368  bottomStrut.setPreferredSize(new java.awt.Dimension(10, 0));
369  gridBagConstraints = new java.awt.GridBagConstraints();
370  gridBagConstraints.gridx = 3;
371  gridBagConstraints.gridy = 6;
372  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
373  gridBagConstraints.weightx = 1.0;
374  add(bottomStrut, gridBagConstraints);
375 
376  ingestRunningWarning.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/warning16.png"))); // NOI18N
377  ingestRunningWarning.setText(org.openide.util.NbBundle.getMessage(WebCategoriesOptionsPanel.class, "WebCategoriesOptionsPanel.ingestRunningWarning.text")); // NOI18N
378  gridBagConstraints = new java.awt.GridBagConstraints();
379  gridBagConstraints.gridx = 0;
380  gridBagConstraints.gridy = 5;
381  gridBagConstraints.gridwidth = 3;
382  gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
383  gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
384  add(ingestRunningWarning, gridBagConstraints);
385  }// </editor-fold>//GEN-END:initComponents
386 
387  private void deleteEntryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteEntryButtonActionPerformed
388  List<DomainCategory> selectedItems = getSelected();
389  if (!CollectionUtils.isEmpty(selectedItems)) {
390  setWaitingCursor();
391  for (DomainCategory selected : selectedItems) {
392  if (selected != null && selected.getHostSuffix() != null) {
393  try {
394  dataModel.deleteRecord(selected.getHostSuffix());
395  } catch (IllegalArgumentException | SQLException ex) {
396  logger.log(Level.WARNING, "There was an error while deleting: " + selected.getHostSuffix(), ex);
397  }
398  }
399  }
400  setDefaultCursor();
401  refresh();
402  }
403  }//GEN-LAST:event_deleteEntryButtonActionPerformed
404 
405  private void newEntryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newEntryButtonActionPerformed
406  DomainCategory newCategory = getAddEditValue(null);
407  if (newCategory != null) {
408  try {
409  runUpdateAction(() -> dataModel.insertUpdateSuffix(newCategory));
410  } catch (IllegalArgumentException | SQLException | IOException ex) {
411  setDefaultCursor();
412  logger.log(Level.WARNING, "There was an error while adding new record: " + newCategory.getHostSuffix(), ex);
413  }
414  }
415  }//GEN-LAST:event_newEntryButtonActionPerformed
416 
417  private void editEntryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editEntryButtonActionPerformed
418  List<DomainCategory> selectedItems = getSelected();
419  if (CollectionUtils.isNotEmpty(selectedItems)) {
420  DomainCategory selected = selectedItems.get(0);
421  if (selected != null && selected.getHostSuffix() != null) {
422  try {
423  DomainCategory newCategory = getAddEditValue(selected);
424  if (newCategory != null) {
425  runUpdateAction(() -> dataModel.insertUpdateSuffix(newCategory));
426  }
427  } catch (IllegalArgumentException | SQLException | IOException ex) {
428  setDefaultCursor();
429  logger.log(Level.WARNING, "There was an error while editing: " + selected.getHostSuffix(), ex);
430  }
431  }
432  }
433  }//GEN-LAST:event_editEntryButtonActionPerformed
434 
435  @Messages({
436  "WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorMessage=There was an error importing this json file.",
437  "WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorTitle=Import Error",
438  "WebCategoriesOptionsPanel_importSetButtonActionPerformed_onConflictTitle=Domain Suffix Already Exists",
439  "# {0} - domainSuffix",
440  "WebCategoriesOptionsPanel_importSetButtonActionPerformed_onConflictMessage=Domain suffix {0} already exists. What would you like to do?",
441  "WebCategoriesOptionsPanel_importSetButtonActionPerformed_onConflictOverwrite=Overwrite",
442  "WebCategoriesOptionsPanel_importSetButtonActionPerformed_onConflictSkip=Skip",
443  "WebCategoriesOptionsPanel_importSetButtonActionPerformed_onConflictCancel=Cancel"})
444  private void importSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importSetButtonActionPerformed
445  fileChooser.setSelectedFile(new File(""));
446  int result = fileChooser.showOpenDialog(this);
447  if (result == JFileChooser.APPROVE_OPTION) {
448  File selectedFile = fileChooser.getSelectedFile();
449  if (selectedFile != null && selectedFile.exists()) {
450  try {
451  runUpdateAction(() -> {
452  List<DomainCategory> categories = dataModel.getJsonEntries(selectedFile);
453 
454  for (DomainCategory domcat : categories) {
455  String normalizedCategory = domcat == null ? "" : WebCategoriesDataModel.getNormalizedCategory(domcat.getCategory());
456  String normalizedSuffix = domcat == null ? "" : WebCategoriesDataModel.getNormalizedSuffix(domcat.getHostSuffix());
457 
458  if (StringUtils.isBlank(normalizedCategory) || StringUtils.isBlank(normalizedSuffix)) {
459  logger.log(Level.WARNING, String.format("Invalid entry [category: %s, domain suffix: %s]", normalizedCategory, normalizedSuffix));
460  continue;
461  }
462 
463  DomainCategory currentCategory = dataModel.getRecordBySuffix(normalizedSuffix);
464  // if a mapping for the domain suffix already exists and the value will change, prompt the user on what to do.
465  if (currentCategory != null) {
466  if (normalizedCategory.equalsIgnoreCase(currentCategory.getCategory())) {
467  // do nothing if import item is same as already present
468  continue;
469  } else {
470 
471  String[] options = {
472  Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_onConflictOverwrite(),
473  Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_onConflictSkip(),
474  Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_onConflictCancel()
475  };
476 
477  int optionItem = JOptionPane.showOptionDialog(null,
478  Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_onConflictMessage(normalizedSuffix),
479  Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_onConflictTitle(),
480  JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
481 
482  switch (optionItem) {
483  case 0:
484  break;
485  case 1:
486  continue;
487  case 2:
488  return;
489  }
490  }
491  }
492 
493  dataModel.insertUpdateSuffix(new DomainCategory(normalizedSuffix, normalizedCategory));
494  }
495  });
496  } catch (IllegalArgumentException | SQLException | IOException ex) {
497  setDefaultCursor();
498  JOptionPane.showMessageDialog(
499  this,
500  Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorMessage(),
501  Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorTitle(),
502  JOptionPane.ERROR_MESSAGE);
503  logger.log(Level.WARNING, "There was an error on import.", ex);
504  }
505  }
506  }
507  }//GEN-LAST:event_importSetButtonActionPerformed
508 
509  @Messages({
510  "WebCategoriesOptionsPanel_exportSetButtonActionPerformed_duplicateMessage=A file already exists at the selected path. The categories will not be exported.",
511  "WebCategoriesOptionsPanel_exportSetButtonActionPerformed_duplicateTitle=File Already Exists",
512  "WebCategoriesOptionsPanel_exportSetButtonActionPerformed_errorMessage=There was an error exporting.",
513  "WebCategoriesOptionsPanel_exportSetButtonActionPerformed_errorTitle=Export Error",
514  "WebCategoriesOptionsPanel_exportSetButtonActionPerformed_defaultFileName=Custom Categories Export"
515  })
516  private void exportSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportSetButtonActionPerformed
517  fileChooser.setSelectedFile(new File(String.format("%s.json", Bundle.WebCategoriesOptionsPanel_exportSetButtonActionPerformed_defaultFileName())));
518  int result = fileChooser.showSaveDialog(this);
519  if (result == JFileChooser.APPROVE_OPTION) {
520  File selectedFile = fileChooser.getSelectedFile();
521  if (selectedFile != null) {
522  if (selectedFile.exists()) {
523  JOptionPane.showMessageDialog(
524  this,
525  Bundle.WebCategoriesOptionsPanel_exportSetButtonActionPerformed_duplicateMessage(),
526  Bundle.WebCategoriesOptionsPanel_exportSetButtonActionPerformed_duplicateTitle(),
527  JOptionPane.ERROR_MESSAGE);
528  return;
529  }
530  try {
531  setWaitingCursor();
532  dataModel.exportToJson(selectedFile);
533  setDefaultCursor();
534  } catch (SQLException | IOException ex) {
535  setDefaultCursor();
536  JOptionPane.showMessageDialog(
537  this,
538  Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorMessage(),
539  Bundle.WebCategoriesOptionsPanel_importSetButtonActionPerformed_errorTitle(),
540  JOptionPane.ERROR_MESSAGE);
541  logger.log(Level.WARNING, "There was an error on export.", ex);
542  }
543  }
544  }
545  }//GEN-LAST:event_exportSetButtonActionPerformed
546 
547 
548  // Variables declaration - do not modify//GEN-BEGIN:variables
549  private javax.swing.JButton deleteEntryButton;
550  private javax.swing.JButton editEntryButton;
551  private javax.swing.JButton exportSetButton;
552  private javax.swing.JButton importSetButton;
553  private javax.swing.JLabel ingestRunningWarning;
554  private javax.swing.JButton newEntryButton;
555  // End of variables declaration//GEN-END:variables
556 
557  @Override
558  public void saveSettings() {
559  // NO OP since saves happen whenever there is a change.
560  }
561 
562  @Override
563  public void store() {
564  // NO OP since saves happen whenever there is a change.
565  }
566 
567  @Override
568  public void load() {
569  refresh();
570  }
571 
572  @Override
573  public void close() {
575  }
576 }
static synchronized IngestManager getInstance()
static< T, CextendsGuiCellModel > JTablePanel< T > getJTablePanel(List< ColumnModel< T, C >> columns)
void removeIngestJobEventListener(final PropertyChangeListener listener)
void addIngestJobEventListener(final PropertyChangeListener listener)
void onRefreshedData(DataFetchResult< List< DomainCategory >> categoriesResult)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.