19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.Component;
22 import org.openide.util.NbBundle;
25 import javax.swing.JFileChooser;
26 import javax.swing.JPanel;
27 import javax.swing.event.DocumentEvent;
28 import javax.swing.event.DocumentListener;
37 @SuppressWarnings(
"PMD.SingularField")
38 final class NewCaseVisualPanel1 extends JPanel implements DocumentListener {
40 private final JFileChooser fileChooser =
new JFileChooser();
41 private final NewCaseWizardPanel1 wizPanel;
48 NewCaseVisualPanel1(NewCaseWizardPanel1 wizPanel) {
49 this.wizPanel = wizPanel;
51 TextFieldListener listener =
new TextFieldListener();
52 caseNameTextField.getDocument().addDocumentListener(listener);
53 caseParentDirTextField.getDocument().addDocumentListener(listener);
54 caseParentDirWarningLabel.setVisible(
false);
63 caseNameTextField.setText(
"");
64 if (UserPreferences.getIsMultiUserModeEnabled()) {
65 multiUserCaseRadioButton.setEnabled(
true);
66 multiUserCaseRadioButton.setSelected(
true);
68 multiUserCaseRadioButton.setEnabled(
false);
69 singleUserCaseRadioButton.setSelected(
true);
81 public String getName() {
82 return NbBundle.getMessage(this.getClass(),
"NewCaseVisualPanel1.getName.text");
90 String getCaseName() {
91 return this.caseNameTextField.getText();
100 void setCaseParentDir(String caseParentDir) {
101 caseParentDirTextField.setText(caseParentDir);
111 String getCaseParentDir() {
112 String parentDir = this.caseParentDirTextField.getText();
113 if (parentDir.endsWith(File.separator) ==
false) {
114 parentDir = parentDir + File.separator;
124 CaseType getCaseType() {
125 CaseType value = CaseType.SINGLE_USER_CASE;
126 if (singleUserCaseRadioButton.isSelected()) {
127 value = CaseType.SINGLE_USER_CASE;
128 }
else if (multiUserCaseRadioButton.isSelected()) {
129 value = CaseType.MULTI_USER_CASE;
139 private void handleUpdate() {
140 wizPanel.fireChangeEvent();
148 private void validateSettings() {
153 caseParentDirWarningLabel.setVisible(
false);
154 String parentDir = getCaseParentDir();
155 if (!PathValidator.isValidForMultiUserCase(parentDir, getCaseType())) {
156 caseParentDirWarningLabel.setVisible(
true);
157 caseParentDirWarningLabel.setText(NbBundle.getMessage(
this.getClass(),
"NewCaseVisualPanel1.CaseFolderOnCDriveError.text"));
164 if(!PathValidator.isValidForRunningOnTarget(parentDir)){
165 caseParentDirWarningLabel.setVisible(
true);
166 if(PlatformUtil.isWindowsOS()){
167 caseParentDirWarningLabel.setText(NbBundle.getMessage(
this.getClass(),
"NewCaseVisualPanel1.CaseFolderOnInternalDriveWindowsError.text" ));
168 }
else if(System.getProperty(
"os.name").toLowerCase().contains(
"nux")) {
169 caseParentDirWarningLabel.setText(NbBundle.getMessage(
this.getClass(),
"NewCaseVisualPanel1.CaseFolderOnInternalDriveLinuxError.text"));
178 String caseName = getCaseName();
179 if (!caseName.equals(
"") && !parentDir.equals(
"")) {
180 caseDirTextField.setText(parentDir + caseName);
181 wizPanel.setIsFinish(
true);
183 caseDirTextField.setText(
"");
184 wizPanel.setIsFinish(
false);
217 private void initComponents() {
219 caseTypeButtonGroup =
new javax.swing.ButtonGroup();
220 caseNameLabel =
new javax.swing.JLabel();
221 caseDirLabel =
new javax.swing.JLabel();
222 caseNameTextField =
new javax.swing.JTextField();
223 caseParentDirTextField =
new javax.swing.JTextField();
224 caseDirBrowseButton =
new javax.swing.JButton();
225 jLabel2 =
new javax.swing.JLabel();
226 caseDirTextField =
new javax.swing.JTextField();
227 singleUserCaseRadioButton =
new javax.swing.JRadioButton();
228 multiUserCaseRadioButton =
new javax.swing.JRadioButton();
229 caseParentDirWarningLabel =
new javax.swing.JLabel();
230 caseTypeLabel =
new javax.swing.JLabel();
232 caseNameLabel.setFont(caseNameLabel.getFont().deriveFont(caseNameLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
233 org.openide.awt.Mnemonics.setLocalizedText(caseNameLabel,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseNameLabel.text_1"));
235 caseDirLabel.setFont(caseDirLabel.getFont().deriveFont(caseDirLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
236 org.openide.awt.Mnemonics.setLocalizedText(caseDirLabel,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseDirLabel.text"));
238 caseNameTextField.setFont(caseNameTextField.getFont().deriveFont(caseNameTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
239 caseNameTextField.setText(
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseNameTextField.text_1"));
241 caseParentDirTextField.setFont(caseParentDirTextField.getFont().deriveFont(caseParentDirTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
242 caseParentDirTextField.setText(
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseParentDirTextField.text"));
244 caseDirBrowseButton.setFont(caseDirBrowseButton.getFont().deriveFont(caseDirBrowseButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
245 org.openide.awt.Mnemonics.setLocalizedText(caseDirBrowseButton,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseDirBrowseButton.text"));
246 caseDirBrowseButton.addActionListener(
new java.awt.event.ActionListener() {
247 public void actionPerformed(java.awt.event.ActionEvent evt) {
248 caseDirBrowseButtonActionPerformed(evt);
252 jLabel2.setFont(jLabel2.getFont().deriveFont(jLabel2.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
253 org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.jLabel2.text_1"));
255 caseDirTextField.setEditable(
false);
256 caseDirTextField.setFont(caseDirTextField.getFont().deriveFont(caseDirTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
257 caseDirTextField.setText(
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseDirTextField.text_1"));
259 caseTypeButtonGroup.add(singleUserCaseRadioButton);
260 singleUserCaseRadioButton.setFont(singleUserCaseRadioButton.getFont().deriveFont(singleUserCaseRadioButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
261 org.openide.awt.Mnemonics.setLocalizedText(singleUserCaseRadioButton,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.singleUserCaseRadioButton.text"));
262 singleUserCaseRadioButton.addActionListener(
new java.awt.event.ActionListener() {
263 public void actionPerformed(java.awt.event.ActionEvent evt) {
264 singleUserCaseRadioButtonActionPerformed(evt);
268 caseTypeButtonGroup.add(multiUserCaseRadioButton);
269 multiUserCaseRadioButton.setFont(multiUserCaseRadioButton.getFont().deriveFont(multiUserCaseRadioButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
270 org.openide.awt.Mnemonics.setLocalizedText(multiUserCaseRadioButton,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.multiUserCaseRadioButton.text"));
271 multiUserCaseRadioButton.addActionListener(
new java.awt.event.ActionListener() {
272 public void actionPerformed(java.awt.event.ActionEvent evt) {
273 multiUserCaseRadioButtonActionPerformed(evt);
277 caseParentDirWarningLabel.setFont(caseParentDirWarningLabel.getFont().deriveFont(caseParentDirWarningLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
278 caseParentDirWarningLabel.setForeground(
new java.awt.Color(255, 0, 0));
279 org.openide.awt.Mnemonics.setLocalizedText(caseParentDirWarningLabel,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseParentDirWarningLabel.text"));
281 caseTypeLabel.setFont(caseTypeLabel.getFont().deriveFont(caseTypeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
282 org.openide.awt.Mnemonics.setLocalizedText(caseTypeLabel,
org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class,
"NewCaseVisualPanel1.caseTypeLabel.text"));
284 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
285 this.setLayout(layout);
286 layout.setHorizontalGroup(
287 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
288 .addGroup(layout.createSequentialGroup()
290 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
291 .addGroup(layout.createSequentialGroup()
292 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
293 .addComponent(jLabel2)
294 .addGroup(layout.createSequentialGroup()
295 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
296 .addComponent(caseDirTextField, javax.swing.GroupLayout.Alignment.LEADING)
297 .addGroup(layout.createSequentialGroup()
298 .addComponent(caseNameLabel)
299 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
300 .addComponent(caseNameTextField))
301 .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
302 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
303 .addComponent(caseDirLabel)
304 .addComponent(caseTypeLabel))
305 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
306 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
307 .addGroup(layout.createSequentialGroup()
308 .addComponent(singleUserCaseRadioButton)
309 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
310 .addComponent(multiUserCaseRadioButton)
311 .addGap(0, 192, Short.MAX_VALUE))
312 .addComponent(caseParentDirTextField))))
313 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
314 .addComponent(caseDirBrowseButton)))
316 .addGroup(layout.createSequentialGroup()
317 .addComponent(caseParentDirWarningLabel)
318 .addGap(0, 0, Short.MAX_VALUE))))
321 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {caseDirLabel, caseNameLabel, caseTypeLabel});
323 layout.setVerticalGroup(
324 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
325 .addGroup(layout.createSequentialGroup()
327 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
328 .addComponent(caseNameLabel)
329 .addComponent(caseNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
330 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
331 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
332 .addComponent(caseDirLabel)
333 .addComponent(caseParentDirTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
334 .addComponent(caseDirBrowseButton))
335 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
336 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
337 .addComponent(singleUserCaseRadioButton)
338 .addComponent(multiUserCaseRadioButton)
339 .addComponent(caseTypeLabel))
340 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
341 .addComponent(jLabel2)
342 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
343 .addComponent(caseDirTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
345 .addComponent(caseParentDirWarningLabel)
346 .addContainerGap(115, Short.MAX_VALUE))
357 private void caseDirBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {
358 fileChooser.setDragEnabled(
false);
359 if (!caseParentDirTextField.getText().trim().equals(
"")) {
360 fileChooser.setCurrentDirectory(
new File(caseParentDirTextField.getText()));
362 fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
363 int choice = fileChooser.showDialog((Component) evt.getSource(), NbBundle.getMessage(this.getClass(),
364 "NewCaseVisualPanel1.caseDirBrowse.selectButton.text"));
365 if (JFileChooser.APPROVE_OPTION == choice) {
366 String path = fileChooser.getSelectedFile().getPath();
367 caseParentDirTextField.setText(path);
371 private void singleUserCaseRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
375 private void multiUserCaseRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
380 private javax.swing.JButton caseDirBrowseButton;
381 private javax.swing.JLabel caseDirLabel;
382 private javax.swing.JTextField caseDirTextField;
383 private javax.swing.JLabel caseNameLabel;
384 private javax.swing.JTextField caseNameTextField;
385 private javax.swing.JTextField caseParentDirTextField;
386 private javax.swing.JLabel caseParentDirWarningLabel;
387 private javax.swing.ButtonGroup caseTypeButtonGroup;
388 private javax.swing.JLabel caseTypeLabel;
389 private javax.swing.JLabel jLabel2;
390 private javax.swing.JRadioButton multiUserCaseRadioButton;
391 private javax.swing.JRadioButton singleUserCaseRadioButton;
401 public void insertUpdate(DocumentEvent e) {
402 this.wizPanel.fireChangeEvent();
414 public void removeUpdate(DocumentEvent e) {
415 this.wizPanel.fireChangeEvent();
425 public void changedUpdate(DocumentEvent e) {
426 this.wizPanel.fireChangeEvent();
437 public void updateUI(DocumentEvent e) {
439 String caseName = getCaseName();
440 String parentDir = getCaseParentDir();
442 if (!caseName.equals(
"") && !parentDir.equals(
"")) {
443 caseDirTextField.setText(parentDir + caseName);
444 wizPanel.setIsFinish(
true);
446 caseDirTextField.setText(
"");
447 wizPanel.setIsFinish(
false);
void insertUpdate(DocumentEvent e)
void removeUpdate(DocumentEvent e)
void changedUpdate(DocumentEvent e)