-
-
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
single line text fields #4138
single line text fields #4138
Conversation
Can't we just change the underlying GUI component from TextArea to TextField? |
@stefan-kolb how about now? I've added EditorTextField class, similar to EditorTextArea, and extracted addToContextMenu to interface (ContextMenuAddable). Also i had to change parameter type TextArea to TextInputControl in few places in order to use classes in generic way. |
That looks good so far for me! Haven't tested it yet, but codewise it looks good, (Although the final in front of method parameter is suerpfllous |
I use finals to avoid stupid bugs, like reassigning variable. With them my IDE automatically underlines such stuff. Another thing is that I've decided to make code more readable, so I've put new lines between SimpleEditor constructor parameters (because there was one long line), and now Codacy yells about that. Should I extract those parameters to another class, like SimpleEditorParameters or sth? |
public static FieldEditorFX getForField(final String fieldName, | ||
final TaskExecutor taskExecutor, | ||
final DialogService dialogService, | ||
final JournalAbbreviationLoader journalAbbreviationLoader, |
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.
You could extract the loader and the prefs parameter and directly pass the JounralAbbrev Repo stuff which is just passed onto the field checkers later
journalAbbreviationLoader.getRepository(journalAbbreviationPreferences)
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.
done; I'm just wonder if it's ok to access repository at the beginning instead of calling for it every time? I mean, is there a way, that the repo could be updated?
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.
In principle, the user might change the journal abbreviations at any time. However, it should be fine to use the repository since the field editors are recreated when switching to the new entry.
final FieldCheckers fieldCheckers = new FieldCheckers( | ||
databaseContext, | ||
preferences.getFileDirectoryPreferences(), | ||
journalAbbreviationLoader.getRepository(journalAbbreviationPreferences), |
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.
Here the abbrev repo stuff is passed
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.
LGTM for me! 👍 Thanks for your conribution
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 code looks very good! I've only two very small remarks.
|
||
FieldCheckers fieldCheckers = new FieldCheckers(databaseContext, preferences.getFileDirectoryPreferences(), journalAbbreviationLoader.getRepository(journalAbbreviationPreferences), preferences.getBoolean(JabRefPreferences.ENFORCE_LEGAL_BIBTEX_KEY)); | ||
final boolean hasSingleLine = SINGLE_LINE_FIELDS.contains(fieldName.toLowerCase()); |
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 might be mistaken here, but isSingleLine(Field)
sounds more natural to me.
public class FieldEditors { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(FieldEditors.class); | ||
|
||
public static FieldEditorFX getForField(String fieldName, TaskExecutor taskExecutor, DialogService dialogService, JournalAbbreviationLoader journalAbbreviationLoader, JournalAbbreviationPreferences journalAbbreviationPreferences, JabRefPreferences preferences, BibDatabaseContext databaseContext, String entryType, SuggestionProviders suggestionProviders, UndoManager undoManager) { | ||
private static final Set<String> SINGLE_LINE_FIELDS = Collections.unmodifiableSet(new HashSet<>( |
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 you please add this list two InternalBibtexFields
(this class needs to be refactored at some point, but for now it is good to have anything at one place).
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.
Yep. Sorry for delay, I will do that on Saturday.
Ping 😄 |
- move SINGLE_LINE_FIELDS list to InternalBibtexFields class - rename hasSingleLine var to isSingleLine
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.
Thanks for the follow-up!
* upstream/master: Update dependencies (#4231) Update to latest release of richtextfx (#4213) Fix fetcher tests (#4216) single line text fields (#4138) Make it easier to rename and move files (#4200) Fix that swing dialogs are hidden behind main window (#4205) Fixed: #4166 add move & rename file (#4217) # Conflicts: # CHANGELOG.md
* upstream/master: (47 commits) Make attached files relative to the file directory (#4212) execute set visible in swing thread to avoid blocking Fix isbn chimbori test (#4234) Rewrite web search pane in JavaFX (#4203) Update dependencies (#4231) Update to latest release of richtextfx (#4213) Fix fetcher tests (#4216) single line text fields (#4138) Make it easier to rename and move files (#4200) Fix that swing dialogs are hidden behind main window (#4205) Fixed: #4166 add move & rename file (#4217) update gradle plugins and gradlen to 4.9 Update dependencies Remove unnecessary look and feel migration (#4204) Revert threading fix since this sometimes lead to freezes... Update year Fix a few more threading exceptions Refactor Convert CiteSeerX fetcher to new infrastructure (#4185) Make global font size customizable (#4178) ... # Conflicts: # src/main/java/org/jabref/gui/BasePanel.java # src/main/java/org/jabref/gui/JabRefFrame.java # src/main/java/org/jabref/gui/mergeentries/MergeEntries.java # src/main/resources/l10n/JabRef_en.properties
Solution for #4126. I've used text formatter to force single line behavior. Hope it's enough :) Particular fields, that should contain only one line, are stored in immutable set.
// 7 tests have failed, but they also had failed before on master: