Skip to content

Commit

Permalink
Switch to Ikonli (JabRef#7424)
Browse files Browse the repository at this point in the history
* [WIP] Switch to Ikonliy

Needs some more changes

* Add provider for own icons

* todo fix jabreficonview

* add getIkon method

* try with font family

* Fix loading of icons

* fix groups icon parsing

* convert em to px

* Fix glyphSize property missing getter! Argh!

* checkstyle

* change to search web

* fix checsktyle
remove fontawesomefx update checker rule from gradle

* remove some obsolete getters
try fix gui test

* lazy load icons

* try with ikonli in test modules

* try with add reads :(

* try again with modules

* try again with reading

* add service provider

* fix test by adding missing service provider
  • Loading branch information
Siedlerchr committed Feb 23, 2021
1 parent 2594c28 commit e50566a
Show file tree
Hide file tree
Showing 18 changed files with 388 additions and 286 deletions.
9 changes: 2 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ dependencies {
implementation group: 'jakarta.annotation', name: 'jakarta.annotation-api', version: '1.3.5'

// JavaFX stuff
implementation 'de.jensd:fontawesomefx-commons:11.0'
implementation 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-11'
implementation 'org.kordamp.ikonli:ikonli-javafx:12.2.0'
implementation 'org.kordamp.ikonli:ikonli-materialdesign2-pack:12.2.0'
implementation 'de.saxsys:mvvmfx-validation:1.9.0-SNAPSHOT'
implementation 'de.saxsys:mvvmfx:1.8.0'
implementation 'com.tobiasdiez:easybind:2.1.0'
Expand Down Expand Up @@ -230,11 +230,6 @@ dependencyUpdates.resolutionStrategy = {
selection.reject('Release candidate')
}
}
rules.withModule("de.jensd:fontawesomefx-materialdesignfont") { ComponentSelection selection ->
if (selection.candidate.version ==~ /2.0.26.*/) {
selection.reject('1.7.22-11 is actually newer (strange version system)')
}
}
rules.withModule("org.javamodularity.moduleplugin:org.javamodularity.moduleplugin.gradle.plugin") { ComponentSelection selection ->
if (selection.candidate.version ==~ /1.6.0/) {
selection.reject("Does not work due to bug, see https://github.com/JabRef/jabref/pull/5270")
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@
requires afterburner.fx;
requires com.jfoenix;
requires de.saxsys.mvvmfx;
requires de.jensd.fx.fontawesomefx.commons;
requires de.jensd.fx.fontawesomefx.materialdesignicons;

requires org.kordamp.ikonli.core;
requires org.kordamp.ikonli.javafx;
requires org.kordamp.ikonli.materialdesign2;
uses org.kordamp.ikonli.IkonHandler;
uses org.kordamp.ikonli.IkonProvider;

provides org.kordamp.ikonli.IkonHandler
with org.jabref.gui.icon.JabRefIkonHandler;
provides org.kordamp.ikonli.IkonProvider
with org.jabref.gui.icon.JabrefIconProvider;

requires org.controlsfx.controls;
requires org.fxmisc.richtext;
requires com.tobiasdiez.easybind;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/FXDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public FXDialog(AlertType type, String title) {
public FXDialog(AlertType type, boolean isModal) {
super(type);

setDialogIcon(IconTheme.getJabRefImageFX());
setDialogIcon(IconTheme.getJabRefImage());

Stage dialogWindow = getDialogWindow();
dialogWindow.setOnCloseRequest(evt -> this.close());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/JabRefDialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static String shortenDialogMessage(String dialogMessage) {
@Override
public <T> Optional<T> showChoiceDialogAndWait(String title, String content, String okButtonLabel, T defaultChoice, Collection<T> choices) {
ChoiceDialog<T> choiceDialog = new ChoiceDialog<>(defaultChoice, choices);
((Stage) choiceDialog.getDialogPane().getScene().getWindow()).getIcons().add(IconTheme.getJabRefImageFX());
((Stage) choiceDialog.getDialogPane().getScene().getWindow()).getIcons().add(IconTheme.getJabRefImage());
ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.OK_DONE);
choiceDialog.getDialogPane().getButtonTypes().setAll(ButtonType.CANCEL, okButtonType);
choiceDialog.setHeaderText(title);
Expand Down Expand Up @@ -287,7 +287,7 @@ public <V> void showProgressDialog(String title, String content, Task<V> task) {
progressDialog.setTitle(title);
progressDialog.setContentText(content);
progressDialog.setGraphic(null);
((Stage) progressDialog.getDialogPane().getScene().getWindow()).getIcons().add(IconTheme.getJabRefImageFX());
((Stage) progressDialog.getDialogPane().getScene().getWindow()).getIcons().add(IconTheme.getJabRefImage());
progressDialog.setOnCloseRequest(evt -> task.cancel());
DialogPane dialogPane = progressDialog.getDialogPane();
dialogPane.getButtonTypes().add(ButtonType.CANCEL);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jabref/gui/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public JabRefGUI(Stage mainStage, List<ParserResult> databases, boolean isBlank)
}

private void openWindow(Stage mainStage) {
IconTheme.loadFonts();

LOGGER.debug("Initializing frame");
mainFrame.init();
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jabref.gui.groups;

import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
Expand All @@ -21,7 +20,6 @@
import org.jabref.gui.DragAndDropDataFormats;
import org.jabref.gui.StateManager;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.icon.InternalMaterialDesignIcon;
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.CustomLocalDragboard;
Expand All @@ -41,10 +39,8 @@
import org.jabref.model.strings.StringUtil;
import org.jabref.preferences.PreferencesService;

import com.google.common.base.Enums;
import com.tobiasdiez.easybind.EasyBind;
import com.tobiasdiez.easybind.EasyObservableList;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

public class GroupNodeViewModel {

Expand Down Expand Up @@ -213,9 +209,7 @@ private JabRefIcon createDefaultIcon() {
}

private Optional<JabRefIcon> parseIcon(String iconCode) {
return Enums.getIfPresent(MaterialDesignIcon.class, iconCode.toUpperCase(Locale.ENGLISH))
.toJavaUtil()
.map(icon -> new InternalMaterialDesignIcon(getColor(), icon));
return IconTheme.findIcon(iconCode, getColor());
}

public ObservableList<GroupNodeViewModel> getChildren() {
Expand Down
Loading

0 comments on commit e50566a

Please sign in to comment.