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 javax.swing.JFileChooser;
 
   27 import javax.swing.event.DocumentEvent;
 
   28 import javax.swing.event.DocumentListener;
 
   29 import javax.swing.JPanel;
 
   30 import javax.swing.filechooser.FileFilter;
 
   32 import org.openide.util.NbBundle;
 
   36 import java.util.logging.Level;
 
   48     private JFileChooser 
fc = 
new JFileChooser();
 
   61     private ImageFilePanel(String context, List<FileFilter> fileChooserFilters) {
 
   63         fc.setDragEnabled(
false);
 
   64         fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
 
   65         fc.setMultiSelectionEnabled(
false);
 
   69         boolean firstFilter = 
true;
 
   70         for (FileFilter filter : fileChooserFilters) {
 
   72                 fc.setFileFilter(filter);
 
   75                 fc.addChoosableFileFilter(filter);
 
   79         this.contextName = context;
 
  107     @SuppressWarnings(
"unchecked")
 
  120         setMinimumSize(
new java.awt.Dimension(0, 65));
 
  121         setPreferredSize(
new java.awt.Dimension(403, 65));
 
  123         org.openide.awt.Mnemonics.setLocalizedText(
pathLabel, 
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class, 
"ImageFilePanel.pathLabel.text")); 
 
  126         browseButton.addActionListener(
new java.awt.event.ActionListener() {
 
  127             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  138         org.openide.awt.Mnemonics.setLocalizedText(noFatOrphansCheckbox, 
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class, 
"ImageFilePanel.noFatOrphansCheckbox.text")); 
 
  139         noFatOrphansCheckbox.setToolTipText(
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class, 
"ImageFilePanel.noFatOrphansCheckbox.toolTipText")); 
 
  141         org.openide.awt.Mnemonics.setLocalizedText(
descLabel, 
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class, 
"ImageFilePanel.descLabel.text")); 
 
  143         errorLabel.setForeground(
new java.awt.Color(255, 0, 0));
 
  144         org.openide.awt.Mnemonics.setLocalizedText(
errorLabel, 
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class, 
"ImageFilePanel.errorLabel.text")); 
 
  146         javax.swing.GroupLayout layout = 
new javax.swing.GroupLayout(
this);
 
  147         this.setLayout(layout);
 
  148         layout.setHorizontalGroup(
 
  149             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  150             .addGroup(layout.createSequentialGroup()
 
  152                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  155             .addGroup(layout.createSequentialGroup()
 
  156                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  157                     .addGroup(layout.createSequentialGroup()
 
  159                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  160                         .addComponent(
timeZoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  162                     .addComponent(noFatOrphansCheckbox)
 
  163                     .addGroup(layout.createSequentialGroup()
 
  167                 .addGap(0, 20, Short.MAX_VALUE))
 
  169         layout.setVerticalGroup(
 
  170             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  171             .addGroup(layout.createSequentialGroup()
 
  173                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  174                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  176                     .addComponent(
pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  180                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  182                     .addComponent(
timeZoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  183                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  184                 .addComponent(noFatOrphansCheckbox)
 
  185                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  187                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  190     @SuppressWarnings(
"deprecation")
 
  194         File currentDir = 
new File(oldText);
 
  195         if (currentDir.exists()) {
 
  196             fc.setCurrentDirectory(currentDir);
 
  199         int retval = fc.showOpenDialog(
this);
 
  200         if (retval == JFileChooser.APPROVE_OPTION) {
 
  201             String path = fc.getSelectedFile().getPath();
 
  207         } 
catch (Exception e) {
 
  208             logger.log(Level.SEVERE, 
"ImageFilePanel listener threw exception", e); 
 
  210                     NbBundle.getMessage(
this.getClass(), 
"ImageFilePanel.moduleErr.msg"),
 
  243         String tz = timeZoneComboBox.getSelectedItem().toString();
 
  244         return tz.substring(tz.indexOf(
")") + 2).trim();
 
  265         if (path == null || path.isEmpty()) {
 
  272         boolean isExist = 
new File(path).isFile();
 
  276         return (isExist || isPhysicalDrive || isPartition);
 
  288             errorLabel.setText(NbBundle.getMessage(
this.getClass(), 
"DataSourceOnCDriveError.text"));
 
  294         if (null != imagePathName) {
 
  295             String imagePath = imagePathName.substring(0, imagePathName.lastIndexOf(File.separator) + 1);
 
  302         if (null != lastImagePath) {
 
  303             if (!lastImagePath.isEmpty()) {
 
  315         String[] ids = SimpleTimeZone.getAvailableIDs();
 
  316         for (String 
id : ids) {
 
  317             TimeZone zone = TimeZone.getTimeZone(
id);
 
  318             int offset = zone.getRawOffset() / 1000;
 
  319             int hour = offset / 3600;
 
  320             int minutes = (offset % 3600) / 60;
 
  321             String item = String.format(
"(GMT%+d:%02d) %s", hour, minutes, 
id); 
 
  332             timeZoneComboBox.addItem(item);
 
  335         TimeZone thisTimeZone = Calendar.getInstance().getTimeZone();
 
  336         int thisOffset = thisTimeZone.getRawOffset() / 1000;
 
  337         int thisHour = thisOffset / 3600;
 
  338         int thisMinutes = (thisOffset % 3600) / 60;
 
  339         String formatted = String.format(
"(GMT%+d:%02d) %s", thisHour, thisMinutes, thisTimeZone.getID()); 
 
  342         timeZoneComboBox.setSelectedItem(formatted);
 
  357         } 
catch (Exception ee) {
 
  358             logger.log(Level.SEVERE, 
"ImageFilePanel listener threw exception", ee); 
 
  360                     NbBundle.getMessage(
this.getClass(), 
"ImageFilePanel.moduleErr.msg"),
 
  369         } 
catch (Exception ee) {
 
  370             logger.log(Level.SEVERE, 
"ImageFilePanel listener threw exception", ee); 
 
  372                     NbBundle.getMessage(
this.getClass(), 
"ImageFilePanel.moduleErr.msg"),
 
  382         } 
catch (Exception ee) {
 
  383             logger.log(Level.SEVERE, 
"ImageFilePanel listener threw exception", ee); 
 
  385                     NbBundle.getMessage(
this.getClass(), 
"ImageFilePanel.moduleErr.msg"),
 
javax.swing.JLabel descLabel
final String PROP_LASTIMAGE_PATH
static boolean isPhysicalDrive(String path)
boolean getNoFatOrphans()
javax.swing.JLabel timeZoneLabel
javax.swing.JLabel pathLabel
void warnIfPathIsInvalid(String path)
static synchronized ImageFilePanel createInstance(String context, List< FileFilter > fileChooserFilters)
static boolean isValid(String path, Case.CaseType caseType)
void createTimeZoneList()
void setContentPath(String s)
void browseButtonActionPerformed(java.awt.event.ActionEvent evt)
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
static boolean isPartition(String path)
javax.swing.JTextField pathTextField
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
static void show(String title, String message, MessageType type, ActionListener actionListener)
javax.swing.JLabel errorLabel
javax.swing.JCheckBox noFatOrphansCheckbox
void removeUpdate(DocumentEvent e)
void insertUpdate(DocumentEvent e)