-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
minor refactor to JabRefDialogService #11767
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,7 +10,6 @@ | |||||
import java.util.List; | ||||||
import java.util.Optional; | ||||||
import java.util.function.Consumer; | ||||||
import java.util.stream.Collectors; | ||||||
|
||||||
import javafx.concurrent.Task; | ||||||
import javafx.geometry.Pos; | ||||||
|
@@ -227,14 +226,15 @@ public void showErrorDialogAndWait(FetcherException fetcherException) { | |||||
Optional<SimpleHttpResponse> httpResponse = fetcherException.getHttpResponse(); | ||||||
if (httpResponse.isPresent()) { | ||||||
int statusCode = httpResponse.get().statusCode(); | ||||||
if (statusCode == 401) { | ||||||
this.showInformationDialogAndWait(failedTitle, Localization.lang("Access denied. You are not authorized to access this resource. Please check your credentials and try again. If you believe you should have access, please contact the administrator for assistance.") + "\n\n" + localizedMessage); | ||||||
} else if (statusCode == 403) { | ||||||
this.showInformationDialogAndWait(failedTitle, Localization.lang("Access denied. You do not have permission to access this resource. Please contact the administrator for assistance or try a different action.") + "\n\n" + localizedMessage); | ||||||
} else if (statusCode == 404) { | ||||||
this.showInformationDialogAndWait(failedTitle, Localization.lang("The requested resource could not be found. It seems that the file you are trying to download is not available or has been moved. Please verify the URL and try again. If you believe this is an error, please contact the administrator for further assistance.") + "\n\n" + localizedMessage); | ||||||
} else { | ||||||
this.showErrorDialogAndWait(failedTitle, Localization.lang("Something is wrong on JabRef side. Please check the URL and try again.") + "\n\n" + localizedMessage); | ||||||
switch (statusCode) { | ||||||
case 401 -> | ||||||
this.showInformationDialogAndWait(failedTitle, Localization.lang("Access denied. You are not authorized to access this resource. Please check your credentials and try again. If you believe you should have access, please contact the administrator for assistance.") + "\n\n" + localizedMessage); | ||||||
case 403 -> | ||||||
this.showInformationDialogAndWait(failedTitle, Localization.lang("Access denied. You do not have permission to access this resource. Please contact the administrator for assistance or try a different action.") + "\n\n" + localizedMessage); | ||||||
case 404 -> | ||||||
this.showInformationDialogAndWait(failedTitle, Localization.lang("The requested resource could not be found. It seems that the file you are trying to download is not available or has been moved. Please verify the URL and try again. If you believe this is an error, please contact the administrator for further assistance.") + "\n\n" + localizedMessage); | ||||||
default -> | ||||||
this.showErrorDialogAndWait(failedTitle, Localization.lang("Something is wrong on JabRef side. Please check the URL and try again.") + "\n\n" + localizedMessage); | ||||||
} | ||||||
} else if (fetcherException instanceof FetcherClientException) { | ||||||
this.showErrorDialogAndWait(failedTitle, Localization.lang("Something is wrong on JabRef side. Please check the URL and try again.") + "\n\n" + localizedMessage); | ||||||
|
@@ -388,7 +388,7 @@ public <V> void showProgressDialogAndWait(String title, String content, Task<V> | |||||
} | ||||||
|
||||||
@Override | ||||||
public <V> Optional<ButtonType> showBackgroundProgressDialogAndWait(String title, String content, StateManager stateManager) { | ||||||
public Optional<ButtonType> showBackgroundProgressDialogAndWait(String title, String content, StateManager stateManager) { | ||||||
TaskProgressView<Task<?>> taskProgressView = new TaskProgressView<>(); | ||||||
EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getRunningBackgroundTasks()); | ||||||
taskProgressView.setRetainTasks(false); | ||||||
|
@@ -424,25 +424,23 @@ public void notify(String message) { | |||||
// The event log is not that user friendly (different purpose). | ||||||
LOGGER.info(message); | ||||||
|
||||||
UiTaskExecutor.runInJavaFXThread(() -> { | ||||||
Notifications.create() | ||||||
.text(message) | ||||||
.position(Pos.BOTTOM_CENTER) | ||||||
.hideAfter(TOAST_MESSAGE_DISPLAY_TIME) | ||||||
.owner(mainWindow) | ||||||
.threshold(5, | ||||||
Notifications.create() | ||||||
.title(Localization.lang("Last notification")) | ||||||
.text( | ||||||
"(" + Localization.lang("Check the event log to see all notifications") + ")" | ||||||
+ "\n\n" + message) | ||||||
.onAction(e -> { | ||||||
ErrorConsoleAction ec = new ErrorConsoleAction(); | ||||||
ec.execute(); | ||||||
})) | ||||||
.hideCloseButton() | ||||||
.show(); | ||||||
}); | ||||||
UiTaskExecutor.runInJavaFXThread(() -> Notifications.create() | ||||||
.text(message) | ||||||
.position(Pos.BOTTOM_CENTER) | ||||||
.hideAfter(TOAST_MESSAGE_DISPLAY_TIME) | ||||||
.owner(mainWindow) | ||||||
.threshold(5, | ||||||
Notifications.create() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This new indent is a bit strange - maybe keep the old indent - on line 428 it also "felt" better, because it is indented 4 spaces, not 30 or so ^^ |
||||||
.title(Localization.lang("Last notification")) | ||||||
.text( | ||||||
"(" + Localization.lang("Check the event log to see all notifications") + ")" | ||||||
+ "\n\n" + message) | ||||||
.onAction(e -> { | ||||||
ErrorConsoleAction ec = new ErrorConsoleAction(); | ||||||
ec.execute(); | ||||||
})) | ||||||
.hideCloseButton() | ||||||
.show()); | ||||||
} | ||||||
|
||||||
@Override | ||||||
|
@@ -472,7 +470,7 @@ public Optional<Path> showDirectorySelectionDialog(DirectoryDialogConfiguration | |||||
public List<Path> showFileOpenDialogAndGetMultipleFiles(FileDialogConfiguration fileDialogConfiguration) { | ||||||
FileChooser chooser = getConfiguredFileChooser(fileDialogConfiguration); | ||||||
List<File> files = chooser.showOpenMultipleDialog(mainWindow); | ||||||
return files != null ? files.stream().map(File::toPath).collect(Collectors.toList()) : Collections.emptyList(); | ||||||
return files != null ? files.stream().map(File::toPath).toList() : Collections.emptyList(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
private DirectoryChooser getConfiguredDirectoryChooser(DirectoryDialogConfiguration directoryDialogConfiguration) { | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be refactored even more?
I would just not care about info and error. I think "info" is OK even in the
default
case.