-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
956c175
Included localization prefs in GeneralPreferences
calixtus 9722ee3
Convertet getLanguage to new prefs pattern
calixtus 70a76c0
Extracted localization from MetaDataDiff in logic
calixtus d5556ff
Merge remote-tracking branch 'upstream/main' into prefs-lang
calixtus d068740
Refactored FileHistory and converted getFileHistory to new prefs model
calixtus 999121a
Partial localization without restart
calixtus 089108c
Convert list to EnumSet
calixtus 5c1b9a6
Merge remote-tracking branch 'upstream/main' into prefs-lang
calixtus 34c84cc
Used pattern matching and applied IDE suggestions
calixtus b3a1d47
Fixed comparison of optionals
calixtus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,61 @@ | ||
package org.jabref.logic.util.io; | ||
|
||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.collections.ModifiableObservableListBase; | ||
|
||
public class FileHistory { | ||
public class FileHistory extends ModifiableObservableListBase<Path> { | ||
|
||
private static final int HISTORY_SIZE = 8; | ||
|
||
private final ObservableList<Path> history; | ||
private final List<Path> history; | ||
|
||
public FileHistory(List<Path> files) { | ||
history = FXCollections.observableList(Objects.requireNonNull(files)); | ||
private FileHistory(List<Path> list) { | ||
history = new ArrayList<>(list); | ||
} | ||
|
||
@Override | ||
public Path get(int index) { | ||
return history.get(index); | ||
} | ||
|
||
public int size() { | ||
return history.size(); | ||
} | ||
|
||
public boolean isEmpty() { | ||
return history.isEmpty(); | ||
@Override | ||
protected void doAdd(int index, Path element) { | ||
history.add(index, element); | ||
} | ||
|
||
@Override | ||
protected Path doSet(int index, Path element) { | ||
return history.set(index, element); | ||
} | ||
|
||
@Override | ||
protected Path doRemove(int index) { | ||
return history.remove(index); | ||
} | ||
|
||
/** | ||
* Adds the file to the top of the list. If it already is in the list, it is merely moved to the top. | ||
*/ | ||
public void newFile(Path file) { | ||
removeItem(file); | ||
history.add(0, file); | ||
this.add(0, file); | ||
while (size() > HISTORY_SIZE) { | ||
history.remove(HISTORY_SIZE); | ||
} | ||
} | ||
|
||
public Path getFileAt(int index) { | ||
return history.get(index); | ||
} | ||
|
||
public void removeItem(Path file) { | ||
history.remove(file); | ||
this.remove(file); | ||
} | ||
|
||
public ObservableList<Path> getHistory() { | ||
return history; | ||
public static FileHistory of(List<Path> list) { | ||
return new FileHistory(new ArrayList<>(list)); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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
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.
That would contradict the whole meaning of this commit, to extract the call to the logic package from the model.
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.
But there is something odd
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.
Correcting myself: to reduce the calls to the Localization package, to be able to move the 'mother' class to the model package.
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.
Then introduce a map with enum keys and l10n values