19 package org.sleuthkit.autopsy.geolocation;
21 import java.awt.BorderLayout;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import java.beans.PropertyChangeEvent;
25 import java.beans.PropertyChangeListener;
27 import java.io.IOException;
28 import java.text.DateFormat;
29 import java.text.SimpleDateFormat;
30 import java.util.ArrayList;
31 import java.util.Date;
32 import java.util.EnumSet;
33 import java.util.List;
34 import java.util.Locale;
36 import java.util.logging.Level;
37 import javax.swing.JOptionPane;
38 import javax.swing.SwingUtilities;
39 import javax.swing.SwingWorker;
40 import org.openide.filesystems.FileUtil;
41 import org.openide.util.NbBundle.Messages;
42 import org.openide.windows.RetainLocation;
43 import org.openide.windows.TopComponent;
44 import org.openide.windows.WindowManager;
66 @TopComponent.Description(preferredID =
"GeolocationTopComponent", persistenceType = TopComponent.PERSISTENCE_NEVER)
67 @TopComponent.Registration(mode =
"geolocation", openAtStartup =
false)
68 @RetainLocation(
"geolocation")
69 @SuppressWarnings(
"PMD.SingularField")
72 private static final long serialVersionUID = 1L;
82 final RefreshPanel refreshPanel =
new RefreshPanel();
84 private static final String REPORT_PATH_FMT_STR =
"%s" + File.separator +
"%s %s %s" + File.separator;
87 private static final String REPORT_KML =
"ReportKML.kml";
89 private boolean mapInitalized =
false;
92 "GLTopComponent_name=Geolocation",
93 "GLTopComponent_initilzation_error=An error occurred during waypoint initilization. Geolocation data maybe incomplete."
103 setName(Bundle.GLTopComponent_name());
105 this.ingestListener = pce -> {
106 String eventType = pce.getPropertyName();
107 if (eventType.equals(DATA_ADDED.toString())) {
110 if (null != eventData
113 || eventData.
getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_LAST_KNOWN_LOCATION.getTypeID()
116 || eventData.
getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_BOOKMARK.getTypeID())) {
118 showRefreshPanel(
true);
123 this.caseEventListener = pce -> {
124 mapPanel.clearWaypoints();
125 if (pce.getNewValue() != null) {
130 refreshPanel.addCloseActionListener(
new ActionListener() {
132 public void actionPerformed(ActionEvent e) {
133 showRefreshPanel(
false);
137 refreshPanel.addRefreshActionListner(
new ActionListener() {
139 public void actionPerformed(ActionEvent e) {
140 geoFilterPanel.updateDataSourceList();
141 mapPanel.clearWaypoints();
143 showRefreshPanel(
false);
147 geoFilterPanel =
new GeoFilterPanel();
148 filterPane.setPanel(geoFilterPanel);
149 geoFilterPanel.addActionListener(
new ActionListener() {
151 public void actionPerformed(ActionEvent e) {
156 mapPanel.addPropertyChangeListener(
MapPanel.CURRENT_MOUSE_GEOPOSITION,
new PropertyChangeListener() {
158 public void propertyChange(PropertyChangeEvent evt) {
160 Object newValue = evt.getNewValue();
161 if (newValue != null) {
162 label = newValue.toString();
165 coordLabel.setText(label);
180 super.removeNotify();
187 super.componentOpened();
188 WindowManager.getDefault().setTopComponentFloating(
this,
true);
193 "GeolocationTC_connection_failure_message=Failed to connect to map title source.\nPlease review map source in Options dialog.",
194 "GeolocationTC_connection_failure_message_title=Connection Failure"
199 mapPanel.clearWaypoints();
200 geoFilterPanel.clearDataSourceList();
201 geoFilterPanel.updateDataSourceList();
204 if (!mapInitalized) {
207 mapInitalized =
true;
209 JOptionPane.showMessageDialog(
this,
210 Bundle.GeolocationTC_connection_failure_message(),
211 Bundle.GeolocationTC_connection_failure_message_title(),
212 JOptionPane.ERROR_MESSAGE);
214 Bundle.GeolocationTC_connection_failure_message_title(),
215 Bundle.GeolocationTC_connection_failure_message());
216 logger.log(Level.SEVERE, ex.getMessage(), ex);
220 mapPanel.setWaypoints(
new ArrayList<>());
231 mapPanel.add(refreshPanel, BorderLayout.NORTH);
233 mapPanel.remove(refreshPanel);
235 mapPanel.revalidate();
243 "GeoTopComponent_no_waypoints_returned_mgs=Applied filter failed to find waypoints that matched criteria.\nRevise filter options and try again.",
244 "GeoTopComponent_no_waypoints_returned_Title=No Waypoints Found",
245 "GeoTopComponent_filter_exception_msg=Exception occured during waypoint filtering.",
246 "GeoTopComponent_filter_exception_Title=Filter Failure",
247 "GeoTopComponent_filer_data_invalid_msg=Unable to run waypoint filter.\nPlease select one or more data sources.",
248 "GeoTopComponent_filer_data_invalid_Title=Filter Failure"
255 filters = geoFilterPanel.getFilterState();
257 JOptionPane.showMessageDialog(
this,
258 Bundle.GeoTopComponent_filer_data_invalid_msg(),
259 Bundle.GeoTopComponent_filer_data_invalid_Title(),
260 JOptionPane.INFORMATION_MESSAGE);
264 setWaypointLoading(
true);
265 geoFilterPanel.setEnabled(
false);
276 void setWaypointLoading(
boolean loading) {
277 progressBar.setEnabled(
true);
278 progressBar.setVisible(loading);
279 progressBar.setString(
"Loading Waypoints");
296 DateFormat dateFormat =
new SimpleDateFormat(
"MM-dd-yyyy-HH-mm-ss", Locale.US);
297 Date date =
new Date();
298 String dateNoTime = dateFormat.format(date);
302 FileUtil.createFolder(
new File(reportPath));
303 }
catch (IOException ex) {
304 throw new IOException(
"Failed to make report folder, unable to generate reports.", ex);
314 @SuppressWarnings(
"unchecked")
316 private
void initComponents() {
317 java.awt.GridBagConstraints gridBagConstraints;
320 statusBar =
new javax.swing.JPanel();
321 reportButton =
new javax.swing.JButton();
322 progressBar =
new javax.swing.JProgressBar();
323 coordLabel =
new javax.swing.JLabel();
326 setLayout(
new java.awt.BorderLayout());
327 add(filterPane, java.awt.BorderLayout.WEST);
329 statusBar.setLayout(
new java.awt.GridBagLayout());
331 org.openide.awt.Mnemonics.setLocalizedText(reportButton,
org.openide.util.NbBundle.getMessage(
GeolocationTopComponent.class,
"GeolocationTopComponent.reportButton.text"));
332 reportButton.addActionListener(
new java.awt.event.ActionListener() {
333 public void actionPerformed(java.awt.event.ActionEvent evt) {
334 reportButtonActionPerformed(evt);
337 gridBagConstraints =
new java.awt.GridBagConstraints();
338 gridBagConstraints.gridx = 2;
339 gridBagConstraints.gridy = 0;
340 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
341 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
342 statusBar.add(reportButton, gridBagConstraints);
344 progressBar.setIndeterminate(
true);
345 gridBagConstraints =
new java.awt.GridBagConstraints();
346 gridBagConstraints.gridx = 1;
347 gridBagConstraints.gridy = 0;
348 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
349 statusBar.add(progressBar, gridBagConstraints);
351 org.openide.awt.Mnemonics.setLocalizedText(coordLabel,
org.openide.util.NbBundle.getMessage(
GeolocationTopComponent.class,
"GeolocationTopComponent.coordLabel.text"));
352 gridBagConstraints =
new java.awt.GridBagConstraints();
353 gridBagConstraints.gridx = 0;
354 gridBagConstraints.gridy = 0;
355 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
356 gridBagConstraints.weightx = 1.0;
357 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 0);
358 statusBar.add(coordLabel, gridBagConstraints);
360 add(statusBar, java.awt.BorderLayout.SOUTH);
361 add(mapPanel, java.awt.BorderLayout.CENTER);
365 "GeolocationTC_empty_waypoint_message=Unable to generate KML report due to a lack of waypoints.\nPlease make sure there are waypoints visible before generating the KML report",
366 "GeolocationTC_KML_report_title=KML Report",
367 "GeolocationTC_report_progress_title=KML Report Progress"
370 List<MapWaypoint> visiblePoints = mapPanel.getVisibleWaypoints();
371 if (visiblePoints.isEmpty()) {
372 JOptionPane.showConfirmDialog(
this, Bundle.GeolocationTC_empty_waypoint_message(), Bundle.GeolocationTC_KML_report_title(), JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE);
378 String reportBaseDir = createReportDirectory();
380 progressPanel.
setLabels(REPORT_KML, reportBaseDir);
382 SwingWorker<Void, Void> worker =
new SwingWorker<Void, Void>() {
384 protected Void doInBackground()
throws Exception {
390 JOptionPane.showConfirmDialog(
this, progressPanel, Bundle.GeolocationTC_report_progress_title(), JOptionPane.CLOSED_OPTION, JOptionPane.PLAIN_MESSAGE);
391 }
catch (IOException ex) {
392 logger.log(Level.WARNING,
"Unable to create KML report", ex);
419 this.filters = filters;
427 filters.getDataSources(),
428 filters.showAllWaypoints(),
429 filters.getMostRecentNumDays(),
430 filters.showWaypointsWithoutTimeStamp(),
434 logger.log(Level.SEVERE,
"Failed to filter waypoints.", ex);
435 SwingUtilities.invokeLater(
new Runnable() {
439 Bundle.GeoTopComponent_filter_exception_Title(),
440 Bundle.GeoTopComponent_filter_exception_msg(),
441 JOptionPane.ERROR_MESSAGE);
443 setWaypointLoading(
false);
457 public void process(
final List<Waypoint> waypoints) {
460 SwingUtilities.invokeLater(
new Runnable() {
465 if (waypoints == null || waypoints.isEmpty()) {
466 mapPanel.clearWaypoints();
468 Bundle.GeoTopComponent_no_waypoints_returned_Title(),
469 Bundle.GeoTopComponent_no_waypoints_returned_mgs(),
470 JOptionPane.INFORMATION_MESSAGE);
471 setWaypointLoading(
false);
472 geoFilterPanel.setEnabled(
true);
475 mapPanel.clearWaypoints();
476 mapPanel.setWaypoints(MapWaypoint.getWaypoints(waypoints));
477 setWaypointLoading(
false);
478 geoFilterPanel.setEnabled(
true);
final void setLabels(String reportName, String reportPath)
BlackboardArtifact.Type getBlackboardArtifactType()
void removeIngestModuleEventListener(final PropertyChangeListener listener)
static String createReportDirectory()
static synchronized IngestManager getInstance()
void showRefreshPanel(boolean show)
javax.swing.JButton reportButton
String getReportDirectory()
org.sleuthkit.autopsy.geolocation.MapPanel mapPanel
final PropertyChangeListener caseEventListener
void process(final List< Waypoint > waypoints)
javax.swing.JProgressBar progressBar
javax.swing.JLabel coordLabel
final GeoFilterPanel geoFilterPanel
static List< Waypoint > getAllWaypoints(SleuthkitCase skCase)
void reportButtonActionPerformed(java.awt.event.ActionEvent evt)
static synchronized KMLReport getDefault()
final PropertyChangeListener ingestListener
void generateReport(String baseReportDir, ReportProgressPanel progressPanel, List< Waypoint > waypointList)
SleuthkitCase getSleuthkitCase()
static void error(String title, String message)
void addIngestModuleEventListener(final PropertyChangeListener listener)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
org.sleuthkit.autopsy.geolocation.HidingPane filterPane
javax.swing.JPanel statusBar
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)