6225 second attempt at fixing screenshot 2

This commit is contained in:
William Schaefer 2020-04-13 14:20:53 -04:00
parent 32e536d9a2
commit 26b7094e18
3 changed files with 306 additions and 241 deletions

View File

@ -30,7 +30,8 @@ import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
/**
* This class contains business logic for saving and validating settings for central repository.
* This class contains business logic for saving and validating settings for
* central repository.
*/
public class CentralRepoDbManager {
@ -48,12 +49,13 @@ public class CentralRepoDbManager {
private static final Object dbChoiceLock = new Object();
private static final Object disabledDueToFailureLock = new Object();
/**
* This saves the currently selected database choice and clears any disabledDueToFailure flag.
* @param choice The choice to save.
* @return The newly saved choice.
* This saves the currently selected database choice and clears any
* disabledDueToFailure flag.
*
* @param choice The choice to save.
*
* @return The newly saved choice.
*/
public static CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice) {
return saveDbChoice(choice, true);
@ -61,15 +63,19 @@ public class CentralRepoDbManager {
/**
* This saves the currently selected database choice.
* @param choice The choice to save.
* @param clearDisabledDueToError Whether or not to clear the 'disabledDueToFailure' settings key.
* @return The newly saved choice.
*
* @param choice The choice to save.
* @param clearDisabledDueToError Whether or not to clear the
* 'disabledDueToFailure' settings key.
*
* @return The newly saved choice.
*/
public static CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice, boolean clearDisabledDueToError) {
synchronized(dbChoiceLock) {
synchronized (dbChoiceLock) {
// clear disabling due to a failure
if (clearDisabledDueToError)
if (clearDisabledDueToError) {
setDisabledDueToFailure(false);
}
// change the settings
CentralRepoDbChoice newChoice = (choice == null) ? CentralRepoDbChoice.DISABLED : choice;
@ -83,27 +89,29 @@ public class CentralRepoDbManager {
}
/**
* This method indicates whether or not 'PostgreSQL using multi-user settings' is a valid option.
* @return True if 'PostgreSQL using multi-user settings' is valid.
* This method indicates whether or not 'PostgreSQL using multi-user
* settings' is a valid option.
*
* @return True if 'PostgreSQL using multi-user settings' is valid.
*/
public static boolean isPostgresMultiuserAllowed() {
// if multi user mode is not enabled, then this cannot be used
if (!UserPreferences.getIsMultiUserModeEnabled())
if (!UserPreferences.getIsMultiUserModeEnabled()) {
return false;
}
// also validate the connection as well
PostgresCentralRepoSettings multiUserSettings =
new PostgresCentralRepoSettings(PostgresSettingsLoader.MULTIUSER_SETTINGS_LOADER);
PostgresCentralRepoSettings multiUserSettings
= new PostgresCentralRepoSettings(PostgresSettingsLoader.MULTIUSER_SETTINGS_LOADER);
return multiUserSettings.testStatus() == DatabaseTestResult.TESTED_OK;
}
/**
* This method loads the selectedPlatform boolean from the config file if it is set.
* This method loads the selectedPlatform boolean from the config file if it
* is set.
*/
public static CentralRepoDbChoice getSavedDbChoice() {
synchronized(dbChoiceLock) {
synchronized (dbChoiceLock) {
if (savedChoice == null) {
String selectedPlatformString = ModuleSettings.getConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DB_SELECTED_PLATFORM_KEY); // NON-NLS
savedChoice = fromKey(selectedPlatformString);
@ -114,8 +122,10 @@ public class CentralRepoDbManager {
}
/**
* This method disables the central repository and indicates through a flag that this was due to a failure during database setup.
* This is used when re-enabling multi-user as a flag to determine whether or not CR should be re-enabled.
* This method disables the central repository and indicates through a flag
* that this was due to a failure during database setup. This is used when
* re-enabling multi-user as a flag to determine whether or not CR should be
* re-enabled.
*/
public static void disableDueToFailure() {
CentralRepoDbUtil.setUseCentralRepo(false);
@ -123,13 +133,15 @@ public class CentralRepoDbManager {
}
/**
* This method sets whether or not the repository has been disabled due to a database setup issue;
* This is used when re-enabling multi-user as a flag to determine whether or not CR should be re-enabled.
* This method sets whether or not the repository has been disabled due to a
* database setup issue; This is used when re-enabling multi-user as a flag
* to determine whether or not CR should be re-enabled.
*
* @param disabledDueToFailure Whether or not the repository has been disabled due to a database setup issue.
* @param disabledDueToFailure Whether or not the repository has been
* disabled due to a database setup issue.
*/
private static void setDisabledDueToFailure(boolean disabledDueToFailure) {
synchronized(disabledDueToFailureLock) {
synchronized (disabledDueToFailureLock) {
boolean oldValue = isDisabledDueToFailure();
ModuleSettings.setConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DISABLED_DUE_TO_FAILURE_KEY, Boolean.toString(disabledDueToFailure));
propertyChangeSupport.firePropertyChange("disabledDueToFailure", oldValue, disabledDueToFailure);
@ -137,36 +149,38 @@ public class CentralRepoDbManager {
}
/**
* This method retrieves setting whether or not the repository has been disabled due to a database setup issue;
* this is used when re-enabling multi-user as a flag to determine whether or not CR should be re-enabled.
* This method retrieves setting whether or not the repository has been
* disabled due to a database setup issue; this is used when re-enabling
* multi-user as a flag to determine whether or not CR should be re-enabled.
*
* @return Whether or not the repository has been disabled due to a database setup issue.
* @return Whether or not the repository has been disabled due to a database
* setup issue.
*/
public static boolean isDisabledDueToFailure() {
synchronized(disabledDueToFailureLock) {
synchronized (disabledDueToFailureLock) {
return Boolean.toString(true).equals(ModuleSettings.getConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DISABLED_DUE_TO_FAILURE_KEY));
}
}
/**
* This method adds a property change listener.
* NOTE: currently only listening for changes in currently saved db choice and disabling due to failure.
* This method adds a property change listener. NOTE: currently only
* listening for changes in currently saved db choice and disabling due to
* failure.
*
* @param listener The listener for the event.
* @param listener The listener for the event.
*/
public static void addPropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.addPropertyChangeListener(listener);
}
propertyChangeSupport.addPropertyChangeListener(listener);
}
/**
* This method removes a propert change listener.
* @param listener The listener to remove.
*
* @param listener The listener to remove.
*/
public static void removePropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.removePropertyChangeListener(listener);
}
public static void removePropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.removePropertyChangeListener(listener);
}
private static CentralRepoDbChoice fromKey(String keyName) {
for (CentralRepoDbChoice dbChoice : CentralRepoDbChoice.values()) {
@ -178,12 +192,11 @@ public class CentralRepoDbManager {
return CentralRepoDbChoice.DISABLED;
}
/**
* This method obtains the database connectivity for central repository.
*
* @return The CentralRepository object that will be used for connection.
*
* @throws CentralRepoException
*/
private static CentralRepository obtainCentralRepository() throws CentralRepoException {
@ -203,8 +216,10 @@ public class CentralRepoDbManager {
/**
* This method obtains a central repository lock.
*
* @param db The database connection.
* @return The lock if acquired.
* @param db The database connection.
*
* @return The lock if acquired.
*
* @throws CentralRepoException
*/
private static CoordinationService.Lock obtainCentralRepoLock(CentralRepository db) throws CentralRepoException {
@ -227,8 +242,9 @@ public class CentralRepoDbManager {
/**
* This method updates the central repository schema if necessary.
*
* @param db The database connectivity object.
* @param lock The acquired lock.
* @param db The database connectivity object.
* @param lock The acquired lock.
*
* @throws CentralRepoException
*/
private static void updatedDbSchema(CentralRepository db, CoordinationService.Lock lock) throws CentralRepoException {
@ -257,9 +273,9 @@ public class CentralRepoDbManager {
}
/**
* This method upgrades the current Central Reposity schema to the newest version. If the
* upgrade fails, the Central Repository will be disabled and the current
* settings will be cleared.
* This method upgrades the current Central Reposity schema to the newest
* version. If the upgrade fails, the Central Repository will be disabled
* and the current settings will be cleared.
*/
@NbBundle.Messages(value = {"EamDbUtil.centralRepoDisabled.message= The Central Repository has been disabled.", "EamDbUtil.centralRepoUpgradeFailed.message=Failed to upgrade Central Repository.", "EamDbUtil.centralRepoConnectionFailed.message=Unable to connect to Central Repository.", "EamDbUtil.exclusiveLockAquisitionFailure.message=Unable to acquire exclusive lock for Central Repository."})
public static void upgradeDatabase() throws CentralRepoException {
@ -296,8 +312,6 @@ public class CentralRepoDbManager {
}
}
private DatabaseTestResult testingStatus;
private CentralRepoDbChoice selectedDbChoice;
@ -314,10 +328,10 @@ public class CentralRepoDbManager {
dbSettingsSqlite = new SqliteCentralRepoSettings();
}
/**
* This method retrieves the current multi-user database settings.
* @return The current multi-user database settings.
*
* @return The current multi-user database settings.
*/
public PostgresCentralRepoSettings getDbSettingsMultiUser() {
return dbSettingsMultiUser;
@ -325,15 +339,18 @@ public class CentralRepoDbManager {
/**
* This method retrieves the current custom postgres database settings.
* @return The current custom postgres database settings.
*
* @return The current custom postgres database settings.
*/
public PostgresCentralRepoSettings getDbSettingsPostgres() {
return dbSettingsPostgres;
}
/**
* This method returns the current SQLite database settings for central repository.
* @return The current SQLite database settings
* This method returns the current SQLite database settings for central
* repository.
*
* @return The current SQLite database settings
*/
public SqliteCentralRepoSettings getDbSettingsSqlite() {
return dbSettingsSqlite;
@ -341,7 +358,8 @@ public class CentralRepoDbManager {
/**
* This method sets up the sqlite database with default settings.
* @throws CentralRepoException if unable to successfully set up database.
*
* @throws CentralRepoException if unable to successfully set up database.
*/
public void setupDefaultSqliteDb() throws CentralRepoException {
// change in-memory settings to default sqlite
@ -366,51 +384,62 @@ public class CentralRepoDbManager {
}
/**
* This method returns if changes to the central repository configuration were
* successfully applied.
* This method returns if changes to the central repository configuration
* were successfully applied.
*
* @return Returns true if the database configuration was successfully changed false
* if it was not.
* @return Returns true if the database configuration was successfully
* changed false if it was not.
*/
public boolean wasConfigurationChanged() {
return configurationChanged;
}
private CentralRepoDbConnectivityManager getSelectedSettings() throws CentralRepoException {
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER) {
return dbSettingsMultiUser;
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM)
}
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM) {
return dbSettingsPostgres;
if (selectedDbChoice == CentralRepoDbChoice.SQLITE)
}
if (selectedDbChoice == CentralRepoDbChoice.SQLITE) {
return dbSettingsSqlite;
if (selectedDbChoice == CentralRepoDbChoice.DISABLED)
}
if (selectedDbChoice == CentralRepoDbChoice.DISABLED) {
return null;
}
throw new CentralRepoException("Unknown database type: " + selectedDbChoice);
throw new CentralRepoException("Unknown database type: " + selectedDbChoice);
}
private RdbmsCentralRepoFactory getDbFactory() throws CentralRepoException {
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER) {
return new RdbmsCentralRepoFactory(CentralRepoPlatforms.POSTGRESQL, dbSettingsMultiUser);
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM)
}
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM) {
return new RdbmsCentralRepoFactory(CentralRepoPlatforms.POSTGRESQL, dbSettingsPostgres);
if (selectedDbChoice == CentralRepoDbChoice.SQLITE)
}
if (selectedDbChoice == CentralRepoDbChoice.SQLITE) {
return new RdbmsCentralRepoFactory(CentralRepoPlatforms.SQLITE, dbSettingsSqlite);
if (selectedDbChoice == CentralRepoDbChoice.DISABLED)
}
if (selectedDbChoice == CentralRepoDbChoice.DISABLED) {
return null;
}
throw new CentralRepoException("Unknown database type: " + selectedDbChoice);
}
/**
* This method creates a central repo database if it does not already exist.
* @return True if successful; false if unsuccessful.
*
* @return True if successful; false if unsuccessful.
*
* @throws CentralRepoException
*/
public boolean createDb() throws CentralRepoException {
CentralRepoDbConnectivityManager selectedDbSettings = getSelectedSettings();
if (selectedDbSettings == null)
if (selectedDbSettings == null) {
throw new CentralRepoException("Unable to derive connectivity manager from settings: " + selectedDbChoice);
}
boolean result = false;
boolean dbCreated = true;
@ -493,18 +522,20 @@ public class CentralRepoDbManager {
}
/**
* This method retrieves the current status.
* Note: this could be a dirty value if testing of the connection has not been performed.
* @return The current status of the database connection.
* This method retrieves the current status. Note: this could be a dirty
* value if testing of the connection has not been performed.
*
* @return The current status of the database connection.
*/
public DatabaseTestResult getStatus() {
return testingStatus;
}
/**
* This method retrieves the currently selected database choice.
* NOTE: This choice may not align with the saved setting.
* @return The currently selected database choice.
* This method retrieves the currently selected database choice. NOTE: This
* choice may not align with the saved setting.
*
* @return The currently selected database choice.
*/
public CentralRepoDbChoice getSelectedDbChoice() {
return selectedDbChoice;
@ -518,8 +549,10 @@ public class CentralRepoDbManager {
}
/**
* This method sets the currently selected database choice and sets the testing status to untested.
* @param newSelected The new database choice.
* This method sets the currently selected database choice and sets the
* testing status to untested.
*
* @param newSelected The new database choice.
*/
public void setSelctedDbChoice(CentralRepoDbChoice newSelected) {
selectedDbChoice = newSelected;
@ -527,8 +560,8 @@ public class CentralRepoDbManager {
}
/**
* This method tests whether or not the settings have been filled in for the UI.
* NOTE: This does not check the connectivity status of these settings.
* This method tests whether or not the settings have been filled in for the
* UI. NOTE: This does not check the connectivity status of these settings.
*
* @return True if database settings are valid.
*/
@ -541,13 +574,11 @@ public class CentralRepoDbManager {
dbSettingsPostgres.setDbName(CENTRAL_REPO_DB_NAME);
dbSettingsPostgres.setUserName(tbDbUsername);
dbSettingsPostgres.setPassword(jpDbPassword);
}
else if (selectedDbChoice == CentralRepoDbChoice.SQLITE) {
} else if (selectedDbChoice == CentralRepoDbChoice.SQLITE) {
File databasePath = new File(tfDatabasePath);
dbSettingsSqlite.setDbName(SqliteCentralRepoSettings.DEFAULT_DBNAME);
dbSettingsSqlite.setDbDirectory(databasePath.getPath());
}
else if (selectedDbChoice != CentralRepoDbChoice.POSTGRESQL_MULTIUSER) {
} else if (selectedDbChoice != CentralRepoDbChoice.POSTGRESQL_MULTIUSER) {
throw new IllegalStateException("Central Repo has an unknown selected platform: " + selectedDbChoice);
}
@ -555,16 +586,18 @@ public class CentralRepoDbManager {
}
/**
* This method tests the current database settings to see if a valid connection can be made.
* @return The result of testing the connection.
* This method tests the current database settings to see if a valid
* connection can be made.
*
* @return The result of testing the connection.
*/
public DatabaseTestResult testStatus() {
try {
CentralRepoDbConnectivityManager manager = getSelectedSettings();
if (manager != null)
if (manager != null) {
testingStatus = manager.testStatus();
}
catch (CentralRepoException e) {
}
} catch (CentralRepoException e) {
logger.log(Level.WARNING, "unable to test status of db connection in central repo", e);
}

View File

@ -38,7 +38,7 @@
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
<Component id="bnCancel" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="pnSQLiteSettings" alignment="0" max="32767" attributes="0"/>
<Component id="pnSQLiteSettings" alignment="0" pref="648" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
@ -94,8 +94,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbDatabasePath.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[191, 16]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/>
<Dimension value="[100, 14]"/>
</Property>
</Properties>
<Constraints>
@ -109,8 +112,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbHostName.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[195, 16]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/>
<Dimension value="[110, 14]"/>
</Property>
</Properties>
<Constraints>
@ -127,7 +133,7 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="3" gridWidth="1" gridHeight="2" fill="0" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="2" gridY="3" gridWidth="1" gridHeight="2" fill="2" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
@ -136,8 +142,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbPort.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[132, 16]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/>
<Dimension value="[90, 14]"/>
</Property>
</Properties>
<Constraints>
@ -154,7 +163,7 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="5" gridWidth="1" gridHeight="2" fill="0" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="2" gridY="5" gridWidth="1" gridHeight="2" fill="2" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
@ -163,8 +172,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbUserName.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[172, 16]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/>
<Dimension value="[100, 14]"/>
</Property>
</Properties>
<Constraints>
@ -181,7 +193,7 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="7" gridWidth="1" gridHeight="2" fill="0" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="2" gridY="7" gridWidth="1" gridHeight="2" fill="2" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
@ -190,8 +202,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbUserPassword.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[194, 16]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/>
<Dimension value="[110, 14]"/>
</Property>
</Properties>
<Constraints>
@ -208,7 +223,7 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="9" gridWidth="1" gridHeight="2" fill="0" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="2" gridY="9" gridWidth="1" gridHeight="2" fill="2" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
@ -218,13 +233,13 @@
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbDatabaseType.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/>
<Dimension value="[180, 14]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/>
<Dimension value="[100, 14]"/>
</Property>
</Properties>
<Constraints>
@ -238,8 +253,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbDatabaseDesc.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[182, 16]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/>
<Dimension value="[100, 14]"/>
</Property>
</Properties>
<Constraints>
@ -296,7 +314,7 @@
<Container class="javax.swing.JPanel" name="pathPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="1" gridWidth="1" gridHeight="2" fill="0" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="2" gridY="1" gridWidth="1" gridHeight="2" fill="2" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
@ -304,11 +322,11 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="tfDatabasePath" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="tfDatabasePath" max="32767" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="bnDatabasePathFileOpen" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -362,10 +380,10 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="cbDatabaseType" min="-2" pref="210" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="cbDatabaseType" pref="210" max="32767" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="lbSingleUserSqLite" pref="318" max="32767" attributes="0"/>
<Component id="lbSingleUserSqLite" pref="303" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
</Group>
</Group>

View File

@ -41,7 +41,6 @@ import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.filechooser.FileFilter;
import org.netbeans.spi.options.OptionsPanelController;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.openide.windows.WindowManager;
@ -65,9 +64,11 @@ public class EamDbSettingsDialog extends JDialog {
private static final long serialVersionUID = 1L;
/**
* This class handles displaying and rendering drop down menu for database choices in central repo.
* This class handles displaying and rendering drop down menu for database
* choices in central repo.
*/
private class DbChoiceRenderer extends JLabel implements ListCellRenderer<CentralRepoDbChoice>, Serializable {
private static final long serialVersionUID = 1L;
@Override
@ -83,7 +84,6 @@ public class EamDbSettingsDialog extends JDialog {
}
}
private final Collection<JTextField> textBoxes;
private final TextBoxChangedListener textBoxChangedListener;
private final CentralRepoDbManager manager = new CentralRepoDbManager();
@ -94,10 +94,9 @@ public class EamDbSettingsDialog extends JDialog {
}
private boolean isDbChoiceSelectable(CentralRepoDbChoice item) {
return (item != CentralRepoDbChoice.POSTGRESQL_MULTIUSER || manager.isPostgresMultiuserAllowed());
return (item != CentralRepoDbChoice.POSTGRESQL_MULTIUSER || CentralRepoDbManager.isPostgresMultiuserAllowed());
}
/**
* Creates new form EamDbSettingsDialog
*/
@ -123,7 +122,7 @@ public class EamDbSettingsDialog extends JDialog {
if (pathname.isDirectory()) {
return true;
}
return pathname.getName().equalsIgnoreCase(SqliteCentralRepoSettings.DEFAULT_DBNAME);
return pathname.getName().equalsIgnoreCase(SqliteCentralRepoSettings.DEFAULT_DBNAME);
}
@Override
@ -137,26 +136,28 @@ public class EamDbSettingsDialog extends JDialog {
display();
}
private void setupDbChoice(CentralRepoDbChoice initialMenuItem) {
// setup initially selected item
CentralRepoDbChoice toSelect = (initialMenuItem == null) ?
(Arrays.asList(CentralRepoDbChoice.DB_CHOICES).contains(manager.getSelectedDbChoice())) ?
manager.getSelectedDbChoice() :
CentralRepoDbChoice.DB_CHOICES[0] :
initialMenuItem;
CentralRepoDbChoice toSelect = (initialMenuItem == null)
? (Arrays.asList(CentralRepoDbChoice.DB_CHOICES).contains(manager.getSelectedDbChoice()))
? manager.getSelectedDbChoice()
: CentralRepoDbChoice.DB_CHOICES[0]
: initialMenuItem;
cbDatabaseType.setRenderer(DB_CHOICE_RENDERER);
changeDbSelection(toSelect);
}
/**
* This method prompts user based on testing status (i.e. failure to connect, invalid schema, db does not exist, etc.).
* @param manager The manager to use when setting up the database.
* @param dialog If non-null value, validates settings and updates 'okay' button enabled state.
* @return Whether or not the ultimate status after prompts is okay to continue.
/**
* This method prompts user based on testing status (i.e. failure to
* connect, invalid schema, db does not exist, etc.).
*
* @param manager The manager to use when setting up the database.
* @param dialog If non-null value, validates settings and updates 'okay'
* button enabled state.
*
* @return Whether or not the ultimate status after prompts is okay to
* continue.
*/
@NbBundle.Messages({"EamDbSettingsDialog.okButton.corruptDatabaseExists.title=Error Loading Central Repository Database",
"EamDbSettingsDialog.okButton.corruptDatabaseExists.message=Central Repository Database exists but is not the right format. Manually delete it or choose a different path (if applicable).",
@ -186,11 +187,11 @@ public class EamDbSettingsDialog extends JDialog {
return (manager.getStatus() == DatabaseTestResult.TESTED_OK);
}
/**
* This method prompts the user whether or not they would like to create a database in the instance that
* it doesn't exist.
* @param manager The manager to use when setting up the database.
/**
* This method prompts the user whether or not they would like to create a
* database in the instance that it doesn't exist.
*
* @param manager The manager to use when setting up the database.
* @param dialog If non-null value, validates settings and updates 'okay'
* button enabled state.
*
@ -219,10 +220,12 @@ public class EamDbSettingsDialog extends JDialog {
return manager.testStatus() == DatabaseTestResult.TESTED_OK;
}
/**
* When an error occurs while going through promptTestStatusWarning, this method is called.
* @param manager1 The manager to use as service class.
* When an error occurs while going through promptTestStatusWarning, this
* method is called.
*
* @param manager1 The manager to use as service class.
*
* @throws HeadlessException
*/
private static void onPromptStatusError(CentralRepoDbManager manager1) {
@ -241,7 +244,6 @@ public class EamDbSettingsDialog extends JDialog {
JOptionPane.WARNING_MESSAGE);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
@ -296,7 +298,8 @@ public class EamDbSettingsDialog extends JDialog {
pnSQLiteSettings.setLayout(new java.awt.GridBagLayout());
org.openide.awt.Mnemonics.setLocalizedText(lbDatabasePath, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbDatabasePath.text")); // NOI18N
lbDatabasePath.setPreferredSize(new java.awt.Dimension(80, 14));
lbDatabasePath.setMaximumSize(new java.awt.Dimension(191, 16));
lbDatabasePath.setPreferredSize(new java.awt.Dimension(100, 14));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
@ -307,7 +310,8 @@ public class EamDbSettingsDialog extends JDialog {
pnSQLiteSettings.add(lbDatabasePath, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(lbHostName, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbHostName.text")); // NOI18N
lbHostName.setPreferredSize(new java.awt.Dimension(80, 14));
lbHostName.setMaximumSize(new java.awt.Dimension(195, 16));
lbHostName.setPreferredSize(new java.awt.Dimension(110, 14));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
@ -322,12 +326,14 @@ public class EamDbSettingsDialog extends JDialog {
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 3;
gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6);
pnSQLiteSettings.add(tbDbHostname, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(lbPort, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbPort.text")); // NOI18N
lbPort.setPreferredSize(new java.awt.Dimension(80, 14));
lbPort.setMaximumSize(new java.awt.Dimension(132, 16));
lbPort.setPreferredSize(new java.awt.Dimension(90, 14));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 5;
@ -342,12 +348,14 @@ public class EamDbSettingsDialog extends JDialog {
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 5;
gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6);
pnSQLiteSettings.add(tbDbPort, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(lbUserName, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbUserName.text")); // NOI18N
lbUserName.setPreferredSize(new java.awt.Dimension(80, 14));
lbUserName.setMaximumSize(new java.awt.Dimension(172, 16));
lbUserName.setPreferredSize(new java.awt.Dimension(100, 14));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 7;
@ -362,12 +370,14 @@ public class EamDbSettingsDialog extends JDialog {
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 7;
gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6);
pnSQLiteSettings.add(tbDbUsername, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(lbUserPassword, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbUserPassword.text")); // NOI18N
lbUserPassword.setPreferredSize(new java.awt.Dimension(80, 14));
lbUserPassword.setMaximumSize(new java.awt.Dimension(194, 16));
lbUserPassword.setPreferredSize(new java.awt.Dimension(110, 14));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 9;
@ -382,14 +392,15 @@ public class EamDbSettingsDialog extends JDialog {
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 9;
gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6);
pnSQLiteSettings.add(jpDbPassword, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseType, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbDatabaseType.text")); // NOI18N
lbDatabaseType.setMaximumSize(new java.awt.Dimension(80, 14));
lbDatabaseType.setMaximumSize(new java.awt.Dimension(180, 14));
lbDatabaseType.setMinimumSize(new java.awt.Dimension(80, 14));
lbDatabaseType.setPreferredSize(new java.awt.Dimension(80, 14));
lbDatabaseType.setPreferredSize(new java.awt.Dimension(100, 14));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
@ -400,7 +411,8 @@ public class EamDbSettingsDialog extends JDialog {
pnSQLiteSettings.add(lbDatabaseType, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseDesc, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbDatabaseDesc.text")); // NOI18N
lbDatabaseDesc.setPreferredSize(new java.awt.Dimension(80, 14));
lbDatabaseDesc.setMaximumSize(new java.awt.Dimension(182, 16));
lbDatabaseDesc.setPreferredSize(new java.awt.Dimension(100, 14));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 11;
@ -452,7 +464,7 @@ public class EamDbSettingsDialog extends JDialog {
pathPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pathPanelLayout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(tfDatabasePath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tfDatabasePath, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(bnDatabasePathFileOpen)
.addGap(0, 0, 0))
@ -471,6 +483,7 @@ public class EamDbSettingsDialog extends JDialog {
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6);
pnSQLiteSettings.add(pathPanel, gridBagConstraints);
@ -492,9 +505,9 @@ public class EamDbSettingsDialog extends JDialog {
typePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(typePanelLayout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(cbDatabaseType, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbDatabaseType, 0, 210, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lbSingleUserSqLite, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
.addComponent(lbSingleUserSqLite, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE)
.addGap(0, 0, 0))
);
typePanelLayout.setVerticalGroup(
@ -545,7 +558,7 @@ public class EamDbSettingsDialog extends JDialog {
.addComponent(bnOk)
.addGap(11, 11, 11)
.addComponent(bnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(pnSQLiteSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(pnSQLiteSettings, javax.swing.GroupLayout.DEFAULT_SIZE, 648, Short.MAX_VALUE))
.addContainerGap())
);
@ -575,12 +588,10 @@ public class EamDbSettingsDialog extends JDialog {
if (manager.getSelectedDbChoice() == CentralRepoDbChoice.SQLITE) {
updatePostgresFields(false);
updateSqliteFields(true);
}
else if (manager.getSelectedDbChoice() == CentralRepoDbChoice.POSTGRESQL_CUSTOM) {
} else if (manager.getSelectedDbChoice() == CentralRepoDbChoice.POSTGRESQL_CUSTOM) {
updatePostgresFields(true);
updateSqliteFields(false);
}
else {
} else {
updatePostgresFields(false);
updateSqliteFields(false);
}
@ -615,35 +626,46 @@ public class EamDbSettingsDialog extends JDialog {
"EamDbSettingsDialog.okButton.errorMsg.text=Please restart Autopsy to begin using the new database platform.",
"EamDbSettingsDialog.okButton.connectionErrorMsg.text=Failed to connect to central repository database."})
private void bnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnOkActionPerformed
if (testStatusAndCreate(this, manager, this))
if (testStatusAndCreate(this, manager, this)) {
dispose();
}
}//GEN-LAST:event_bnOkActionPerformed
/**
* This method tests status for central repo db / creation and prompts user accordingly.
* @param parent The parent component (the anchor for displaying dialogs).
* @param manager The central repo db manager with settings to be tested and saved.
* @return Whether or not central repo db was successfully be created or found.
* This method tests status for central repo db / creation and prompts user
* accordingly.
*
* @param parent The parent component (the anchor for displaying dialogs).
* @param manager The central repo db manager with settings to be tested and
* saved.
*
* @return Whether or not central repo db was successfully be created or
* found.
*/
public static boolean testStatusAndCreate(Component parent, CentralRepoDbManager manager) {
return testStatusAndCreate(parent, manager, null);
}
/**
* This method tests status for central repo db / creation and prompts user accordingly.
* @param parent The parent component (the anchor for displaying dialogs).
* @param manager The central repo db manager with settings to be tested and saved.
* @param dialog The db settings dialog; if non-null, will validate okay button state.
* @return Whether or not central repo db was successfully be created or found.
* This method tests status for central repo db / creation and prompts user
* accordingly.
*
* @param parent The parent component (the anchor for displaying dialogs).
* @param manager The central repo db manager with settings to be tested and
* saved.
* @param dialog The db settings dialog; if non-null, will validate okay
* button state.
*
* @return Whether or not central repo db was successfully be created or
* found.
*/
private static boolean testStatusAndCreate(Component parent, CentralRepoDbManager manager, EamDbSettingsDialog dialog) {
parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
manager.testStatus();
if (dialog != null)
if (dialog != null) {
dialog.valid();
}
boolean testedOk = promptTestStatusWarnings(manager, dialog);
if (!testedOk) {
@ -651,15 +673,14 @@ public class EamDbSettingsDialog extends JDialog {
return false;
}
try{
try {
manager.saveNewCentralRepo();
}
catch (CentralRepoException e) {
} catch (CentralRepoException e) {
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(parent,
Bundle.EamDbSettingsDialog_okButton_errorMsg_text(),
Bundle.EamDbSettingsDialog_okButton_errorTitle_text(),
JOptionPane.WARNING_MESSAGE);
Bundle.EamDbSettingsDialog_okButton_errorMsg_text(),
Bundle.EamDbSettingsDialog_okButton_errorTitle_text(),
JOptionPane.WARNING_MESSAGE);
});
parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
@ -670,13 +691,12 @@ public class EamDbSettingsDialog extends JDialog {
return true;
}
/**
* This method returns if changes to the central repository configuration were
* successfully applied.
* This method returns if changes to the central repository configuration
* were successfully applied.
*
* @return True if the database configuration was successfully changed; false
* if it was not.
* @return True if the database configuration was successfully changed;
* false if it was not.
*/
public boolean wasConfigurationChanged() {
return manager.wasConfigurationChanged();
@ -696,8 +716,7 @@ public class EamDbSettingsDialog extends JDialog {
if (isDbChoiceSelectable(selectedItem)) {
manager.setSelctedDbChoice(selectedItem);
cbDatabaseType.setSelectedItem(selectedItem);
}
else {
} else {
cbDatabaseType.setSelectedItem(manager.getSelectedDbChoice());
}
@ -800,7 +819,7 @@ public class EamDbSettingsDialog extends JDialog {
* Adds a change listener to a collection of text fields.
*
* @param textFields The text fields.
* @param listener The change listener.
* @param listener The change listener.
*/
private static void addDocumentListeners(Collection<JTextField> textFields, TextBoxChangedListener listener) {
textFields.forEach((textField) -> {
@ -823,8 +842,7 @@ public class EamDbSettingsDialog extends JDialog {
// && !tbDbName.getText().trim().isEmpty()
&& !tbDbUsername.getText().trim().isEmpty()
&& 0 < jpDbPassword.getPassword().length;
}
else if (manager.getSelectedDbChoice() == CentralRepoDbChoice.SQLITE) {
} else if (manager.getSelectedDbChoice() == CentralRepoDbChoice.SQLITE) {
result = !tfDatabasePath.getText().trim().isEmpty();
}
@ -841,7 +859,6 @@ public class EamDbSettingsDialog extends JDialog {
&& databaseSettingsAreValid();
}
/**
* Validates that the form is filled out correctly for our usage.
*
@ -868,8 +885,6 @@ public class EamDbSettingsDialog extends JDialog {
}
/**
* Tests whether or not the database settings are valid.
*
@ -883,8 +898,7 @@ public class EamDbSettingsDialog extends JDialog {
tbDbUsername.getText().trim(),
tfDatabasePath.getText().trim(),
new String(jpDbPassword.getPassword()));
}
catch (CentralRepoException | NumberFormatException | IllegalStateException e) {
} catch (CentralRepoException | NumberFormatException | IllegalStateException e) {
return false;
}