Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
FilesSetPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014-2016 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.modules.interestingitems;
20 
21 import org.openide.DialogDisplayer;
22 import org.openide.NotifyDescriptor;
23 import org.openide.util.NbBundle;
25 
30 public class FilesSetPanel extends javax.swing.JPanel {
31 
32  @NbBundle.Messages({"FilesSetPanel.ingest.title=File Ingest Filter", "FilesSetPanel.ingest.createNewFilter=Create/edit file ingest filters...", "FilesSetPanel.ingest.messages.filtersMustBeNamed=File ingest filters must be named."})
33 
34  private static final String CREATE_NEW_FILE_INGEST_FILTER = Bundle.FilesSetPanel_ingest_createNewFilter();
35  private final String mustBeNamedErrorText;
36 
40  public static String getCreateNewFileIngestFilterString() {
42  }
43 
47  FilesSetPanel(PANEL_TYPE panelType) {
49  if (panelType == PANEL_TYPE.FILE_INGEST_FILTERS) {
50  ignoreKnownFilesCheckbox.setVisible(false);
51  mustBeNamedErrorText = NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.ingest.messages.filtersMustBeNamed");
52  org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.ingest.nameLabel.text")); // NOI18N
53  } else {
54  mustBeNamedErrorText = NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.interesting.messages.filesSetsMustBeNamed");
55  ignoreUnallocCheckbox.setVisible(false);
56  }
57  }
58 
64  FilesSetPanel(FilesSet filesSet, PANEL_TYPE panelType) {
66  if (panelType == PANEL_TYPE.FILE_INGEST_FILTERS) {
67  ignoreKnownFilesCheckbox.setVisible(false);
68  mustBeNamedErrorText = NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.ingest.messages.filtersMustBeNamed");
69  } else {
70  ignoreUnallocCheckbox.setVisible(false);
71  mustBeNamedErrorText = NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.interesting.messages.filesSetsMustBeNamed");
72  }
73  this.nameTextField.setText(filesSet.getName());
74  this.descTextArea.setText(filesSet.getDescription());
75  this.ignoreKnownFilesCheckbox.setSelected(filesSet.ignoresKnownFiles());
76  this.ignoreUnallocCheckbox.setSelected(filesSet.ingoresUnallocatedSpace());
77  }
78 
86  boolean isValidDefinition() {
87  if (this.nameTextField.getText().isEmpty()) {
88  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
89  mustBeNamedErrorText,
90  NotifyDescriptor.WARNING_MESSAGE);
91  DialogDisplayer.getDefault().notify(notifyDesc);
92  return false;
93  } else {
94  // The FileIngestFilters have reserved names for default filter, and creating a new filter from the jComboBox
95  // These names if used would have undefined results, so prohibiting the user from using them is necessary
96  for (FilesSet filesSet : FilesSetsManager.getStandardFileIngestFilters()) {
97  if (this.nameTextField.getText().equals(filesSet.getName())) {
98  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
99  NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.messages.filesSetsReservedName"),
100  NotifyDescriptor.WARNING_MESSAGE);
101  DialogDisplayer.getDefault().notify(notifyDesc);
102  return false;
103  }
104  }
105  if (this.nameTextField.getText().equals(getCreateNewFileIngestFilterString())) {
106  NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
107  NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.messages.filesSetsReservedName"),
108  NotifyDescriptor.WARNING_MESSAGE);
109  DialogDisplayer.getDefault().notify(notifyDesc);
110  return false;
111  }
112  }
113  return true;
114  }
115 
121  String getFilesSetName() {
122  String returnValue = this.nameTextField.getText();
123  return returnValue;
124  }
125 
132  String getFilesSetDescription() {
133  return this.descTextArea.getText();
134  }
135 
142  boolean getFileSetIgnoresKnownFiles() {
143  return this.ignoreKnownFilesCheckbox.isSelected();
144  }
145 
149  boolean getFileSetIgnoresUnallocatedSpace() {
150  return ignoreUnallocCheckbox.isSelected();
151  }
152 
158  @SuppressWarnings("unchecked")
159  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
160  private void initComponents() {
161 
162  nameLabel = new javax.swing.JLabel();
163  nameTextField = new javax.swing.JTextField();
164  descPanel = new javax.swing.JPanel();
165  descScrollPanel = new javax.swing.JScrollPane();
166  descTextArea = new javax.swing.JTextArea();
167  ignoreKnownFilesCheckbox = new javax.swing.JCheckBox();
168  ignoreUnallocCheckbox = new javax.swing.JCheckBox();
169 
170  org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.interesting.nameLabel.text")); // NOI18N
171 
172  descPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.descPanel.border.title"))); // NOI18N
173 
174  descTextArea.setColumns(20);
175  descTextArea.setLineWrap(true);
176  descTextArea.setRows(5);
177  descTextArea.setWrapStyleWord(true);
178  descScrollPanel.setViewportView(descTextArea);
179 
180  javax.swing.GroupLayout descPanelLayout = new javax.swing.GroupLayout(descPanel);
181  descPanel.setLayout(descPanelLayout);
182  descPanelLayout.setHorizontalGroup(
183  descPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
184  .addGroup(descPanelLayout.createSequentialGroup()
185  .addContainerGap()
186  .addComponent(descScrollPanel)
187  .addContainerGap())
188  );
189  descPanelLayout.setVerticalGroup(
190  descPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
191  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, descPanelLayout.createSequentialGroup()
192  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
193  .addComponent(descScrollPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
194  .addContainerGap())
195  );
196 
197  org.openide.awt.Mnemonics.setLocalizedText(ignoreKnownFilesCheckbox, org.openide.util.NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.ignoreKnownFilesCheckbox.text")); // NOI18N
198 
199  org.openide.awt.Mnemonics.setLocalizedText(ignoreUnallocCheckbox, org.openide.util.NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.ignoreUnallocCheckbox.text")); // NOI18N
200  ignoreUnallocCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.ignoreUnallocCheckbox.toolTipText")); // NOI18N
201 
202  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
203  this.setLayout(layout);
204  layout.setHorizontalGroup(
205  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
206  .addGroup(layout.createSequentialGroup()
207  .addContainerGap()
208  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
209  .addComponent(descPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
210  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
211  .addGap(0, 0, Short.MAX_VALUE)
212  .addComponent(nameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
213  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
214  .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE))
215  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
216  .addComponent(ignoreKnownFilesCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
217  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
218  .addComponent(ignoreUnallocCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
219  .addContainerGap())
220  );
221  layout.setVerticalGroup(
222  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
223  .addGroup(layout.createSequentialGroup()
224  .addContainerGap()
225  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
226  .addComponent(nameLabel)
227  .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
228  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
229  .addComponent(descPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
230  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
231  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
232  .addComponent(ignoreKnownFilesCheckbox)
233  .addComponent(ignoreUnallocCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
234  .addContainerGap())
235  );
236  }// </editor-fold>//GEN-END:initComponents
237 
238 
239  // Variables declaration - do not modify//GEN-BEGIN:variables
240  private javax.swing.JPanel descPanel;
241  private javax.swing.JScrollPane descScrollPanel;
242  private javax.swing.JTextArea descTextArea;
243  private javax.swing.JCheckBox ignoreKnownFilesCheckbox;
244  private javax.swing.JCheckBox ignoreUnallocCheckbox;
245  private javax.swing.JLabel nameLabel;
246  private javax.swing.JTextField nameTextField;
247  // End of variables declaration//GEN-END:variables
248 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.