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

Completed General Fields Customizer conversion to JavaFX #4346

Merged
merged 26 commits into from
Sep 25, 2018

Conversation

abepolk
Copy link
Contributor

@abepolk abepolk commented Sep 15, 2018

This is what I have so far. The problem is that most, but not all of the time, when I run the "Set up general fields" dialog, there is a problem with ViewLoader and the program throws an error. Perhaps it is because I left the view model unfinished?


  • Change in CHANGELOG.md described
  • Tests created for changes
  • Manually tested changed features in running JabRef
  • Screenshots added in PR description (for bigger UI changes)
  • Ensured that the git commit message is a good one
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

@Siedlerchr Siedlerchr changed the title Gen javafx dialog [WIP] Gen javafx dialog Sep 16, 2018
@Siedlerchr
Copy link
Member

I looked into this and I think the main problem was that you missed the fx:ids for the button and the textarea. The fx:id must correspond to the variable in the View.

To spot such errors, it helps if you set a breakpoint in the initialize method of the View and then debug through it step by step. Then I discovered that the textarea variable was null -> so conclusion was missing id in the fxml

I fixed this and exported it as git patch. Remove the .txt extension and you can import it with
git am < 0001-fix-missing-ids.patch
0001-fix-missing-ids.patch.txt

@abepolk
Copy link
Contributor Author

abepolk commented Sep 21, 2018

I finished changing the Set Up General Fields Dialogs to JavaFX. The automatic build failures were unrelated to the changed code, and think I fixed all the true problems that Codacy mentioned.

The functions getCustomTabsNamesAndFields() and getCustomTabFieldNames() in the class JabRefPreferences, are very similar and it might be worth writing one as a function of the other to reduce boilerplate. I thought they were different enough (especially with respect to the return types) to keep them separate.

@abepolk abepolk changed the title [WIP] Gen javafx dialog Completed General Fields Customizer conversion to JavaFX Sep 21, 2018
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.

Thank you very much for your contribution! 👍
Overall looks good, just some minor improvements to fix and it's good!

<VBox prefHeight="300.0" prefWidth="650.0">
<children>
<Label text="General Fields" />
<Label text="Create custom fields for each BibTeX entry" />
Copy link
Member

Choose a reason for hiding this comment

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

To ensure that the labels are correctly translated in other languages it is necessary to add the percent sign in front of the text., e. G. %create custom...
This will probably also resolve the Travis failure due to localisation

String name = (String) defaults.get(CUSTOM_TAB_NAME + "_def" + defNumber);
String fields = (String) defaults.get(CUSTOM_TAB_FIELDS + "_def" + defNumber);

if ((name == null) || (fields == null) || name.isEmpty() || fields.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

You can use StringUtil.IsNullOrEmpty (from org.jabref.model.strings.StringUtil)

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 contribution. The code looks good to me, except one or two very minor things. Please also have a look at the travis build, which currently fails.

@Inject private PreferencesService preferences;
private GenFieldsCustomizerDialogViewModel viewModel;

public GenFieldsCustomizerDialogView() {
Copy link
Member

Choose a reason for hiding this comment

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

Can you please rename all classes related to the dialog to something like CustomizeGeneralFieldsDialog

sb.append(':');
sb.append(entry.getValue());
sb.append('\n');
fieldsText.set(sb.toString());
Copy link
Member

Choose a reason for hiding this comment

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

The fieldsText.set should probably come after the for loop.

@abepolk
Copy link
Contributor Author

abepolk commented Sep 24, 2018

Thanks for the feedback! I've made the changes. I believe Codacy fails because it does not recognize that ViewLoader takes care of the FXML in the controller, so I don't need to explicitly use all the variables that I create in the controller. The build now passes, but it does say some dependency updates are needed.

@FXML private ButtonType resetButton;
@FXML private ButtonType helpButton;
@FXML private ButtonType okButton;
@FXML private ButtonType cancelButton;
Copy link
Member

Choose a reason for hiding this comment

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

If you don't use the cancel button further in your code, you can remove it here and in the fxml remove the fx:id from it.

@@ -927,7 +927,7 @@ private MenuBar createMenu() {

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.SETUP_GENERAL_FIELDS, new SetupGeneralFieldsAction(this)),
factory.createMenuItem(StandardActions.SETUP_GENERAL_FIELDS, new SetupGeneralFieldsAction()),
Copy link
Member

Choose a reason for hiding this comment

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

Please align/indent it with the other ones below

@Siedlerchr
Copy link
Member

Thank you very much! It looks good to me now. Just one formatting issue and that you don't need the variable in the controller for cancelButton.

Ignore the dependency updates, the dependency check is run with every build and is just a hint that there might be some dependencies which could be updated. It fails if newer versions are found. But some of them are incompatible so ignore them

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 again!

@tobiasdiez tobiasdiez merged commit 2f433d2 into JabRef:master Sep 25, 2018
@abepolk
Copy link
Contributor Author

abepolk commented Sep 25, 2018

My pleasure.

@abepolk
Copy link
Contributor Author

abepolk commented Sep 25, 2018

Hi, I have another question. In terms of broad categories of fixes, what are the highest priorities right now for working on JabRef, apart from the conversion to JavaFX? I'm glad to convert more dialogs, but I also want to be involved with the logic and model. Let me know. Thanks!

@tobiasdiez
Copy link
Member

You can have a look at https://github.com/JabRef/jabref/projects/5 for high-priority bugs that need to be fixed. But I fear that most of them are purely UI-related.
Most of stuff labeled with fetcher or code quality involves only the backend. For example, creating a fetcher for worldcat would be nice.

@abepolk
Copy link
Contributor Author

abepolk commented Sep 25, 2018

Good to know. I'll keep you posted when I take up another dialog or issue from the issue page. Thanks for being so friendly!

@Siedlerchr
Copy link
Member

We have to thank you for your interest in making JabRef great again 😏

Siedlerchr added a commit that referenced this pull request Oct 13, 2018
* upstream/master:
  Update Libraries (#4366)
  ArXiv fetcher support http url (#4367)
  Fix issue 3861 : XMP Dialog, Add new Groups dialog, Append Library dialog to javafx (#4264)
  fix IndexOutOfBoundsException when saving preferences
  group RadioButtons in ExportSortingPrefsTab to prevent the selection of multiple or no order types
  Convert Part of the Issue#3861 Quality->Cleanup entries (#4268)
  UPDATE gradle to 4.10.2 (#4358)
  Completed General Fields Customizer conversion to JavaFX (#4346)
  Fix JavaFX thread exception when fetching new infos (#4354)
  Auto trim url field (#4355)
  Fix freezes in entry editor (#4351)

# Conflicts:
#	src/main/java/org/jabref/preferences/PreferencesService.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants