-
-
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
Right click menus should allow copying doi url #2040
Conversation
c4d4c19
to
444b5ca
Compare
- Added to the special fields right click menu in the main table - Added to the DOI field in the entry editor
444b5ca
to
63b5914
Compare
# Conflicts: # CHANGELOG.md
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.
LGTM 👍
I only have a very small remark regarding the usage of the DOI class.
public void actionPerformed(ActionEvent e) { | ||
identifier = component == null ? identifier : component.getText(); | ||
|
||
Optional<DOI> doiOptional = DOI.build(identifier); |
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 can be simplified a bit:
Optional<String> url = DOI.build(identifier).map(DOI::getURIAsASCIIString)
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.
Done
Thanks! |
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
identifier = component == null ? identifier : component.getText(); |
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 split that in an if/else, because that ternary operator and the assignment in one statement make it hard to understand for non java exports, especially if you don't know about the operator precedence.
@@ -407,6 +408,9 @@ private void showIconRightClickMenu(MouseEvent e, int row, MainTableColumn colum | |||
} | |||
menu.add(new ExternalFileMenuItem(panel.frame(), entry, content.get(), content.get(), icon, | |||
panel.getBibDatabaseContext(), field)); | |||
if (field == FieldName.DOI) { |
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.
Beware! Although FieldName.XXX looks like an enum, is is String constant, so I think you should better use equals
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.
Always tricked by this equals vs == in Java....when do we finally port JabRef to the nice C# world 😄
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.
Blame Java for no operator overloading...
boolean isDOIField = field.getFieldName().equals(FieldName.DOI); | ||
doiMenuItem.setVisible(isDOIField); | ||
boolean isDoiFieldEmpty = field.getText().isEmpty(); | ||
doiMenuItem.setEnabled(!isDoiFieldEmpty); |
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 consider splitting that in an if/else, too, e.g. simple: if(! field.getText.IsEmpty) ...
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 find his version more readable than if/else 😸
@tobiasdiez A bit too fast. At least the equals thing should be fixed. |
@Siedlerchr can I still push to this branch or should I create a new branch + pull request? |
Hm, not sure. Better create a new one based on master and then fix the things and we merge it in |
I fixed it in ffa3299. |
@tobiasdiez thank you. |
* Allow copying DOI url - Added to the special fields right click menu in the main table - Added to the DOI field in the entry editor * Refactored getting the uri
Right clicking on the doi field in the main table or the entry editor shows a sub menu where the user can copy the url of the doi to the clipboard. Refs #490
Right click menu when doi field isn't present
Right click menu in entry editor when doi field is not empty
Right click menu in entry editor when doi field is empty