Skip to content

Commit

Permalink
Fixes 6705 , added icon for multiple identifiers
Browse files Browse the repository at this point in the history
and modified behaviour to open eprint when clicked without opening menu

Added change log

Changed name for enum

Fixed checkstyle errors
  • Loading branch information
hemantgs committed Aug 30, 2020
1 parent 5540b93 commit f8e2ed8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Changelog

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

- We fixed linked identifier icon inconsistency[#6705](https://github.com/JabRef/jabref/issues/6705)
### Removed

- We removed the option of the "enforce legal key". [#6295](https://github.com/JabRef/jabref/issues/6295)
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/gui/icon/IconTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ public enum JabRefIcons implements JabRefIcon {
REMOVE_ABBREVIATION(MaterialDesignIcon.PLAYLIST_MINUS),
NEW_ENTRY_FROM_PLAIN_TEXT(MaterialDesignIcon.PLUS_BOX),
REMOTE_DATABASE(MaterialDesignIcon.DATABASE),
HOME(MaterialDesignIcon.HOME);
HOME(MaterialDesignIcon.HOME),
DATABASE(MaterialDesignIcon.DATABASE),
DATABASE_PLUS(MaterialDesignIcon.DATABASE_PLUS);

private final JabRefIcon icon;

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/org/jabref/gui/maintable/CellFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ public CellFactory(ExternalFileTypes externalFileTypes, UndoManager undoManager)
// icon.setToo(Localization.lang("Open") + " PDF");
TABLE_ICONS.put(StandardField.PDF, icon);

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

icon = IconTheme.JabRefIcons.DATABASE_PLUS;
// icon.setToolTipText(Localization.lang("Open") + " URL");
TABLE_ICONS.put(StandardField.URLS, icon);

icon = IconTheme.JabRefIcons.WWW;
// icon.setToolTipText(Localization.lang("Open") + " CiteSeer URL");
TABLE_ICONS.put(new UnknownField("citeseerurl"), icon);
Expand Down Expand Up @@ -94,6 +98,7 @@ public CellFactory(ExternalFileTypes externalFileTypes, UndoManager undoManager)
icon = printedViewModel.getIcon();
// icon.setToolTipText(printedViewModel.getLocalization());
TABLE_ICONS.put(SpecialField.PRINTED, icon);

}

public Node getTableIcon(Field field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.Tooltip;
import javafx.scene.input.MouseButton;

import org.jabref.gui.DialogService;
import org.jabref.gui.desktop.JabRefDesktop;
Expand Down Expand Up @@ -49,17 +50,31 @@ public LinkedIdentifierColumn(MainTableColumnModel model,
this.setResizable(false);
this.setCellValueFactory(cellData -> cellData.getValue().getLinkedIdentifiers());
new ValueTableCellFactory<BibEntryTableViewModel, Map<Field, String>>()
.withGraphic(this::createIdentifierGraphic)
.withGraphic(values -> createIdentifierGraphic(values))
.withTooltip(this::createIdentifierTooltip)
.withMenu(this::createIdentifierMenu)
.withOnMouseClickedEvent((entry, linkedFiles) -> event -> {
if ((event.getButton() == MouseButton.PRIMARY) && (linkedFiles.size() == 1)) {
// Open linked identifier directly only if 1 entry is preset
try {
for (Field field : linkedFiles.keySet()) {
JabRefDesktop.openExternalViewer(database, linkedFiles.get(field), field);
}
} catch (IOException e) {
dialogService.showErrorDialogAndWait(Localization.lang("Unable to open link."), e);
}
}
})
.install(this);
}

private Node createIdentifierGraphic(Map<Field, String> values) {
if (values.isEmpty()) {
return null;
} else {
if (values.size() > 1) {
return cellFactory.getTableIcon(StandardField.URLS);
} else if (values.size() == 1) {
return cellFactory.getTableIcon(StandardField.URL);
} else {
return null;
}
}

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

if (values.size() <= 1) {
return null;
}

values.keySet().forEach(field -> {
MenuItem menuItem = new MenuItem(field.getDisplayName() + ": " +
ControlHelper.truncateString(values.get(field), -1, "...", ControlHelper.EllipsisPosition.CENTER),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public enum StandardField implements Field {
TYPE("type", FieldProperty.TYPE),
URI("uri", "URI"),
URL("url", "URL", FieldProperty.EXTERNAL, FieldProperty.VERBATIM),
URLS("urls", "URLS", FieldProperty.VERBATIM),
URLDATE("urldate", FieldProperty.DATE),
VENUE("venue"),
VERSION("version"),
Expand Down

0 comments on commit f8e2ed8

Please sign in to comment.