exposing geolocation and button setup

This commit is contained in:
Greg DiCristofaro 2020-11-23 15:41:07 -05:00
parent 3b5463a53d
commit 83c4a64fc2
6 changed files with 88 additions and 111 deletions

View File

@ -230,6 +230,13 @@ public class WhereUsedSummary implements DefaultArtifactUpdateGovernor {
this.provider = provider; this.provider = provider;
this.logger = logger; this.logger = logger;
} }
/**
* @return Returns all the geolocation artifact types.
*/
public List<ARTIFACT_TYPE> getGeoTypes() {
return GPS_ARTIFACT_TYPES;
}
@Override @Override
public Set<Integer> getArtifactTypeIdsForRefresh() { public Set<Integer> getArtifactTypeIdsForRefresh() {

View File

@ -182,7 +182,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties" key="WhereUsedPanel.viewInGeolocationBtn.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties" key="WhereUsedPanel.viewInGeolocationBtn.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="viewInGeolocationBtnActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.Box$Filler" name="filler5"> <Component class="javax.swing.Box$Filler" name="filler5">
<Properties> <Properties>

View File

@ -20,21 +20,31 @@ package org.sleuthkit.autopsy.datasourcesummary.ui;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.CallableSystemAction;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.datasourcesummary.datamodel.WhereUsedSummary; import org.sleuthkit.autopsy.datasourcesummary.datamodel.WhereUsedSummary;
import org.sleuthkit.autopsy.datasourcesummary.datamodel.WhereUsedSummary.CityCount; import org.sleuthkit.autopsy.datasourcesummary.datamodel.WhereUsedSummary.CityCount;
import org.sleuthkit.autopsy.datasourcesummary.datamodel.WhereUsedSummary.CityRecord; import org.sleuthkit.autopsy.datasourcesummary.datamodel.WhereUsedSummary.CityRecord;
import org.sleuthkit.autopsy.datasourcesummary.uiutils.CellModelTableCellRenderer.DefaultCellModel; import org.sleuthkit.autopsy.datasourcesummary.uiutils.CellModelTableCellRenderer.DefaultCellModel;
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchResult;
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchWorker; import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchWorker;
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchWorker.DataFetchComponents; import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchWorker.DataFetchComponents;
import org.sleuthkit.autopsy.datasourcesummary.uiutils.IngestRunningLabel; import org.sleuthkit.autopsy.datasourcesummary.uiutils.IngestRunningLabel;
import org.sleuthkit.autopsy.datasourcesummary.uiutils.JTablePanel; import org.sleuthkit.autopsy.datasourcesummary.uiutils.JTablePanel;
import org.sleuthkit.autopsy.datasourcesummary.uiutils.JTablePanel.ColumnModel; import org.sleuthkit.autopsy.datasourcesummary.uiutils.JTablePanel.ColumnModel;
import org.sleuthkit.autopsy.geolocation.GeoFilter;
import org.sleuthkit.autopsy.geolocation.GeolocationTopComponent;
import org.sleuthkit.autopsy.geolocation.OpenGeolocationAction;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.DataSource; import org.sleuthkit.datamodel.DataSource;
/** /**
* A tab shown in data source summary displaying information about a data source's geolocation data. * A tab shown in data source summary displaying information about a data
* source's geolocation data.
*/ */
@Messages({ @Messages({
"WhereUsedPanel_cityColumn_title=Closest City", "WhereUsedPanel_cityColumn_title=Closest City",
@ -45,10 +55,11 @@ public class WhereUsedPanel extends BaseDataSourceSummaryPanel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final String GPX_FACTORY = "org.python.proxies.GPX_Parser_Module$GPXParserFileIngestModuleFactory"; private static final String GPX_FACTORY = "org.python.proxies.GPX_Parser_Module$GPXParserFileIngestModuleFactory";
private static final String GPX_NAME = "GPX Parser"; private static final String GPX_NAME = "GPX Parser";
/** /**
* Retrieves the city name to display from the record. * Retrieves the city name to display from the record.
*
* @param record The record for the city to display. * @param record The record for the city to display.
* @return The display name (city, country). * @return The display name (city, country).
*/ */
@ -56,14 +67,14 @@ public class WhereUsedPanel extends BaseDataSourceSummaryPanel {
if (record == null) { if (record == null) {
return null; return null;
} }
if (StringUtils.isBlank(record.getCountry())) { if (StringUtils.isBlank(record.getCountry())) {
return record.getCityName(); return record.getCityName();
} }
return String.format("%s, %s", record.getCityName(), record.getCountry()); return String.format("%s, %s", record.getCityName(), record.getCountry());
} }
private static final ColumnModel<CityCount> CITY_COL = new ColumnModel<>( private static final ColumnModel<CityCount> CITY_COL = new ColumnModel<>(
Bundle.WhereUsedPanel_cityColumn_title(), Bundle.WhereUsedPanel_cityColumn_title(),
(cityCount) -> new DefaultCellModel(getCityName(cityCount.getCityRecord())), (cityCount) -> new DefaultCellModel(getCityName(cityCount.getCityRecord())),
@ -90,6 +101,8 @@ public class WhereUsedPanel extends BaseDataSourceSummaryPanel {
private final IngestRunningLabel ingestRunningLabel = new IngestRunningLabel(); private final IngestRunningLabel ingestRunningLabel = new IngestRunningLabel();
private final WhereUsedSummary whereUsedData;
/** /**
* Main constructor. * Main constructor.
*/ */
@ -99,25 +112,52 @@ public class WhereUsedPanel extends BaseDataSourceSummaryPanel {
/** /**
* Main constructor. * Main constructor.
* @param geolocationData The GeolocationSummary instance to use. *
* @param whereUsedData The GeolocationSummary instance to use.
*/ */
public WhereUsedPanel(WhereUsedSummary geolocationData) { public WhereUsedPanel(WhereUsedSummary whereUsedData) {
this.whereUsedData = whereUsedData;
// set up data acquisition methods // set up data acquisition methods
dataFetchComponents = Arrays.asList( dataFetchComponents = Arrays.asList(
new DataFetchWorker.DataFetchComponents<>( new DataFetchWorker.DataFetchComponents<>(
(dataSource) -> geolocationData.getCityCounts(dataSource), (dataSource) -> whereUsedData.getCityCounts(dataSource),
(result) -> showResultWithModuleCheck(cityCountsTable, result, GPX_FACTORY, GPX_NAME))); (result) -> handleData(result)));
initComponents(); initComponents();
} }
private void handleData(DataFetchResult<List<CityCount>> result) {
if (result != null && result.getResultType() == DataFetchResult.ResultType.SUCCESS && CollectionUtils.isNotEmpty(result.getData())) {
viewInGeolocationBtn.setEnabled(true);
}
showResultWithModuleCheck(cityCountsTable, result, GPX_FACTORY, GPX_NAME);
}
private void openGeolocationWindow(DataSource dataSource) {
// open the window
OpenGeolocationAction geoAction = CallableSystemAction.get(OpenGeolocationAction.class);
if (geoAction != null) {
geoAction.performAction();
}
// set the filter
TopComponent topComponent = WindowManager.getDefault().findTopComponent(GeolocationTopComponent.class.getSimpleName());
if (topComponent instanceof GeolocationTopComponent) {
GeolocationTopComponent geoComponent = (GeolocationTopComponent) topComponent;
geoComponent.fetchAndShowWaypoints(new GeoFilter(true, false, 0, Arrays.asList(dataSource), whereUsedData.getGeoTypes()));
}
}
@Override @Override
protected void fetchInformation(DataSource dataSource) { protected void fetchInformation(DataSource dataSource) {
viewInGeolocationBtn.setEnabled(false);
fetchInformation(dataFetchComponents, dataSource); fetchInformation(dataFetchComponents, dataSource);
} }
@Override @Override
protected void onNewDataSource(DataSource dataSource) { protected void onNewDataSource(DataSource dataSource) {
viewInGeolocationBtn.setEnabled(false);
onNewDataSource(dataFetchComponents, tables, dataSource); onNewDataSource(dataFetchComponents, tables, dataSource);
} }
@ -180,6 +220,12 @@ public class WhereUsedPanel extends BaseDataSourceSummaryPanel {
mainContentPanel.add(filler3); mainContentPanel.add(filler3);
org.openide.awt.Mnemonics.setLocalizedText(viewInGeolocationBtn, org.openide.util.NbBundle.getMessage(WhereUsedPanel.class, "WhereUsedPanel.viewInGeolocationBtn.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(viewInGeolocationBtn, org.openide.util.NbBundle.getMessage(WhereUsedPanel.class, "WhereUsedPanel.viewInGeolocationBtn.text")); // NOI18N
viewInGeolocationBtn.setEnabled(false);
viewInGeolocationBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
viewInGeolocationBtnActionPerformed(evt);
}
});
mainContentPanel.add(viewInGeolocationBtn); mainContentPanel.add(viewInGeolocationBtn);
filler5.setAlignmentX(0.0F); filler5.setAlignmentX(0.0F);
@ -199,6 +245,10 @@ public class WhereUsedPanel extends BaseDataSourceSummaryPanel {
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void viewInGeolocationBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewInGeolocationBtnActionPerformed
openGeolocationWindow(getDataSource());
}//GEN-LAST:event_viewInGeolocationBtnActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton viewInGeolocationBtn; private javax.swing.JButton viewInGeolocationBtn;

View File

@ -39,14 +39,14 @@ abstract class AbstractWaypointFetcher implements WaypointBuilder.WaypointFilter
private static final Logger logger = Logger.getLogger(AbstractWaypointFetcher.class.getName()); private static final Logger logger = Logger.getLogger(AbstractWaypointFetcher.class.getName());
private final GeoFilterPanel.GeoFilter filters; private final GeoFilter filters;
/** /**
* Constructs the Waypoint Runner * Constructs the Waypoint Runner
* *
* @param filters * @param filters
*/ */
AbstractWaypointFetcher(GeoFilterPanel.GeoFilter filters) { AbstractWaypointFetcher(GeoFilter filters) {
this.filters = filters; this.filters = filters;
} }

View File

@ -356,98 +356,6 @@ class GeoFilterPanel extends javax.swing.JPanel {
private javax.swing.JCheckBox showWaypointsWOTSCheckBox; private javax.swing.JCheckBox showWaypointsWOTSCheckBox;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
/**
* Class to store the values of the Geolocation user set filter parameters
*/
final class GeoFilter {
private final boolean showAll;
private final boolean showWithoutTimeStamp;
private final int mostRecentNumDays;
private final List<DataSource> dataSources;
private final List<ARTIFACT_TYPE> artifactTypes;
/**
* Construct a Geolocation filter. showAll and mostRecentNumDays are
* exclusive filters, ie they cannot be used together.
*
* withoutTimeStamp is only applicable if mostRecentNumDays is true.
*
* When using the filters "most recent days" means to include waypoints
* for the numbers of days after the most recent waypoint, not the
* current date.
*
* @param showAll True if all waypoints should be shown
* @param withoutTimeStamp True to show waypoints without timeStamps,
* this filter is only applicable if mostRecentNumDays is true
* @param mostRecentNumDays Show Waypoint for the most recent given
* number of days. This parameter is ignored if showAll is true.
* @param dataSources A list of dataSources to filter waypoint for.
* @param artifactTypes A list of artifactTypes to filter waypoint for.
*/
GeoFilter(boolean showAll, boolean withoutTimeStamp,
int mostRecentNumDays, List<DataSource> dataSources,
List<ARTIFACT_TYPE> artifactTypes) {
this.showAll = showAll;
this.showWithoutTimeStamp = withoutTimeStamp;
this.mostRecentNumDays = mostRecentNumDays;
this.dataSources = dataSources;
this.artifactTypes = artifactTypes;
}
/**
* Returns whether or not to show all waypoints.
*
* @return True if all waypoints should be shown.
*/
boolean showAllWaypoints() {
return showAll;
}
/**
* Returns whether or not to include waypoints with time stamps.
*
* This filter is only applicable if "showAll" is true.
*
* @return True if waypoints with time stamps should be shown.
*/
boolean showWaypointsWithoutTimeStamp() {
return showWithoutTimeStamp;
}
/**
* Returns the number of most recent days to show waypoints for. This
* value should be ignored if showAll is true.
*
* @return The number of most recent days to show waypoints for
*/
int getMostRecentNumDays() {
return mostRecentNumDays;
}
/**
* Returns a list of data sources to filter the waypoints by, or null if
* all datasources should be include.
*
* @return A list of dataSources or null if all dataSources should be
* included.
*/
List<DataSource> getDataSources() {
return Collections.unmodifiableList(dataSources);
}
/**
* Returns a list of artifact types to filter the waypoints by, or null
* if all types should be include.
*
* @return A list of artifactTypes or null if all artifactTypes should
* be included.
*/
List<ARTIFACT_TYPE> getArtifactTypes() {
return Collections.unmodifiableList(artifactTypes);
}
}
/** /**
* Container for data sources and artifact types to be given as filter * Container for data sources and artifact types to be given as filter
* options * options

View File

@ -48,7 +48,6 @@ import static org.sleuthkit.autopsy.casemodule.Case.Events.CURRENT_CASE;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.coreutils.ThreadConfined; import org.sleuthkit.autopsy.coreutils.ThreadConfined;
import org.sleuthkit.autopsy.geolocation.GeoFilterPanel.GeoFilter;
import org.sleuthkit.autopsy.geolocation.datamodel.GeoLocationDataException; import org.sleuthkit.autopsy.geolocation.datamodel.GeoLocationDataException;
import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.IngestManager;
import static org.sleuthkit.autopsy.ingest.IngestManager.IngestModuleEvent.DATA_ADDED; import static org.sleuthkit.autopsy.ingest.IngestManager.IngestModuleEvent.DATA_ADDED;
@ -295,6 +294,15 @@ public final class GeolocationTopComponent extends TopComponent {
return; return;
} }
fetchAndShowWaypoints(filters);
}
/**
* Loads and shows waypoints based on the filters.
*
* @param filters The filters to use.
*/
public void fetchAndShowWaypoints(GeoFilter filters) {
setWaypointLoading(true); setWaypointLoading(true);
geoFilterPanel.setEnabled(false); geoFilterPanel.setEnabled(false);
@ -491,8 +499,8 @@ public final class GeolocationTopComponent extends TopComponent {
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
/** /**
* Extends AbstractWaypointFetcher to handle the returning of * Extends AbstractWaypointFetcher to handle the returning of the filters
* the filters set of MapWaypoints. * set of MapWaypoints.
*/ */
@Messages({ @Messages({
"GeolocationTopComponent.WaypointFetcher.onErrorTitle=Error gathering GPS Track Data", "GeolocationTopComponent.WaypointFetcher.onErrorTitle=Error gathering GPS Track Data",
@ -507,13 +515,13 @@ public final class GeolocationTopComponent extends TopComponent {
@Override @Override
void handleFilteredWaypointSet(Set<MapWaypoint> mapWaypoints, List<Set<MapWaypoint>> tracks, boolean wasEntirelySuccessful) { void handleFilteredWaypointSet(Set<MapWaypoint> mapWaypoints, List<Set<MapWaypoint>> tracks, boolean wasEntirelySuccessful) {
addWaypointsToMap(mapWaypoints, tracks); addWaypointsToMap(mapWaypoints, tracks);
// if there is an error, present to the user. // if there is an error, present to the user.
if (!wasEntirelySuccessful) { if (!wasEntirelySuccessful) {
JOptionPane.showMessageDialog(GeolocationTopComponent.this, JOptionPane.showMessageDialog(GeolocationTopComponent.this,
Bundle.GeolocationTopComponent_WaypointFetcher_onErrorDescription(), Bundle.GeolocationTopComponent_WaypointFetcher_onErrorDescription(),
Bundle.GeolocationTopComponent_WaypointFetcher_onErrorTitle(), Bundle.GeolocationTopComponent_WaypointFetcher_onErrorTitle(),
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
} }
} }
} }