19 package org.sleuthkit.autopsy.casemodule;
22 import java.awt.Component;
23 import org.openide.util.NbBundle;
26 import javax.swing.JFileChooser;
27 import javax.swing.JPanel;
28 import javax.swing.event.DocumentEvent;
29 import javax.swing.event.DocumentListener;
38 @SuppressWarnings(
"PMD.SingularField")
39 final class NewCaseVisualPanel1 extends JPanel implements DocumentListener {
41 private final JFileChooser fileChooser =
new JFileChooser();
42 private final NewCaseWizardPanel1 wizPanel;
49 NewCaseVisualPanel1(NewCaseWizardPanel1 wizPanel) {
50 this.wizPanel = wizPanel;
52 TextFieldListener listener =
new TextFieldListener();
53 caseNameTextField.getDocument().addDocumentListener(listener);
54 caseParentDirTextField.getDocument().addDocumentListener(listener);
55 caseParentDirWarningLabel.setVisible(
false);
64 caseNameTextField.setText(
"");
65 if (FeatureAccessUtils.canCreateMultiUserCases()) {
66 multiUserCaseRadioButton.setEnabled(
true);
67 multiUserCaseRadioButton.setSelected(
true);
69 multiUserCaseRadioButton.setEnabled(
false);
70 singleUserCaseRadioButton.setSelected(
true);
82 public String getName() {
83 return NbBundle.getMessage(this.getClass(),
"NewCaseVisualPanel1.getName.text");
91 String getCaseName() {
92 return this.caseNameTextField.getText().trim();
101 void setCaseParentDir(String caseParentDir) {
102 caseParentDirTextField.setText(caseParentDir);
112 String getCaseParentDir() {
113 String parentDir = this.caseParentDirTextField.getText().trim();
114 if (parentDir.endsWith(File.separator) ==
false) {
115 parentDir = parentDir + File.separator;
125 CaseType getCaseType() {
126 CaseType value = CaseType.SINGLE_USER_CASE;
127 if (singleUserCaseRadioButton.isSelected()) {
128 value = CaseType.SINGLE_USER_CASE;
129 }
else if (multiUserCaseRadioButton.isSelected()) {
130 value = CaseType.MULTI_USER_CASE;
140 private void handleUpdate() {
141 wizPanel.fireChangeEvent();
149 private void validateSettings() {
154 caseParentDirWarningLabel.setVisible(
false);
155 String parentDir = getCaseParentDir();
156 if (!PathValidator.isValidForMultiUserCase(parentDir, getCaseType())) {
157 caseParentDirWarningLabel.setVisible(
true);
158 caseParentDirWarningLabel.setText(NbBundle.getMessage(
this.getClass(),
"NewCaseVisualPanel1.CaseFolderOnCDriveError.text"));
165 if(!PathValidator.isValidForRunningOnTarget(parentDir)){
166 caseParentDirWarningLabel.setVisible(
true);
167 if(PlatformUtil.isWindowsOS()){
168 caseParentDirWarningLabel.setText(NbBundle.getMessage(
this.getClass(),
"NewCaseVisualPanel1.CaseFolderOnInternalDriveWindowsError.text" ));
169 }
else if(System.getProperty(
"os.name").toLowerCase().contains(
"nux")) {
170 caseParentDirWarningLabel.setText(NbBundle.getMessage(
this.getClass(),
"NewCaseVisualPanel1.CaseFolderOnInternalDriveLinuxError.text"));
179 String caseName = getCaseName();
180 if (!caseName.equals(
"") && !parentDir.equals(
"")) {
181 caseDirTextField.setText(parentDir + caseName);
182 wizPanel.setIsFinish(
true);
184 caseDirTextField.setText(
"");
185 wizPanel.setIsFinish(
false);
218 private void initComponents() {
220 caseTypeButtonGroup =
new javax.swing.ButtonGroup();
221 caseNameLabel =
new javax.swing.JLabel();
222 caseDirLabel =
new javax.swing.JLabel();
223 caseNameTextField =
new javax.swing.JTextField();
224 caseParentDirTextField =
new javax.swing.JTextField();
225 caseDirBrowseButton =
new javax.swing.JButton();
226 jLabel2 =
new javax.swing.JLabel();
227 caseDirTextField =
new javax.swing.JTextField();
228 singleUserCaseRadioButton =
new javax.swing.JRadioButton();
229 multiUserCaseRadioButton =
new javax.swing.JRadioButton();
230 caseParentDirWarningLabel =
new javax.swing.JLabel();
231 caseTypeLabel =
new javax.swing.JLabel();
233 caseNameLabel.setFont(caseNameLabel.getFont().deriveFont(caseNameLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
234 org.openide.awt.Mnemonics.setLocalizedText(caseNameLabel,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseNameLabel.text_1"));
236 caseDirLabel.setFont(caseDirLabel.getFont().deriveFont(caseDirLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
237 org.openide.awt.Mnemonics.setLocalizedText(caseDirLabel,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseDirLabel.text"));
239 caseNameTextField.setFont(caseNameTextField.getFont().deriveFont(caseNameTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
240 caseNameTextField.setText(
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseNameTextField.text_1"));
242 caseParentDirTextField.setFont(caseParentDirTextField.getFont().deriveFont(caseParentDirTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
243 caseParentDirTextField.setText(
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseParentDirTextField.text"));
245 caseDirBrowseButton.setFont(caseDirBrowseButton.getFont().deriveFont(caseDirBrowseButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
246 org.openide.awt.Mnemonics.setLocalizedText(caseDirBrowseButton,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseDirBrowseButton.text"));
247 caseDirBrowseButton.addActionListener(
new java.awt.event.ActionListener() {
248 public void actionPerformed(java.awt.event.ActionEvent evt) {
249 caseDirBrowseButtonActionPerformed(evt);
253 jLabel2.setFont(jLabel2.getFont().deriveFont(jLabel2.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
254 org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.jLabel2.text_1"));
256 caseDirTextField.setEditable(
false);
257 caseDirTextField.setFont(caseDirTextField.getFont().deriveFont(caseDirTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
258 caseDirTextField.setText(
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseDirTextField.text_1"));
260 caseTypeButtonGroup.add(singleUserCaseRadioButton);
261 singleUserCaseRadioButton.setFont(singleUserCaseRadioButton.getFont().deriveFont(singleUserCaseRadioButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
262 org.openide.awt.Mnemonics.setLocalizedText(singleUserCaseRadioButton,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.singleUserCaseRadioButton.text"));
263 singleUserCaseRadioButton.addActionListener(
new java.awt.event.ActionListener() {
264 public void actionPerformed(java.awt.event.ActionEvent evt) {
265 singleUserCaseRadioButtonActionPerformed(evt);
269 caseTypeButtonGroup.add(multiUserCaseRadioButton);
270 multiUserCaseRadioButton.setFont(multiUserCaseRadioButton.getFont().deriveFont(multiUserCaseRadioButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
271 org.openide.awt.Mnemonics.setLocalizedText(multiUserCaseRadioButton,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.multiUserCaseRadioButton.text"));
272 multiUserCaseRadioButton.addActionListener(
new java.awt.event.ActionListener() {
273 public void actionPerformed(java.awt.event.ActionEvent evt) {
274 multiUserCaseRadioButtonActionPerformed(evt);
278 caseParentDirWarningLabel.setFont(caseParentDirWarningLabel.getFont().deriveFont(caseParentDirWarningLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
279 caseParentDirWarningLabel.setForeground(
new java.awt.Color(255, 0, 0));
280 org.openide.awt.Mnemonics.setLocalizedText(caseParentDirWarningLabel,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseParentDirWarningLabel.text"));
282 caseTypeLabel.setFont(caseTypeLabel.getFont().deriveFont(caseTypeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
283 org.openide.awt.Mnemonics.setLocalizedText(caseTypeLabel,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseTypeLabel.text"));
285 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
286 this.setLayout(layout);
287 layout.setHorizontalGroup(
288 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
289 .addGroup(layout.createSequentialGroup()
291 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
292 .addGroup(layout.createSequentialGroup()
293 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
294 .addComponent(jLabel2)
295 .addGroup(layout.createSequentialGroup()
296 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
297 .addComponent(caseDirTextField, javax.swing.GroupLayout.Alignment.LEADING)
298 .addGroup(layout.createSequentialGroup()
299 .addComponent(caseNameLabel)
300 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
301 .addComponent(caseNameTextField))
302 .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
303 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
304 .addComponent(caseDirLabel)
305 .addComponent(caseTypeLabel))
306 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
307 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
308 .addGroup(layout.createSequentialGroup()
309 .addComponent(singleUserCaseRadioButton)
310 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
311 .addComponent(multiUserCaseRadioButton)
312 .addGap(0, 192, Short.MAX_VALUE))
313 .addComponent(caseParentDirTextField))))
314 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
315 .addComponent(caseDirBrowseButton)))
317 .addGroup(layout.createSequentialGroup()
318 .addComponent(caseParentDirWarningLabel)
319 .addGap(0, 0, Short.MAX_VALUE))))
322 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {caseDirLabel, caseNameLabel, caseTypeLabel});
324 layout.setVerticalGroup(
325 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
326 .addGroup(layout.createSequentialGroup()
328 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
329 .addComponent(caseNameLabel)
330 .addComponent(caseNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
331 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
332 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
333 .addComponent(caseDirLabel)
334 .addComponent(caseParentDirTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
335 .addComponent(caseDirBrowseButton))
336 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
337 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
338 .addComponent(singleUserCaseRadioButton)
339 .addComponent(multiUserCaseRadioButton)
340 .addComponent(caseTypeLabel))
341 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
342 .addComponent(jLabel2)
343 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
344 .addComponent(caseDirTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
346 .addComponent(caseParentDirWarningLabel)
347 .addContainerGap(115, Short.MAX_VALUE))
358 private void caseDirBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {
359 fileChooser.setDragEnabled(
false);
360 if (!caseParentDirTextField.getText().trim().equals(
"")) {
361 fileChooser.setCurrentDirectory(
new File(caseParentDirTextField.getText()));
363 fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
364 int choice = fileChooser.showDialog((Component) evt.getSource(), NbBundle.getMessage(this.getClass(),
365 "NewCaseVisualPanel1.caseDirBrowse.selectButton.text"));
366 if (JFileChooser.APPROVE_OPTION == choice) {
367 String path = fileChooser.getSelectedFile().getPath();
368 caseParentDirTextField.setText(path);
372 private void singleUserCaseRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
376 private void multiUserCaseRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
381 private javax.swing.JButton caseDirBrowseButton;
382 private javax.swing.JLabel caseDirLabel;
383 private javax.swing.JTextField caseDirTextField;
384 private javax.swing.JLabel caseNameLabel;
385 private javax.swing.JTextField caseNameTextField;
386 private javax.swing.JTextField caseParentDirTextField;
387 private javax.swing.JLabel caseParentDirWarningLabel;
388 private javax.swing.ButtonGroup caseTypeButtonGroup;
389 private javax.swing.JLabel caseTypeLabel;
390 private javax.swing.JLabel jLabel2;
391 private javax.swing.JRadioButton multiUserCaseRadioButton;
392 private javax.swing.JRadioButton singleUserCaseRadioButton;
402 public void insertUpdate(DocumentEvent e) {
403 this.wizPanel.fireChangeEvent();
415 public void removeUpdate(DocumentEvent e) {
416 this.wizPanel.fireChangeEvent();
426 public void changedUpdate(DocumentEvent e) {
427 this.wizPanel.fireChangeEvent();
438 public void updateUI(DocumentEvent e) {
440 String caseName = getCaseName();
441 String parentDir = getCaseParentDir();
443 if (!caseName.equals(
"") && !parentDir.equals(
"")) {
444 caseDirTextField.setText(parentDir + caseName);
445 wizPanel.setIsFinish(
true);
447 caseDirTextField.setText(
"");
448 wizPanel.setIsFinish(
false);
void insertUpdate(DocumentEvent e)
void removeUpdate(DocumentEvent e)
void changedUpdate(DocumentEvent e)