-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Automatic field editor: Add Clear content tab + viewmodel #13824
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
base: main
Are you sure you want to change the base?
Automatic field editor: Add Clear content tab + viewmodel #13824
Conversation
Field chosen = fieldCombo.getValue(); // keep ComboBox<Field> | ||
if (chosen != null) { | ||
viewModel.clearField(chosen); // VM builds/publishes the undo compound | ||
System.out.println("Cleared field: " + chosen.getName()); |
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.
No System.out and remove the comments
|
||
List<BibEntry> selected = stateManager.getSelectedEntries(); | ||
for (BibEntry entry : selected) { | ||
// clearField returns Optional<FieldChange> |
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.
remove comments
List<BibEntry> selected = stateManager.getSelectedEntries(); | ||
Set<Field> setFields = new LinkedHashSet<>(); | ||
|
||
for (BibEntry entry : selected) { |
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.
can be refactored into a stream
private final ClearContentViewModel viewModel; | ||
|
||
public ClearContentTabView(StateManager stateManager) { | ||
super(); |
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.
Is there a reasony why you did not creae an fxml? I guess you used AI..
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.
Yes, I initially used AI to generate the layout in Java so I could focus on getting the logic working first but forgot to move it into a proper FXML file. I've made the changes now.
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.
.
Sorry, misunderstood PR. Nevermind. |
public Set<Field> getSetFieldsOnly() { | ||
return stateManager.getSelectedEntries().stream() | ||
.flatMap(entry -> entry.getFields().stream() | ||
.filter(f -> entry.getField(f).isPresent() && !entry.getField(f).get().isBlank())) | ||
.collect(Collectors.toCollection(LinkedHashSet::new)); | ||
} |
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.
The method uses Optional.isPresent() followed by get() which is an anti-pattern. Should use Optional.map() or filter() instead to handle the Optional value in a more functional way.
Closes #13780
This PR introduces a dedicated "Clear content" tab in the Automatic Field Editor:
Steps to test
author
,journal
).author
) and click Clear field content: the field value should be removed from all selected entries.Mandatory checks
CHANGELOG.md
in a way that is understandable for the average user (if change is visible to the user)