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

Journal abbreviations dialog ported to JavaFX #1526

Merged
merged 35 commits into from
Sep 1, 2016

Conversation

boceckts
Copy link
Contributor

@boceckts boceckts commented Jun 29, 2016

I tried to extract the logic in a test driven approach to completely separate ui and ui-model and to have a high code test coverage. The design of the dialog was made after the ui-model was finisehd and is close to what was specified in #1396.

  • Change in CHANGELOG.md described
  • Tests created for changes
  • Screenshots added (for bigger UI changes)

listview
listvieweditname
listviewbuiltinlist


@Override
protected void updateItem(String s, boolean b) {
super.updateItem(s, b);
Copy link
Member

Choose a reason for hiding this comment

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

Try using a lambda for the callback, makes the code more readable:
http://stackoverflow.com/questions/23978676/convert-callback-into-java-8-lambda-expression

Please use more speaking variable names for s and b, for example like here:
http://code.makery.ch/blog/javafx-8-tableview-cell-renderer/

@Siedlerchr
Copy link
Member

Looks good 👍 !
Instead of the "+" Button would suggest simply the text "Add".
What is the purpose of the "-" Icon? Deletion? If yes, a kind of trash can symbol would be more suitable

public AbbreviationsFile(File file) {
super(file.getAbsolutePath());
public AbbreviationsFile(String filePath) {
path = FileSystems.getDefault().getPath(filePath.replaceAll("\\\\", "/"));
Copy link
Member

Choose a reason for hiding this comment

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

You could simply use Paths.get(filePath) this is a shorthand for the FileSystems.getDefault...

What are you trying to do here? I do not understand the Replace stuff... In case you are trying to escape sth like Slashes, that is absolutely not necessary, as the Path methods are able to handle both relative and absolute.
Have a look here for some examples
https://docs.oracle.com/javase/tutorial/essential/io/pathOps.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea was indeed to escape the backslashes for windows systems...but thanks for the tip

@boceckts
Copy link
Contributor Author

I updated the description and added screenshots for the latest commit. Is it really the best idea to add the "+" to the end of the list of journal abbrevaitions? This would mean the user always has to scroll to the bottom to add more journal abbreviations to the list. In my opinion this is less ideal than having a button that is always visible and in the same place. Any thoughts?


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add for all classes, that you've added, a short comment?

@tobiasdiez
Copy link
Member

Personally, I prefer inline editing for lists/tables with only a handful of columns. See for example http://designingwebinterfaces.com/ultimate-guide-to-table-ui-patterns. The very first row could be an "insert row", i.e. it shows (in italic) "Create new abbreviation" and when you click you just have an empty textfield to insert the new abbreviation.

Other from that, I really like how the dialog looks. Maybe change the close/remove icon? Btw what is the purpose of this "JabRef Lists" button at the bottom?

@boceckts
Copy link
Contributor Author

@tobiasdiez so when clicking on the edit icon on the right the column should be editable?
The "JabRef Lists" button shows the jabref built in journal abbreviations which are not modifyable. In the swing version there is a "view" button to show these abbreviations in a separate window.

@tobiasdiez
Copy link
Member

@boceckts Yes exactly, clicking edit (and I would also support double clicking) makes the row editable. Mhh on second thought, one might not even need the edit button but show it directly in the cell upon mouse hover and a single click then makes the cell editable. Decide based on what is easier to implement.

For the "JabRef List" button, you also have a JabRef built in list in the drop-down. What is the difference here?

@boceckts
Copy link
Contributor Author

@tobiasdiez The built in lists in the drop down will only appear when the toggle button is activated

@tobiasdiez
Copy link
Member

Is there a need to hide it from the drop-down list? If not, then I would just remove the toggle button.

@boceckts
Copy link
Contributor Author

@tobiasdiez I just thought it's nice to give the user the option to only display their custom lists

@koppor
Copy link
Member

koppor commented Jul 13, 2016

@boceckts Please remove "JabRef lists" button. 🌻

@codecov-io
Copy link

codecov-io commented Jul 18, 2016

Current coverage is 10.79% (diff: 4.20%)

Merging #1526 into javafx will increase coverage by 0.02%

@@             javafx      #1526   diff @@
==========================================
  Files           705        707     +2   
  Lines         46412      46379    -33   
  Methods           0          0          
  Messages          0          0          
  Branches       7637       7630     -7   
==========================================
+ Hits           5002       5008     +6   
+ Misses        40963      40921    -42   
- Partials        447        450     +3   

Powered by Codecov. Last update bc6f0c9...0524ca4

@Override
protected void updateItem(Boolean isPseudoAbbreviation, boolean isEmpty) {
super.updateItem(isPseudoAbbreviation, isEmpty);
if (isPseudoAbbreviation != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this really needed ? When can this be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it is necessary because we have to call setGraphic(null) if the item to update is null. Otherwise we get some weird graphic bugs when switching from a custom list to a built in list since the graphics don't get reset.

journalabb

.observableArrayList(Globals.journalAbbreviationLoader.getBuiltInAbbreviations());
ObservableList<AbbreviationViewModel> actual = viewModel.abbreviationsProperty().get();
ObservableList<Abbreviation> actualAbbreviations = FXCollections.observableArrayList();
actual.forEach(abbViewModel -> actualAbbreviations.add(abbViewModel.getAbbreviationObject()));
Copy link
Member

Choose a reason for hiding this comment

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

use map function, viewModel.getAbbrevations().stream().map(getAbbrevaitonObject).collect()

@tobiasdiez
Copy link
Member

I just made some final remarks. After these are fixed, this PR can be merged in my opinion. @koppor pls do the final review & merge, thanks.

@boceckts (and the all others who worked on this PR): good job! I really like your code, especially that you wrote tests to implement the logic! One can see that you learned a lot in the last few weeks.

@tobiasdiez tobiasdiez assigned koppor and unassigned tobiasdiez Aug 14, 2016
@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 15, 2016
- foreach converted to stream
- return path as optional
- updated language
- test class completely refactored
the view model now decides whether a file or abbreviation can be edited
or removed and provides boolean properties for easy binding with the ui
components
@boceckts
Copy link
Contributor Author

I think I now addressed all of your comments.

@boceckts boceckts added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 31, 2016
@tobiasdiez
Copy link
Member

I'll merge this now, since it looks good to me and all the javafx code will be finally reviewed anyway.

@tobiasdiez tobiasdiez merged commit 94f3d13 into JabRef:javafx Sep 1, 2016
@boceckts boceckts deleted the JournalAbbreviationsFX branch September 5, 2016 10:00
@koppor
Copy link
Member

koppor commented Sep 7, 2016

Does not work in javafx. @boceckts Can you please check?

Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Cannot load net.sf.jabref.gui.journals.managejournalabbreviations
        at com.airhacks.afterburner.views.FXMLView.loadSynchronously(FXMLView.java:94)
        at com.airhacks.afterburner.views.FXMLView.initializeFXMLLoader(FXMLView.java:101)
        at com.airhacks.afterburner.views.FXMLView.getView(FXMLView.java:113)
        at net.sf.jabref.gui.journals.ManageJournalAbbreviationsView.showAndWait(ManageJournalAbbreviationsView.java:201)
        at net.sf.jabref.gui.journals.ManageJournalsAction.lambda$actionPerformed$0(ManageJournalsAction.java:21)
        at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
        at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException: No resources specified.
/C:/git-repositories/jabref/jabref/build/resources/main/net/sf/jabref/gui/journals/managejournalabbreviations.fxml:22

        at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597)

@boceckts
Copy link
Contributor Author

boceckts commented Sep 7, 2016

@koppor I will look into it, did this happen after the javafx branch has been updated?

@boceckts
Copy link
Contributor Author

boceckts commented Sep 7, 2016

@koppor Ok so I tracked the issue and came to the conclusion that the this pr #1918 causes the exception. As described in the pr's description @tobiasdiez had to out comment the line bundle = Localization.getMessages(); since otherwise the localization tests would fail. After adding it back it works for me again.

@tobiasdiez
Copy link
Member

@boceckts do the localization tests also work after readding the bundle = ... line?

@boceckts
Copy link
Contributor Author

boceckts commented Sep 7, 2016

No but it gives me the same errors when the line is out commented, I'm not sure if this statement is causing the failing tests..

@koppor
Copy link
Member

koppor commented Sep 7, 2016

Yes, this happens with the current javafx branch (merge of master). I did not check the state before the merge. My gut feeling is that the merge broke it. But I'm not sure.

I is not about failing tests, it is about that "Options -> Manage Journal Abbreviations" is a noop.

@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Sep 7, 2016
@boceckts
Copy link
Contributor Author

boceckts commented Sep 7, 2016

Yes it's about opening the dialog. But still, re-adding the line as described by me two comments ago fixes the issue for me.

@tobiasdiez
Copy link
Member

Reenabled in #1935.

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.

7 participants