Skip to content

Commit 5b3c785

Browse files
committed
Reformat to 100 line length
1 parent 6f151ec commit 5b3c785

File tree

1,345 files changed

+13606
-42347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,345 files changed

+13606
-42347
lines changed

src/main/java/org/jabref/gui/JabRefDialogService.java

+39-145
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,16 @@ public class JabRefDialogService implements DialogService {
6565
// Snackbar dialog maximum size
6666
public static final int DIALOG_SIZE_LIMIT = 300;
6767

68-
private static final Duration TOAST_MESSAGE_DISPLAY_TIME = Duration.millis(
69-
3000
70-
);
71-
private static final Logger LOGGER = LoggerFactory.getLogger(
72-
JabRefDialogService.class
73-
);
68+
private static final Duration TOAST_MESSAGE_DISPLAY_TIME = Duration.millis(3000);
69+
private static final Logger LOGGER = LoggerFactory.getLogger(JabRefDialogService.class);
7470

7571
private final Window mainWindow;
7672

7773
public JabRefDialogService(Window mainWindow) {
7874
this.mainWindow = mainWindow;
7975
}
8076

81-
private FXDialog createDialog(
82-
AlertType type,
83-
String title,
84-
String content
85-
) {
77+
private FXDialog createDialog(AlertType type, String title, String content) {
8678
FXDialog alert = new FXDialog(type, title, true);
8779
alert.setHeaderText(null);
8880
alert.setContentText(content);
@@ -111,9 +103,7 @@ private FXDialog createDialogWithOptOut(
111103
protected Node createDetailsButton() {
112104
CheckBox optOut = new CheckBox();
113105
optOut.setText(optOutMessage);
114-
optOut.setOnAction(e ->
115-
optOutAction.accept(optOut.isSelected())
116-
);
106+
optOut.setOnAction(e -> optOutAction.accept(optOut.isSelected()));
117107
return optOut;
118108
}
119109
}
@@ -139,10 +129,7 @@ public static String shortenDialogMessage(String dialogMessage) {
139129
return (
140130
dialogMessage.substring(
141131
0,
142-
Math.min(
143-
dialogMessage.length(),
144-
JabRefDialogService.DIALOG_SIZE_LIMIT
145-
)
132+
Math.min(dialogMessage.length(), JabRefDialogService.DIALOG_SIZE_LIMIT)
146133
) +
147134
"..."
148135
).trim();
@@ -156,20 +143,11 @@ public <T> Optional<T> showChoiceDialogAndWait(
156143
T defaultChoice,
157144
Collection<T> choices
158145
) {
159-
ChoiceDialog<T> choiceDialog = new ChoiceDialog<>(
160-
defaultChoice,
161-
choices
162-
);
146+
ChoiceDialog<T> choiceDialog = new ChoiceDialog<>(defaultChoice, choices);
163147
((Stage) choiceDialog.getDialogPane().getScene().getWindow()).getIcons()
164148
.add(IconTheme.getJabRefImage());
165-
ButtonType okButtonType = new ButtonType(
166-
okButtonLabel,
167-
ButtonBar.ButtonData.OK_DONE
168-
);
169-
choiceDialog
170-
.getDialogPane()
171-
.getButtonTypes()
172-
.setAll(ButtonType.CANCEL, okButtonType);
149+
ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.OK_DONE);
150+
choiceDialog.getDialogPane().getButtonTypes().setAll(ButtonType.CANCEL, okButtonType);
173151
choiceDialog.setHeaderText(title);
174152
choiceDialog.setTitle(title);
175153
choiceDialog.setContentText(content);
@@ -178,10 +156,7 @@ public <T> Optional<T> showChoiceDialogAndWait(
178156
}
179157

180158
@Override
181-
public Optional<String> showInputDialogAndWait(
182-
String title,
183-
String content
184-
) {
159+
public Optional<String> showInputDialogAndWait(String title, String content) {
185160
TextInputDialog inputDialog = new TextInputDialog();
186161
inputDialog.setHeaderText(title);
187162
inputDialog.setContentText(content);
@@ -230,11 +205,7 @@ public void showErrorDialogAndWait(String message, Throwable exception) {
230205
}
231206

232207
@Override
233-
public void showErrorDialogAndWait(
234-
String title,
235-
String content,
236-
Throwable exception
237-
) {
208+
public void showErrorDialogAndWait(String title, String content, Throwable exception) {
238209
ExceptionDialog exceptionDialog = new ExceptionDialog(exception);
239210
exceptionDialog.setHeaderText(title);
240211
exceptionDialog.setContentText(content);
@@ -255,10 +226,7 @@ public void showErrorDialogAndWait(String message) {
255226
@Override
256227
public boolean showConfirmationDialogAndWait(String title, String content) {
257228
FXDialog alert = createDialog(AlertType.CONFIRMATION, title, content);
258-
return alert
259-
.showAndWait()
260-
.filter(buttonType -> buttonType == ButtonType.OK)
261-
.isPresent();
229+
return alert.showAndWait().filter(buttonType -> buttonType == ButtonType.OK).isPresent();
262230
}
263231

264232
@Override
@@ -268,15 +236,9 @@ public boolean showConfirmationDialogAndWait(
268236
String okButtonLabel
269237
) {
270238
FXDialog alert = createDialog(AlertType.CONFIRMATION, title, content);
271-
ButtonType okButtonType = new ButtonType(
272-
okButtonLabel,
273-
ButtonBar.ButtonData.OK_DONE
274-
);
239+
ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.OK_DONE);
275240
alert.getButtonTypes().setAll(ButtonType.CANCEL, okButtonType);
276-
return alert
277-
.showAndWait()
278-
.filter(buttonType -> buttonType == okButtonType)
279-
.isPresent();
241+
return alert.showAndWait().filter(buttonType -> buttonType == okButtonType).isPresent();
280242
}
281243

282244
@Override
@@ -287,19 +249,10 @@ public boolean showConfirmationDialogAndWait(
287249
String cancelButtonLabel
288250
) {
289251
FXDialog alert = createDialog(AlertType.CONFIRMATION, title, content);
290-
ButtonType okButtonType = new ButtonType(
291-
okButtonLabel,
292-
ButtonBar.ButtonData.OK_DONE
293-
);
294-
ButtonType cancelButtonType = new ButtonType(
295-
cancelButtonLabel,
296-
ButtonBar.ButtonData.NO
297-
);
252+
ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.OK_DONE);
253+
ButtonType cancelButtonType = new ButtonType(cancelButtonLabel, ButtonBar.ButtonData.NO);
298254
alert.getButtonTypes().setAll(okButtonType, cancelButtonType);
299-
return alert
300-
.showAndWait()
301-
.filter(buttonType -> buttonType == okButtonType)
302-
.isPresent();
255+
return alert.showAndWait().filter(buttonType -> buttonType == okButtonType).isPresent();
303256
}
304257

305258
@Override
@@ -317,10 +270,7 @@ public boolean showConfirmationDialogWithOptOutAndWait(
317270
optOutAction
318271
);
319272
alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO);
320-
return alert
321-
.showAndWait()
322-
.filter(buttonType -> buttonType == ButtonType.YES)
323-
.isPresent();
273+
return alert.showAndWait().filter(buttonType -> buttonType == ButtonType.YES).isPresent();
324274
}
325275

326276
@Override
@@ -339,19 +289,10 @@ public boolean showConfirmationDialogWithOptOutAndWait(
339289
optOutMessage,
340290
optOutAction
341291
);
342-
ButtonType okButtonType = new ButtonType(
343-
okButtonLabel,
344-
ButtonBar.ButtonData.YES
345-
);
346-
ButtonType cancelButtonType = new ButtonType(
347-
cancelButtonLabel,
348-
ButtonBar.ButtonData.NO
349-
);
292+
ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.YES);
293+
ButtonType cancelButtonType = new ButtonType(cancelButtonLabel, ButtonBar.ButtonData.NO);
350294
alert.getButtonTypes().setAll(okButtonType, cancelButtonType);
351-
return alert
352-
.showAndWait()
353-
.filter(buttonType -> buttonType == okButtonType)
354-
.isPresent();
295+
return alert.showAndWait().filter(buttonType -> buttonType == okButtonType).isPresent();
355296
}
356297

357298
@Override
@@ -382,23 +323,16 @@ public Optional<ButtonType> showCustomDialogAndWait(
382323
}
383324

384325
@Override
385-
public <R> Optional<R> showCustomDialogAndWait(
386-
javafx.scene.control.Dialog<R> dialog
387-
) {
326+
public <R> Optional<R> showCustomDialogAndWait(javafx.scene.control.Dialog<R> dialog) {
388327
if (dialog.getOwner() == null) {
389328
dialog.initOwner(mainWindow);
390329
}
391330
return dialog.showAndWait();
392331
}
393332

394333
@Override
395-
public Optional<String> showPasswordDialogAndWait(
396-
String title,
397-
String header,
398-
String content
399-
) {
400-
javafx.scene.control.Dialog<String> dialog =
401-
new javafx.scene.control.Dialog<>();
334+
public Optional<String> showPasswordDialogAndWait(String title, String header, String content) {
335+
javafx.scene.control.Dialog<String> dialog = new javafx.scene.control.Dialog<>();
402336
dialog.setTitle(title);
403337
dialog.setHeaderText(header);
404338

@@ -410,10 +344,7 @@ public Optional<String> showPasswordDialogAndWait(
410344
dialog.setTitle(title);
411345
dialog.getDialogPane().setContent(box);
412346

413-
dialog
414-
.getDialogPane()
415-
.getButtonTypes()
416-
.addAll(ButtonType.CANCEL, ButtonType.OK);
347+
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL, ButtonType.OK);
417348
dialog.setResultConverter(dialogButton -> {
418349
if (dialogButton == ButtonType.OK) {
419350
return passwordField.getText();
@@ -424,27 +355,18 @@ public Optional<String> showPasswordDialogAndWait(
424355
}
425356

426357
@Override
427-
public <V> void showProgressDialog(
428-
String title,
429-
String content,
430-
Task<V> task
431-
) {
358+
public <V> void showProgressDialog(String title, String content, Task<V> task) {
432359
ProgressDialog progressDialog = new ProgressDialog(task);
433360
progressDialog.setHeaderText(null);
434361
progressDialog.setTitle(title);
435362
progressDialog.setContentText(content);
436363
progressDialog.setGraphic(null);
437-
((Stage) progressDialog
438-
.getDialogPane()
439-
.getScene()
440-
.getWindow()).getIcons()
364+
((Stage) progressDialog.getDialogPane().getScene().getWindow()).getIcons()
441365
.add(IconTheme.getJabRefImage());
442366
progressDialog.setOnCloseRequest(evt -> task.cancel());
443367
DialogPane dialogPane = progressDialog.getDialogPane();
444368
dialogPane.getButtonTypes().add(ButtonType.CANCEL);
445-
Button cancelButton = (Button) dialogPane.lookupButton(
446-
ButtonType.CANCEL
447-
);
369+
Button cancelButton = (Button) dialogPane.lookupButton(ButtonType.CANCEL);
448370
cancelButton.setOnAction(evt -> {
449371
task.cancel();
450372
progressDialog.close();
@@ -460,10 +382,7 @@ public <V> Optional<ButtonType> showBackgroundProgressDialogAndWait(
460382
StateManager stateManager
461383
) {
462384
TaskProgressView<Task<?>> taskProgressView = new TaskProgressView<>();
463-
EasyBind.bindContent(
464-
taskProgressView.getTasks(),
465-
stateManager.getBackgroundTasks()
466-
);
385+
EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getBackgroundTasks());
467386
taskProgressView.setRetainTasks(false);
468387
taskProgressView.setGraphicFactory(BackgroundTask::getIcon);
469388

@@ -512,9 +431,7 @@ public void notify(String message) {
512431
// TODO: Change to a notification overview instead of event log when that is available. The event log is not that user friendly (different purpose).
513432
.text(
514433
"(" +
515-
Localization.lang(
516-
"Check the event log to see all notifications"
517-
) +
434+
Localization.lang("Check the event log to see all notifications") +
518435
")" +
519436
"\n\n" +
520437
message
@@ -530,9 +447,7 @@ public void notify(String message) {
530447
}
531448

532449
@Override
533-
public Optional<Path> showFileSaveDialog(
534-
FileDialogConfiguration fileDialogConfiguration
535-
) {
450+
public Optional<Path> showFileSaveDialog(FileDialogConfiguration fileDialogConfiguration) {
536451
FileChooser chooser = getConfiguredFileChooser(fileDialogConfiguration);
537452
File file = chooser.showSaveDialog(mainWindow);
538453
Optional
@@ -542,9 +457,7 @@ public Optional<Path> showFileSaveDialog(
542457
}
543458

544459
@Override
545-
public Optional<Path> showFileOpenDialog(
546-
FileDialogConfiguration fileDialogConfiguration
547-
) {
460+
public Optional<Path> showFileOpenDialog(FileDialogConfiguration fileDialogConfiguration) {
548461
FileChooser chooser = getConfiguredFileChooser(fileDialogConfiguration);
549462
File file = chooser.showOpenDialog(mainWindow);
550463
Optional
@@ -557,9 +470,7 @@ public Optional<Path> showFileOpenDialog(
557470
public Optional<Path> showDirectorySelectionDialog(
558471
DirectoryDialogConfiguration directoryDialogConfiguration
559472
) {
560-
DirectoryChooser chooser = getConfiguredDirectoryChooser(
561-
directoryDialogConfiguration
562-
);
473+
DirectoryChooser chooser = getConfiguredDirectoryChooser(directoryDialogConfiguration);
563474
File file = chooser.showDialog(mainWindow);
564475
return Optional.ofNullable(file).map(File::toPath);
565476
}
@@ -586,19 +497,11 @@ private DirectoryChooser getConfiguredDirectoryChooser(
586497
return chooser;
587498
}
588499

589-
private FileChooser getConfiguredFileChooser(
590-
FileDialogConfiguration fileDialogConfiguration
591-
) {
500+
private FileChooser getConfiguredFileChooser(FileDialogConfiguration fileDialogConfiguration) {
592501
FileChooser chooser = new FileChooser();
593-
chooser
594-
.getExtensionFilters()
595-
.addAll(fileDialogConfiguration.getExtensionFilters());
596-
chooser.setSelectedExtensionFilter(
597-
fileDialogConfiguration.getDefaultExtension()
598-
);
599-
chooser.setInitialFileName(
600-
fileDialogConfiguration.getInitialFileName()
601-
);
502+
chooser.getExtensionFilters().addAll(fileDialogConfiguration.getExtensionFilters());
503+
chooser.setSelectedExtensionFilter(fileDialogConfiguration.getDefaultExtension());
504+
chooser.setInitialFileName(fileDialogConfiguration.getInitialFileName());
602505
fileDialogConfiguration
603506
.getInitialDirectory()
604507
.map(Path::toFile)
@@ -612,20 +515,11 @@ public boolean showPrintDialog(PrinterJob job) {
612515
}
613516

614517
@Override
615-
public Optional<Path> showFileOpenFromArchiveDialog(Path archivePath)
616-
throws IOException {
617-
try (
618-
FileSystem zipFile = FileSystems.newFileSystem(
619-
archivePath,
620-
(ClassLoader) null
621-
)
622-
) {
518+
public Optional<Path> showFileOpenFromArchiveDialog(Path archivePath) throws IOException {
519+
try (FileSystem zipFile = FileSystems.newFileSystem(archivePath, (ClassLoader) null)) {
623520
return new ZipFileChooser(zipFile).showAndWait();
624521
} catch (NoClassDefFoundError exc) {
625-
throw new IOException(
626-
"Could not instantiate ZIP-archive reader.",
627-
exc
628-
);
522+
throw new IOException("Could not instantiate ZIP-archive reader.", exc);
629523
}
630524
}
631525

0 commit comments

Comments
 (0)