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.Exceptions;
35 import org.openide.util.NbBundle;
70 private ImageFilePanel(String context, List<FileFilter> fileChooserFilters) {
71 this.contextName = context;
75 for (String
id : SimpleTimeZone.getAvailableIDs()) {
82 for (String choice : SECTOR_SIZE_CHOICES) {
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);
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"));
140 browseButton.addActionListener(
new java.awt.event.ActionListener() {
141 public void actionPerformed(java.awt.event.ActionEvent evt) {
155 org.openide.awt.Mnemonics.setLocalizedText(
descLabel,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.descLabel.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()
168 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
171 .addGroup(layout.createSequentialGroup()
172 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
173 .addGroup(layout.createSequentialGroup()
175 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
176 .addComponent(
timeZoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
179 .addGroup(layout.createSequentialGroup()
183 .addGroup(layout.createSequentialGroup()
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()
193 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
194 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
196 .addComponent(
pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
200 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
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)
205 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
208 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
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"})
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) {
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();
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."
316 if (StringUtils.isBlank(path)) {
324 pathErrorLabel.setText(Bundle.ImageFilePanel_pathValidation_dataSourceOnCDriveError());
328 pathErrorLabel.setText(Bundle.ImageFilePanel_pathValidation_getOpenCase_Error());
331 return new File(path).isFile()
338 if (null != imagePathName) {
339 String imagePath = imagePathName.substring(0, imagePathName.lastIndexOf(File.separator) + 1);
346 if (StringUtils.isNotBlank(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);
javax.swing.JLabel descLabel
static final String PROP_LASTIMAGE_PATH
static boolean isPhysicalDrive(String path)
boolean getNoFatOrphans()
javax.swing.JLabel timeZoneLabel
static Case getOpenCase()
javax.swing.JLabel pathLabel
static final String[] SECTOR_SIZE_CHOICES
static String timeZoneToString(TimeZone zone)
javax.swing.JComboBox< String > sectorSizeComboBox
static synchronized ImageFilePanel createInstance(String context, List< FileFilter > fileChooserFilters)
final JFileChooser fileChooser
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)
static final Logger logger
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)
javax.swing.JCheckBox noFatOrphansCheckbox
void removeUpdate(DocumentEvent e)
void insertUpdate(DocumentEvent e)