Skip to content

Commit

Permalink
Fix icon size - the second (JabRef#4993)
Browse files Browse the repository at this point in the history
* Refactor fixing wrong icon size

* Refactor and fix configureIconButton
  • Loading branch information
calixtus authored and Siedlerchr committed May 25, 2019
1 parent d3b193c commit 3ebc59a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
9 changes: 2 additions & 7 deletions src/main/java/org/jabref/gui/actions/ActionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.lang.reflect.Method;
import java.util.Objects;

import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBase;
import javafx.scene.control.CheckMenuItem;
Expand Down Expand Up @@ -148,13 +147,9 @@ public ButtonBase configureIconButton(Action action, Command command, ButtonBase
button.getStyleClass().add("icon-button");

// For some reason the graphic is not set correctly, so let's fix this
// ToDO: Find a way to reuse JabRefIconView
button.graphicProperty().unbind();
action.getIcon().ifPresent(icon -> {
// ToDO: Find a way to reuse JabRefIconView
Node graphicNode = icon.getGraphicNode();
graphicNode.setStyle(String.format("-fx-font-family: %s; -fx-font-size: %s;", icon.fontFamily(), "1em"));
button.setGraphic(graphicNode);
});
action.getIcon().ifPresent(icon -> button.setGraphic(icon.getGraphicNode()));

return button;
}
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/org/jabref/gui/entryeditor/EntryEditor.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@
<Tooltip text="%Change entry type"/>
</tooltip>
</Button>
<Button fx:id="generateCiteKeyButton" styleClass="narrow"/>
<Button styleClass="icon-button,narrow" onAction="#generateCiteKeyButton">
<graphic>
<JabRefIconView glyph="MAKE_KEY"/>
</graphic>
<tooltip>
<Tooltip text="%Generate BibTeX key"/>
</tooltip>
</Button>
<Button fx:id="fetcherButton" styleClass="icon-button,narrow">
<graphic>
<JabRefIconView glyph="REFRESH"/>
Expand Down
16 changes: 6 additions & 10 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.GUIGlobals;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.bibtexkeypattern.GenerateBibtexKeySingleAction;
import org.jabref.gui.entryeditor.fileannotationtab.FileAnnotationTab;
import org.jabref.gui.externalfiles.ExternalFilesEntryLinker;
Expand Down Expand Up @@ -87,7 +85,6 @@ public class EntryEditor extends BorderPane {
@FXML private Button typeChangeButton;
@FXML private Button fetcherButton;
@FXML private Label typeLabel;
@FXML private Button generateCiteKeyButton;

private final EntryEditorPreferences preferences;
private final DialogService dialogService;
Expand Down Expand Up @@ -261,6 +258,12 @@ private void deleteEntry() {
panel.delete(entry);
}

@FXML
void generateCiteKeyButton() {
GenerateBibtexKeySingleAction action = new GenerateBibtexKeySingleAction(getEntry(), databaseContext, dialogService, preferences, undoManager);
action.execute();
}

@FXML
private void navigateToPreviousEntry() {
panel.selectPreviousEntry();
Expand Down Expand Up @@ -387,13 +390,6 @@ private void setupToolBar() {
fetcherMenu.getItems().add(fetcherMenuItem);
}
fetcherButton.setOnMouseClicked(event -> fetcherMenu.show(fetcherButton, Side.RIGHT, 0, 0));

// Configure cite key button
new ActionFactory(preferences.getKeyBindings())
.configureIconButton(
StandardActions.GENERATE_CITE_KEY,
new GenerateBibtexKeySingleAction(getEntry(), databaseContext, dialogService, preferences, undoManager),
generateCiteKeyButton);
}

private void fetchAndMerge(EntryBasedFetcher fetcher) {
Expand Down

0 comments on commit 3ebc59a

Please sign in to comment.