Skip to content

Commit 8fda4f7

Browse files
committed
Fixes JabRef#6705 , added icon for multiple identifiers
and modified behaviour to open eprint when clicked without opening menu Added change log Changed name for enum
1 parent 5540b93 commit 8fda4f7

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# Changelog
23

34
All notable changes to this project will be documented in this file.
@@ -108,7 +109,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
108109
- We fixed an issue with the Science Direct fetcher where PDFs could not be downloaded. Fixes [#5860](https://github.com/JabRef/jabref/issues/5860)
109110
- We fixed an issue with the Library of Congress importer.
110111
- We fixed the [link to the external libraries listing](https://github.com/JabRef/jabref/blob/master/external-libraries.md) in the about dialog
111-
112+
- We fixed linked identifier icon inconsistency[#6705](https://github.com/JabRef/jabref/issues/6705)
112113
### Removed
113114

114115
- We removed the option of the "enforce legal key". [#6295](https://github.com/JabRef/jabref/issues/6295)

src/main/java/org/jabref/gui/icon/IconTheme.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ public enum JabRefIcons implements JabRefIcon {
300300
REMOVE_ABBREVIATION(MaterialDesignIcon.PLAYLIST_MINUS),
301301
NEW_ENTRY_FROM_PLAIN_TEXT(MaterialDesignIcon.PLUS_BOX),
302302
REMOTE_DATABASE(MaterialDesignIcon.DATABASE),
303-
HOME(MaterialDesignIcon.HOME);
303+
HOME(MaterialDesignIcon.HOME),
304+
DATABASE(MaterialDesignIcon.DATABASE),
305+
DATABASE_PLUS(MaterialDesignIcon.DATABASE_PLUS);
304306

305307
private final JabRefIcon icon;
306308

src/main/java/org/jabref/gui/maintable/CellFactory.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ public CellFactory(ExternalFileTypes externalFileTypes, UndoManager undoManager)
2727
// icon.setToo(Localization.lang("Open") + " PDF");
2828
TABLE_ICONS.put(StandardField.PDF, icon);
2929

30-
icon = IconTheme.JabRefIcons.WWW;
30+
icon = IconTheme.JabRefIcons.DATABASE;
3131
// icon.setToolTipText(Localization.lang("Open") + " URL");
3232
TABLE_ICONS.put(StandardField.URL, icon);
3333

34+
icon = IconTheme.JabRefIcons.DATABASE_PLUS;
35+
// icon.setToolTipText(Localization.lang("Open") + " URL");
36+
TABLE_ICONS.put(StandardField.URLS, icon);
37+
3438
icon = IconTheme.JabRefIcons.WWW;
3539
// icon.setToolTipText(Localization.lang("Open") + " CiteSeer URL");
3640
TABLE_ICONS.put(new UnknownField("citeseerurl"), icon);
@@ -94,6 +98,7 @@ public CellFactory(ExternalFileTypes externalFileTypes, UndoManager undoManager)
9498
icon = printedViewModel.getIcon();
9599
// icon.setToolTipText(printedViewModel.getLocalization());
96100
TABLE_ICONS.put(SpecialField.PRINTED, icon);
101+
97102
}
98103

99104
public Node getTableIcon(Field field) {

src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java

+23-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import javafx.scene.control.ContextMenu;
88
import javafx.scene.control.MenuItem;
99
import javafx.scene.control.Tooltip;
10+
import javafx.scene.input.MouseButton;
1011

1112
import org.jabref.gui.DialogService;
1213
import org.jabref.gui.desktop.JabRefDesktop;
@@ -49,17 +50,31 @@ public LinkedIdentifierColumn(MainTableColumnModel model,
4950
this.setResizable(false);
5051
this.setCellValueFactory(cellData -> cellData.getValue().getLinkedIdentifiers());
5152
new ValueTableCellFactory<BibEntryTableViewModel, Map<Field, String>>()
52-
.withGraphic(this::createIdentifierGraphic)
53+
.withGraphic(values -> createIdentifierGraphic(values))
5354
.withTooltip(this::createIdentifierTooltip)
5455
.withMenu(this::createIdentifierMenu)
56+
.withOnMouseClickedEvent((entry, linkedFiles) -> event -> {
57+
if ((event.getButton() == MouseButton.PRIMARY) && (linkedFiles.size() == 1)) {
58+
// Open linked identifier directly only if 1 entry is preset
59+
try {
60+
for(Field field:linkedFiles.keySet()){
61+
JabRefDesktop.openExternalViewer(database, linkedFiles.get(field), field);
62+
}
63+
} catch (IOException e) {
64+
dialogService.showErrorDialogAndWait(Localization.lang("Unable to open link."), e);
65+
}
66+
}
67+
})
5568
.install(this);
5669
}
5770

5871
private Node createIdentifierGraphic(Map<Field, String> values) {
59-
if (values.isEmpty()) {
60-
return null;
61-
} else {
72+
if (values.size() > 1) {
73+
return cellFactory.getTableIcon(StandardField.URLS);
74+
} else if (values.size() == 1) {
6275
return cellFactory.getTableIcon(StandardField.URL);
76+
} else {
77+
return null;
6378
}
6479
}
6580

@@ -72,6 +87,10 @@ private String createIdentifierTooltip(Map<Field, String> values) {
7287
private ContextMenu createIdentifierMenu(BibEntryTableViewModel entry, Map<Field, String> values) {
7388
ContextMenu contextMenu = new ContextMenu();
7489

90+
if (values.size() <= 1) {
91+
return null;
92+
}
93+
7594
values.keySet().forEach(field -> {
7695
MenuItem menuItem = new MenuItem(field.getDisplayName() + ": " +
7796
ControlHelper.truncateString(values.get(field), -1, "...", ControlHelper.EllipsisPosition.CENTER),

src/main/java/org/jabref/model/entry/field/StandardField.java

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public enum StandardField implements Field {
123123
TYPE("type", FieldProperty.TYPE),
124124
URI("uri", "URI"),
125125
URL("url", "URL", FieldProperty.EXTERNAL, FieldProperty.VERBATIM),
126+
URLS("urls", "URLS",FieldProperty.VERBATIM),
126127
URLDATE("urldate", FieldProperty.DATE),
127128
VENUE("venue"),
128129
VERSION("version"),

0 commit comments

Comments
 (0)