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;
48 private PropertyChangeSupport
pcs = null;
49 private JFileChooser
fc =
new JFileChooser();
59 private ImageFilePanel(String context, List<FileFilter> fileChooserFilters) {
61 fc.setDragEnabled(
false);
62 fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
63 fc.setMultiSelectionEnabled(
false);
65 boolean firstFilter =
true;
66 for (FileFilter filter: fileChooserFilters ) {
68 fc.setFileFilter(filter);
72 fc.addChoosableFileFilter(filter);
76 this.contextName = context;
77 pcs =
new PropertyChangeSupport(
this);
107 @SuppressWarnings(
"unchecked")
119 setMinimumSize(
new java.awt.Dimension(0, 65));
120 setPreferredSize(
new java.awt.Dimension(403, 65));
122 org.openide.awt.Mnemonics.setLocalizedText(
pathLabel,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.pathLabel.text"));
125 browseButton.addActionListener(
new java.awt.event.ActionListener() {
126 public void actionPerformed(java.awt.event.ActionEvent evt) {
137 org.openide.awt.Mnemonics.setLocalizedText(noFatOrphansCheckbox,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.noFatOrphansCheckbox.text"));
138 noFatOrphansCheckbox.setToolTipText(
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.noFatOrphansCheckbox.toolTipText"));
140 org.openide.awt.Mnemonics.setLocalizedText(
descLabel,
org.openide.util.NbBundle.getMessage(
ImageFilePanel.class,
"ImageFilePanel.descLabel.text"));
142 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
143 this.setLayout(layout);
144 layout.setHorizontalGroup(
145 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
146 .addGroup(layout.createSequentialGroup()
148 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
151 .addGroup(layout.createSequentialGroup()
152 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
153 .addGroup(layout.createSequentialGroup()
155 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
156 .addComponent(
timeZoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
158 .addComponent(noFatOrphansCheckbox)
159 .addGroup(layout.createSequentialGroup()
162 .addGap(0, 20, Short.MAX_VALUE))
164 layout.setVerticalGroup(
165 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
166 .addGroup(layout.createSequentialGroup()
168 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
169 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
171 .addComponent(
pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
173 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
175 .addComponent(
timeZoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
176 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
177 .addComponent(noFatOrphansCheckbox)
178 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
180 .addContainerGap(13, Short.MAX_VALUE))
187 File currentDir =
new File(oldText);
188 if (currentDir.exists()) {
189 fc.setCurrentDirectory(currentDir);
192 int retval = fc.showOpenDialog(
this);
193 if (retval == JFileChooser.APPROVE_OPTION) {
194 String path = fc.getSelectedFile().getPath();
203 catch (Exception e) {
204 logger.log(Level.SEVERE,
"ImageFilePanel listener threw exception", e);
206 NbBundle.getMessage(
this.getClass(),
"ImageFilePanel.moduleErr.msg"),
237 String tz = timeZoneComboBox.getSelectedItem().toString();
238 return tz.substring(tz.indexOf(
")") + 2).trim();
259 if (path == null || path.isEmpty()) {
264 boolean isPhysicalDrive =
Case.isPhysicalDrive(path);
265 boolean isPartition =
Case.isPartition(path);
267 return (isExist || isPhysicalDrive || isPartition);
273 if (null != imagePathName ) {
274 String imagePath = imagePathName.substring(0, imagePathName.lastIndexOf(File.separator) + 1);
281 if (null != lastImagePath) {
282 if (!lastImagePath.isEmpty())
292 String[] ids = SimpleTimeZone.getAvailableIDs();
293 for (String
id : ids) {
294 TimeZone zone = TimeZone.getTimeZone(
id);
295 int offset = zone.getRawOffset() / 1000;
296 int hour = offset / 3600;
297 int minutes = (offset % 3600) / 60;
298 String item = String.format(
"(GMT%+d:%02d) %s", hour, minutes,
id);
309 timeZoneComboBox.addItem(item);
312 TimeZone thisTimeZone = Calendar.getInstance().getTimeZone();
313 int thisOffset = thisTimeZone.getRawOffset() / 1000;
314 int thisHour = thisOffset / 3600;
315 int thisMinutes = (thisOffset % 3600) / 60;
316 String formatted = String.format(
"(GMT%+d:%02d) %s", thisHour, thisMinutes, thisTimeZone.getID());
319 timeZoneComboBox.setSelectedItem(formatted);
333 catch (Exception ee) {
334 logger.log(Level.SEVERE,
"ImageFilePanel listener threw exception", ee);
336 NbBundle.getMessage(
this.getClass(),
"ImageFilePanel.moduleErr.msg"),
346 catch (Exception ee) {
347 logger.log(Level.SEVERE,
"ImageFilePanel listener threw exception", ee);
349 NbBundle.getMessage(
this.getClass(),
"ImageFilePanel.moduleErr.msg"),
360 catch (Exception ee) {
361 logger.log(Level.SEVERE,
"ImageFilePanel listener threw exception", ee);
363 NbBundle.getMessage(
this.getClass(),
"ImageFilePanel.moduleErr.msg"),
378 super.addPropertyChangeListener(pcl);
381 pcs =
new PropertyChangeSupport(
this);
384 pcs.addPropertyChangeListener(pcl);
389 super.removePropertyChangeListener(pcl);
391 pcs.removePropertyChangeListener(pcl);
javax.swing.JLabel descLabel
final String PROP_LASTIMAGE_PATH
void removePropertyChangeListener(PropertyChangeListener pcl)
PropertyChangeSupport pcs
FOCUS_NEXT
the caller UI may move focus the the next UI element, following the panel.
UPDATE_UI
the content of JPanel has changed that MAY warrant updates to the caller UI
boolean getNoFatOrphans()
javax.swing.JLabel timeZoneLabel
synchronized void addPropertyChangeListener(PropertyChangeListener pcl)
javax.swing.JLabel pathLabel
static synchronized ImageFilePanel createInstance(String context, List< FileFilter > fileChooserFilters)
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 void show(String title, String message, MessageType type, ActionListener actionListener)
javax.swing.JCheckBox noFatOrphansCheckbox
void removeUpdate(DocumentEvent e)
static Logger getLogger(String name)
void insertUpdate(DocumentEvent e)