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;
33 @SuppressWarnings(
"PMD.SingularField")
34 final class GlobalListSettingsPanel extends javax.swing.JPanel implements OptionsPanel {
36 private static final long serialVersionUID = 1L;
38 private final GlobalListsManagementPanel listsManagementPanel =
new GlobalListsManagementPanel(
this);
39 private final GlobalEditListPanel editListPanel =
new GlobalEditListPanel();
41 GlobalListSettingsPanel() {
43 customizeComponents();
44 setName(
org.openide.util.NbBundle.getMessage(DropdownToolbar.class,
"ListBundleConfig"));
47 private void customizeComponents() {
48 listsManagementPanel.addListSelectionListener(editListPanel);
49 listsManagementPanel.addDeleteButtonActionPerformed(
new ActionListener() {
51 public void actionPerformed(ActionEvent e) {
52 if (KeywordSearchUtil.displayConfirmDialog(NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.title"), NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.body"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN)) {
54 listsManagementPanel.resync();
59 listsManagementPanel.addRenameButtonActionPerformed(
new ActionListener() {
61 public void actionPerformed(ActionEvent e) {
64 listsManagementPanel.resync();
69 listsManagementPanel.addCopyButtonActionPerformed(
new ActionListener() {
71 public void actionPerformed(ActionEvent e) {
73 listsManagementPanel.resync();
77 mainSplitPane.setLeftComponent(listsManagementPanel);
78 mainSplitPane.setRightComponent(editListPanel);
79 mainSplitPane.revalidate();
80 mainSplitPane.repaint();
88 private void deleteAction() {
89 listsManagementPanel.deleteSelected();
90 editListPanel.setCurrentKeywordList(null);
91 editListPanel.setButtonStates();
92 listsManagementPanel.setButtonStates();
101 private boolean copyAction() {
102 final String FEATURE_NAME = NbBundle.getMessage(this.getClass(),
103 "KeywordSearchGlobalListSettingsPanel.component.featureName.text");
104 KeywordList currentKeywordList = editListPanel.getCurrentKeywordList();
106 List<Keyword> keywords =
new ArrayList<>();
107 keywords.addAll(currentKeywordList.getKeywords());
109 String listName = (String) JOptionPane.showInputDialog(
111 NbBundle.getMessage(
this.getClass(),
"KeywordSearch.newKwListTitle"),
113 JOptionPane.PLAIN_MESSAGE,
116 currentKeywordList.getName());
118 if (listName == null) {
122 listName = listName.trim();
124 if (listName.equals(
"") || listName.equals(currentKeywordList.getName())) {
127 XmlKeywordSearchList writer = XmlKeywordSearchList.getCurrent();
128 if (writer.listExists(listName) && writer.getList(listName).isEditable()) {
129 KeywordSearchUtil.displayDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.noOwDefaultMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);
132 if (writer.listExists(listName)) {
133 if (!KeywordSearchUtil.displayConfirmDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.kwListExistMsg", listName),
134 KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN)) {
138 writer.addList(listName, keywords);
139 KeywordSearchUtil.displayDialog(FEATURE_NAME, NbBundle.getMessage(
this.getClass(),
"KeywordSearchConfigurationPanel1.customizeComponents.kwListSavedMsg", listName), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
144 public void addPropertyChangeListener(PropertyChangeListener l) {
145 super.addPropertyChangeListener(l);
165 if (null != listsManagementPanel) {
166 listsManagementPanel.addPropertyChangeListener(l);
168 if (null != editListPanel) {
169 editListPanel.addPropertyChangeListener(l);
174 public void removePropertyChangeListener(PropertyChangeListener l) {
175 super.removePropertyChangeListener(l);
176 listsManagementPanel.removePropertyChangeListener(l);
177 editListPanel.removePropertyChangeListener(l);
181 public void store() {
182 XmlKeywordSearchList.getCurrent().save(
false);
184 DropdownListSearchPanel.getDefault().resync();
189 listsManagementPanel.load();
195 void setFocusOnKeywordTextBox() {
196 editListPanel.setFocusOnKeywordTextBox();
204 @SuppressWarnings(
"unchecked")
206 private
void initComponents() {
208 jScrollPane1 =
new javax.swing.JScrollPane();
209 mainSplitPane =
new javax.swing.JSplitPane();
210 leftPanel =
new javax.swing.JPanel();
211 rightPanel =
new javax.swing.JPanel();
213 mainSplitPane.setBorder(null);
214 mainSplitPane.setDividerSize(1);
216 leftPanel.setPreferredSize(
new java.awt.Dimension(309, 327));
217 leftPanel.setVerifyInputWhenFocusTarget(
false);
219 javax.swing.GroupLayout leftPanelLayout =
new javax.swing.GroupLayout(leftPanel);
220 leftPanel.setLayout(leftPanelLayout);
221 leftPanelLayout.setHorizontalGroup(
222 leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
223 .addGap(0, 309, Short.MAX_VALUE)
225 leftPanelLayout.setVerticalGroup(
226 leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
227 .addGap(0, 327, Short.MAX_VALUE)
230 mainSplitPane.setLeftComponent(leftPanel);
232 rightPanel.setPreferredSize(
new java.awt.Dimension(360, 327));
234 javax.swing.GroupLayout rightPanelLayout =
new javax.swing.GroupLayout(rightPanel);
235 rightPanel.setLayout(rightPanelLayout);
236 rightPanelLayout.setHorizontalGroup(
237 rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
238 .addGap(0, 362, Short.MAX_VALUE)
240 rightPanelLayout.setVerticalGroup(
241 rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
242 .addGap(0, 327, Short.MAX_VALUE)
245 mainSplitPane.setRightComponent(rightPanel);
247 jScrollPane1.setViewportView(mainSplitPane);
249 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
250 this.setLayout(layout);
251 layout.setHorizontalGroup(
252 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
253 .addGroup(layout.createSequentialGroup()
254 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 675, Short.MAX_VALUE)
257 layout.setVerticalGroup(
258 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
259 .addGroup(layout.createSequentialGroup()
260 .addComponent(jScrollPane1)
265 private javax.swing.JScrollPane jScrollPane1;
266 private javax.swing.JPanel leftPanel;
267 private javax.swing.JSplitPane mainSplitPane;
268 private javax.swing.JPanel rightPanel;