-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Changes from 6 commits
4172fcd
830903c
014ef0c
073a60c
a546c32
dff1c16
fe14e54
64f6a54
4a441d9
a3050cd
760cc05
d2df6f7
2ea22fb
02d4022
60d7697
224471e
7b21c7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -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) { | ||
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 -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Siedlerchr There is a typo in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @systemoperator Yes, that should be |
||
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
|
||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,12 @@ | |
|
||
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.undo.CountingUndoManager; | ||
|
@@ -23,6 +26,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; | ||
|
||
public class ChangeEntryTypeMenu { | ||
|
||
|
@@ -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 = getDescription(type); | ||
if (StringUtil.isNotBlank(description)) { | ||
Tooltip tooltip = new Tooltip(description); | ||
Tooltip.install(menuItem.getContent(), tooltip); | ||
} | ||
return menuItem; | ||
} | ||
|
||
|
@@ -92,4 +102,116 @@ 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); | ||
} | ||
|
||
//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 entryType) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please avoid duplicating the method |
||
if (entryType instanceof StandardEntryType entry) { | ||
switch (entry) { | ||
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 -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be cool if could do a global renaming (refactor/rename) to change the type to Dataset There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Siedlerchr do you want it to be Dataset or DataSet? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dataset There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Siedlerchr what do you think about my latest commit? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM now! I just merged in master and resolved the conflicts. When all relevant tests pass we can merge. |
||
return Localization.lang("A data set or a similar collection of (mostly) raw data."); | ||
} | ||
default -> { | ||
return ""; | ||
} | ||
} | ||
} else { | ||
return ""; | ||
} | ||
} | ||
|
||
} |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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!