19 package org.sleuthkit.autopsy.casemodule;
21 import java.beans.PropertyChangeListener;
22 import java.beans.PropertyChangeSupport;
24 import java.util.Calendar;
25 import java.util.List;
26 import java.util.SimpleTimeZone;
27 import java.util.TimeZone;
28 import javax.swing.JFileChooser;
29 import javax.swing.event.DocumentEvent;
30 import javax.swing.event.DocumentListener;
31 import javax.swing.JPanel;
32 import javax.swing.filechooser.FileFilter;
34 import org.openide.util.NbBundle;
38 import java.util.logging.Level;
49 private PropertyChangeSupport
pcs = null;
50 private JFileChooser
fc =
new JFileChooser();
63 private ImageFilePanel(String context, List<FileFilter> fileChooserFilters) {
65 fc.setDragEnabled(
false);
66 fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
67 fc.setMultiSelectionEnabled(
false);
71 boolean firstFilter =
true;
72 for (FileFilter filter : fileChooserFilters) {
74 fc.setFileFilter(filter);
77 fc.addChoosableFileFilter(filter);
81 this.contextName = context;
82 pcs =
new PropertyChangeSupport(
this);
110 @SuppressWarnings(
"unchecked")
123 setMinimumSize(
new java.awt.Dimension(0, 65));
124 setPreferredSize(
new java.awt.Dimension(403, 65));
126 org.openide.awt.Mnemonics.setLocalizedText(
pathLabel,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.pathLabel.text"));
129 browseButton.addActionListener(
new java.awt.event.ActionListener() {
130 public void actionPerformed(java.awt.event.ActionEvent evt) {
141 org.openide.awt.Mnemonics.setLocalizedText(noFatOrphansCheckbox,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.noFatOrphansCheckbox.text"));
142 noFatOrphansCheckbox.setToolTipText(
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.noFatOrphansCheckbox.toolTipText"));
144 org.openide.awt.Mnemonics.setLocalizedText(
descLabel,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.descLabel.text"));
146 errorLabel.setForeground(
new java.awt.Color(255, 0, 0));
147 org.openide.awt.Mnemonics.setLocalizedText(
errorLabel,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.errorLabel.text"));
149 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
150 this.setLayout(layout);
151 layout.setHorizontalGroup(
152 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
153 .addGroup(layout.createSequentialGroup()
155 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
158 .addGroup(layout.createSequentialGroup()
159 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
160 .addGroup(layout.createSequentialGroup()
162 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
163 .addComponent(
timeZoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
165 .addComponent(noFatOrphansCheckbox)
166 .addGroup(layout.createSequentialGroup()
170 .addGap(0, 20, Short.MAX_VALUE))
172 layout.setVerticalGroup(
173 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
174 .addGroup(layout.createSequentialGroup()
176 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
177 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
179 .addComponent(
pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
183 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
185 .addComponent(
timeZoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
186 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
187 .addComponent(noFatOrphansCheckbox)
188 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
190 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
193 @SuppressWarnings(
"deprecation")
197 File currentDir =
new File(oldText);
198 if (currentDir.exists()) {
199 fc.setCurrentDirectory(currentDir);
202 int retval = fc.showOpenDialog(
this);
203 if (retval == JFileChooser.APPROVE_OPTION) {
204 String path = fc.getSelectedFile().getPath();
210 }
catch (Exception e) {
211 logger.log(Level.SEVERE,
"ImageFilePanel listener threw exception", e);
213 NbBundle.getMessage(
this.getClass(),
"ImageFilePanel.moduleErr.msg"),
246 String tz = timeZoneComboBox.getSelectedItem().toString();
247 return tz.substring(tz.indexOf(
")") + 2).trim();
268 if (path == null || path.isEmpty()) {
276 boolean isPhysicalDrive =
Case.isPhysicalDrive(path);
277 boolean isPartition =
Case.isPartition(path);
279 return (isExist || isPhysicalDrive || isPartition);
291 errorLabel.setText(NbBundle.getMessage(
this.getClass(),
"DataSourceOnCDriveError.text"));
297 if (null != imagePathName) {
298 String imagePath = imagePathName.substring(0, imagePathName.lastIndexOf(File.separator) + 1);
305 if (null != lastImagePath) {
306 if (!lastImagePath.isEmpty()) {
318 String[] ids = SimpleTimeZone.getAvailableIDs();
319 for (String
id : ids) {
320 TimeZone zone = TimeZone.getTimeZone(
id);
321 int offset = zone.getRawOffset() / 1000;
322 int hour = offset / 3600;
323 int minutes = (offset % 3600) / 60;
324 String item = String.format(
"(GMT%+d:%02d) %s", hour, minutes,
id);
335 timeZoneComboBox.addItem(item);
338 TimeZone thisTimeZone = Calendar.getInstance().getTimeZone();
339 int thisOffset = thisTimeZone.getRawOffset() / 1000;
340 int thisHour = thisOffset / 3600;
341 int thisMinutes = (thisOffset % 3600) / 60;
342 String formatted = String.format(
"(GMT%+d:%02d) %s", thisHour, thisMinutes, thisTimeZone.getID());
345 timeZoneComboBox.setSelectedItem(formatted);
360 }
catch (Exception ee) {
361 logger.log(Level.SEVERE,
"ImageFilePanel listener threw exception", ee);
363 NbBundle.getMessage(
this.getClass(),
"ImageFilePanel.moduleErr.msg"),
372 }
catch (Exception ee) {
373 logger.log(Level.SEVERE,
"ImageFilePanel listener threw exception", ee);
375 NbBundle.getMessage(
this.getClass(),
"ImageFilePanel.moduleErr.msg"),
385 }
catch (Exception ee) {
386 logger.log(Level.SEVERE,
"ImageFilePanel listener threw exception", ee);
388 NbBundle.getMessage(
this.getClass(),
"ImageFilePanel.moduleErr.msg"),
402 super.addPropertyChangeListener(pcl);
405 pcs =
new PropertyChangeSupport(
this);
408 pcs.addPropertyChangeListener(pcl);
413 super.removePropertyChangeListener(pcl);
415 pcs.removePropertyChangeListener(pcl);
javax.swing.JLabel descLabel
final String PROP_LASTIMAGE_PATH
void removePropertyChangeListener(PropertyChangeListener pcl)
PropertyChangeSupport pcs
boolean getNoFatOrphans()
javax.swing.JLabel timeZoneLabel
synchronized void addPropertyChangeListener(PropertyChangeListener pcl)
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 boolean pathExists(String imgPath)
static String getConfigSetting(String moduleName, String settingName)
javax.swing.JButton browseButton
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)