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

JournalAbbreviation search feature #7804

Merged
merged 22 commits into from
Jun 15, 2021

Conversation

btut
Copy link
Contributor

@btut btut commented Jun 7, 2021

I Implemented a string filter for the journal abbreviations tab.
This is not working as of yet. Performing a search currently cleares a list of filtered
abbreviations and fills it back up with abbreviations that contain the
search string. Right now the clearing not only cleares the filtered list
but also the list of all abbreviations and I don't unterstand why.

Fixes #7751

  • 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 documentation: Is the information available and up to date? If not created an issue at https://github.com/JabRef/user-documentation/issues or, even better, submitted a pull request to the documentation repository.
    image

Implemented a string filter for the journal abbreviations tab.
Not working. Performing a search currently cleares a list of filtered
abbreviations and fills it back up with abbreviations that contain the
search string. Right now the clearing not only cleares the filtered list
but also the list of all abbreviations and I don't unterstand why.

Issue JabRef#7751
btut added 6 commits June 7, 2021 18:43
Changed implementation to use JavaFX's FilteredList.
I think the conversion of the search term to lower-case makes more sense
in the contains (now containsLowerCase) method. We already need to
convert the terms to compare there, so people expecting contains() to be
case-dependent (as it usually is) would be fooled.
@btut
Copy link
Contributor Author

btut commented Jun 8, 2021

The documentation includes a screenshot of the abbreviations tab. I could update that, but since the feature is not released yet, it's misleading.
Is there a way to create a PR on the documentation repo and mark it to only be merged when the feature is merged/released?

@btut btut changed the title [WIP] JournalAbbreviation search feature JournalAbbreviation search feature Jun 8, 2021
@btut btut marked this pull request as ready for review June 8, 2021 08:16
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.

Some minor code imprvements, otherwise lgtm

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jun 8, 2021
@mlep
Copy link
Contributor

mlep commented Jun 8, 2021

The documentation includes a screenshot of the abbreviations tab. I could update that, but since the feature is not released yet, it's misleading.
Is there a way to create a PR on the documentation repo and mark it to only be merged when the feature is merged/released?

I do not know about this, but an alternative could be to alter the documentation while mentioning this is valid for v 5.3 only.

@Siedlerchr
Copy link
Member

For the documentation create a PR and we merge it afterwards, but with gitbook I'm unsure if this doesn't break all...

Copy link
Member

@k3KAW8Pnf7mkmdSMPHz27 k3KAW8Pnf7mkmdSMPHz27 left a comment

Choose a reason for hiding this comment

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

Pretty much everything from my side is nitpicking. View them as suggestions and include them if you agree.

However, I would like you to change JournalAbbreviationsTab.selectNewAbbreviation so that it uses the length of the filtered list instead (perhaps journalAbbreviationsTable.getItems().size() is better).

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member

However, I would like you to change JournalAbbreviationsTab.selectNewAbbreviation so that it uses the length of the filtered list instead (perhaps journalAbbreviationsTable.getItems().size() is better).

I meant

private void selectNewAbbreviation() {
int lastRow = viewModel.abbreviationsCountProperty().get() - 1;
journalAbbreviationsTable.scrollTo(lastRow);
journalAbbreviationsTable.getSelectionModel().select(lastRow);
journalAbbreviationsTable.getFocusModel().focus(lastRow);

GitHub doesn't allow me to comment on code that is that far out of the region of your changes 😝

Since abbreviationsCountProperty uses the non-filtered list. Since the filtered list is always equal or smaller, I don't believe it can throw an error and, at least for now, works.

@btut
Copy link
Contributor Author

btut commented Jun 9, 2021

However, I would like you to change JournalAbbreviationsTab.selectNewAbbreviation so that it uses the length of the filtered list instead (perhaps journalAbbreviationsTable.getItems().size() is better).

I meant

private void selectNewAbbreviation() {
int lastRow = viewModel.abbreviationsCountProperty().get() - 1;
journalAbbreviationsTable.scrollTo(lastRow);
journalAbbreviationsTable.getSelectionModel().select(lastRow);
journalAbbreviationsTable.getFocusModel().focus(lastRow);

GitHub doesn't allow me to comment on code that is that far out of the region of your changes stuck_out_tongue_closed_eyes

Since abbreviationsCountProperty uses the non-filtered list. Since the filtered list is always equal or smaller, I don't believe it can throw an error and, at least for now, works.

Ah, I did not see that. But what if the new abbreviation does not match the search criteria? Then setting the selection to the last row in the search result is not very useful. Would it maybe make sense to clear the search before adding new abbreviations?

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member

Ah, I did not see that. But what if the new abbreviation does not match the search criteria? Then setting the selection to the last row in the search result is not very useful. Would it maybe make sense to clear the search before adding new abbreviations?

Huh, I hadn't thought of that 🤔
I think your suggestion is good. On the one hand, I dislike disappearing search text, but on the other hand, that seems far better than not giving visual feedback on an added abbreviation. @Siedlerchr do you know of anything?

@Siedlerchr
Copy link
Member

What about adding a label e..g No search results found?

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member

k3KAW8Pnf7mkmdSMPHz27 commented Jun 9, 2021

@Siedlerchr the use case is,

  1. You have filtered the list, (say you only want IEEE)
  2. You are adding a new Abbreviation that has nothing to do with IEEE and should therefore not be shown in the filtered list
  3. After the abbreviation is added, the current behavior would select the last item in the filtered list (even if the last item is not the added abbreviation)

@Siedlerchr
Copy link
Member

Ah, now I understand. I would simply not select anything after adding, the same as when you search for something and add a new entry to the table. The new entry is not shown because you have filtered the list and as far as I remember it's also not selected

@btut
Copy link
Contributor Author

btut commented Jun 10, 2021

Ah, now I understand. I would simply not select anything after adding, the same as when you search for something and add a new entry to the table. The new entry is not shown because you have filtered the list and as far as I remember it's also not selected

Are you talking about the main bib-table? It's a little different there as when you add an entry, the entryeditor is opened so there is some visual feedback that an entry was added and users are able to edit them.
For journal abbreviations, there is no such thing. They are edited directly in the table. So from a users perspective, I would probably click the 'add' button several times if no new entry shows up. I would prefer jabref losing my search term rather than my new entry.

@koppor
Copy link
Member

koppor commented Jun 10, 2021

+1 for clearing the search when adding a new abbreviation.

@btut
Copy link
Contributor Author

btut commented Jun 11, 2021

As discussed yesterday with @koppor and @calixtus, I added visual feedback when invalidating the search when adding a new abbreviation. The search-bar now will briefly flash in red color.
Peek 2021-06-11 12-29

@calixtus
Copy link
Member

Thanks for integrating the flash. This should make it now very obvious that the search has been cleared. UI looks very good to me. I will take a closer look at the source tonight.

Also added UnitTest for new ColorUtil.toRGBAcode.
Copy link
Member

@k3KAW8Pnf7mkmdSMPHz27 k3KAW8Pnf7mkmdSMPHz27 left a comment

Choose a reason for hiding this comment

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

Looks good to me! Change the SimpleStringProperty and it should be good to go.


There are still some issues with which Abbreviation gets selected and how, but I'd consider it unrelated to this PR. Perhaps a follow-up issue? Some of it might be beginner friendly.

One example of this is

  1. Create a new Abbreviation
  2. The first column (with default text Name should be selected)
  3. Click on an empty spot of the table
  4. Press enter and get a Cannot invoke "javafx.scene.control.TableColumnBase.isEditable()" because the return value of "javafx.scene.control.TablePositionBase.getTableColumn()" is null message (most likely we are selecting the full row rather than the cell, I haven't verified this)

Another seem to be that there always is an empty row in a custom abbreviations list.

@btut
Copy link
Contributor Author

btut commented Jun 12, 2021

There are still some issues with which Abbreviation gets selected and how, but I'd consider it unrelated to this PR. Perhaps a follow-up issue? Some of it might be beginner friendly.

One example of this is

1. Create a new Abbreviation

2. The first column (with default text `Name` **should** be selected)

3. Click on an empty spot of the table

4. Press enter and get a `Cannot invoke "javafx.scene.control.TableColumnBase.isEditable()" because the return value of "javafx.scene.control.TablePositionBase.getTableColumn()" is null` message (most likely we are selecting the full row rather than the cell, I haven't verified this)

Selecting the right column (add2d44) does not completely fix this, but gets rid of the exception. Hitting enter keeps the text-field in the name column selected, but does not commit it. One has to click the text again and hit enter to apply the changes.

@btut
Copy link
Contributor Author

btut commented Jun 12, 2021

Speaking of the selection, I don't know how safe it is to do the selection right after starting the animation for the search-invalidation. Maybe it would be better to do all the actions for the new abbreviation (addAbbreviation, selectNewAbbreviation, editAbbreviation) only after the search is invalidated? Just to make sure the abbreviation is visible when doing the selection?

Edit: Tried it out, behaviour is still the same but I think it is safer like this. 4cf14b7

@Siedlerchr
Copy link
Member

I would have expected to have the search field above the table, what do the others think?

@calixtus
Copy link
Member

As the line above the list is already crowded with various controls, I would vote to merge this PR as it is now and redesign the whole dialog in another PR.

@calixtus calixtus merged commit d80e164 into JabRef:main Jun 15, 2021
@calixtus
Copy link
Member

Thanks!

Siedlerchr added a commit to koppor/jabref that referenced this pull request Jun 16, 2021
* upstream/main:
  [Bot] Update CSL styles (JabRef#7824)
  Pin version of citeproc-java (JabRef#7827)
  JournalAbbreviation search feature (JabRef#7804)
  Bump fontbox from 2.0.23 to 2.0.24 (JabRef#7815)
  Revert "Bump org.eclipse.jgit (JabRef#7820)" (JabRef#7823)
  Bump bcprov-jdk15on from 1.68 to 1.69 (JabRef#7816)
  Bump postgresql from 42.2.20 to 42.2.21 (JabRef#7817)
  Bump org.eclipse.jgit (JabRef#7820)
  Bump mockito-core from 3.11.0 to 3.11.1 (JabRef#7819)
  Bump pdfbox from 2.0.23 to 2.0.24 (JabRef#7818)
  Bump byte-buddy-parent from 1.11.1 to 1.11.2 (JabRef#7821)
  Bump xmpbox from 2.0.23 to 2.0.24 (JabRef#7822)
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.

Add a search for the journal abbreviations
6 participants