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

Fix for issue 3861 : Preferences Dialog to javafx #4253

Merged
merged 65 commits into from
Aug 19, 2018

Conversation

Super-Tang
Copy link
Contributor

@Super-Tang Super-Tang commented Aug 8, 2018


  • 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?)

@Super-Tang
Copy link
Contributor Author

Below are what we have done to the dialog Options->Preference. The left is the original.

fc614eb383bd210d1852503555065eb
c75201e95ecb9927765952a9bcc653e
cae239f92de3b1c952596cbf1a7bdce
02c337e56200c1496d4477377dedd76
3c1f226f65035bda9d3482c106b2393
f34b59245e53e45fda0eb1f36131d75

@Siedlerchr
Copy link
Member

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.
https://git-scm.com/book/de/v2/Git-Branching-Rebasing

@Super-Tang
Copy link
Contributor Author

Thanks for the advice, I am going to fix it. @Siedlerchr

@Super-Tang Super-Tang changed the title Fix dialog Fix for issue 3861 Aug 9, 2018
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.

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).

@@ -68,10 +68,11 @@ private void buildGUI() {
sp.setBorder(BorderFactory.createEmptyBorder());
pan.setLayout(gbl);
setLayout(gbl);

javafx.scene.text.Font font1 = new javafx.scene.text.Font(10);
// The header - can be removed
JLabel lblEntryType = new JLabel(Localization.lang("Entry type"));
Copy link
Member

Choose a reason for hiding this comment

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

missed one ;)

@@ -87,7 +88,8 @@ private void buildGUI() {

JLabel lblKeyPattern = new JLabel(Localization.lang("Key pattern"));
Copy link
Member

Choose a reason for hiding this comment

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

here, too

Copy link
Contributor Author

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 :)

Copy link
Member

Choose a reason for hiding this comment

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

Still here

@Super-Tang
Copy link
Contributor Author

I have solved fix the NullPointerException in setting for External Application. Then I run the JabRefMain.java, it goes ok sometimes, like this
1cdff6dfb27e671db2cd6d05e045900
but mostly, the program doesn't respond.
d91d7626f487c9559c934a9357d3e47
Is that OK or I have messed sth up ? @Siedlerchr

@Siedlerchr
Copy link
Member

It looks right so far. The Settings Dialog is still an old Swing dialog PushToApplicationSettingsDialog together with PushToApplicationSettings
which will be displayed as modal and blocking. You have to first close the swing dialog to make the rest of the application work again. If the dialog is not visible, use Alt+Tab to switch to the window),

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:
I added this to the list in #3861
You can embed Swing in JavaFX by using a SwingNode

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.

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()
Copy link
Member

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.

build.gradle Outdated
}
}
rules.withModule("com.github.tomtung:latex2unicode_2.12") { ComponentSelection selection ->
rules.withModule("com.github.tomtung:latex2unicode_2.12") { ComponentSelection selection ->
Copy link
Member

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?

@@ -38,56 +46,87 @@ private void init() {
fieldNames.add(BibEntry.KEY_FIELD);
Collections.sort(fieldNames);
String[] allPlusKey = fieldNames.toArray(new String[fieldNames.size()]);
savePriSort = new JComboBox<>(allPlusKey);
savePriSort = new ComboBox<>(FXCollections.observableArrayList(allPlusKey));
Copy link
Member

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"));
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

@@ -31,8 +31,8 @@ public AboutDialogView() {
this.setResizable(true);

ViewLoader.view(this)
.load()
.setAsDialogPane(this);
.load()
Copy link
Member

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);
Copy link
Member

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");
Copy link
Member

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() {
Copy link
Member

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)

Copy link
Contributor Author

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(exportInTableOrder, 1, 4);
builder.add(new Line(), 2, 5);
builder.add(exportInSpecifiedOrder, 1, 6);
builder.add(new Line(), 2, 7);

exportOrderPanel = new SaveOrderConfigDisplay();
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 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);
        };

Copy link
Contributor Author

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

@@ -88,6 +102,10 @@ private void buildGUI() {
con.gridy = 1;
con.gridx = 0;
JLabel lab = new JLabel(Localization.lang("Default pattern"));
Copy link
Member

Choose a reason for hiding this comment

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

still and old jlabel

@@ -97,6 +115,11 @@ private void buildGUI() {
JButton btnDefault = new JButton(Localization.lang("Default"));
Copy link
Member

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

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.

If you just remove the 2 or 3 remainig swing labels and buttons which are no longer needed, we can merge it

@Super-Tang
Copy link
Contributor Author

I am sorry for forgetting this, done it. :) @Siedlerchr

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.

Thanks for your work on this!

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