20 package org.sleuthkit.autopsy.casemodule;
22 import org.openide.util.NbBundle;
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;
37 final class NewCaseVisualPanel1
extends JPanel implements DocumentListener{
39 private JFileChooser fc =
new JFileChooser();
40 private NewCaseWizardPanel1 wizPanel;
42 NewCaseVisualPanel1(NewCaseWizardPanel1 wizPanel) {
44 this.wizPanel = wizPanel;
45 caseNameTextField.getDocument().addDocumentListener(
this);
46 caseParentDirTextField.getDocument().addDocumentListener(
this);
56 public String getName() {
57 return NbBundle.getMessage(this.getClass(),
"NewCaseVisualPanel1.getName.text");
65 public String getCaseName(){
66 return this.caseNameTextField.getText();
75 public String getCaseParentDir(){
76 String parentDir = this.caseParentDirTextField.getText();
78 if (parentDir.endsWith(File.separator) ==
false) {
79 parentDir = parentDir + File.separator;
84 public JTextField getCaseParentDirTextField(){
85 return this.caseParentDirTextField;
93 private void initComponents() {
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();
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"));
108 org.openide.awt.Mnemonics.setLocalizedText(caseNameLabel,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseNameLabel.text_1"));
110 org.openide.awt.Mnemonics.setLocalizedText(caseDirLabel,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseDirLabel.text"));
112 caseNameTextField.setText(
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseNameTextField.text_1"));
114 caseParentDirTextField.setText(
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseParentDirTextField.text"));
116 org.openide.awt.Mnemonics.setLocalizedText(caseDirBrowseButton,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseDirBrowseButton.text"));
117 caseDirBrowseButton.addActionListener(
new java.awt.event.ActionListener() {
118 public void actionPerformed(java.awt.event.ActionEvent evt) {
119 caseDirBrowseButtonActionPerformed(evt);
123 org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.jLabel2.text_1"));
125 caseDirTextField.setEditable(
false);
126 caseDirTextField.setText(
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseDirTextField.text_1"));
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()
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))
152 layout.setVerticalGroup(
153 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
154 .addGroup(layout.createSequentialGroup()
156 .addComponent(jLabel1)
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))
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))
181 private void caseDirBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {
183 fc.setDragEnabled(
false);
184 if(!caseParentDirTextField.getText().trim().equals(
"")){
185 fc.setCurrentDirectory(
new File(caseParentDirTextField.getText()));
187 fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
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);
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;
217 public void insertUpdate(DocumentEvent e) {
218 this.wizPanel.fireChangeEvent();
230 public void removeUpdate(DocumentEvent e) {
231 this.wizPanel.fireChangeEvent();
241 public void changedUpdate(DocumentEvent e) {
242 this.wizPanel.fireChangeEvent();
252 public void updateUI(DocumentEvent e) {
254 String caseName = getCaseName();
255 String parentDir = getCaseParentDir();
257 if(!caseName.equals(
"") && !parentDir.equals(
"")){
258 caseDirTextField.setText( parentDir + caseName);
259 wizPanel.setIsFinish(
true);
262 caseDirTextField.setText(
"");
263 wizPanel.setIsFinish(
false);