Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
GlobalListSettingsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2014 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.keywordsearch;
20 
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;
28 
29 final class GlobalListSettingsPanel extends javax.swing.JPanel implements OptionsPanel {
30 
31  private static final long serialVersionUID = 1L;
32 
33  private final GlobalListsManagementPanel listsManagementPanel = new GlobalListsManagementPanel(this);
34  private final GlobalEditListPanel editListPanel = new GlobalEditListPanel();
35 
36  GlobalListSettingsPanel() {
37  initComponents();
38  customizeComponents();
39  setName(org.openide.util.NbBundle.getMessage(DropdownToolbar.class, "ListBundleConfig"));
40  }
41 
42  private void customizeComponents() {
43  listsManagementPanel.addListSelectionListener(editListPanel);
44  editListPanel.addDeleteButtonActionPerformed(new ActionListener() {
45  @Override
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();
54  }
55  }
56  });
57 
58  editListPanel.addSaveButtonActionPerformed(new ActionListener() {
59  @Override
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();
64 
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);
69  return;
70  }
71 
72  String listName = (String) JOptionPane.showInputDialog(
73  null,
74  NbBundle.getMessage(this.getClass(), "KeywordSearch.newKwListTitle"),
75  FEATURE_NAME,
76  JOptionPane.PLAIN_MESSAGE,
77  null,
78  null,
79  currentKeywordList != null ? currentKeywordList.getName() : "");
80  if (listName == null || listName.trim().equals("")) {
81  return;
82  }
83 
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);
87  return;
88  }
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);
93  if (replace) {
94  shouldAdd = true;
95  }
96 
97  } else {
98  shouldAdd = true;
99  }
100 
101  if (shouldAdd) {
102  writer.addList(listName, keywords);
103  KeywordSearchUtil.displayDialog(FEATURE_NAME, NbBundle.getMessage(this.getClass(), "KeywordSearchConfigurationPanel1.customizeComponents.kwListSavedMsg", listName), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
104  }
105 
106  listsManagementPanel.resync();
107  }
108  });
109 
110  mainSplitPane.setLeftComponent(listsManagementPanel);
111  mainSplitPane.setRightComponent(editListPanel);
112  mainSplitPane.revalidate();
113  mainSplitPane.repaint();
114  }
115 
116  @Override
117  public void addPropertyChangeListener(PropertyChangeListener l) {
118  listsManagementPanel.addPropertyChangeListener(l);
119  editListPanel.addPropertyChangeListener(l);
120  }
121 
122  @Override
123  public void removePropertyChangeListener(PropertyChangeListener l) {
124  listsManagementPanel.removePropertyChangeListener(l);
125  editListPanel.removePropertyChangeListener(l);
126  }
127 
128  @Override
129  public void store() {
130  XmlKeywordSearchList.getCurrent().save(false);
131  //refresh the list viewer/searcher panel
132  DropdownListSearchPanel.getDefault().resync();
133  }
134 
135  @Override
136  public void load() {
137  listsManagementPanel.load();
138  }
139 
143  void setFocusOnKeywordTextBox() {
144  editListPanel.setFocusOnKeywordTextBox();
145  }
146 
152  @SuppressWarnings("unchecked")
153  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
154  private void initComponents() {
155 
156  jScrollPane1 = new javax.swing.JScrollPane();
157  mainSplitPane = new javax.swing.JSplitPane();
158  leftPanel = new javax.swing.JPanel();
159  rightPanel = new javax.swing.JPanel();
160 
161  mainSplitPane.setBorder(null);
162  mainSplitPane.setDividerLocation(275);
163  mainSplitPane.setDividerSize(1);
164 
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)
170  );
171  leftPanelLayout.setVerticalGroup(
172  leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
173  .addGap(0, 327, Short.MAX_VALUE)
174  );
175 
176  mainSplitPane.setLeftComponent(leftPanel);
177 
178  rightPanel.setPreferredSize(new java.awt.Dimension(360, 327));
179 
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)
185  );
186  rightPanelLayout.setVerticalGroup(
187  rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
188  .addGap(0, 327, Short.MAX_VALUE)
189  );
190 
191  mainSplitPane.setRightComponent(rightPanel);
192 
193  jScrollPane1.setViewportView(mainSplitPane);
194 
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)
201  .addGap(0, 0, 0))
202  );
203  layout.setVerticalGroup(
204  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
205  .addGroup(layout.createSequentialGroup()
206  .addComponent(jScrollPane1)
207  .addGap(0, 0, 0))
208  );
209  }// </editor-fold>//GEN-END:initComponents
210  // Variables declaration - do not modify//GEN-BEGIN:variables
211  private javax.swing.JScrollPane jScrollPane1;
212  private javax.swing.JPanel leftPanel;
213  private javax.swing.JSplitPane mainSplitPane;
214  private javax.swing.JPanel rightPanel;
215  // End of variables declaration//GEN-END:variables
216 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.