mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Load and save list dialogs
This commit is contained in:
parent
bcb23023f0
commit
4825aff6ee
@ -31,6 +31,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
@ -58,6 +59,7 @@ public final class KeywordSearchListTopComponent extends TopComponent implements
|
|||||||
|
|
||||||
private static Logger logger = Logger.getLogger(KeywordSearchListTopComponent.class.getName());
|
private static Logger logger = Logger.getLogger(KeywordSearchListTopComponent.class.getName());
|
||||||
private KeywordTableModel tableModel;
|
private KeywordTableModel tableModel;
|
||||||
|
private String currentKeywordList;
|
||||||
|
|
||||||
public KeywordSearchListTopComponent() {
|
public KeywordSearchListTopComponent() {
|
||||||
tableModel = new KeywordTableModel();
|
tableModel = new KeywordTableModel();
|
||||||
@ -103,6 +105,10 @@ public final class KeywordSearchListTopComponent extends TopComponent implements
|
|||||||
keywordTable.setCellSelectionEnabled(false);
|
keywordTable.setCellSelectionEnabled(false);
|
||||||
|
|
||||||
loadDefaultKeywords();
|
loadDefaultKeywords();
|
||||||
|
|
||||||
|
if (KeywordSearchListsXML.getInstance().getNumberLists() == 0) {
|
||||||
|
loadListButton.setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadDefaultKeywords() {
|
private void loadDefaultKeywords() {
|
||||||
@ -322,18 +328,26 @@ public final class KeywordSearchListTopComponent extends TopComponent implements
|
|||||||
}//GEN-LAST:event_addWordButtonActionPerformed
|
}//GEN-LAST:event_addWordButtonActionPerformed
|
||||||
|
|
||||||
private void saveListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveListButtonActionPerformed
|
private void saveListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveListButtonActionPerformed
|
||||||
|
final String FEATURE_NAME = "Save Keyword List";
|
||||||
KeywordSearchListsXML writer = KeywordSearchListsXML.getInstance();
|
KeywordSearchListsXML writer = KeywordSearchListsXML.getInstance();
|
||||||
|
|
||||||
//TODO popup with name / check if overwrite, then save
|
String listName = (String) JOptionPane.showInputDialog(
|
||||||
|
null,
|
||||||
String listName = "initial";
|
"New keyword list name:",
|
||||||
|
FEATURE_NAME,
|
||||||
|
JOptionPane.PLAIN_MESSAGE,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
currentKeywordList != null ? currentKeywordList : "");
|
||||||
|
if (listName == null || listName.equals("")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<String> keywords = tableModel.getAllKeywords();
|
List<String> keywords = tableModel.getAllKeywords();
|
||||||
|
|
||||||
boolean shouldWrite = false;
|
boolean shouldWrite = false;
|
||||||
boolean written = false;
|
boolean written = false;
|
||||||
if (writer.listExists(listName)) {
|
if (writer.listExists(listName)) {
|
||||||
boolean replace = KeywordSearchUtil.displayConfirmDialog("Save Keyword List", "Keyword List <" + listName + "> already exists, do you want to replace it?",
|
boolean replace = KeywordSearchUtil.displayConfirmDialog(FEATURE_NAME, "Keyword List <" + listName + "> already exists, do you want to replace it?",
|
||||||
KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);
|
KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);
|
||||||
if (replace) {
|
if (replace) {
|
||||||
shouldWrite = true;
|
shouldWrite = true;
|
||||||
@ -349,9 +363,13 @@ public final class KeywordSearchListTopComponent extends TopComponent implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (written) {
|
if (written) {
|
||||||
KeywordSearchUtil.displayDialog("Save Keyword List", "Keyword List <" + listName + "> saved", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
|
currentKeywordList = listName;
|
||||||
|
KeywordSearchUtil.displayDialog(FEATURE_NAME, "Keyword List <" + listName + "> saved", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
|
||||||
|
//enable load button if it was previously disabled, as lists now exist
|
||||||
|
if (loadListButton.isEnabled() == false) {
|
||||||
|
loadListButton.setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}//GEN-LAST:event_saveListButtonActionPerformed
|
}//GEN-LAST:event_saveListButtonActionPerformed
|
||||||
|
|
||||||
private void chLiteralWordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chLiteralWordActionPerformed
|
private void chLiteralWordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chLiteralWordActionPerformed
|
||||||
@ -366,11 +384,23 @@ public final class KeywordSearchListTopComponent extends TopComponent implements
|
|||||||
}//GEN-LAST:event_deleteAllWordsButtonActionPerformed
|
}//GEN-LAST:event_deleteAllWordsButtonActionPerformed
|
||||||
|
|
||||||
private void loadListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadListButtonActionPerformed
|
private void loadListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadListButtonActionPerformed
|
||||||
|
|
||||||
|
final String FEATURE_NAME = "Load Keyword List";
|
||||||
|
|
||||||
KeywordSearchListsXML loader = KeywordSearchListsXML.getInstance();
|
KeywordSearchListsXML loader = KeywordSearchListsXML.getInstance();
|
||||||
|
|
||||||
//TODO popup widget with all lists in a a table, user picks name, then load into the model
|
String listName = (String) JOptionPane.showInputDialog(
|
||||||
String listName = "initial";
|
null,
|
||||||
|
"Keyword list to load:",
|
||||||
|
FEATURE_NAME,
|
||||||
|
JOptionPane.PLAIN_MESSAGE,
|
||||||
|
null,
|
||||||
|
loader.getListNames().toArray(),
|
||||||
|
currentKeywordList);
|
||||||
|
|
||||||
|
if(listName == null || listName.equals(""))
|
||||||
|
return;
|
||||||
|
|
||||||
KeywordSearchList list = loader.getList(listName);
|
KeywordSearchList list = loader.getList(listName);
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
List<String> keywords = list.getKeywords();
|
List<String> keywords = list.getKeywords();
|
||||||
@ -378,8 +408,9 @@ public final class KeywordSearchListTopComponent extends TopComponent implements
|
|||||||
//TODO clear/append option ?
|
//TODO clear/append option ?
|
||||||
tableModel.deleteAll();
|
tableModel.deleteAll();
|
||||||
tableModel.addKeywords(keywords);
|
tableModel.addKeywords(keywords);
|
||||||
KeywordSearchUtil.displayDialog("Save Keyword List", "Keyword List <" + listName + "> loaded", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
|
currentKeywordList = listName;
|
||||||
}
|
KeywordSearchUtil.displayDialog(FEATURE_NAME, "Keyword List <" + listName + "> loaded", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
|
||||||
|
}
|
||||||
|
|
||||||
}//GEN-LAST:event_loadListButtonActionPerformed
|
}//GEN-LAST:event_loadListButtonActionPerformed
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
@ -110,6 +110,22 @@ public class KeywordSearchListsXML {
|
|||||||
Map<String, KeywordSearchList> getLists() {
|
Map<String, KeywordSearchList> getLists() {
|
||||||
return theLists;
|
return theLists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get list of all loaded keyword list names
|
||||||
|
* @return List of keyword list names
|
||||||
|
*/
|
||||||
|
List<String>getListNames() {
|
||||||
|
return new ArrayList(theLists.keySet());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get number of lists currently stored
|
||||||
|
* @return number of lists currently stored
|
||||||
|
*/
|
||||||
|
int getNumberLists() {
|
||||||
|
return theLists.size();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get list by name or null
|
* get list by name or null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user