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

Tooltips for entry editor fields #6046

Merged
merged 18 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/FieldNameLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;

import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.InternalField;
import org.jabref.model.entry.field.StandardField;

public class FieldNameLabel extends Label {

Expand All @@ -14,5 +18,39 @@ public FieldNameLabel(Field field) {
setPadding(new Insets(4, 0, 0, 0));
setAlignment(Pos.CENTER);
setPrefHeight(Double.POSITIVE_INFINITY);
setTip(field);
}

public void setTip(Field field) {
Tooltip tip = new Tooltip();
if (field.isStandardField()) {
StandardField standardField = (StandardField) field;
switch (standardField) {
case AUTHOR:
tip.setText(Localization.lang("The name(s) of the author(s), in the format described in the LaTeX book. Remember, all names are separated with the and keyword, and not commas."));
Copy link
Contributor

@systemoperator systemoperator Mar 6, 2020

Choose a reason for hiding this comment

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

I would not refer to an external document (e.g. "described in the LaTeX book"), which is not properly accessible. In my opinion, more (and local) information is better than the need of looking it up somewhere else. I see self-contained information where one needs it as the key. (If more information gets added to the tooltips, maybe the information could be structured in sections, split with new lines.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I would set quotation marks as well, when some specific syntax is addressed:
E.g. change are separated with the and keyword to are separated with the "and" keyword

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 would not refer to an external document (e.g. "described in the LaTeX book"), which is not properly accessible. In my opinion, more (and local) information is better than the need of looking it up somewhere else. I see self-contained information where one needs it as the key. (If more information gets added to the tooltips, maybe the information could be structured in sections, split with new lines.)

Yes, thank you for your comment. I have the exact same feeling for these tips, I think that the context for each tip could be improved. I read those official documents, but I don't know how to summarize it properly.

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 would set quotation marks as well, when some specific syntax is addressed:
E.g. change are separated with the and keyword to are separated with the "and" keyword

This is better. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, thank you for your comment. I have the exact same feeling for these tips, I think that the context for each tip could be improved. I read those official documents, but I don't know how to summarize it properly.

I agree, this is not an easy task. Let's collaboratively see, how they can be improved. :)

Copy link
Member

Choose a reason for hiding this comment

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

Can't we use the texts from our help page? --> https://docs.jabref.org/fields#standard-bibtex-fields

In case these text could be improved, feel free to submit a pull request.

I would say, the text for author can be improved ^^.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, another nice resource for additional information! :)

break;
case JOURNAL:
tip.setText(Localization.lang("Journal name. Abbrevations may be used."));
break;
case TITLE:
tip.setText(Localization.lang("The work's title"));
break;
case YEAR:
tip.setText(Localization.lang("The year of publication or, for an unpublished work, the year it was written. Generally it should consist of four numerals, such as 1984, although the standard styles can handle any year whose last four nonpunctuation characters are numerals, such as '(about 1984)'."));
break;
default:
return;
}
} else if (field instanceof InternalField) {
InternalField internalField = (InternalField) field;
switch (internalField) {
case KEY_FIELD:
tip.setText(Localization.lang("[First author'last name][Article year], e.g. Jones2020"));
break;
default:
return;
}
}
this.setTooltip(tip);
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently, tooltips are only added for five fields (author, journal, title, year and key). It would be really great, if the other fields (e.g. in the other tabs of the entry editor) would get tooltips as well. Examples: date, editor, DOI, pages, number, language, volume, urldate, ...

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, what I made is just a start.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is really good to hear! Thank you for your effort! :)

}
}
7 changes: 7 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2117,3 +2117,10 @@ Entry\ type\ cannot\ be\ empty.\ Please\ enter\ a\ name.=Entry type cannot be em
Field\ cannot\ be\ empty.\ Please\ enter\ a\ name.=Field cannot be empty. Please enter a name.
Shared\ database=Shared database
Lookup=Lookup

The\ name(s)\ of\ the\ author(s),\ in\ the\ format\ described\ in\ the\ LaTeX\ book.\ Remember,\ all\ names\ are\ separated\ with\ the\ and\ keyword,\ and\ not\ commas.=The name(s) of the author(s), in the format described in the LaTeX book. Remember, all names are separated with the and keyword, and not commas.
Journal\ name.\ Abbrevations\ may\ be\ used.=Journal name. Abbrevations may be used.
[First\ author'last\ name][Article\ year],\ e.g.\ Jones2020=[First author'last name][Article year], e.g. Jones2020
The\ work's\ title=The work's title
The\ year\ of\ publication\ or,\ for\ an\ unpublished\ work,\ the\ year\ it\ was\ written.\ Generally\ it\ should\ consist\ of\ four\ numerals,\ such\ as\ 1984,\ although\ the\ standard\ styles\ can\ handle\ any\ year\ whose\ last\ four\ nonpunctuation\ characters\ are\ numerals,\ such\ as\ '(about\ 1984)'.=The year of publication or, for an unpublished work, the year it was written. Generally it should consist of four numerals, such as 1984, although the standard styles can handle any year whose last four nonpunctuation characters are numerals, such as '(about 1984)'.