-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix for issue 3861 : Preferences Dialog to javafx #4253
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
Conversation
|
I think it would be easier to rebase your changes in the branch on the current (upstream, the JabRef project master) master branch, so that would hopefully avoid that conflitcts. |
|
Thanks for the advice, I am going to fix it. @Siedlerchr |
tobiasdiez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a first glance, the code changes look good. Nice work!
Some of the option panes need a bit of cleanup. Mostly visually, but also from the content (e.g. under "File" there is now an option "When downloading files, ..." which was not there before). Besides these points, I have two bigger wishes:
- It looks like you already converted all preference panes to JavaFX. Thus, there is no longer a need to have the right pane in Swing and include everything via
JFXPanels. Can you please convert the right selection pane also to JavaFX. - Some of the tabs still contain Swing controls, which should be removed/converted.
Moreover, please note that there are still merge problems (e.g. for the changelog).
|
|
||
| javafx.scene.text.Font font1 = new javafx.scene.text.Font(10); | ||
| // The header - can be removed | ||
| JLabel lblEntryType = new JLabel(Localization.lang("Entry type")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed one ;)
| gbl.setConstraints(lblEntryType, con); | ||
| pan.add(lblEntryType); | ||
|
|
||
| JLabel lblKeyPattern = new JLabel(Localization.lang("Key pattern")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here, too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that, I will do that soon :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still here
|
I have solved fix the NullPointerException in setting for External Application. Then I run the JabRefMain.java, it goes ok sometimes, like this |
|
It looks right so far. The Settings Dialog is still an old Swing dialog For the moment I would let this dialog stay as is and concentrate to convert the rest of the Panes as it is a bit out of scope of this PR: |
tobiasdiez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I scrolled over the code a bit and added some remarks that catched my eye. As I said before, in general the code looks good. It would be great if you now could also cleanup all the small things. Remove duplicates etc.
| .map(File::getAbsolutePath) | ||
| .orElse(Globals.prefs.get(JabRefPreferences.LAST_FOCUSED)); | ||
|
|
||
| .findFirst() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code formatting was correct before.
| } | ||
| } | ||
| rules.withModule("com.github.tomtung:latex2unicode_2.12") { ComponentSelection selection -> | ||
| rules.withModule("com.github.tomtung:latex2unicode_2.12") { ComponentSelection selection -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess these formatting changes are copied from a different PR. Did you merged the latest changes from master?
| Collections.sort(fieldNames); | ||
| String[] allPlusKey = fieldNames.toArray(new String[fieldNames.size()]); | ||
| savePriSort = new JComboBox<>(allPlusKey); | ||
| savePriSort = new ComboBox<>(FXCollections.observableArrayList(allPlusKey)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You no longer need to use an array. Instead, directly use the fieldNames collection.
|
|
||
| Font font = new Font(10); | ||
| GridPane builder = new GridPane(); | ||
| Label label = new Label(Localization.lang("Primary sort criterion")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use descriptive names for the controls, here eg primarySortLabel. This essentially applies to all controls on all tabs.
| Label label = new Label(Localization.lang("Primary sort criterion")); | ||
| label.setFont(font); | ||
| builder.add(label,1,1); | ||
| builder.add(savePriSort,2,1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our code formatting convention is that there should be a space after the comma.
|
|
||
| JComboBox<String> savePriSort1 = new JComboBox<>(allPlusKey); | ||
| savePriSort1.setEditable(true); | ||
| JComboBox<String> saveSecSort1 = new JComboBox<>(allPlusKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part here looks like a unnecessary code duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to remove these, but it seems they are used to initialize a JPanel used in DatabasePropertiesDialog.java, I haven't changed that file so far, so I kept them. As for other duplicates, I will cleanup them soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, in this case you can use a JFXPanel in DatabasePropertiesDialog to display the JavaFX controls.
| ViewLoader.view(this) | ||
| .load() | ||
| .setAsDialogPane(this); | ||
| .load() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formatting was ok before (applies also to some other code style changes).
| pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); | ||
| setLayout(new BorderLayout()); | ||
| add(pan, BorderLayout.CENTER); | ||
| Font font = new Font(10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of specifying the font in the code for every tab again, it is better to create one css file for the whole preference dialog. Then you can add a style class heading with a bigger font size (and maybe higher bottom padding). In the code, you then simply use useRemoteServer.setStyleClass("heading").
| button[i].setFont(new javafx.scene.text.Font(10)); | ||
| button[i].setOnAction(e-> defaultPat.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN))); | ||
| } | ||
| label[0] = new Label("Article"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of hard-coding these fields, you can use a foreach loop like for (EntryType type : EntryTypes.getAllValues(mode))
| add(panel, BorderLayout.CENTER); | ||
| } | ||
|
|
||
| public VBox getContainer() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better set the return type to Node, it's always better to return the Interface Type (https://www.quora.com/What-is-the-use-of-having-an-interface-as-a-return-type-in-Java)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, Done it
| builder.add(exportInSpecifiedOrder, 1, 6); | ||
| builder.add(new Line(), 2, 7); | ||
|
|
||
| exportOrderPanel = new SaveOrderConfigDisplay(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you directly initialize this SaveOrderConfigDisplay Variable at declaration above, you can change your event listener to this neat lambda:
EventHandler<ActionEvent> listener = (event) -> {
boolean selected = event.getSource() == exportInSpecifiedOrder;
exportOrderPanel.setEnabled(selected);
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the advice :). Done it
|
|
||
| con.gridy = 1; | ||
| con.gridx = 0; | ||
| JLabel lab = new JLabel(Localization.lang("Default pattern")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still and old jlabel
| gbl.setConstraints(defaultPat, con); | ||
| pan.add(defaultPat); | ||
| con.insets = new Insets(5, 5, 10, 5); | ||
| JButton btnDefault = new JButton(Localization.lang("Default")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old jbutton. Please remove all rest of the old swing stuff and it would be good to merge
Siedlerchr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you just remove the 2 or 3 remainig swing labels and buttons which are no longer needed, we can merge it
|
I am sorry for forgetting this, done it. :) @Siedlerchr |
Siedlerchr
left a comment
There was a problem hiding this 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!








Uh oh!
There was an error while loading. Please reload this page.