started on issue #174. Changed Save button to OK button. Updated default db path. Use default db path in file chooser. Use default db dir in file chooser.

This commit is contained in:
Nick Davis 2017-06-15 18:03:52 -04:00
parent a8ec3ac499
commit cc3d21c3ca
4 changed files with 24 additions and 19 deletions

View File

@ -41,7 +41,7 @@ public final class SqliteEamDbSettings {
private final static Logger LOGGER = Logger.getLogger(SqliteEamDbSettings.class.getName());
private final String DEFAULT_DBNAME = "EnterpriseArtifacts.db"; // NON-NLS
private final String DEFAULT_DBDIRECTORY = PlatformUtil.getUserDirectory() + File.separator + "Autopsy" + File.separator + "eamdb"; // NON-NLS
private final String DEFAULT_DBDIRECTORY = PlatformUtil.getUserDirectory() + File.separator + "enterprise_artifacts_manager"; // NON-NLS
private final int DEFAULT_BULK_THRESHHOLD = 1000;
private final String DEFAULT_BAD_TAGS = "Evidence"; // NON-NLS
private final String JDBC_DRIVER = "org.sqlite.JDBC"; // NON-NLS

View File

@ -17,7 +17,6 @@ EamPostgresSettingsDialog.bnSave.text=Save
EamPostgresSettingsDialog.lbHostName.text=Host Name / IP :
EamPostgresSettingsDialog.bnTestConnection.text=Test Connection
EamPostgresSettingsDialog.lbDatabaseName.text=Database name :
EamSqliteSettingsDialog.bnSave.text=Save
EamSqliteSettingsDialog.bnCancel.text=Cancel
EamSqliteSettingsDialog.lbTestDatabase.text=
EamSqliteSettingsDialog.bnTestDatabase.text=Test Connection
@ -68,3 +67,4 @@ ManageArtifactTypesDialog.cancelButton.text=Cancel
ManageArtifactTypesDialog.okButton.text=OK
ManageArtifactTypesDialog.lbWarningMsg.text=Warning Message
ManageArtifactTypesDialog.taInstructionsMsg.text=Select one or more artifact types to store in the database and use for correlation during Ingest.
EamSqliteSettingsDialog.bnOk.text=OK

View File

@ -91,7 +91,7 @@
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="lbTestDatabase" min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="bnSave" min="-2" max="-2" attributes="0"/>
<Component id="bnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="bnCancel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@ -116,7 +116,7 @@
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="bnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="bnSave" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="bnOk" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
@ -198,14 +198,14 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bnCancelActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="bnSave">
<Component class="javax.swing.JButton" name="bnOk">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/experimental/enterpriseartifactsmanager/optionspanel/Bundle.properties" key="EamSqliteSettingsDialog.bnSave.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="org/sleuthkit/autopsy/experimental/enterpriseartifactsmanager/optionspanel/Bundle.properties" key="EamSqliteSettingsDialog.bnOk.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="bnSaveActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bnOkActionPerformed"/>
</Events>
</Component>
</SubComponents>

View File

@ -87,7 +87,7 @@ public class EamSqliteSettingsDialog extends javax.swing.JDialog {
lbTestDatabaseWarning.setText("");
hasChanged = false;
tfDatabasePath.getDocument().addDocumentListener(textBoxChangedListener);
bnSave.setEnabled(false);
bnOk.setEnabled(false);
bnTestDatabase.setEnabled(false);
}
@ -135,11 +135,11 @@ public class EamSqliteSettingsDialog extends javax.swing.JDialog {
private boolean valid() {
boolean result = false;
if (tfDatabasePath.getText().trim().isEmpty()) {
bnSave.setEnabled(false);
bnOk.setEnabled(false);
bnTestDatabase.setEnabled(false);
} else {
storeDbNameAndDirectory();
bnSave.setEnabled(true);
bnOk.setEnabled(true);
bnTestDatabase.setEnabled(true);
result = true;
}
@ -182,7 +182,7 @@ public class EamSqliteSettingsDialog extends javax.swing.JDialog {
bnTestDatabase = new javax.swing.JButton();
lbTestDatabase = new javax.swing.JLabel();
bnCancel = new javax.swing.JButton();
bnSave = new javax.swing.JButton();
bnOk = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@ -218,10 +218,10 @@ public class EamSqliteSettingsDialog extends javax.swing.JDialog {
}
});
org.openide.awt.Mnemonics.setLocalizedText(bnSave, org.openide.util.NbBundle.getMessage(EamSqliteSettingsDialog.class, "EamSqliteSettingsDialog.bnSave.text")); // NOI18N
bnSave.addActionListener(new java.awt.event.ActionListener() {
org.openide.awt.Mnemonics.setLocalizedText(bnOk, org.openide.util.NbBundle.getMessage(EamSqliteSettingsDialog.class, "EamSqliteSettingsDialog.bnOk.text")); // NOI18N
bnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bnSaveActionPerformed(evt);
bnOkActionPerformed(evt);
}
});
@ -247,7 +247,7 @@ public class EamSqliteSettingsDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lbTestDatabase, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(bnSave)
.addComponent(bnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(bnCancel)
.addContainerGap())))
@ -267,7 +267,7 @@ public class EamSqliteSettingsDialog extends javax.swing.JDialog {
.addGap(19, 19, 19)
.addGroup(pnContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bnCancel)
.addComponent(bnSave)))
.addComponent(bnOk)))
.addGroup(pnContentLayout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(pnContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -311,11 +311,15 @@ public class EamSqliteSettingsDialog extends javax.swing.JDialog {
@Messages({"EnterpriseArtifactsManagerSQLiteSettingsDialog.chooserPath.failedToGetDbPathMsg=Selected database path is invalid. Try again."})
private void bnDatabasePathFileOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnDatabasePathFileOpenActionPerformed
fcDatabasePath.setCurrentDirectory(new File(dbSettings.getDbDirectory()));
fcDatabasePath.setSelectedFile(new File(dbSettings.getFileNameWithPath()));
if (fcDatabasePath.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
File databaseFile = fcDatabasePath.getSelectedFile();
try {
tfDatabasePath.setText(databaseFile.getCanonicalPath());
valid();
// TODO: create the db/schema if it doesn't exist.
// TODO: set variable noting that we created a new db, so it can be removed if Cancel button is clicked.
} catch (IOException ex) {
LOGGER.log(Level.SEVERE, "Failed to get path of selected database file", ex); // NON-NLS
@ -339,20 +343,21 @@ public class EamSqliteSettingsDialog extends javax.swing.JDialog {
}//GEN-LAST:event_bnTestDatabaseActionPerformed
private void bnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnCancelActionPerformed
// TODO: if a new db was created, then delete it. update settings to disable this platform
dispose();
}//GEN-LAST:event_bnCancelActionPerformed
private void bnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnSaveActionPerformed
private void bnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnOkActionPerformed
hasChanged = true;
dbSettings.setEnabled(true);
dbSettings.saveSettings();
dispose();
}//GEN-LAST:event_bnSaveActionPerformed
}//GEN-LAST:event_bnOkActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton bnCancel;
private javax.swing.JButton bnDatabasePathFileOpen;
private javax.swing.JButton bnSave;
private javax.swing.JButton bnOk;
private javax.swing.JButton bnTestDatabase;
private javax.swing.JFileChooser fcDatabasePath;
private javax.swing.JScrollPane jScrollPane;