Skip to content

Commit

Permalink
Fixed Closing of the Shared Database Login Dialog if the user enters …
Browse files Browse the repository at this point in the history
…wrong authentication details - #4857 (#4892)

* Fix for the issue - #4783 Group creation not possible anymore with default settings

* Changed the position of the listeners and onaction replaced with changelistener

* Removed changelog entry

* Fix for issue 4783 - Simplified listeners in to lambdas

* Update GroupDialog.java

* Fixed shared db dialog close when incorrect authentication details

* Changed Boolean in to boolean as requested changes - SharedDatabaseLoginDialog
  • Loading branch information
harinda05 authored and tobiasdiez committed Apr 17, 2019
1 parent 9ab59d0 commit 6fd0102
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
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

0 comments on commit 6fd0102

Please sign in to comment.