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

Observable Preferences O (Language and FileHistory) #9173

Merged
merged 10 commits into from
Sep 28, 2022
Merged

Conversation

calixtus
Copy link
Member

Follow-up to #9135

  • Embedded localization pref in GeneralPreferences
  • Extracted localization for metadata difference out of business logic to gui
  • Refactored getLanguage to new prefs
  • Refactored FileHistory and converted to new prefs model

.

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • 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
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

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

The Enum handling can be simplied

import org.jabref.model.metadata.MetaData;
import org.jabref.preferences.PreferencesService;

public class MetaDataDiff {
public enum Difference {
PROTECTED,
Copy link
Member

Choose a reason for hiding this comment

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

I would extend the enum here and add the localization as second parameter so you don't need a switch statement and instead you can directly return the message

Copy link
Member Author

Choose a reason for hiding this comment

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

That would contradict the whole meaning of this commit, to extract the call to the logic package from the model.

Copy link
Member Author

Choose a reason for hiding this comment

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

But there is something odd

Copy link
Member Author

Choose a reason for hiding this comment

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

Correcting myself: to reduce the calls to the Localization package, to be able to move the 'mother' class to the model package.

Copy link
Member

Choose a reason for hiding this comment

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

Then introduce a map with enum keys and l10n values

public List<String> getDifferences(PreferencesService preferences) {
List<String> changes = new ArrayList<>();
public List<Difference> getDifferences(PreferencesService preferences) {
List<Difference> changes = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

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

I suggest using an EnumSet, can be initialized with noneOf.

Copy link
Member Author

@calixtus calixtus Sep 28, 2022

Choose a reason for hiding this comment

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

EnumSet is done, but it does not make sense to me to introduce a map to store the localized strings, as they would have to be initialized. But it is probably very rare that many metadata diffs happen the same time. So initializing all of the strings would be just a waste of memory and time.

@calixtus
Copy link
Member Author

found some bugs i'll fix on the fly

@calixtus calixtus added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Sep 28, 2022
@calixtus calixtus requested a review from Siedlerchr September 28, 2022 14:40
@Siedlerchr Siedlerchr merged commit 246ce02 into main Sep 28, 2022
@Siedlerchr Siedlerchr deleted the prefs-lang branch September 28, 2022 17:32
Siedlerchr added a commit to LIM0000/jabref that referenced this pull request Oct 3, 2022
* upstream/main: (27 commits)
  Bump slf4j-api from 2.0.2 to 2.0.3 (JabRef#9207)
  Bump slf4j-api from 2.0.2 to 2.0.3 in /buildSrc (JabRef#9211)
  Add mappings on ModsImporter.java (JabRef#9193)
  Improve installation of java 18 in devcontainer (JabRef#9197)
  Fix missing title for "customize entry types" (JabRef#9198) (JabRef#9201)
  Squashed 'buildres/csl/csl-locales/' changes from b2afeb4d87..cb98d36691
  Squashed 'buildres/csl/csl-styles/' changes from 201e022..7bde3e4
  "Capitalize" capitalizes words after hyphens (JabRef#9186)
  Observable Preferences O (Language and FileHistory) (JabRef#9173)
  Fix jakarta annotation missing (JabRef#9183)
  Bump junit-platform-launcher from 1.9.0 to 1.9.1 (JabRef#9177)
  Bump WyriHaximus/github-action-wait-for-status from 1.6 to 1.7.1 (JabRef#9178)
  Bump junit-jupiter from 5.9.0 to 5.9.1 (JabRef#9180)
  Bump checkstyle from 10.3.3 to 10.3.4 (JabRef#9179)
  Bump slf4j-api from 2.0.1 to 2.0.2 (JabRef#9181)
  Bump slf4j-api from 2.0.1 to 2.0.2 in /buildSrc (JabRef#9182)
  Remove Java Flight Recorder (JabRef#9174)
  Fixes fetcher tests (JabRef#9175)
  Update afterburner to jakarta (JabRef#9168)
  Improve startup-behavior of pdf indexer (JabRef#9166)
  ...
HoussemNasri pushed a commit that referenced this pull request Oct 25, 2022
* Included localization prefs in GeneralPreferences

* Convertet getLanguage to new prefs pattern

* Extracted localization from MetaDataDiff in logic

* Refactored FileHistory and converted getFileHistory to new prefs model

* Partial localization without restart

* Convert list to EnumSet

* Used pattern matching and applied IDE suggestions

* Fixed comparison of optionals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preferences status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants