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 12 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
39 changes: 39 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,40 @@ 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;
ShikunXiong marked this conversation as resolved.
Show resolved Hide resolved
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."));
ShikunXiong marked this conversation as resolved.
Show resolved Hide resolved
break;
case JOURNAL:
tip.setText(Localization.lang("Journal name. Abbrevations could be used."));
ShikunXiong marked this conversation as resolved.
Show resolved Hide resolved
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) {
ShikunXiong marked this conversation as resolved.
Show resolved Hide resolved
InternalField internalField = (InternalField) field;
switch (internalField) {
case KEY_FIELD:
tip.setText(Localization.lang("[First author'last name][Article year] e.g. Jones2020"));
ShikunXiong marked this conversation as resolved.
Show resolved Hide resolved
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\ could\ be\ used.=Journal name. Abbrevations could 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)'.