Added mbtile test button

This commit is contained in:
Kelly Kelly 2019-12-04 11:51:38 -05:00
parent f98c7a23ff
commit 870546fa2c
4 changed files with 89 additions and 4 deletions

View File

@ -34,3 +34,4 @@ GeolocationSettingsPanel.zipFilePathField.text=
GeolocationSettingsPanel.serverTestBtn.text=Test
GeolocationSettingsPanel.mbtilesBrowseBtn.text=Browse
GeolocationSettingsPanel.zipFileBrowseBnt.text=Browse
GeolocationSettingsPanel.mbtileTestBtn.text=Test

View File

@ -3,6 +3,14 @@ CTL_GeolocationTopComponentAction=GeolocationTopComponent
CTL_GeolocationTopComponent=Geolocation
GeoFilterPanel_DataSource_List_Title=Data Sources
GeoFilterPanel_empty_dataSource=Data Source list is empty.
GeolocationSettings_mbtile_does_not_exist_message=The file supplied does not exist.\nPlease verify that the file exists and try again.
GeolocationSettings_mbtile_does_not_exist_title=File Not Found
GeolocationSettings_mbtile_not_valid_message=The supplied file is not a raster tile file.
GeolocationSettings_mbtile_not_valid_title=File Not Valid
GeolocationSettings_mbtile_test_success_message=The supplied file is a valid mbtile raster file.
GeolocationSettings_mbtile_test_success_title=Success
GeolocationSettings_path_not_valid_message=The supplied file path is empty.\nPlease supply a valid file path.
GeolocationSettings_path_not_valid_title=File Not Valid
GeolocationSettingsPanel_malformed_url_message=The supplies OSM tile server address is invalid.\nPlease supply a well formed url prefixed with http://
GeolocationSettingsPanel_malformed_url_message_tile=Malformed URL
GeolocationSettingsPanel_osm_server_test_fail_message=OSM tile server test failed.\nUnable to connect to server.
@ -58,4 +66,5 @@ GeolocationSettingsPanel.zipFilePathField.text=
GeolocationSettingsPanel.serverTestBtn.text=Test
GeolocationSettingsPanel.mbtilesBrowseBtn.text=Browse
GeolocationSettingsPanel.zipFileBrowseBnt.text=Browse
GeolocationSettingsPanel.mbtileTestBtn.text=Test
WaypointExtractAction_label=Extract Files(s)

View File

@ -61,7 +61,7 @@
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="3" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="9" insetsLeft="0" insetsBottom="9" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
<GridBagConstraints gridX="0" gridY="0" gridWidth="4" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="9" insetsLeft="0" insetsBottom="9" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
@ -145,7 +145,7 @@
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="9" insetsBottom="9" insetsRight="9" anchor="18" weightX="1.0" weightY="0.0"/>
<GridBagConstraints gridX="2" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="9" insetsBottom="9" insetsRight="9" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
@ -215,6 +215,21 @@
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="mbtileTestBtn">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/geolocation/Bundle.properties" key="GeolocationSettingsPanel.mbtileTestBtn.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mbtileTestBtnActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="3" gridY="3" gridWidth="1" gridHeight="1" fill="0" ipadX="20" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>

View File

@ -20,7 +20,9 @@ package org.sleuthkit.autopsy.geolocation;
import java.awt.Color;
import java.io.File;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.logging.Level;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import org.apache.commons.validator.routines.UrlValidator;
@ -28,10 +30,12 @@ import org.jxmapviewer.OSMTileFactoryInfo;
import org.jxmapviewer.viewer.TileFactoryInfo;
import org.jxmapviewer.viewer.util.GeoUtil;
import org.netbeans.spi.options.OptionsPanelController;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.GeneralFilter;
import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
import org.sleuthkit.autopsy.coreutils.Logger;
/**
* A panel to allow the user to set the custom properties of the geolocation
@ -42,6 +46,8 @@ final class GeolocationSettingsPanel extends javax.swing.JPanel implements Optio
private static final long serialVersionUID = 1L;
private static final Logger logger = Logger.getLogger(GeolocationSettingsPanel.class.getName());
/**
* Creates new GeolocationSettingsPanel
*/
@ -92,6 +98,7 @@ final class GeolocationSettingsPanel extends javax.swing.JPanel implements Optio
zipFileBrowseBnt.setEnabled(zipFileRBnt.isSelected());
mbtileFileField.setEnabled(mbtilesRBtn.isSelected());
mbtilesBrowseBtn.setEnabled(mbtilesRBtn.isSelected());
mbtileTestBtn.setEnabled(mbtilesRBtn.isSelected());
}
/**
@ -154,6 +161,7 @@ final class GeolocationSettingsPanel extends javax.swing.JPanel implements Optio
mbtilesRBtn = new javax.swing.JRadioButton();
mbtileFileField = new javax.swing.JTextField();
mbtilesBrowseBtn = new javax.swing.JButton();
mbtileTestBtn = new javax.swing.JButton();
setLayout(new java.awt.GridBagLayout());
@ -171,7 +179,7 @@ final class GeolocationSettingsPanel extends javax.swing.JPanel implements Optio
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.gridwidth = 4;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(9, 0, 9, 0);
@ -230,7 +238,6 @@ final class GeolocationSettingsPanel extends javax.swing.JPanel implements Optio
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 9, 9, 9);
tilePane.add(zipFileBrowseBnt, gridBagConstraints);
@ -284,6 +291,20 @@ final class GeolocationSettingsPanel extends javax.swing.JPanel implements Optio
gridBagConstraints.insets = new java.awt.Insets(0, 9, 9, 9);
tilePane.add(mbtilesBrowseBtn, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(mbtileTestBtn, org.openide.util.NbBundle.getMessage(GeolocationSettingsPanel.class, "GeolocationSettingsPanel.mbtileTestBtn.text")); // NOI18N
mbtileTestBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mbtileTestBtnActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 3;
gridBagConstraints.ipadx = 20;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weightx = 1.0;
tilePane.add(mbtileTestBtn, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
@ -369,10 +390,49 @@ final class GeolocationSettingsPanel extends javax.swing.JPanel implements Optio
}
}//GEN-LAST:event_mbtilesBrowseBtnActionPerformed
@Messages({
"GeolocationSettings_mbtile_does_not_exist_message=The file supplied does not exist.\nPlease verify that the file exists and try again.",
"GeolocationSettings_mbtile_does_not_exist_title=File Not Found",
"GeolocationSettings_mbtile_not_valid_message=The supplied file is not a raster tile file.",
"GeolocationSettings_mbtile_not_valid_title=File Not Valid",
"GeolocationSettings_path_not_valid_message=The supplied file path is empty.\nPlease supply a valid file path.",
"GeolocationSettings_path_not_valid_title=File Not Valid",
"GeolocationSettings_mbtile_test_success_message=The supplied file is a valid mbtile raster file.",
"GeolocationSettings_mbtile_test_success_title=Success",
})
private void mbtileTestBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mbtileTestBtnActionPerformed
String mbtilePath = mbtileFileField.getText();
if(mbtilePath.isEmpty()) {
JOptionPane.showMessageDialog(this, Bundle.GeolocationSettings_path_not_valid_message(), Bundle.GeolocationSettings_path_not_valid__title(), JOptionPane.ERROR_MESSAGE);
return;
}
File file = new File(mbtilePath);
if(!file.exists()) {
JOptionPane.showMessageDialog(this, Bundle.GeolocationSettings_mbtile_does_not_exist_message(), Bundle.GeolocationSettings_mbtile_does_not_exist_title(), JOptionPane.ERROR_MESSAGE);
return;
}
try {
if(!MBTilesFileConnector.isValidMBTileRasterFile(mbtilePath)) {
JOptionPane.showMessageDialog(this, Bundle.GeolocationSettings_mbtile_not_valid_message(), Bundle.GeolocationSettings_mbtile_not_valid_title(), JOptionPane.ERROR_MESSAGE);
return;
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(this, Bundle.GeolocationSettings_mbtile_not_valid_message(), Bundle.GeolocationSettings_mbtile_not_valid_title(), JOptionPane.ERROR_MESSAGE);
logger.log(Level.WARNING, String.format("Exception thrown while testing mbtile file %s", mbtilePath), ex);
return;
}
JOptionPane.showMessageDialog(this, Bundle.GeolocationSettings_mbtile_test_success_message(), Bundle.GeolocationSettings_mbtile_test_success_title(), JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_mbtileTestBtnActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JRadioButton defaultDataSource;
private javax.swing.JTextField mbtileFileField;
private javax.swing.JButton mbtileTestBtn;
private javax.swing.JButton mbtilesBrowseBtn;
private javax.swing.JRadioButton mbtilesRBtn;
private javax.swing.JTextField osmServerAddressField;