Autopsy  3.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.util.List;
24 import javax.swing.JOptionPane;
25 import org.openide.util.NbBundle;
27 
28 final class GlobalListSettingsPanel extends javax.swing.JPanel implements OptionsPanel {
29 
30  private final GlobalListsManagementPanel listsManagementPanel = new GlobalListsManagementPanel();
31  private final GlobalEditListPanel editListPanel = new GlobalEditListPanel();
32 
33  GlobalListSettingsPanel() {
34  initComponents();
35  customizeComponents();
36  setName(org.openide.util.NbBundle.getMessage(DropdownToolbar.class, "ListBundleConfig"));
37  }
38 
39  private void customizeComponents() {
40  listsManagementPanel.addListSelectionListener(editListPanel);
41  editListPanel.addDeleteButtonActionPerformed(new ActionListener() {
42  @Override
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();
51  }
52  }
53  });
54 
55  editListPanel.addSaveButtonActionPerformed(new ActionListener() {
56  @Override
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();
61 
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);
66  return;
67  }
68 
69  String listName = (String) JOptionPane.showInputDialog(
70  null,
71  NbBundle.getMessage(this.getClass(), "KeywordSearch.newKwListTitle"),
72  FEATURE_NAME,
73  JOptionPane.PLAIN_MESSAGE,
74  null,
75  null,
76  currentKeywordList != null ? currentKeywordList.getName() : "");
77  if (listName == null || listName.trim().equals("")) {
78  return;
79  }
80 
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);
84  return;
85  }
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);
90  if (replace) {
91  shouldAdd = true;
92  }
93 
94  } else {
95  shouldAdd = true;
96  }
97 
98  if (shouldAdd) {
99  writer.addList(listName, keywords);
100  KeywordSearchUtil.displayDialog(FEATURE_NAME, NbBundle.getMessage(this.getClass(), "KeywordSearchConfigurationPanel1.customizeComponents.kwListSavedMsg", listName), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
101  }
102 
103  listsManagementPanel.resync();
104  }
105  });
106 
107  mainSplitPane.setLeftComponent(listsManagementPanel);
108  mainSplitPane.setRightComponent(editListPanel);
109  mainSplitPane.revalidate();
110  mainSplitPane.repaint();
111  }
112 
113  @Override
114  public void store() {
115  XmlKeywordSearchList.getCurrent().save(false);
116  //refresh the list viewer/searcher panel
117  DropdownListSearchPanel.getDefault().resync();
118  }
119 
120  @Override
121  public void load() {
122  listsManagementPanel.load();
123  }
124 
130  @SuppressWarnings("unchecked")
131  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
132  private void initComponents() {
133 
134  mainSplitPane = new javax.swing.JSplitPane();
135  leftPanel = new javax.swing.JPanel();
136  rightPanel = new javax.swing.JPanel();
137 
138  mainSplitPane.setBorder(null);
139  mainSplitPane.setDividerLocation(275);
140 
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)
146  );
147  leftPanelLayout.setVerticalGroup(
148  leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
149  .addGap(0, 327, Short.MAX_VALUE)
150  );
151 
152  mainSplitPane.setLeftComponent(leftPanel);
153 
154  rightPanel.setPreferredSize(new java.awt.Dimension(360, 327));
155 
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)
161  );
162  rightPanelLayout.setVerticalGroup(
163  rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
164  .addGap(0, 327, Short.MAX_VALUE)
165  );
166 
167  mainSplitPane.setRightComponent(rightPanel);
168 
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)
174  );
175  layout.setVerticalGroup(
176  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
177  .addComponent(mainSplitPane)
178  );
179  }// </editor-fold>//GEN-END:initComponents
180  // Variables declaration - do not modify//GEN-BEGIN:variables
181  private javax.swing.JPanel leftPanel;
182  private javax.swing.JSplitPane mainSplitPane;
183  private javax.swing.JPanel rightPanel;
184  // End of variables declaration//GEN-END:variables
185 }

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