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

Fixes #6705 , added icon for multiple identifiers #6809

Merged
merged 5 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions 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 All @@ -20,6 +21,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- We fixed a linked identifier icon inconsistency. [#6705](https://github.com/JabRef/jabref/issues/6705)
- We fixed the wrong behavior that font size changes are not reflected in dialogs. [#6039](https://github.com/JabRef/jabref/issues/6039)

### Removed
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),
LINK(MaterialDesignIcon.LINK_VARIANT_OFF),
LINK_VARIANT(MaterialDesignIcon.LINK_VARIANT);

private final JabRefIcon icon;

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 All @@ -21,7 +22,6 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.StandardField;

/**
* A clickable icons column for DOIs, URLs, URIs and EPrints.
Expand Down Expand Up @@ -52,14 +52,28 @@ public LinkedIdentifierColumn(MainTableColumnModel model,
.withGraphic(this::createIdentifierGraphic)
.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;
if (values.size() > 1) {
return IconTheme.JabRefIcons.LINK_VARIANT.getGraphicNode();
} else if (values.size() == 1) {
return IconTheme.JabRefIcons.LINK.getGraphicNode();
} else {
return cellFactory.getTableIcon(StandardField.URL);
return null;
}
}

Expand All @@ -72,6 +86,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