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.ArrayList;
25 import java.util.List;
26 import javax.swing.JOptionPane;
27 import org.openide.util.NbBundle;
30 final class GlobalListSettingsPanel
extends javax.swing.JPanel implements OptionsPanel {
32 private static final long serialVersionUID = 1L;
34 private final GlobalListsManagementPanel listsManagementPanel =
new GlobalListsManagementPanel(
this);
35 private final GlobalEditListPanel editListPanel =
new GlobalEditListPanel();
37 GlobalListSettingsPanel() {
39 customizeComponents();
40 setName(
org.openide.util.NbBundle.getMessage(DropdownToolbar.class,
"ListBundleConfig"));
43 private void customizeComponents() {
44 listsManagementPanel.addListSelectionListener(editListPanel);
45 listsManagementPanel.addDeleteButtonActionPerformed(
new ActionListener() {
47 public void actionPerformed(ActionEvent e) {
48 if (KeywordSearchUtil.displayConfirmDialog(NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.title"), NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.body"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN)) {
49 String toDelete = editListPanel.getCurrentKeywordList().getName();
50 deleteAction(toDelete);
51 listsManagementPanel.resync();
56 listsManagementPanel.addRenameButtonActionPerformed(
new ActionListener() {
58 public void actionPerformed(ActionEvent e) {
59 String toDelete = editListPanel.getCurrentKeywordList().getName();
61 deleteAction(toDelete);
62 listsManagementPanel.resync();
67 listsManagementPanel.addCopyButtonActionPerformed(
new ActionListener() {
69 public void actionPerformed(ActionEvent e) {
71 listsManagementPanel.resync();
75 mainSplitPane.setLeftComponent(listsManagementPanel);
76 mainSplitPane.setRightComponent(editListPanel);
77 mainSplitPane.revalidate();
78 mainSplitPane.repaint();
86 private void deleteAction(String toDelete) {
87 XmlKeywordSearchList deleter = XmlKeywordSearchList.getCurrent();
88 deleter.deleteList(toDelete);
89 editListPanel.setCurrentKeywordList(null);
90 editListPanel.setButtonStates();
91 listsManagementPanel.setButtonStates();
100 private boolean copyAction() {
101 final String FEATURE_NAME = NbBundle.getMessage(this.getClass(),
102 "KeywordSearchGlobalListSettingsPanel.component.featureName.text");
103 KeywordList currentKeywordList = editListPanel.getCurrentKeywordList();
105 List<Keyword> keywords =
new ArrayList<>();
106 keywords.addAll(currentKeywordList.getKeywords());
108 String listName = (String) JOptionPane.showInputDialog(
110 NbBundle.getMessage(
this.getClass(),
"KeywordSearch.newKwListTitle"),
112 JOptionPane.PLAIN_MESSAGE,
115 currentKeywordList.getName());
117 if (listName == null) {
121 listName = listName.trim();
123 if (listName.equals(
"") || listName.equals(currentKeywordList.getName())) {
126 XmlKeywordSearchList writer = XmlKeywordSearchList.getCurrent();
127 if (writer.listExists(listName) && writer.getList(listName).isEditable()) {
128 KeywordSearchUtil.displayDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.noOwDefaultMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);
131 if (writer.listExists(listName)) {
132 if (!KeywordSearchUtil.displayConfirmDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.kwListExistMsg", listName),
133 KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN)) {
137 writer.addList(listName, keywords);
138 KeywordSearchUtil.displayDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.kwListSavedMsg", listName), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
143 public void addPropertyChangeListener(PropertyChangeListener l) {
144 listsManagementPanel.addPropertyChangeListener(l);
145 editListPanel.addPropertyChangeListener(l);
149 public void removePropertyChangeListener(PropertyChangeListener l) {
150 listsManagementPanel.removePropertyChangeListener(l);
151 editListPanel.removePropertyChangeListener(l);
155 public void store() {
156 XmlKeywordSearchList.getCurrent().save(
false);
158 DropdownListSearchPanel.getDefault().resync();
163 listsManagementPanel.load();
169 void setFocusOnKeywordTextBox() {
170 editListPanel.setFocusOnKeywordTextBox();
178 @SuppressWarnings(
"unchecked")
180 private
void initComponents() {
182 jScrollPane1 =
new javax.swing.JScrollPane();
183 mainSplitPane =
new javax.swing.JSplitPane();
184 leftPanel =
new javax.swing.JPanel();
185 rightPanel =
new javax.swing.JPanel();
187 mainSplitPane.setBorder(null);
188 mainSplitPane.setDividerLocation(361);
189 mainSplitPane.setDividerSize(1);
191 leftPanel.setPreferredSize(
new java.awt.Dimension(309, 327));
192 leftPanel.setVerifyInputWhenFocusTarget(
false);
194 javax.swing.GroupLayout leftPanelLayout =
new javax.swing.GroupLayout(leftPanel);
195 leftPanel.setLayout(leftPanelLayout);
196 leftPanelLayout.setHorizontalGroup(
197 leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
198 .addGap(0, 361, Short.MAX_VALUE)
200 leftPanelLayout.setVerticalGroup(
201 leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
202 .addGap(0, 327, Short.MAX_VALUE)
205 mainSplitPane.setLeftComponent(leftPanel);
207 rightPanel.setPreferredSize(
new java.awt.Dimension(360, 327));
209 javax.swing.GroupLayout rightPanelLayout =
new javax.swing.GroupLayout(rightPanel);
210 rightPanel.setLayout(rightPanelLayout);
211 rightPanelLayout.setHorizontalGroup(
212 rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
213 .addGap(0, 311, Short.MAX_VALUE)
215 rightPanelLayout.setVerticalGroup(
216 rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
217 .addGap(0, 327, Short.MAX_VALUE)
220 mainSplitPane.setRightComponent(rightPanel);
222 jScrollPane1.setViewportView(mainSplitPane);
224 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
225 this.setLayout(layout);
226 layout.setHorizontalGroup(
227 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
228 .addGroup(layout.createSequentialGroup()
229 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 675, Short.MAX_VALUE)
232 layout.setVerticalGroup(
233 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
234 .addGroup(layout.createSequentialGroup()
235 .addComponent(jScrollPane1)
240 private javax.swing.JScrollPane jScrollPane1;
241 private javax.swing.JPanel leftPanel;
242 private javax.swing.JSplitPane mainSplitPane;
243 private javax.swing.JPanel rightPanel;