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

Add tooltips for all entry types for #6074 #6203

Merged
merged 17 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
127 changes: 127 additions & 0 deletions src/main/java/org/jabref/gui/EntryTypeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.control.TitledPane;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.FlowPane;
import javafx.stage.Screen;

import org.jabref.Globals;
import org.jabref.gui.util.BaseDialog;
Expand All @@ -26,6 +28,8 @@
import org.jabref.model.entry.types.BibtexEntryTypeDefinitions;
import org.jabref.model.entry.types.EntryType;
import org.jabref.model.entry.types.IEEETranEntryTypeDefinitions;
import org.jabref.model.entry.types.StandardEntryType;
import org.jabref.model.strings.StringUtil;
import org.jabref.preferences.JabRefPreferences;

import com.airhacks.afterburner.views.ViewLoader;
Expand Down Expand Up @@ -92,6 +96,16 @@ private void addEntriesToPane(FlowPane pane, Collection<? extends BibEntryType>
entryButton.setUserData(entryType);
entryButton.setOnAction(event -> setEntryTypeForReturnAndClose(Optional.of(entryType)));
pane.getChildren().add(entryButton);

String description = getDescription(entryType);
if (StringUtil.isNotBlank(description)) {
Screen currentScreen = Screen.getPrimary();
double maxWidth = currentScreen.getBounds().getWidth();
Tooltip tooltip = new Tooltip(description);
tooltip.setMaxWidth((maxWidth * 2) / 3);
tooltip.setWrapText(true);
entryButton.setTooltip(tooltip);
}
}
}

Expand Down Expand Up @@ -168,4 +182,117 @@ private void setEntryTypeForReturnAndClose(Optional<BibEntryType> entryType) {
viewModel.stopFetching();
this.close();
}

//The description is coming from biblatex manual chapter 2
//Biblatex documentation is favored over the bibtex,
//since bibtex is a subset of biblatex and biblatex is better documented.
public String getDescription(BibEntryType selectedType) {
Copy link
Contributor

@systemoperator systemoperator Apr 7, 2020

Choose a reason for hiding this comment

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

You could e.g. declare this method static, then you can access it in the other class as well. (Or you could create some helper class with this static method, or probably find some different location for it.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@systemoperator I have implemented your first suggestion! Please let me know what you think!

EntryType entryType = selectedType.getType();
if (entryType instanceof StandardEntryType entry) {
switch (entry) {
tobiasdiez marked this conversation as resolved.
Show resolved Hide resolved
case Article -> {
return Localization.lang("An article in a journal, magazine, newspaper, or other periodical which forms a self-contained unit with its own title.");
}
case Book -> {
return Localization.lang("A single-volume book with one or more authors where the authors share credit for the work as a whole.");
}
case Booklet -> {
return Localization.lang("A book-like work without a formal publisher or sponsoring institution.");
}
case Collection -> {
return Localization.lang("A single-volume collection with multiple, self-contained contributions by distinct authors which have their own title. The work as a whole has no overall author but it will usually have an editor.");
}
case Conference -> {
return Localization.lang("A legacy alias for \"InProceedings\".");
}
case InBook -> {
return Localization.lang("A part of a book which forms a self-contained unit with its own title.");
}
case InCollection -> {
return Localization.lang("A contribution to a collection which forms a self-contained unit with a distinct author and title.");
}
case InProceedings -> {
return Localization.lang("An article in a conference proceedings.");
}
case Manual -> {
return Localization.lang("Technical or other documentation, not necessarily in printed form.");
}
case MastersThesis -> {
return Localization.lang("Similar to \"Thesis\" except that the type field is optional and defaults to the localised term Master's thesis.");
}
case Misc -> {
return Localization.lang("A fallback type for entries which do not fit into any other category.");
}
case PhdThesis -> {
return Localization.lang("Similar to \"Thesis\" except that the type field is optional and defaults to the localised term PhD thesis.");
}
case Proceedings -> {
return Localization.lang("A single-volume conference proceedings. This type is very similar to \"Collection\".");
}
case TechReport -> {
return Localization.lang("Similar to \"Report\" except that the type field is optional and defaults to the localised term technical report.");
}
case Unpublished -> {
return Localization.lang("A work with an author and a title which has not been formally published, such as a manuscript or the script of a talk.");
}
case BookInBook -> {
return Localization.lang("This type is similar to \"InBook\" but intended for works originally published as a stand-alone book.");
}
case InReference -> {
return Localization.lang("An article in a work of reference. This is a more specific variant of the generic \"InCollection\" entry type.");
}
case MvBook -> {
return Localization.lang("A multi-volume \"Book\".");
}
case MvCollection -> {
return Localization.lang("A multi-volume \"Collection\".");
}
case MvProceedings -> {
return Localization.lang("A multi-volume \"Proceedings\" entry.");
}
case MvReference -> {
return Localization.lang("A multi-volume \"Reference\" entry. The standard styles will treat this entry type as an alias for \"MvCollection\".");
}
case Online -> {
return Localization.lang("This entry type is intended for sources such as web sites which are intrinsically online resources.");
}
case Reference -> {
return Localization.lang("A single-volume work of reference such as an encyclopedia or a dictionary.");
}
case Report -> {
return Localization.lang("A technical report, research report, or white paper published by a university or some other institution.");
}
case Set -> {
return Localization.lang("An entry set is a group of entries which are cited as a single reference and listed as a single item in the bibliography.");
}
case SuppBook -> {
return Localization.lang("Supplemental material in a \"Book\". This type is provided for elements such as prefaces, introductions, forewords, afterwords, etc. which often have a generic title only.");
}
case SuppCollection -> {
return Localization.lang("Supplemental material in a \"Collection\".");
}
case SuppPeriodical -> {
return Localization.lang("Supplemental material in a \"Periodical\". This type may be useful when referring to items such as regular columns, obituaries, letters to the editor, etc. which only have a generic title.");
}
case Thesis -> {
return Localization.lang("A thesis written for an educational institution to satisfy the requirements for a degree.");
}
case WWW -> {
return Localization.lang("An alias for \"Online\", provided for jurabib compatibility.");
}
case Software -> {
return Localization.lang("Computer software. The standard styles will treat this entry type as an alias for \"Misc\".");
}
case DATESET -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Siedlerchr There is a typo in DATESET, it should be called DATASET or even more preferrably Dataset, right?

Copy link
Member

Choose a reason for hiding this comment

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

@systemoperator Yes, that should be Dataset.

return Localization.lang("A data set or a similar collection of (mostly) raw data.");
tobiasdiez marked this conversation as resolved.
Show resolved Hide resolved
}
default -> {
return "";
}
}
} else {
return "";
tobiasdiez marked this conversation as resolved.
Show resolved Hide resolved
}
}

}
33 changes: 33 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2169,3 +2169,36 @@ Year\ of\ publication.=Year of publication.

Remove\ formatter\ for\ %0=Remove formatter for %0
Remove\ formatter\ '%0'=Remove formatter '%0'

An\ article\ in\ a\ journal,\ magazine,\ newspaper,\ or\ other\ periodical\ which\ forms\ a\ self-contained\ unit\ with\ its\ own\ title.=An article in a journal, magazine, newspaper, or other periodical which forms aself-contained unit with its own title.
A\ single-volume\ book\ with\ one\ or\ more\ authors\ where\ the\ authors\ share\ credit\ for\ the\ work\ as\ a\ whole.=A single-volume book with one or more authors where the authors share credit for the work as a whole.
A\ book-like\ work\ without\ a\ formal\ publisher\ or\ sponsoring\ institution.=A book-like work without a formal publisher or sponsoring institution.
A\ single-volume\ collection\ with\ multiple,\ self-contained\ contributions\ by\ distinct\ authors\ which\ have\ their\ own\ title.\ The\ work\ as\ a\ whole\ has\ no\ overall\ author\ but\ it\ will\ usually\ have\ an\ editor.=A single-volume collection with multiple, self-contained contributions by distinct authors which have their own title. The work as a whole has no overall author but it will usually have an editor.
A\ legacy\ alias\ for\ "InProceedings".=A legacy alias for "InProceedings".
A\ part\ of\ a\ book\ which\ forms\ a\ self-contained\ unit\ with\ its\ own\ title.=A part of a book which forms a self-contained unit with its own title.
A\ contribution\ to\ a\ collection\ which\ forms\ a\ self-contained\ unit\ with\ a\ distinct\ author\ and\ title.=A contribution to a collection which forms a self-contained unit with a distinct author and title.
An\ article\ in\ a\ conference\ proceedings.=An article in a conference proceedings.
Technical\ or\ other\ documentation,\ not\ necessarily\ in\ printed\ form.=Technical or other documentation, not necessarily in printed form.
Similar\ to\ "Thesis"\ except\ that\ the\ type\ field\ is\ optional\ and\ defaults\ to\ the\ localised\ term\ Master's\ thesis.=Similar to "Thesis" except that the type field is optional and defaults to the localised term Master's thesis.
A\ fallback\ type\ for\ entries\ which\ do\ not\ fit\ into\ any\ other\ category.=A fallback type for entries which do not fit into any other category.
Similar\ to\ "Thesis"\ except\ that\ the\ type\ field\ is\ optional\ and\ defaults\ to\ the\ localised\ term\ PhD\ thesis.=Similar to "Thesis" except that the type field is optional and defaults to the localised term PhD thesis.
A\ single-volume\ conference\ proceedings.\ This\ type\ is\ very\ similar\ to\ "Collection".=A single-volume conference proceedings. This type is very similar to "Collection".
Similar\ to\ "Report"\ except\ that\ the\ type\ field\ is\ optional\ and\ defaults\ to\ the\ localised\ term\ technical\ report.=Similar to "Report" except that the type field is optional and defaults to the localised term technical report.
A\ work\ with\ an\ author\ and\ a\ title\ which\ has\ not\ been\ formally\ published,\ such\ as\ a\ manuscript\ or\ the\ script\ of\ a\ talk.=A work with an author and a title which has not been formally published, such as a manuscript or the script of a talk.
This\ type\ is\ similar\ to\ "InBook"\ but\ intended\ for\ works\ originally\ published\ as\ a\ stand-alone\ book.=This type is similar to "InBook" but intended for works originally published as a stand-alone book.
An\ article\ in\ a\ work\ of\ reference.\ This\ is\ a\ more\ specific\ variant\ of\ the\ generic\ "InCollection"\ entry\ type.=An article in a work of reference. This is a more specific variant of the generic "InCollection" entry type.
A\ multi-volume\ "Book".=A multi-volume "Book".
A\ multi-volume\ "Collection".=A multi-volume "Collection".
A\ multi-volume\ "Proceedings"\ entry.=A multi-volume "Proceedings" entry.
A\ multi-volume\ "Reference"\ entry.\ The\ standard\ styles\ will\ treat\ this\ entry\ type\ as\ an\ alias\ for\ "MvCollection".=A multi-volume "Reference" entry. The standard styles will treat this entry type as an alias for "MvCollection".
This\ entry\ type\ is\ intended\ for\ sources\ such\ as\ web\ sites\ which\ are\ intrinsically\ online\ resources.=This entry type is intended for sources such as web sites which are intrinsically online resources.
A\ single-volume\ work\ of\ reference\ such\ as\ an\ encyclopedia\ or\ a\ dictionary.=A single-volume work of reference such as an encyclopedia or a dictionary.
A\ technical\ report,\ research\ report,\ or\ white\ paper\ published\ by\ a\ university\ or\ some\ other\ institution.=A technical report, research report, or white paper published by a university or some other institution.
An\ entry\ set\ is\ a\ group\ of\ entries\ which\ are\ cited\ as\ a\ single\ reference\ and\ listed\ as\ a\ single\ item\ in\ the\ bibliography.=An entry set is a group of entries which are cited as a single reference and listed as a single item in the bibliography.
Supplemental\ material\ in\ a\ "Book".\ This\ type\ is\ provided\ for\ elements\ such\ as\ prefaces,\ introductions,\ forewords,\ afterwords,\ etc.\ which\ often\ have\ a\ generic\ title\ only.=Supplemental material in a "Book". This type is provided for elements such as prefaces, introductions, forewords, afterwords, etc. which often have a generic title only.
Supplemental\ material\ in\ a\ "Collection".=Supplemental material in a "Collection".
Supplemental\ material\ in\ a\ "Periodical".\ This\ type\ may\ be\ useful\ when\ referring\ to\ items\ such\ as\ regular\ columns,\ obituaries,\ letters\ to\ the\ editor,\ etc.\ which\ only\ have\ a\ generic\ title.=Supplemental material in a "Periodical". This type may be useful when referring to items such as regular columns, obituaries, letters to the editor, etc. which only have a generic title.
A\ thesis\ written\ for\ an\ educational\ institution\ to\ satisfy\ the\ requirements\ for\ a\ degree.=A thesis written for an educational institution to satisfy the requirements for a degree.
An\ alias\ for\ "Online",\ provided\ for\ jurabib\ compatibility.=An alias for "Online", provided for jurabib compatibility.
Computer\ software.\ The\ standard\ styles\ will\ treat\ this\ entry\ type\ as\ an\ alias\ for\ "Misc".=Computer software. The standard styles will treat this entry type as an alias for "Misc".
A\ data\ set\ or\ a\ similar\ collection\ of\ (mostly)\ raw\ data.=A data set or a similar collection of (mostly) raw data.