-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Miscellaneous refactoring #13178
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
Miscellaneous refactoring #13178
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,7 +106,7 @@ private void setupEntryTypesTable() { | |
| entryTypeActionsColumn.setReorderable(false); | ||
| entryTypeActionsColumn.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().entryType().get().getType().getDisplayName())); | ||
| new ValueTableCellFactory<EntryTypeViewModel, String>() | ||
| .withGraphic((type, name) -> { | ||
| .withGraphic((type, _) -> { | ||
| if (type instanceof CustomEntryTypeViewModel) { | ||
| return IconTheme.JabRefIcons.DELETE_ENTRY.getGraphicNode(); | ||
| } else { | ||
|
|
@@ -120,11 +120,11 @@ private void setupEntryTypesTable() { | |
| return null; | ||
| } | ||
| }) | ||
| .withOnMouseClickedEvent((type, name) -> { | ||
| .withOnMouseClickedEvent((type, _) -> { | ||
| if (type instanceof CustomEntryTypeViewModel) { | ||
| return evt -> viewModel.removeEntryType(entryTypesTable.getSelectionModel().getSelectedItem()); | ||
| return _ -> viewModel.removeEntryType(entryTypesTable.getSelectionModel().getSelectedItem()); | ||
| } else { | ||
| return evt -> { | ||
| return _ -> { | ||
| }; | ||
| } | ||
| }) | ||
|
|
@@ -135,7 +135,7 @@ private void setupEntryTypesTable() { | |
|
|
||
| EasyBind.subscribe(viewModel.selectedEntryTypeProperty(), type -> { | ||
| if (type != null) { | ||
| var items = type.fields(); | ||
| ObservableList<FieldViewModel> items = type.fields(); | ||
|
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. The patch replaces 'var' with 'ObservableList', which is correct for type safety, but it should also consider using modern Java data structures as per best practices. |
||
| fields.setItems(items); | ||
| } else { | ||
| fields.setItems(null); | ||
|
|
@@ -185,9 +185,9 @@ private void setupFieldsTable() { | |
| fieldTypeActionColumn.setCellValueFactory(cellData -> cellData.getValue().displayNameProperty()); | ||
|
|
||
| new ValueTableCellFactory<FieldViewModel, String>() | ||
| .withGraphic(item -> IconTheme.JabRefIcons.DELETE_ENTRY.getGraphicNode()) | ||
| .withGraphic(_ -> IconTheme.JabRefIcons.DELETE_ENTRY.getGraphicNode()) | ||
| .withTooltip(name -> Localization.lang("Remove field %0 from currently selected entry type", name)) | ||
| .withOnMouseClickedEvent(item -> evt -> viewModel.removeField(fields.getSelectionModel().getSelectedItem())) | ||
| .withOnMouseClickedEvent(_ -> _ -> viewModel.removeField(fields.getSelectionModel().getSelectedItem())) | ||
| .install(fieldTypeActionColumn); | ||
|
|
||
| new ViewModelTableRowFactory<FieldViewModel>() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,7 @@ public static Optional<Exporter> getExporter(FileChooser.ExtensionFilter extensi | |
| } | ||
|
|
||
| public static FileChooser.ExtensionFilter forAllImporters(SortedSet<Importer> importers) { | ||
| List<FileType> fileTypes = importers.stream().map(Importer::getFileType).collect(Collectors.toList()); | ||
| List<FileType> fileTypes = importers.stream().map(Importer::getFileType).toList(); | ||
| List<String> flatExtensions = fileTypes.stream() | ||
| .flatMap(type -> type.getExtensionsWithAsteriskAndDot().stream()) | ||
| .collect(Collectors.toList()); | ||
|
|
@@ -86,7 +86,7 @@ public static FileFilter toFileFilter(FileChooser.ExtensionFilter extensionFilte | |
| } | ||
|
|
||
| public static FileFilter toFileFilter(List<String> extensions) { | ||
| var filter = toDirFilter(extensions); | ||
| Filter<Path> filter = toDirFilter(extensions); | ||
|
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. The explicit type declaration 'Filter' is preferred over 'var' for clarity and type safety, aligning with modern Java best practices. |
||
| return file -> { | ||
| try { | ||
| return filter.accept(file.toPath()); | ||
|
|
@@ -100,10 +100,10 @@ public static Filter<Path> toDirFilter(List<String> extensions) { | |
| List<String> extensionsCleaned = extensions.stream() | ||
| .map(extension -> extension.replace(".", "").replace("*", "")) | ||
| .filter(StringUtil::isNotBlank) | ||
| .collect(Collectors.toList()); | ||
| .toList(); | ||
| if (extensionsCleaned.isEmpty()) { | ||
| // Except every file | ||
| return path -> true; | ||
| return _ -> true; | ||
| } else { | ||
| return path -> FileUtil.getFileExtension(path) | ||
| .map(extensionsCleaned::contains) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.