Skip to content
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

Tag-Based Selection for Entry fields in Preferences #12592

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

vi-anusha
Copy link

@vi-anusha vi-anusha commented Mar 2, 2025

This PR Fixes #12550

This PR replaces the existing text-based field selection with a tag-based selection format, similar to the implementation in the Autocompletion settings.

Changes Made

  • Converted text-based text input to TagsField components, allowing users to select fields dynamically instead of relying on static text labels.
  • Improved layout alignment to ensure text and tags are displayed correctly.
  • Adjusted spacing and padding in HBox to prevent label truncation or misalignment.
  • Ensured that the new TagsField selection method works consistently with other settings sections.

Screenshots after Fix Applied

new

Mandatory checks

  • I own the copyright of the code submitted and I licence it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues.
In case of issues with the import order, double check that you activated Auto Import. You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues.
In case of issues with the import order, double check that you activated Auto Import. You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues.
In case of issues with the import order, double check that you activated Auto Import. You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports.

Copy link
Member

@subhramit subhramit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, welcome to JabRef and thanks for your contribution!
Below are some comments on first look.

Comment on lines 52 to 53
<CheckBox fx:id="addModificationDate"
text="%Add timestamp to modified entries (field &quot;modificationdate&quot;)"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this line-break unintentional? Please revert.

}

public void initialize() {
this.viewModel = new EntryTabViewModel(preferences);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert these.

Comment on lines 72 to 73
setupTagsField();
resolveStrings.selectedProperty().bindBidirectional(viewModel.resolveStringsProperty());
Copy link
Member

@subhramit subhramit Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert line break before line 71 and add one after 72.

timestampPreferences.setAddCreationDate(addCreationDateProperty.getValue());
timestampPreferences.setAddModificationDate(addModificationDateProperty.getValue());
fieldPreferences.getResolvableFields().clear();
fieldPreferences.getResolvableFields().addAll(resolveStringsForFieldsProperty.getValue());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fieldPreferences.getResolvableFields().addAll(resolveStringsForFieldsProperty.getValue());
fieldPreferences.getResolvableFields().addAll(resolveStringsForFieldsProperty.getValue().trim());

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values are in list format, so can not trim them here.

Copy link
Member

@subhramit subhramit Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use map to trim them individually then.

resolveStringsForFieldsProperty.getValue().stream()
    .map(String::trim)
    .forEach(fieldPreferences.getResolvableFields()::add);

fieldPreferences.getResolvableFields().clear();
fieldPreferences.getResolvableFields().addAll(resolveStringsForFieldsProperty.getValue());
fieldPreferences.getNonWrappableFields().clear();
fieldPreferences.getNonWrappableFields().addAll(nonWrappableFieldsProperty.getValue());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fieldPreferences.getNonWrappableFields().addAll(nonWrappableFieldsProperty.getValue());
fieldPreferences.getNonWrappableFields().addAll(nonWrappableFieldsProperty.getValue().trim());

Comment on lines 32 to 38
private TextField keywordSeparator;
@FXML
private CheckBox resolveStrings;
@FXML
private TagsField<Field> resolveStringsForFields;
@FXML
private TagsField<Field> nonWrappableFields;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate these declarations into groups like before


@Override
public Field fromString(String string) {
return FieldFactory.parseField(string);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we use parseField instead of parseFieldList now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I was updating it according to the autocompletion module, and that uses parseFieldList.

nonWrappableFields.setShowSearchIcon(false);
nonWrappableFields.setOnMouseClicked(event -> nonWrappableFields.getEditor().requestFocus());
nonWrappableFields.getEditor().getStyleClass().clear();
nonWrappableFields.getEditor().focusedProperty().addListener((observable, oldValue, newValue) -> nonWrappableFields.pseudoClassStateChanged(FOCUSED, newValue));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nonWrappableFields.getEditor().focusedProperty().addListener((observable, oldValue, newValue) -> nonWrappableFields.pseudoClassStateChanged(FOCUSED, newValue));
nonWrappableFields.getEditor().focusedProperty().addListener((_, _, newValue) -> nonWrappableFields.pseudoClassStateChanged(FOCUSED, newValue));

resolveStringsForFields.setShowSearchIcon(false);
resolveStringsForFields.setOnMouseClicked(event -> resolveStringsForFields.getEditor().requestFocus());
resolveStringsForFields.getEditor().getStyleClass().clear();
resolveStringsForFields.getEditor().focusedProperty().addListener((observable, oldValue, newValue) -> resolveStringsForFields.pseudoClassStateChanged(FOCUSED, newValue));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resolveStringsForFields.getEditor().focusedProperty().addListener((observable, oldValue, newValue) -> resolveStringsForFields.pseudoClassStateChanged(FOCUSED, newValue));
resolveStringsForFields.getEditor().focusedProperty().addListener((_, _, newValue) -> resolveStringsForFields.pseudoClassStateChanged(FOCUSED, newValue));

@subhramit subhramit changed the title Fix for issue 12550 Tag-Based Selection in Preferences -> Entry Fields Tag-Based Selection for Entry fields in Preferences Mar 3, 2025
Comment on lines 5 to 6
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please don't use * here. Import only what you're using.

@Siedlerchr Siedlerchr added the status: changes required Pull requests that are not yet complete label Mar 7, 2025
@Siedlerchr Siedlerchr marked this pull request as draft March 8, 2025 20:51
Copy link

trag-bot bot commented Mar 13, 2025

@trag-bot didn't find any issues in the code! ✅✨

@vi-anusha vi-anusha requested a review from subhramit March 13, 2025 07:22
@koppor koppor added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers status: changes required Pull requests that are not yet complete and removed status: changes required Pull requests that are not yet complete status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Mar 13, 2025
@koppor
Copy link
Member

koppor commented Mar 13, 2025

  1. Cannot enter custom field:
    image
  2. Pressing ENTER when entering a field should NOT close the dialog -> the focus should be in the fields
  3. There is no suggestion of keywords while typing. see keywords fields for an implementation
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: changes required Pull requests that are not yet complete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use a Tag Field for Resolve strings and Do not wrap under Preferences -> Entry for
4 participants