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

Copyright © 2012-2019 Basis Technology. Generated on: Tue Jan 7 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.