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

Allow reordering of custom entry types fields #6152

Merged
merged 51 commits into from
Jul 1, 2020
Merged

Conversation

Siedlerchr
Copy link
Member

@Siedlerchr Siedlerchr commented Mar 21, 2020

Additionally, restore the old Multiline Property and make it configurable.

Current status:

  • Adding/Removing/Reordering works

  • Removing standard entry types has no effect (they are always readded if deleted

  • Sort fields alphabetically? Would that effect the order? Needs investigation
    ==> cannot sort. it influences the save order

Refs #5230 and #4373

Fixes #6338

* upstream/master:
  Fix image path
  Check for secrets being present at GitHub workflows (#5973)
  Add "JabRef and Software Engineering"
  Make Java code acceptable for GitBook - and fix link to JUnit antipatterns
  Let "Contributing" be displayed
  Merge the reviewing steops of "Code Quality" to "Development Strategy"
  Try to include CONTRIBUTING.md in devdocs.jabref.org
  Minor improvments in CONTRIBUTING.md
  Update Codecov yaml with proper indentation (#6156)
  Complete refactor of LibraryProperties to mvvm (#6107)
  Try comment:false
  Remove duplicated line
  Fix: Only if `.sav` file has changes a recovery dialog is shown (#6116)
  Fix formatting for GitBook
  Add hint to scroll down
* upstream/master:
  Refine teaching explanation
  % include doesn't work on GitBook.io. Thus, add explicit text
  Bump unirest-java from 3.6.01 to 3.7.00 (#6166)
  Bump pdfbox from 2.0.18 to 2.0.19 (#6163)
  Bump xmpbox from 2.0.18 to 2.0.19 (#6164)
  Bump junit-vintage-engine from 5.6.0 to 5.6.1 (#6162)
  Bump mariadb-java-client from 2.5.4 to 2.6.0 (#6160)
  Bump fontbox from 2.0.18 to 2.0.19 (#6167)
  Bump junit-jupiter from 5.6.0 to 5.6.1 (#6159)
  Bump junit-platform-launcher from 1.6.0 to 1.6.1 (#6168)
  Add link to teaching page
  Refine teaching information
  Replace donation link to directly point to PayPal
Still some differences in the custom entry type dlg
seems to work now more or less
todo sorting is weird
@JabRef JabRef deleted a comment from codecov bot Apr 6, 2020
@Siedlerchr
Copy link
Member Author

LinkedHashSet is no solution either, as the standard fields are always inserted first.
TODO check it again

@tobiasdiez tobiasdiez marked this pull request as draft April 17, 2020 16:08
@koppor koppor changed the title [WIP] allow Reordering of custom entry types fields Allow reordering of custom entry types fields Apr 23, 2020
* upstream/master: (166 commits)
  New Crowdin translations (#6382)
  Update code-howtos.md (#6393)
  Fix jstyle was invalid with default section at the start (#6386)
  Correcting file name for groups.uml (#6373)
  Fix underscore character being omitted from file name in Recent Libraries list (#6389)
  Rework journal abbreviation caching (#6304)
  Fix selecting custom export for copy to clipboard with uppercase file ext (#6290)
  New Crowdin translations (#6375)
  Squashed 'src/main/resources/csl-styles/' changes from 143464e..906cd6d
  Fixes #6357: File directory (#6377)
  Disable the generate button if the ID field is empty (#6371)
  Fix Preferences style value too long (#6372)
  Fix various Dark theme issues (#6368)
  Correct label name in dependabot
  Bump java-diff-utils from 4.5 to 4.7 (#6365)
  Try with info.plist.template also (#6366)
  Fix wrong button order (Apply and Cancel) in ManageProtectedTermsDialog. (#6358)
  Bump flexmark-ext-gfm-strikethrough from 0.61.6 to 0.61.20 (#6361)
  Bump checkstyle from 8.31 to 8.32 (#6360)
  Bump flexmark-ext-gfm-tasklist from 0.61.16 to 0.61.20 (#6364)
  ...
compare bibentry types because it takes fields into account
still not saved correct in order argh
# By dependabot-preview[bot] (18) and others
# Via GitHub (17) and others
* upstream/master: (77 commits)
  Reenable caching of gradle
  Refactor BibtexKeyPatternPreferences (#6489)
  Update CHANGELOG.md
  Add changelog entry and remove unnecessary code
  EasyBind revision part two
  Fix Drag and Drop on empty database
  Truncates DOIs and URLs in the column "Linked identifiers" in main table, if too long (#6498)
  Bump flexmark-ext-gfm-tasklist from 0.61.26 to 0.61.30
  Bump flexmark from 0.61.26 to 0.61.30
  Bump xmlunit-matchers from 2.6.4 to 2.7.0
  Bump java-string-similarity from 1.2.1 to 2.0.0
  Bump flexmark-ext-gfm-strikethrough from 0.61.26 to 0.61.30
  Bump xmlunit-core from 2.6.4 to 2.7.0
  Truncates the link and/or the link description in the column "linked files" in main table, if too long (#6179)
  Keep group pane size when resizing window (#6180) (#6423)
  Changelog: Fix missing citation for biblatex-mla
  Update AUTHORS
  Check duplicate DOI (#6333)
  Fix missing citation for biblatex-mla
  Change EasyBind dependency (#6480)
  ...

# Conflicts:
#	src/main/java/org/jabref/gui/actions/ActionHelper.java
#	src/main/java/org/jabref/gui/customentrytypes/CustomEntryTypeDialogViewModel.java
#	src/main/java/org/jabref/gui/customentrytypes/CustomizeEntryTypeDialogView.java
#	src/main/java/org/jabref/model/entry/field/FieldFactory.java
@Siedlerchr
Copy link
Member Author

@tobiasdiez I currently have the problems that in my HashMap which contains entry types with their corresponding fields, the fields order is not updated if I change them via drag and drop in the main table.
This is logical, because the fieldsWithTypes is not an Observable.
Any idea how I can do this with some Binding Foo? Can I add some ObservabeList to that map?

https://github.com/JabRef/jabref/pull/6152/files#diff-8313b29670cb7c9bc50c020e1b2b5f17L80-R101

@tobiasdiez
Copy link
Member

I'm not sure what exactly you mean. A Map<EntryType, ObservableList<Field>> does not work?

@Siedlerchr
Copy link
Member Author

I tired it, but its a bit more complicated I think (Or maybe I am thinking too complicated)

I would need to bind a ListProperty to the values Collection of my map
and then I would need to change that ListProperty (fieldsForType) content based on my selected entry types. Currently I am doing this more or less manually.

    private final ListProperty<FieldViewModel> fieldsForType;

    private final ObservableList<FieldViewModel> allFieldsForType = FXCollections.observableArrayList(extractor -> new Observable[] {extractor.fieldName(), extractor.fieldType()});

      for (BibEntryType entryType : allTypes) {
            List<FieldViewModel> fields = entryType.getAllFields().stream().map(bibField -> new FieldViewModel(bibField.getField(), entryType.isRequired(bibField.getField()), bibField.getPriority(), entryType)).collect(Collectors.toList());
            typesWithFields.put(entryType, FXCollections.observableArrayList(fields));
        }
        

        this.fieldsForType = new SimpleListProperty<>(allFieldsForType);

        EasyBind.subscribe(selectedEntryTypes, type -> {
            if (type != null) {
                allFieldsForType.setAll(typesWithFields.get(type));
            }
        });

@tobiasdiez
Copy link
Member

I guess the following might work:

  • Create your Map<EntryType, ObservableList<Fields>> entryTypesWithFields.
  • When the user selects an entryType then set fieldsForType to entryTypesWithFields.get(entryType). It is important that you set really the observable list and not the contents of the list (i.e. not setAll).

By the way, the whole map construction seems to be overly complicated. Why not create a EntryTypeViewModel that wraps a given entry type and also contains an observable list of fields. Then you can have a simple observable list of EntryTypeViewModels, which you can bind to the list and then bind the contents of the field list to the observable list of the current entry type.

* upstream/master: (110 commits)
  Fix DOI import in RIS Importer
  Rename bibtexkey (#6545)
  check if fields are empty
  fix comment checkstyle arght
  Fix XMP Exctrator not returning empty optional
  Fix Group hit counter calculation preferences (#6554)
  add changelog entry
  Make test concise
  Add test for getXmpMetadata with no description
  guidelines updated
  lint and hint for JEE
  Update eclipse setting
  Bump checkstyle from 8.32 to 8.33
  Bump classgraph from 4.8.78 to 4.8.80
  Add more menu items to library context menu (#6551)
  Squashed 'src/main/resources/csl-styles/' changes from 586e0b8..c5f14e2
  Correct return description in javadoc
  iterate to get all selected leaf nodes
  check if metadata has start and end tag
  Update RisImporterTest.java
  ...
adapt bindings

TODO: add/remove
@Siedlerchr Siedlerchr marked this pull request as ready for review June 12, 2020 15:44
disable control helper button for the moment
* upstream/master:
  fix markdown lint
  Fix library marked as changed when opening library properties
  Fixed an issue where entry preview in preferences has white theme. (#5522)
  Checkstyle
  Fixed GrobidServiceTest
  Remove senseless tests for getHelpPage and fixed some IDE warnings
  Changed expected result of GrobidCitationFetcherTest, fixed some minor IDE suggestions
  Moved IEEE api key to github secrets
  Revert change in GrobidServiceTest
  Moved ADS api key to github secrets
  Fix INSPIREFetcherTest
  Fix GrobidServiceTest
  Fix more links
  Fixed some broken links in fetcher tests
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

This PR looks finished and looks awesome!

Nevertheless, I have some comments...

* upstream/master:
  Validates the file path of a TexGroup and fixes Texgroup's "Library has been modified by another program" (#6586)
  Bump postgresql from 42.2.12 to 42.2.14 (#6610)
  Add markdown-link-check (#6542)
  Catch InaccessibleObjectException (#6519)
  Fix author formatter for unchanged names (#6552)
  Bump com.simonharrer.modernizer from 1.8.0-1 to 2.1.0-1
  Bump org.beryx.jlink from 2.19.0 to 2.20.0
  Bump classgraph from 4.8.83 to 4.8.86
  Update FileUtilTest.java
  Update FileUtilTest.java
  Squashed 'src/main/resources/csl-styles/' changes from c5f14e2..716f635
  Update FileUtilTest.java
  Update MoveFilesCleanupTest.java
  checkstyle
  Fix dowmloaded files moved to citaiton key dir
and pages order
clean empty lines
* upstream/master:
  Bump fontbox from 2.0.19 to 2.0.20
  Bump xmpbox from 2.0.19 to 2.0.20
  Bump unirest-java from 3.7.02 to 3.7.04
  Bump byte-buddy-parent from 1.10.11 to 1.10.12
  Bump pdfbox from 2.0.19 to 2.0.20
@Siedlerchr
Copy link
Member Author

TODO:

  1. Modify type article, add field langid
  2. Make optional
  3. Move after number
  4. Save
  5. Reopen dialog
    => langid field is no longer after number, it has moved to a different position

Problem possible: in BibEntryTypesManager;

   public SortedSet<BibEntryType> getAllTypes() {
            SortedSet<BibEntryType> allTypes = new TreeSet<>(customOrModifiedType);
            allTypes.addAll(standardTypes);
            return allTypes;
        }

* upstream/master:
  Update README.md
  Link the most important page from the beginning
  add removable-media info in snap description (#6619)
  Set version of markdown-link-check to v1
Change EntryEditor to LInkedHashSet as well
@Siedlerchr
Copy link
Member Author

Siedlerchr commented Jun 27, 2020

Yeah! I found the bug:
Custom Entry types order is now correctly stored and also applied to entry editor!

grafik

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jun 28, 2020
@Siedlerchr Siedlerchr merged commit c83ea3f into master Jul 1, 2020
@Siedlerchr Siedlerchr deleted the allowReordering branch July 1, 2020 15:18
koppor pushed a commit that referenced this pull request Aug 1, 2022
c750b6e APA: Put conditional event-title logic in a macro (#6161)
a87414f Remove month from association-for-compuational-linguistics.csl (#6158)
6153db0 Remove issue numbers from BJOC style (#6155)
e231ea3 Bug fix for `event` regression (#6154)
0dab651 Add event-title to other APA styles (#6153)
698cf1c APA: `event-title` and conditional `event` (#6152)
58d3f8f Update vancouver-author-date.csl (#6148)
f1638a9 add substitute to Vancouver author date (#6147)
39fede5 Update associacao-brasileira-de-normas-tecnicas.csl (#6138)
fde7695 Include chapter title (#6140)
1e3d8b4 Update n.d. abbreivation for DGP style (#6136)
ebb728b suffix '.' after first group; changed e-mail (#6135)
eed4f07 Update and rename sciences-po-ecole-doctorale-note-french.csl to scie… (#6127)
f194647 Delete TU Dresden Medizin as requested by library (#6131)
d8423d8 Create entomological-review.csl (#6120)
064a394 Create australasian-journal-of-philosophy.csl (#6063)
a998ded Add composer.json (#5668)
37083c9 Update copernicus-publications.csl (#6062)
694c97b Create chaucer review (#6061)
625a424 Create haffner-style-manual.csl (#6054)
8b7224b make annals-of-allergy-asthma-and-immunology independent (#6041)
710748c Create university-of-pretoria-harvard-theology-religion.csl (#6106)
d16dffd Create health-physics.csl (#6040)
ca9e184 Update style-manual-australian-government.csl (#6119)
e412277 Create chemical-engineering-technology.csl (#6039)
bebdb48 Create bibliothek-forschung-und-praxis.csl (#6038)
29e49cd Update nature.csl (#6117)
891897d fix short title for SBL (#6118)

git-subtree-dir: buildres/csl/csl-styles
git-subtree-split: c750b6e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Dialog "Customize Entry Types" - drag&drop not working - adding new field buggy
3 participants