Improve entrytype customization#2331
Conversation
aa3c3b2 to
34f5f29
Compare
46772ba to
0d45001
Compare
|
Okay... I think the current state is now a good improvement of the old status-quo. Apart from that I would appreciate some feedback ;-) |
lenhard
left a comment
There was a problem hiding this comment.
I just looked through the code, but did not test this in a running JabRef. There are a number of things that can be improved quality/architecture-wise, but none of these is a blocker. So please fix what you agree with.
| sb.append(type).append(", "); | ||
| public void performAction(BasePanel panel, ParserResult parserResult) { | ||
|
|
||
| BibDatabaseMode mode = parserResult.getMetaData().getMode().orElse(Globals.prefs.getDefaultBibDatabaseMode()); |
There was a problem hiding this comment.
To avoid writing that method chain multiple times in this class, maybe extract a helper method?
| List<EntryType> newTypes = new ArrayList<>(); | ||
| List<EntryType> differentCustomizations = new ArrayList<>(); | ||
|
|
||
| for(EntryType customType : allCustomizedEntryTypes) { |
There was a problem hiding this comment.
please adhere to the formatting guidelines: for ( and below if (
| JPanel checkboxPanel = new JPanel(); | ||
| checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.PAGE_AXIS)); | ||
|
|
||
| JLabel customFoundLabel = new JLabel(Localization.lang("Custom entry types found in file")+"."); |
There was a problem hiding this comment.
Also formatting problems here. I should be sufficient to auto-format the file.
| menu.add(new ChangeTypeAction(type, panel)); | ||
| } | ||
|
|
||
| List<EntryType> customTypes = EntryTypes.getAllCustomTypes(BibDatabaseMode.BIBLATEX); |
There was a problem hiding this comment.
Would it be possible to extract the following code in a private method? It is duplicated below and the only difference is the mode.
There was a problem hiding this comment.
I would prefer to leave it as it, as the helper method would require three params (BibDatabaseMode, Menu and BasePanel) for just a simple get, if, create...
| if (frame.getCurrentBasePanel().getBibDatabaseContext().isBiblatexMode()) { | ||
| panel.add(createEntryGroupPanel("BibLateX", BibLatexEntryTypes.ALL)); | ||
|
|
||
| List<EntryType> customTypes = EntryTypes.getAllCustomTypes(BibDatabaseMode.BIBLATEX); |
There was a problem hiding this comment.
Would it be possible to extract the following code in a private method? It is duplicated below and the only difference is the mode.
There was a problem hiding this comment.
Same as above - helper method would be overkill, imho
| * Load all custom entry types from preferences. This method is | ||
| * called from JabRef when the program starts. | ||
| */ | ||
| public static void loadCustomEntryTypes(JabRefPreferences prefs) { |
There was a problem hiding this comment.
Could you change this class to be independent of JabRefPreferences? This would get us one step closer to our desired architecture. For the load method, this is easy (just put in CustomEntryType instead of the preferences). For the saving it is a little more tricky and you will need to push code into the calling UI-class.
There was a problem hiding this comment.
Mhmmm... This is basically just a UI-Helper class. loadCustomEntryTypes is called from the JabRefMain and the CLI Argument processer.
Storage is also used in the UI only...
So would it be possible and sensible to move it as is into the gui package?
There was a problem hiding this comment.
Not entirely, unfortunately. See: https://github.com/JabRef/jabref/wiki/High-Level-Documentation
The CLI is not supposed to call the gui, so anything accessed from GUI and CLI should be in logic, but it should be independent of the preferences. You could move the save and leave the load for instance.
There was a problem hiding this comment.
No we just need a new package net.sf.ui which could be called by gui and cli!
... just kidding 😉 I'll think about it...
| */ | ||
| public static List<EntryType> getAllCustomTypes(BibDatabaseMode mode) { | ||
| Collection<EntryType> allTypes = getAllValues(mode); | ||
| if(mode == BibDatabaseMode.BIBTEX) { |
There was a problem hiding this comment.
Can you extract the almost duplicated lambda into a private helper method?
There was a problem hiding this comment.
Sorry, but I cannot come up with an intelligent solution for such a helper method which is not basically the same as I already wrote here 😉
There was a problem hiding this comment.
Sure, no problem. This is just a suggestion.
| } | ||
|
|
||
| public static List<EntryType> getAllModifiedStandardTypes(BibDatabaseMode mode) { | ||
| if (mode == BibDatabaseMode.BIBTEX) { |
There was a problem hiding this comment.
Again, can the lambda be extracted into a helper method?
| */ | ||
| private static boolean checkEqualityOfLists(List<String> fieldList1, List<String> fieldList2) { | ||
|
|
||
| if(fieldList1.size()!=fieldList2.size()) { |
…ndard equals of List is possible
Conflicts: src/main/java/net/sf/jabref/model/EntryTypes.java src/main/java/net/sf/jabref/preferences/JabRefPreferences.java
|
Apart from a CHANGELOG and some more tests this is good to go from my side. |
|
@mlep @frithnanth It is not yet decided whether we will include this improvement in 3.8 or not. However, there are three more translations which are added in this pull request. Could you provide me translations for these three strings? Then I'll add them manually. |
|
On Thu, Dec 15, 2016 at 11:17 AM, Matthias Geiger ***@***.***> wrote:
@mlep <https://github.com/mlep> @frithnanth
<https://github.com/frithnanth> It is not yet decided whether we will
include this improvement in 3.8 or not. However, there are three more
translations which are added in this pull request. Could you provide me
translations for these three strings? Then I'll add them manually.
Thanks!
Select_all_customized_types_to_be_stored_in_local_preferences=
Select_all_customized_types_to_be_stored_in_local_
preferences=Seleziona_tutti_i_tipi_personalizzati_da_registrare_nelle_preferenze_locali
Currently_unknown=
Currently_unknown=Attualmente_sconosciuto
That's the singular mode, the plural is "Attualmente_sconosciuti".
But since Italian is profoundly evil, that's OK if referred to a masculine
noun, the feminine forms are different, but I'm digressing :-)
Different_Customization,_current_settings_will_be_overwritten=
Different_Customization,_current_settings_will_be_
overwritten=Personalizzazione_differente,_i_parametri_correnti_saranno_sovrascritti
… —
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2331 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADyA2AnC2wjebXAMoi4YuB2CzYqky1Bgks5rIRPHgaJpZM4LCcrA>
.
--
Fernando Santagata
|
|
Thank you @frithnanth ! |
|
You're welcome!
…On Fri, Dec 16, 2016 at 9:30 PM, Matthias Geiger ***@***.***> wrote:
Thank you @frithnanth <https://github.com/frithnanth> !
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2331 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADyA2EhYM65slWyTwdWTJwH8EDTLmMC4ks5rIvT2gaJpZM4LCcrA>
.
--
Fernando Santagata
|
|
How did we proceed regarding standard types? Is it a v4.0 issue? See JabRef#248 |
Goals:
Entry customization based on BibDatabaseMode
defaultBibDatabaseMode, old prefs are not deleted)enable testing with cleanup after test execution
various bug fixes and improvements, e.g., Customizing the entry types freezes Jabref #2318 custom entry types bug #772 Refactor entry type/custom entry type logic #366 Save custom entry types in bib file #365
refactor/rewrite parts of
EntryCustomizationDialogto improve performance (refs Customizing the entry types freezes Jabref #2318)fixes Reset preferences & Import preferences not working for custom entry types. #2261 (and also clearing of bibtexKeyPatterns using "reset preferences")
custom entry types bug #772: Deleting custom type, restoring customized default type from exported prefs, no multiple import of customized entry types
Refactor entry type/custom entry type logic #366: Check "Resetting overridden default entry types does not work, sometimes even crashes" - not reproducible in reworked state (ask @stefan-kolb whether still an issue) - related to Customizing the entry types freezes Jabref #2318? --> caused by running through all entries in all open DBs
If a customized type is declared in a file it will be tried to import the declarations - if a customType already exists, a warning should be shown that it will be overwritten
a customized standard type should not appear in the "custom" section of the "New entry" dialog, and not in the "custom entries" section of the "change entry type" menu
CHANGELOG