19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.List;
24 import javax.swing.JOptionPane;
25 import org.openide.util.NbBundle;
28 final class GlobalListSettingsPanel
extends javax.swing.JPanel implements OptionsPanel {
30 private final GlobalListsManagementPanel listsManagementPanel =
new GlobalListsManagementPanel();
31 private final GlobalEditListPanel editListPanel =
new GlobalEditListPanel();
33 GlobalListSettingsPanel() {
35 customizeComponents();
36 setName(
org.openide.util.NbBundle.getMessage(DropdownToolbar.class,
"ListBundleConfig"));
39 private void customizeComponents() {
40 listsManagementPanel.addListSelectionListener(editListPanel);
41 editListPanel.addDeleteButtonActionPerformed(
new ActionListener() {
43 public void actionPerformed(ActionEvent e) {
44 if (KeywordSearchUtil.displayConfirmDialog(NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.title"), NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.body"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN)) {
45 String toDelete = editListPanel.getCurrentKeywordList().getName();
46 editListPanel.setCurrentKeywordList(null);
47 editListPanel.setButtonStates();
48 XmlKeywordSearchList deleter = XmlKeywordSearchList.getCurrent();
49 deleter.deleteList(toDelete);
50 listsManagementPanel.resync();
55 editListPanel.addSaveButtonActionPerformed(
new ActionListener() {
57 public void actionPerformed(ActionEvent e) {
58 final String FEATURE_NAME = NbBundle.getMessage(this.getClass(),
59 "KeywordSearchGlobalListSettingsPanel.component.featureName.text");
60 KeywordList currentKeywordList = editListPanel.getCurrentKeywordList();
62 List<Keyword> keywords = currentKeywordList.getKeywords();
63 if (keywords.isEmpty()) {
64 KeywordSearchUtil.displayDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.keywordListEmptyErr"),
65 KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
69 String listName = (String) JOptionPane.showInputDialog(
71 NbBundle.getMessage(
this.getClass(),
"KeywordSearch.newKwListTitle"),
73 JOptionPane.PLAIN_MESSAGE,
76 currentKeywordList != null ? currentKeywordList.getName() :
"");
77 if (listName == null || listName.trim().equals(
"")) {
81 XmlKeywordSearchList writer = XmlKeywordSearchList.getCurrent();
82 if (writer.listExists(listName) && writer.getList(listName).isLocked()) {
83 KeywordSearchUtil.displayDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.noOwDefaultMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);
86 boolean shouldAdd =
false;
87 if (writer.listExists(listName)) {
88 boolean replace = KeywordSearchUtil.displayConfirmDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.kwListExistMsg", listName),
89 KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);
99 writer.addList(listName, keywords);
100 KeywordSearchUtil.displayDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.kwListSavedMsg", listName), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
103 listsManagementPanel.resync();
107 mainSplitPane.setLeftComponent(listsManagementPanel);
108 mainSplitPane.setRightComponent(editListPanel);
109 mainSplitPane.revalidate();
110 mainSplitPane.repaint();
114 public void store() {
115 XmlKeywordSearchList.getCurrent().save(
false);
117 DropdownListSearchPanel.getDefault().resync();
122 listsManagementPanel.load();
130 @SuppressWarnings(
"unchecked")
132 private
void initComponents() {
134 mainSplitPane =
new javax.swing.JSplitPane();
135 leftPanel =
new javax.swing.JPanel();
136 rightPanel =
new javax.swing.JPanel();
138 mainSplitPane.setBorder(null);
139 mainSplitPane.setDividerLocation(275);
141 javax.swing.GroupLayout leftPanelLayout =
new javax.swing.GroupLayout(leftPanel);
142 leftPanel.setLayout(leftPanelLayout);
143 leftPanelLayout.setHorizontalGroup(
144 leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
145 .addGap(0, 275, Short.MAX_VALUE)
147 leftPanelLayout.setVerticalGroup(
148 leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
149 .addGap(0, 327, Short.MAX_VALUE)
152 mainSplitPane.setLeftComponent(leftPanel);
154 rightPanel.setPreferredSize(
new java.awt.Dimension(360, 327));
156 javax.swing.GroupLayout rightPanelLayout =
new javax.swing.GroupLayout(rightPanel);
157 rightPanel.setLayout(rightPanelLayout);
158 rightPanelLayout.setHorizontalGroup(
159 rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
160 .addGap(0, 385, Short.MAX_VALUE)
162 rightPanelLayout.setVerticalGroup(
163 rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
164 .addGap(0, 327, Short.MAX_VALUE)
167 mainSplitPane.setRightComponent(rightPanel);
169 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
170 this.setLayout(layout);
171 layout.setHorizontalGroup(
172 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
173 .addComponent(mainSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 665, Short.MAX_VALUE)
175 layout.setVerticalGroup(
176 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
177 .addComponent(mainSplitPane)
181 private javax.swing.JPanel leftPanel;
182 private javax.swing.JSplitPane mainSplitPane;
183 private javax.swing.JPanel rightPanel;