-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Conversation
|
||
@Override | ||
protected void updateItem(String s, boolean b) { | ||
super.updateItem(s, b); |
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.
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/
Looks good 👍 ! |
public AbbreviationsFile(File file) { | ||
super(file.getAbsolutePath()); | ||
public AbbreviationsFile(String filePath) { | ||
path = FileSystems.getDefault().getPath(filePath.replaceAll("\\\\", "/")); |
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 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
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 idea was indeed to escape the backslashes for windows systems...but thanks for the tip
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; | ||
|
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.
Could you add for all classes, that you've added, a short comment?
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? |
@tobiasdiez so when clicking on the edit icon on the right the column should be editable? |
@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? |
@tobiasdiez The built in lists in the drop down will only appear when the toggle button is activated |
Is there a need to hide it from the drop-down list? If not, then I would just remove the toggle button. |
@tobiasdiez I just thought it's nice to give the user the option to only display their custom lists |
@boceckts Please remove "JabRef lists" button. 🌻 |
Current coverage is 10.79% (diff: 4.20%)@@ 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
|
@Override | ||
protected void updateItem(Boolean isPseudoAbbreviation, boolean isEmpty) { | ||
super.updateItem(isPseudoAbbreviation, isEmpty); | ||
if (isPseudoAbbreviation != null) { |
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.
is this really needed ? When can this be null?
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.
.observableArrayList(Globals.journalAbbreviationLoader.getBuiltInAbbreviations()); | ||
ObservableList<AbbreviationViewModel> actual = viewModel.abbreviationsProperty().get(); | ||
ObservableList<Abbreviation> actualAbbreviations = FXCollections.observableArrayList(); | ||
actual.forEach(abbViewModel -> actualAbbreviations.add(abbViewModel.getAbbreviationObject())); |
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.
use map function, viewModel.getAbbrevations().stream().map(getAbbrevaitonObject).collect()
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. |
- 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
I think I now addressed all of your comments. |
I'll merge this now, since it looks good to me and all the javafx code will be finally reviewed anyway. |
Does not work in
|
@koppor I will look into it, did this happen after the javafx branch has been updated? |
@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 |
@boceckts do the localization tests also work after readding the |
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.. |
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. |
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. |
Reenabled in #1935. |
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.