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 8 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,17 @@ private void addEntriesToPane(FlowPane pane, Collection<? extends BibEntryType>
entryButton.setUserData(entryType);
entryButton.setOnAction(event -> setEntryTypeForReturnAndClose(Optional.of(entryType)));
pane.getChildren().add(entryButton);

EntryType selectedType = entryType.getType();
String description = getDescription(selectedType);
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 +183,116 @@ 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 static String getDescription(EntryType selectedType) {
if (selectedType instanceof StandardEntryType entry) {
dimitra-karadima marked this conversation as resolved.
Show resolved Hide resolved
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 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
}
}

}
13 changes: 12 additions & 1 deletion src/main/java/org/jabref/gui/menus/ChangeEntryTypeMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@

import javafx.collections.ObservableList;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.CustomMenuItem;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.Tooltip;

import org.jabref.Globals;
import org.jabref.gui.EntryTypeView;
import org.jabref.gui.undo.CountingUndoManager;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.gui.undo.UndoableChangeType;
Expand All @@ -23,6 +27,7 @@
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.strings.StringUtil;

public class ChangeEntryTypeMenu {

Expand All @@ -31,13 +36,18 @@ public ChangeEntryTypeMenu() {
}

public static MenuItem createMenuItem(EntryType type, BibEntry entry, UndoManager undoManager) {
MenuItem menuItem = new MenuItem(type.getDisplayName());
CustomMenuItem menuItem = new CustomMenuItem(new Label(type.getDisplayName()));
menuItem.setOnAction(event -> {
NamedCompound compound = new NamedCompound(Localization.lang("Change entry type"));
entry.setType(type)
.ifPresent(change -> compound.addEdit(new UndoableChangeType(change)));
undoManager.addEdit(compound);
});
String description = EntryTypeView.getDescription(type);
if (StringUtil.isNotBlank(description)) {
Tooltip tooltip = new Tooltip(description);
Tooltip.install(menuItem.getContent(), tooltip);
}
return menuItem;
}

Expand Down Expand Up @@ -92,4 +102,5 @@ private void populate(ObservableList<MenuItem> items, Collection<BibEntryType> t
private void populate(Menu menu, Collection<BibEntryType> types, BibEntry entry, UndoManager undoManager) {
populate(menu.getItems(), types, entry, undoManager);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public class BiblatexEntryTypeDefinitions {
.build();

private static final BibEntryType DATASET = new BibEntryTypeBuilder()
.withType(StandardEntryType.DATESET)
.withType(StandardEntryType.Dataset)
.withImportantFields(
StandardField.SUBTITLE, StandardField.TITLEADDON, StandardField.HOWPUBLISHED, StandardField.LOCATION, StandardField.DOI,
StandardField.EPRINT, StandardField.EPRINTCLASS, StandardField.EPRINTTYPE, StandardField.URL, StandardField.URLDATE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public enum StandardEntryType implements EntryType {
Thesis("Thesis"),
WWW("WWW"),
Software("Software"),
DATESET("DataSet");
Dataset("Dataset");



Expand Down
34 changes: 34 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2199,4 +2199,38 @@ User-specific\ relevance\ flag,\ in\ case\ the\ entry\ is\ relevant.=User-specif

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.

Display\ count\ of\ items\ in\ group=Display count of items in group