Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
NewCaseVisualPanel1.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 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 
20 package org.sleuthkit.autopsy.casemodule;
21 
22 import org.openide.util.NbBundle;
23 
24 import java.awt.*;
25 import java.io.File;
26 import javax.swing.JFileChooser;
27 import javax.swing.JPanel;
28 import javax.swing.JTextField;
29 import javax.swing.event.DocumentEvent;
30 import javax.swing.event.DocumentListener;
31 
37 final class NewCaseVisualPanel1 extends JPanel implements DocumentListener{
38 
39  private JFileChooser fc = new JFileChooser();
40  private NewCaseWizardPanel1 wizPanel;
41 
42  NewCaseVisualPanel1(NewCaseWizardPanel1 wizPanel) {
43  initComponents();
44  this.wizPanel = wizPanel;
45  caseNameTextField.getDocument().addDocumentListener(this);
46  caseParentDirTextField.getDocument().addDocumentListener(this);
47  }
48 
55  @Override
56  public String getName() {
57  return NbBundle.getMessage(this.getClass(), "NewCaseVisualPanel1.getName.text");
58  }
59 
65  public String getCaseName(){
66  return this.caseNameTextField.getText();
67  }
68 
75  public String getCaseParentDir(){
76  String parentDir = this.caseParentDirTextField.getText();
77 
78  if (parentDir.endsWith(File.separator) == false) {
79  parentDir = parentDir + File.separator;
80  }
81  return parentDir;
82  }
83 
84  public JTextField getCaseParentDirTextField(){
85  return this.caseParentDirTextField;
86  }
87 
92  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
93  private void initComponents() {
94 
95  jLabel1 = new javax.swing.JLabel();
96  caseNameLabel = new javax.swing.JLabel();
97  caseDirLabel = new javax.swing.JLabel();
98  caseNameTextField = new javax.swing.JTextField();
99  caseParentDirTextField = new javax.swing.JTextField();
100  caseDirBrowseButton = new javax.swing.JButton();
101  jLabel2 = new javax.swing.JLabel();
102  caseDirTextField = new javax.swing.JTextField();
103 
104  jLabel1.setFont(jLabel1.getFont().deriveFont(Font.BOLD, 14));
105  org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle
106  .getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.jLabel1.text_1")); // NOI18N
107 
108  org.openide.awt.Mnemonics.setLocalizedText(caseNameLabel, org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.caseNameLabel.text_1")); // NOI18N
109 
110  org.openide.awt.Mnemonics.setLocalizedText(caseDirLabel, org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.caseDirLabel.text")); // NOI18N
111 
112  caseNameTextField.setText(org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.caseNameTextField.text_1")); // NOI18N
113 
114  caseParentDirTextField.setText(org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.caseParentDirTextField.text")); // NOI18N
115 
116  org.openide.awt.Mnemonics.setLocalizedText(caseDirBrowseButton, org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.caseDirBrowseButton.text")); // NOI18N
117  caseDirBrowseButton.addActionListener(new java.awt.event.ActionListener() {
118  public void actionPerformed(java.awt.event.ActionEvent evt) {
119  caseDirBrowseButtonActionPerformed(evt);
120  }
121  });
122 
123  org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.jLabel2.text_1")); // NOI18N
124 
125  caseDirTextField.setEditable(false);
126  caseDirTextField.setText(org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.caseDirTextField.text_1")); // NOI18N
127 
128  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
129  this.setLayout(layout);
130  layout.setHorizontalGroup(
131  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
132  .addGroup(layout.createSequentialGroup()
133  .addContainerGap()
134  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
135  .addComponent(jLabel2)
136  .addGroup(layout.createSequentialGroup()
137  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
138  .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
139  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
140  .addComponent(caseDirLabel)
141  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
142  .addComponent(caseParentDirTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE))
143  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
144  .addComponent(caseNameLabel)
145  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
146  .addComponent(caseNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE))
147  .addComponent(caseDirTextField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 380, javax.swing.GroupLayout.PREFERRED_SIZE))
148  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
149  .addComponent(caseDirBrowseButton)))
150  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
151  );
152  layout.setVerticalGroup(
153  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
154  .addGroup(layout.createSequentialGroup()
155  .addGap(31, 31, 31)
156  .addComponent(jLabel1)
157  .addGap(18, 18, 18)
158  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
159  .addComponent(caseNameLabel)
160  .addComponent(caseNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
161  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
162  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
163  .addComponent(caseDirLabel)
164  .addComponent(caseParentDirTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
165  .addComponent(caseDirBrowseButton))
166  .addGap(18, 18, 18)
167  .addComponent(jLabel2)
168  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
169  .addComponent(caseDirTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
170  .addContainerGap(32, Short.MAX_VALUE))
171  );
172  }// </editor-fold>//GEN-END:initComponents
173 
181  private void caseDirBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_caseDirBrowseButtonActionPerformed
182  // show the directory chooser where the case directory will be created
183  fc.setDragEnabled(false);
184  if(!caseParentDirTextField.getText().trim().equals("")){
185  fc.setCurrentDirectory(new File(caseParentDirTextField.getText()));
186  }
187  fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
188  //fc.setSelectedFile(new File("C:\\Program Files\\"));
189  //disableTextField(fc); // disable all the text field on the file chooser
190 
191  int returnValue = fc.showDialog((Component)evt.getSource(), NbBundle.getMessage(this.getClass(),
192  "NewCaseVisualPanel1.caseDirBrowse.selectButton.text"));
193  if(returnValue == JFileChooser.APPROVE_OPTION){
194  String path = fc.getSelectedFile().getPath();
195  caseParentDirTextField.setText(path); // put the path to the textfield
196  }
197  }//GEN-LAST:event_caseDirBrowseButtonActionPerformed
198 
199  // Variables declaration - do not modify//GEN-BEGIN:variables
200  private javax.swing.JButton caseDirBrowseButton;
201  private javax.swing.JLabel caseDirLabel;
202  private javax.swing.JTextField caseDirTextField;
203  private javax.swing.JLabel caseNameLabel;
204  private javax.swing.JTextField caseNameTextField;
205  private javax.swing.JTextField caseParentDirTextField;
206  private javax.swing.JLabel jLabel1;
207  private javax.swing.JLabel jLabel2;
208  // End of variables declaration//GEN-END:variables
209 
216  @Override
217  public void insertUpdate(DocumentEvent e) {
218  this.wizPanel.fireChangeEvent();
219  updateUI(e);
220  }
221 
229  @Override
230  public void removeUpdate(DocumentEvent e) {
231  this.wizPanel.fireChangeEvent();
232  updateUI(e);
233  }
234 
240  @Override
241  public void changedUpdate(DocumentEvent e) {
242  this.wizPanel.fireChangeEvent();
243  updateUI(e);
244  }
245 
252  public void updateUI(DocumentEvent e) {
253 
254  String caseName = getCaseName();
255  String parentDir = getCaseParentDir();
256 
257  if(!caseName.equals("") && !parentDir.equals("")){
258  caseDirTextField.setText( parentDir + caseName);
259  wizPanel.setIsFinish(true);
260  }
261  else{
262  caseDirTextField.setText("");
263  wizPanel.setIsFinish(false);
264  }
265  }
266 }

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.