From 511032d66e2c2f8f5766259238a22cd198de83e4 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Mon, 2 Dec 2019 15:14:02 -0500 Subject: [PATCH 1/2] fixed minor bugs --- .../geolocation/CheckBoxListPanel.java | 22 ++++++++++++++++++- .../autopsy/geolocation/GeoFilterPanel.java | 2 +- .../geolocation/GeolocationTopComponent.java | 22 ++++++++++++------- .../autopsy/geolocation/MapPanel.java | 13 +++++++---- 4 files changed, 45 insertions(+), 14 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/CheckBoxListPanel.java b/Core/src/org/sleuthkit/autopsy/geolocation/CheckBoxListPanel.java index ff3fd5b4a4..0942a9e528 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/CheckBoxListPanel.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/CheckBoxListPanel.java @@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.geolocation; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; +import java.util.Objects; import javax.swing.DefaultListModel; import javax.swing.Icon; @@ -52,7 +53,11 @@ final class CheckBoxListPanel extends javax.swing.JPanel { * @param obj Object that the checkbox represents */ void addElement(String displayName, T obj) { - model.addElement(new ObjectCheckBox<>(displayName, true, obj)); + ObjectCheckBox newCheckBox = new ObjectCheckBox<>(displayName, true, obj); + + if(!model.contains(newCheckBox)) { + model.addElement(newCheckBox); + } } /** @@ -244,6 +249,21 @@ final class CheckBoxListPanel extends javax.swing.JPanel { public String getDisplayName() { return displayName; } + + @Override + public boolean equals(Object obj) { + if(obj instanceof ObjectCheckBox) { + return object.equals(((ObjectCheckBox)obj).object); + } + return false; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 31 * hash + Objects.hashCode(this.object); + return hash; + } } } diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/GeoFilterPanel.java b/Core/src/org/sleuthkit/autopsy/geolocation/GeoFilterPanel.java index fe20a9bceb..92419736f1 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/GeoFilterPanel.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/GeoFilterPanel.java @@ -135,7 +135,7 @@ class GeoFilterPanel extends javax.swing.JPanel { private void initCheckboxList() throws TskCoreException { final SleuthkitCase sleuthkitCase = Case.getCurrentCase().getSleuthkitCase(); - checkboxPanel.clearList(); +// checkboxPanel.clearList(); for (DataSource dataSource : sleuthkitCase.getDataSources()) { String dsName = sleuthkitCase.getContentById(dataSource.getId()).getName(); diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java b/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java index 1bf0aaabbf..012573887a 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java @@ -65,6 +65,7 @@ public final class GeolocationTopComponent extends TopComponent { private static final Set INGEST_MODULE_EVENTS_OF_INTEREST = EnumSet.of(DATA_ADDED); private final PropertyChangeListener ingestListener; + private final PropertyChangeListener caseEventListener; private final GeoFilterPanel geoFilterPanel; final RefreshPanel refreshPanel = new RefreshPanel(); @@ -100,6 +101,13 @@ public final class GeolocationTopComponent extends TopComponent { } } }; + + this.caseEventListener = pce -> { + mapPanel.clearWaypoints(); + if (pce.getNewValue() != null) { + updateWaypoints(); + } + }; refreshPanel.addCloseActionListener(new ActionListener() { @Override @@ -111,6 +119,7 @@ public final class GeolocationTopComponent extends TopComponent { refreshPanel.addRefreshActionListner(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + geoFilterPanel.updateDataSourceList(); mapPanel.clearWaypoints(); updateWaypoints(); showRefreshPanel(false); @@ -121,7 +130,7 @@ public final class GeolocationTopComponent extends TopComponent { filterPane.setPanel(geoFilterPanel); geoFilterPanel.addActionListener(new ActionListener() { @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed(ActionEvent e) { updateWaypoints(); } }); @@ -131,26 +140,23 @@ public final class GeolocationTopComponent extends TopComponent { public void addNotify() { super.addNotify(); IngestManager.getInstance().addIngestModuleEventListener(INGEST_MODULE_EVENTS_OF_INTEREST, ingestListener); - Case.addEventTypeSubscriber(EnumSet.of(CURRENT_CASE), evt -> { - mapPanel.clearWaypoints(); - if (evt.getNewValue() != null) { - updateWaypoints(); - } - }); + Case.addEventTypeSubscriber(EnumSet.of(CURRENT_CASE), caseEventListener); } @Override public void removeNotify() { super.removeNotify(); IngestManager.getInstance().removeIngestModuleEventListener(ingestListener); + Case.removeEventTypeSubscriber(EnumSet.of(CURRENT_CASE), caseEventListener); } @Override public void componentOpened() { super.componentOpened(); WindowManager.getDefault().setTopComponentFloating(this, true); + } - + @Messages({ "GeolocationTC_connection_failure_message=Failed to connect to map title source.\nPlease review map source in Options dialog.", "GeolocationTC_connection_failure_message_title=Connection Failure" diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java b/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java index 03ec22cf2b..918f2de88d 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java @@ -25,6 +25,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; +import java.awt.event.MouseEvent; import java.awt.geom.Point2D; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -312,7 +313,9 @@ final public class MapPanel extends javax.swing.JPanel { // it the popup is currently visible if (waypoint != null && !waypoint.equals(currentlySelectedWaypoint)) { currentlySelectedWaypoint = waypoint; - showDetailsPopup(); + if(currentPopup != null) { + showDetailsPopup(); + } } } catch (TskCoreException ex) { logger.log(Level.WARNING, "Failed to show popup for waypoint", ex); @@ -340,7 +343,7 @@ final public class MapPanel extends javax.swing.JPanel { popupMenu.add(new JSeparator()); } } - popupMenu.show(this, point.x, point.y); + popupMenu.show(mapViewer, point.x, point.y); } /** @@ -612,8 +615,10 @@ final public class MapPanel extends javax.swing.JPanel { }//GEN-LAST:event_mapViewerMouseMoved private void mapViewerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mapViewerMouseClicked - currentlySelectedWaypoint = findClosestWaypoint(evt.getPoint()); - showDetailsPopup(); + if(!evt.isPopupTrigger() && (evt.getButton() == MouseEvent.BUTTON1)) { + currentlySelectedWaypoint = findClosestWaypoint(evt.getPoint()); + showDetailsPopup(); + } }//GEN-LAST:event_mapViewerMouseClicked From acc06117dc76b85a43309b7a3732586da6bb6c79 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Wed, 4 Dec 2019 13:23:39 -0500 Subject: [PATCH 2/2] Fixed bug will found. --- .../sleuthkit/autopsy/geolocation/GeoFilterPanel.java | 9 +++++++-- .../autopsy/geolocation/GeolocationTopComponent.java | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/GeoFilterPanel.java b/Core/src/org/sleuthkit/autopsy/geolocation/GeoFilterPanel.java index 92419736f1..51238a033e 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/GeoFilterPanel.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/GeoFilterPanel.java @@ -95,6 +95,13 @@ class GeoFilterPanel extends javax.swing.JPanel { logger.log(Level.WARNING, "Failed to initialize the CheckboxListPane", ex); //NON-NLS } } + + /** + * Clears the data source list. + */ + void clearDataSourceList() { + checkboxPanel.clearList(); + } /** * Adds an actionListener to listen for the filter apply action @@ -134,8 +141,6 @@ class GeoFilterPanel extends javax.swing.JPanel { */ private void initCheckboxList() throws TskCoreException { final SleuthkitCase sleuthkitCase = Case.getCurrentCase().getSleuthkitCase(); - -// checkboxPanel.clearList(); for (DataSource dataSource : sleuthkitCase.getDataSources()) { String dsName = sleuthkitCase.getContentById(dataSource.getId()).getName(); diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java b/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java index 012573887a..969eab6b91 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java @@ -164,6 +164,7 @@ public final class GeolocationTopComponent extends TopComponent { @Override public void open() { super.open(); + geoFilterPanel.clearDataSourceList(); geoFilterPanel.updateDataSourceList(); try { mapPanel.initMap();