19 package org.sleuthkit.autopsy.casemodule;
22 import java.util.Calendar;
23 import java.util.List;
24 import java.util.SimpleTimeZone;
25 import java.util.TimeZone;
26 import java.util.logging.Level;
27 import javax.swing.JFileChooser;
28 import javax.swing.JOptionPane;
29 import javax.swing.JPanel;
30 import javax.swing.event.DocumentEvent;
31 import javax.swing.event.DocumentListener;
32 import javax.swing.filechooser.FileFilter;
33 import org.apache.commons.lang3.StringUtils;
34 import org.openide.util.NbBundle;
48 @SuppressWarnings(
"PMD.SingularField")
52 private static final String PROP_LASTIMAGE_PATH =
"LBL_LastImage_PATH";
53 private static final String[] SECTOR_SIZE_CHOICES = {
"Auto Detect",
"512",
"1024",
"2048",
"4096"};
55 private final JFileChooser fileChooser =
new JFileChooser();
70 private ImageFilePanel(String context, List<FileFilter> fileChooserFilters) {
71 this.contextName = context;
75 for (String
id : SimpleTimeZone.getAvailableIDs()) {
76 timeZoneComboBox.addItem(timeZoneToString(TimeZone.getTimeZone(
id)));
79 timeZoneComboBox.setSelectedItem(timeZoneToString(Calendar.getInstance().getTimeZone()));
82 for (String choice : SECTOR_SIZE_CHOICES) {
83 sectorSizeComboBox.addItem(choice);
85 sectorSizeComboBox.setSelectedIndex(0);
87 pathErrorLabel.setVisible(
false);
89 fileChooser.setDragEnabled(
false);
90 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
91 fileChooser.setMultiSelectionEnabled(
false);
92 fileChooserFilters.forEach(fileChooser::addChoosableFileFilter);
93 if (fileChooserFilters.isEmpty() ==
false) {
94 fileChooser.setFileFilter(fileChooserFilters.get(0));
111 instance.
pathTextField.getDocument().addDocumentListener(instance);
123 pathLabel =
new javax.swing.JLabel();
124 browseButton =
new javax.swing.JButton();
125 pathTextField =
new javax.swing.JTextField();
126 timeZoneLabel =
new javax.swing.JLabel();
127 timeZoneComboBox =
new javax.swing.JComboBox<>();
128 noFatOrphansCheckbox =
new javax.swing.JCheckBox();
129 descLabel =
new javax.swing.JLabel();
130 pathErrorLabel =
new javax.swing.JLabel();
131 sectorSizeLabel =
new javax.swing.JLabel();
132 sectorSizeComboBox =
new javax.swing.JComboBox<>();
134 setMinimumSize(
new java.awt.Dimension(0, 65));
135 setPreferredSize(
new java.awt.Dimension(403, 65));
137 org.openide.awt.Mnemonics.setLocalizedText(pathLabel,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.pathLabel.text"));
139 org.openide.awt.Mnemonics.setLocalizedText(browseButton,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.browseButton.text"));
140 browseButton.addActionListener(
new java.awt.event.ActionListener() {
141 public void actionPerformed(java.awt.event.ActionEvent evt) {
142 browseButtonActionPerformed(evt);
146 pathTextField.setText(
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.pathTextField.text"));
148 org.openide.awt.Mnemonics.setLocalizedText(timeZoneLabel,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.timeZoneLabel.text"));
150 timeZoneComboBox.setMaximumRowCount(30);
152 org.openide.awt.Mnemonics.setLocalizedText(noFatOrphansCheckbox,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.noFatOrphansCheckbox.text"));
153 noFatOrphansCheckbox.setToolTipText(
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.noFatOrphansCheckbox.toolTipText"));
155 org.openide.awt.Mnemonics.setLocalizedText(descLabel,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.descLabel.text"));
157 pathErrorLabel.setForeground(
new java.awt.Color(255, 0, 0));
158 org.openide.awt.Mnemonics.setLocalizedText(pathErrorLabel,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.pathErrorLabel.text"));
160 org.openide.awt.Mnemonics.setLocalizedText(sectorSizeLabel,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.sectorSizeLabel.text"));
162 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
163 this.setLayout(layout);
164 layout.setHorizontalGroup(
165 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
166 .addGroup(layout.createSequentialGroup()
167 .addComponent(pathTextField)
168 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
169 .addComponent(browseButton)
171 .addGroup(layout.createSequentialGroup()
172 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
173 .addGroup(layout.createSequentialGroup()
174 .addComponent(timeZoneLabel)
175 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
176 .addComponent(timeZoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
177 .addComponent(pathLabel)
178 .addComponent(noFatOrphansCheckbox)
179 .addGroup(layout.createSequentialGroup()
181 .addComponent(descLabel))
182 .addComponent(pathErrorLabel)
183 .addGroup(layout.createSequentialGroup()
184 .addComponent(sectorSizeLabel)
185 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
186 .addComponent(sectorSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)))
187 .addGap(0, 20, Short.MAX_VALUE))
189 layout.setVerticalGroup(
190 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
191 .addGroup(layout.createSequentialGroup()
192 .addComponent(pathLabel)
193 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
194 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
195 .addComponent(browseButton)
196 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
198 .addComponent(pathErrorLabel)
200 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
201 .addComponent(timeZoneLabel)
202 .addComponent(timeZoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
203 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
204 .addComponent(noFatOrphansCheckbox)
205 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
206 .addComponent(descLabel)
208 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
209 .addComponent(sectorSizeLabel)
210 .addComponent(sectorSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
211 .addContainerGap(43, Short.MAX_VALUE))
215 @NbBundle.Messages({
"ImageFilePanel.000.confirmationMessage=The selected file"
216 +
" has extenson .001 but there is a .000 file in the sequence of raw images."
217 +
"\nShould the .000 file be used as the start, instead of the selected .001 file?\n"})
219 String oldText = getContentPaths();
221 File currentDir =
new File(oldText);
222 if (currentDir.exists()) {
223 fileChooser.setCurrentDirectory(currentDir);
226 if (fileChooser.showOpenDialog(
this) == JFileChooser.APPROVE_OPTION) {
227 String path = fileChooser.getSelectedFile().getPath();
228 if (path.endsWith(
".001")) {
229 String zeroX3_path = StringUtils.removeEnd(path,
".001") +
".000";
230 if (
new File(zeroX3_path).exists()) {
231 int showConfirmDialog = JOptionPane.showConfirmDialog(
this,
232 Bundle.ImageFilePanel_000_confirmationMessage(),
233 "Choose .001 file?", JOptionPane.YES_NO_OPTION);
234 if (showConfirmDialog == JOptionPane.YES_OPTION) {
239 setContentPath(path);
264 return pathTextField.getText();
273 pathTextField.setText(s);
282 int sectorSizeSelectionIndex = sectorSizeComboBox.getSelectedIndex();
284 if (sectorSizeSelectionIndex == 0) {
288 return Integer.valueOf((String) sectorSizeComboBox.getSelectedItem());
292 String tz = timeZoneComboBox.getSelectedItem().toString();
293 return tz.substring(tz.indexOf(
')') + 2).trim();
297 return noFatOrphansCheckbox.isSelected();
302 pathTextField.setText(null);
310 @NbBundle.Messages({
"ImageFilePanel.pathValidation.dataSourceOnCDriveError=Warning: Path to multi-user data source is on \"C:\" drive",
311 "ImageFilePanel.pathValidation.getOpenCase.Error=Warning: Exception while getting open case."
314 pathErrorLabel.setVisible(
false);
315 String path = getContentPaths();
316 if (StringUtils.isBlank(path)) {
323 pathErrorLabel.setVisible(
true);
324 pathErrorLabel.setText(Bundle.ImageFilePanel_pathValidation_dataSourceOnCDriveError());
327 pathErrorLabel.setVisible(
true);
328 pathErrorLabel.setText(Bundle.ImageFilePanel_pathValidation_getOpenCase_Error());
331 return new File(path).isFile()
337 String imagePathName = getContentPaths();
338 if (null != imagePathName) {
339 String imagePath = imagePathName.substring(0, imagePathName.lastIndexOf(File.separator) + 1);
346 if (StringUtils.isNotBlank(lastImagePath)) {
347 setContentPath(lastImagePath);
360 int offset = zone.getRawOffset() / 1000;
361 int hour = offset / 3600;
362 int minutes = (offset % 3600) / 60;
363 return String.format(
"(GMT%+d:%02d) %s", hour, minutes, zone.getID());
387 @NbBundle.Messages({
"ImageFilePanel.moduleErr=Module Error",
388 "ImageFilePanel.moduleErr.msg=A module caused an error listening to ImageFilePanel updates."
389 +
" See log to determine which module. Some data could be incomplete.\n"})
393 }
catch (Exception e) {
394 logger.log(Level.SEVERE,
"ImageFilePanel listener threw exception", e);
403 pathTextField.requestFocusInWindow();
javax.swing.JLabel descLabel
static boolean isPhysicalDrive(String path)
boolean getNoFatOrphans()
javax.swing.JLabel timeZoneLabel
javax.swing.JLabel pathLabel
static String timeZoneToString(TimeZone zone)
javax.swing.JComboBox< String > sectorSizeComboBox
static synchronized ImageFilePanel createInstance(String context, List< FileFilter > fileChooserFilters)
static boolean isValid(String path, Case.CaseType caseType)
void setContentPath(String s)
void browseButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JLabel sectorSizeLabel
static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal)
ImageFilePanel(String context, List< FileFilter > fileChooserFilters)
javax.swing.JComboBox< String > timeZoneComboBox
void changedUpdate(DocumentEvent e)
static String getConfigSetting(String moduleName, String settingName)
javax.swing.JButton browseButton
javax.swing.JLabel pathErrorLabel
static void error(String title, String message)
static boolean isPartition(String path)
javax.swing.JTextField pathTextField
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
javax.swing.JCheckBox noFatOrphansCheckbox
void removeUpdate(DocumentEvent e)
void insertUpdate(DocumentEvent e)