19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.beans.PropertyChangeListener;
24 import java.util.List;
25 import javax.swing.JOptionPane;
26 import org.openide.util.NbBundle;
29 final class GlobalListSettingsPanel
extends javax.swing.JPanel implements OptionsPanel {
31 private static final long serialVersionUID = 1L;
33 private final GlobalListsManagementPanel listsManagementPanel =
new GlobalListsManagementPanel(
this);
34 private final GlobalEditListPanel editListPanel =
new GlobalEditListPanel();
36 GlobalListSettingsPanel() {
38 customizeComponents();
39 setName(
org.openide.util.NbBundle.getMessage(DropdownToolbar.class,
"ListBundleConfig"));
42 private void customizeComponents() {
43 listsManagementPanel.addListSelectionListener(editListPanel);
44 editListPanel.addDeleteButtonActionPerformed(
new ActionListener() {
46 public void actionPerformed(ActionEvent e) {
47 if (KeywordSearchUtil.displayConfirmDialog(NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.title"), NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.body"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN)) {
48 String toDelete = editListPanel.getCurrentKeywordList().getName();
49 editListPanel.setCurrentKeywordList(null);
50 editListPanel.setButtonStates();
51 XmlKeywordSearchList deleter = XmlKeywordSearchList.getCurrent();
52 deleter.deleteList(toDelete);
53 listsManagementPanel.resync();
58 editListPanel.addSaveButtonActionPerformed(
new ActionListener() {
60 public void actionPerformed(ActionEvent e) {
61 final String FEATURE_NAME = NbBundle.getMessage(this.getClass(),
62 "KeywordSearchGlobalListSettingsPanel.component.featureName.text");
63 KeywordList currentKeywordList = editListPanel.getCurrentKeywordList();
65 List<Keyword> keywords = currentKeywordList.getKeywords();
66 if (keywords.isEmpty()) {
67 KeywordSearchUtil.displayDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.keywordListEmptyErr"),
68 KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
72 String listName = (String) JOptionPane.showInputDialog(
74 NbBundle.getMessage(
this.getClass(),
"KeywordSearch.newKwListTitle"),
76 JOptionPane.PLAIN_MESSAGE,
79 currentKeywordList != null ? currentKeywordList.getName() :
"");
80 if (listName == null || listName.trim().equals(
"")) {
84 XmlKeywordSearchList writer = XmlKeywordSearchList.getCurrent();
85 if (writer.listExists(listName) && writer.getList(listName).isEditable()) {
86 KeywordSearchUtil.displayDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.noOwDefaultMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);
89 boolean shouldAdd =
false;
90 if (writer.listExists(listName)) {
91 boolean replace = KeywordSearchUtil.displayConfirmDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.kwListExistMsg", listName),
92 KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);
102 writer.addList(listName, keywords);
103 KeywordSearchUtil.displayDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.kwListSavedMsg", listName), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
106 listsManagementPanel.resync();
110 mainSplitPane.setLeftComponent(listsManagementPanel);
111 mainSplitPane.setRightComponent(editListPanel);
112 mainSplitPane.revalidate();
113 mainSplitPane.repaint();
117 public void addPropertyChangeListener(PropertyChangeListener l) {
118 listsManagementPanel.addPropertyChangeListener(l);
119 editListPanel.addPropertyChangeListener(l);
123 public void removePropertyChangeListener(PropertyChangeListener l) {
124 listsManagementPanel.removePropertyChangeListener(l);
125 editListPanel.removePropertyChangeListener(l);
129 public void store() {
130 XmlKeywordSearchList.getCurrent().save(
false);
132 DropdownListSearchPanel.getDefault().resync();
137 listsManagementPanel.load();
143 void setFocusOnKeywordTextBox() {
144 editListPanel.setFocusOnKeywordTextBox();
152 @SuppressWarnings(
"unchecked")
154 private
void initComponents() {
156 jScrollPane1 =
new javax.swing.JScrollPane();
157 mainSplitPane =
new javax.swing.JSplitPane();
158 leftPanel =
new javax.swing.JPanel();
159 rightPanel =
new javax.swing.JPanel();
161 mainSplitPane.setBorder(null);
162 mainSplitPane.setDividerLocation(275);
163 mainSplitPane.setDividerSize(1);
165 javax.swing.GroupLayout leftPanelLayout =
new javax.swing.GroupLayout(leftPanel);
166 leftPanel.setLayout(leftPanelLayout);
167 leftPanelLayout.setHorizontalGroup(
168 leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
169 .addGap(0, 275, Short.MAX_VALUE)
171 leftPanelLayout.setVerticalGroup(
172 leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
173 .addGap(0, 327, Short.MAX_VALUE)
176 mainSplitPane.setLeftComponent(leftPanel);
178 rightPanel.setPreferredSize(
new java.awt.Dimension(360, 327));
180 javax.swing.GroupLayout rightPanelLayout =
new javax.swing.GroupLayout(rightPanel);
181 rightPanel.setLayout(rightPanelLayout);
182 rightPanelLayout.setHorizontalGroup(
183 rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
184 .addGap(0, 397, Short.MAX_VALUE)
186 rightPanelLayout.setVerticalGroup(
187 rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
188 .addGap(0, 327, Short.MAX_VALUE)
191 mainSplitPane.setRightComponent(rightPanel);
193 jScrollPane1.setViewportView(mainSplitPane);
195 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
196 this.setLayout(layout);
197 layout.setHorizontalGroup(
198 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
199 .addGroup(layout.createSequentialGroup()
200 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 675, Short.MAX_VALUE)
203 layout.setVerticalGroup(
204 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
205 .addGroup(layout.createSequentialGroup()
206 .addComponent(jScrollPane1)
211 private javax.swing.JScrollPane jScrollPane1;
212 private javax.swing.JPanel leftPanel;
213 private javax.swing.JSplitPane mainSplitPane;
214 private javax.swing.JPanel rightPanel;