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

Convert Strings Dialog to javafx #3735

Merged
merged 38 commits into from
Feb 17, 2019
Merged

Convert Strings Dialog to javafx #3735

merged 38 commits into from
Feb 17, 2019

Conversation

Siedlerchr
Copy link
Member

@Siedlerchr Siedlerchr commented Feb 17, 2018

Convert Strings Dialog to javafx

I decided to take a shot at the String dialog. But I have some questions about the String handling in the Database class. I know that I can define some user defined strings as kind of template and then reuse them in my bib entries.

The only thing which does not look that good is the position of the Validation error icon.
Needs perhaps some CSS tweaking, but for the moment not important.

  • Store Strings back in DB
  • Validate Strings and label

grafik


  • Change in CHANGELOG.md described
  • Tests created for changes
  • Screenshots added (for bigger UI changes)
  • Manually tested changed features in running JabRef
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

TODO: store strings back to db
@tobiasdiez
Copy link
Member

tobiasdiez commented Feb 17, 2018

Nice that you want the dialog to JavaFX. However, I don't understand what questions you now have.

@Siedlerchr
Copy link
Member Author

@tobiasdiez I was wondering why the BibtexString is stored in a Map<String, BibTexString in the databse.
The key of the Map is some generated id and is also stored in the BibTexString itself.
So I see no reason why the list of BibTexStrings is not a simple list or set.

public synchronized void addString(BibtexString string) throws KeyCollisionException {
if (hasStringLabel(string.getName())) {
throw new KeyCollisionException("A string with that label already exists");
}
if (bibtexStrings.containsKey(string.getId())) {
throw new KeyCollisionException("Duplicate BibTeX string id.");
}
bibtexStrings.put(string.getId(), string);
}

@tobiasdiez
Copy link
Member

This is probably for performance reasons (hashmap provides a quicker lookup than to transverse the list).

TODO: validation
@Siedlerchr Siedlerchr changed the base branch from javafxGlobalEverything to maintable-beta February 22, 2018 09:44
@Siedlerchr
Copy link
Member Author

I now tried around and got the Validation running somehow, but it doesn't really work
I just used an EmptyValidator, but although I have entered text, it is shown as "red"
grafik
@tobiasdiez Any idea how I have to configure that? I looked at the entry editor validation, but that is a bit different as always only one single property is validated

t.getTableView()
.getItems()
.get(
t.getTablePosition().getRow())
Copy link
Member

Choose a reason for hiding this comment

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

t.getRowValue is easier (and please rename t to something more descriptive.

@tobiasdiez
Copy link
Member

tobiasdiez commented Feb 25, 2018

I strongly recommend to use the mvvmfx.validation framework instead of directly using controlsfx. The latter has the problem that UI components are mixed with validation logic. The validation should not be concerned with the text in the text field, but with the content of a StringProperty in the view model, which is bound to the text field. The mvvmfx has a good documentation at https://github.com/sialcasa/mvvmFX/wiki/Validation#validator.

@Siedlerchr
Copy link
Member Author

Okay, yes, that seems pretty streightfoward, except that I have now the problem:
I have my DialogViewModel and the StringViewModel which has just the content properties.
Should I merge this two ViewModels into one or is there another solution?
I think I did it that way in my Sharelatex PR, but with the consequence that I had all stuff double on each dialog opening

@tobiasdiez
Copy link
Member

Two view models are what you need here. One for the whole dialog (contains a list of all strings, the composite validation status, methods for load/save) and one for each string (determines how the string should be displayed and its validation status). The validation of the per-string view model should be bound to the text field similar to how you did it before.

@Siedlerchr
Copy link
Member Author

Okay, I managed to get it work and the validation is triggered correctly, but I have no idea why no icon is shown. I used JabRef's own IconDecorator class. Any idea why it's not showing?
I debugged through it, but could not identify why no icon etc is shown

You have to click new -> Its triggered for the first ime
Remove all content -> Hit enter -> Validation triggers again and returns the Validation.warning/error message statusbut no icon

…gsjavafx

* upstream/maintable-beta:
  Save order of columns across sessions (#3783)
  Allow side pane to be completely hidden (#3784)
  Show empty group pane if no database is open (#3785)
  Reenable drag'n'drop support for tabs / libraries (#3688)
@Siedlerchr
Copy link
Member Author

@tobiasdiez Do you have an idea why the Validation error/warning icon is not showing? the validation is triggered, but it doesn't display anything

…gsjavafx

* upstream/maintable-beta: (188 commits)
  Fix checkstyle
  Exchange Ignore by Disabled (#3912)
  Remove all @author comments and empty method/class comments
  Clean unused imports
  Fix missing icons and wrong package for custom icons
  Consistent FX color scheme for JabRef (#3839)
  javafx replacement for file dialog (#3005)
  Reenable closing of entry preview by pressing Esc (#3883)
  Load all field editors using ViewLoader
  Use JabRef icons in FXML
  Move icon stuff to new package gui.icon
  Load EntryEditor using new ViewLoader
  Improve tooltip tests
  Fix import thread problem
  Don't use null as parameter in DialogService
  Make it easier to create FXML dialogs (#3880)
  update slf4j from 1.8.0-beta1 -> 1.8.0-beta2
  New translations JabRef_en.properties (Tagalog)
  New translations JabRef_en.properties (Italian)
  New translations Menu_en.properties (Italian)
  ...

# Conflicts:
#	src/main/java/org/jabref/gui/JabRefFrame.java
@Siedlerchr
Copy link
Member Author

As the validation still does not show up I created an issue:
sialcasa/mvvmFX#546

…gsjavafx

* upstream/maintable-beta:
  fix checkstyle
  fix closing preferences on save Remove unused code in cleanup No need to set swing content on swing thread
validation icon is now correctly shown, although it needs some css mods
fix toolbar max width
@Siedlerchr
Copy link
Member Author

Got it working now, not perfect, but at least it works. Currently it works only after you hit enter

grafik

* upstream/master:
  Fix NPE and not on FX Thread in PreviewPrefs Tabs (#4624)
  Fix preview style configuration (#4613)
  Bump wiremock from 2.20.0 to 2.21.0 (#4623)
  snap: disable tests build, add removable media and specify architectures (#4619)
  Bump checkstyle from 8.16 to 8.17 (#4620)
  Fix preferences path: use _JAVA_OPTIONS
  Try to fix not on FX thread for search and autocomplete (#4618)
  Update snapcraft.yaml Move to snap folder
  Convert DuplicateResolverDialog to javafx (#4601)
  Fix for BibTex source tab parsing issue if field contains {} (#4581)
  Convert OO/LO SidePanel to javafx (#4341)
  Convert "Customize importer" dialog to JavaFX (#4608)
  Convert "From Aux file" dialog to JavaFX (#4607)
  Convert "Show preferences" dialog to JavaFX (#4605)
  Fix not on FX thread exception
  Force javafx to run thread (#4604)
  Convert new version dialog to JavaFX (#4602)
  Add a variable to track the change in preview style (#4587)
  Solution for submitting dialog with Ctrl + Enter (#4496) (#4592)
  Bump mysql-connector-java from 8.0.13 to 8.0.14 (#4599)

# Conflicts:
#	src/main/resources/l10n/JabRef_en.properties
TODO: fix validation
optimize layout a bit
fix l10n
@Siedlerchr Siedlerchr changed the title [WIP] Convert Strings Dialog to javafx Convert Strings Dialog to javafx Feb 2, 2019
@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Feb 2, 2019
@Siedlerchr
Copy link
Member Author

I finally solved the validation @tobiasdiez , so this dialog is now ready for review

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this dialog. Sadly, the quality of this PR is not as high as I'm used from you. Probably because it lied dead for so long and you grew as a programmer in the meantime and I'm now used to your better PRs ;-). Anyway, I've quite a few remarks and suggestions for improvement.

src/main/java/org/jabref/gui/JabRefFrame.java Outdated Show resolved Hide resolved
src/main/java/org/jabref/gui/JabRefFrame.java.orig Outdated Show resolved Hide resolved
src/main/java/org/jabref/gui/strings/StringAction.java Outdated Show resolved Hide resolved
src/main/java/org/jabref/gui/strings/StringDialog.css Outdated Show resolved Hide resolved
src/main/java/org/jabref/gui/strings/StringViewModel.java Outdated Show resolved Hide resolved
src/main/java/org/jabref/gui/strings/StringViewModel.java Outdated Show resolved Hide resolved
src/main/java/org/jabref/gui/strings/StringViewModel.java Outdated Show resolved Hide resolved
* upstream/master:
  Bump mockito-core from 2.23.4 to 2.24.0 (#4626)
  Bump mysql-connector-java from 8.0.14 to 8.0.15 (#4627)
* upstream/master: (21 commits)
  Bump applicationinsights-core from 2.3.0 to 2.3.1 (#4656)
  Bump applicationinsights-logging-log4j2 from 2.3.0 to 2.3.1 (#4657)
  Bump bcprov-jdk15on from 1.60 to 1.61 (#4653)
  Bump log4j-jcl from 2.11.1 to 2.11.2 (#4646)
  Bump log4j-api from 2.11.1 to 2.11.2 (#4650)
  Bump assertj-swing-junit from 3.8.0 to 3.9.2 (#4647)
  Bump log4j-jul from 2.11.1 to 2.11.2 (#4648)
  Bump log4j-slf4j18-impl from 2.11.1 to 2.11.2 (#4649)
  Bump log4j-core from 2.11.1 to 2.11.2 (#4651)
  Remove old code for PDF import (#4634)
  Reorder conditional checks
  Automatically created groups with Field to group by as entrytype (#4539) (#4555)
  Fix for issue 4641: Remove usage of TempDirectory extension from junit-pioneer (#4644)
  Edit localization file
  Add Integrity check for books with edition reported as 1
  Use 'junit-jupiter' aggregator module (#4640)
  Bump junit-jupiter-params from 5.3.2 to 5.4.0 (#4638)
  Bump junit-vintage-engine from 5.3.2 to 5.4.0 (#4637)
  Bump junit-platform-launcher from 1.3.2 to 1.4.0 (#4636)
  Bump junit-jupiter-api from 5.3.2 to 5.4.0 (#4639)
  ...

# Conflicts:
#	src/main/resources/l10n/JabRef_en.properties
@Siedlerchr
Copy link
Member Author

Addressed all remaininig issues so far. Also extracted the column setup with validation to an extra Factory.
As explained earlier, decided not to move the undo stuff as all undo things are in one package now.
And moving the viewModel stuff adding the strings does not really make sense how the internal class is now architectured

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

There are still some unresolved comments.
Can you please also explain why it is not possible to refactor the save method to do something like:

  • Convert list of String-ViewModel to list of BibtexStrings.
  • Update all strings in the database with this new list.

Would make this method easier to understand and extract code that can be used somewhere else.

@Siedlerchr
Copy link
Member Author

@tobiasdiez Moved the code to the bibdatabase for adding new strings from a collection

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

Thanks! Looks very good to me now.

@tobiasdiez tobiasdiez merged commit e5ede3a into master Feb 17, 2019
@tobiasdiez tobiasdiez deleted the editStringsjavafx branch February 17, 2019 22:08
Siedlerchr added a commit that referenced this pull request Feb 18, 2019
…tofx

* upstream/master:
  Convert Strings Dialog to javafx (#3735)
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.

2 participants