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 4 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
125 changes: 125 additions & 0 deletions src/main/java/org/jabref/gui/EntryTypeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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 org.jabref.Globals;
Expand All @@ -26,6 +27,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 +95,13 @@ 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)) {
Tooltip tooltip = new Tooltip();
Copy link
Contributor

@systemoperator systemoperator Apr 3, 2020

Choose a reason for hiding this comment

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

I would recommend refactoring the tooltip creation to the following, which prevents display issues, if some text exceeds the screen width 😃:

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);

tooltip.setText(description);
entryButton.setTooltip(tooltip);
}
}
}

Expand Down Expand Up @@ -168,4 +178,119 @@ 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();
try {
StandardEntryType entry = (StandardEntryType) entryType;
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.");
Copy link
Contributor

@systemoperator systemoperator Apr 3, 2020

Choose a reason for hiding this comment

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

@dimitra-karadima Minor suggestion: e.g. inproceedings could be renamed to InProceedings. Reasoning: For consistency reasons, entry types which are documented with a preceding @ (like @proceedings) in the descriptional text for an entry type could be written in the same way, as they are selectable in the UI of JabRef (e.g. Conference: @inproceedings -> InProceedings; MvBook: @book -> Book; MasterThesis: @thesis -> Thesis; ...)

Copy link
Contributor

@systemoperator systemoperator Apr 3, 2020

Choose a reason for hiding this comment

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

@dimitra-karadima For even better distinction between common text, you could also encapsulate those entry type phrases in ticks (e.g. 'InProceedings') or quotes (e.g. "InProceedings"), which makes it even more understandable. In the biblatex documentation this is done on the one hand with the @ symbol and formatting it as some code, but encapsulation would be really nice in this case. Then it is easy to distinguish e.g. the common text term theses from an the entry type 'Thesis' (which should reference to @thesis).

Copy link
Member

Choose a reason for hiding this comment

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

mvBook stand for multi volume book

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 So what do you suggest better? Ticks or quotes over the preceding @ ?

Copy link
Contributor

@systemoperator systemoperator Apr 3, 2020

Choose a reason for hiding this comment

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

@dimitra-karadima Please use quotes, as they are used for describing the entry fields of an entry type as well (see: #6239).

}
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 "";
}
}
} catch (Exception e) {
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.