Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Closing of the Shared Database Login Dialog if the user enters wrong authentication details - #4857 #4892

Merged
merged 11 commits into from
Apr 17, 2019
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ public SharedDatabaseLoginDialogView(JabRefFrame frame) {

@FXML
private void openDatabase() {
viewModel.openDatabase();
this.close();
boolean connected = viewModel.openDatabase();

if (connected) {
this.close();
}
}

@FXML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public SharedDatabaseLoginDialogViewModel(JabRefFrame frame, DialogService dialo
applyPreferences();
}

public void openDatabase() {
public boolean openDatabase() {

DBMSConnectionProperties connectionProperties = new DBMSConnectionProperties();
connectionProperties.setType(selectedDBMSType.getValue());
Expand All @@ -122,7 +122,8 @@ public void openDatabase() {
connectionProperties.setServerTimezone(serverTimezone.getValue());

setupKeyStore();
openSharedDatabase(connectionProperties);
boolean connected = openSharedDatabase(connectionProperties);
return connected;
}

private void setupKeyStore() {
Expand All @@ -131,12 +132,12 @@ private void setupKeyStore() {
System.setProperty("javax.net.debug", "ssl");
}

private void openSharedDatabase(DBMSConnectionProperties connectionProperties) {
private boolean openSharedDatabase(DBMSConnectionProperties connectionProperties) {
if (isSharedDatabaseAlreadyPresent(connectionProperties)) {

dialogService.showWarningDialogAndWait(Localization.lang("Shared database connection"),
Localization.lang("You are already connected to a database using entered connection details."));
return;
return true;
}

if (autosave.get()) {
Expand All @@ -149,7 +150,7 @@ private void openSharedDatabase(DBMSConnectionProperties connectionProperties) {
Localization.lang("Overwrite file"),
Localization.lang("Cancel"));
if (!overwriteFilePressed) {
return;
return true;
}
}
}
Expand All @@ -169,7 +170,7 @@ private void openSharedDatabase(DBMSConnectionProperties connectionProperties) {
}
}

return;
return true;
} catch (SQLException | InvalidDBMSConnectionPropertiesException exception) {

frame.getDialogService().showErrorDialogAndWait(Localization.lang("Connection error"), exception);
Expand All @@ -191,7 +192,7 @@ private void openSharedDatabase(DBMSConnectionProperties connectionProperties) {

}
loading.set(false);

return false;
}

private void setPreferences() {
Expand Down