Skip to content

Commit 825e542

Browse files
authored
Merge pull request #95 from DavidDamke/feature/removeFontAwesome2
Feature/remove font awesome mvn dependency
2 parents 1c9b59e + 8bf3422 commit 825e542

File tree

18 files changed

+559
-110
lines changed

18 files changed

+559
-110
lines changed

pom.xml

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55

66
<groupId>de.doubleslash</groupId>
@@ -31,24 +31,6 @@
3131
<relativePath /> <!-- lookup parent from repository -->
3232
</parent>
3333

34-
<repositories>
35-
36-
<!-- Including for fontawesome-->
37-
<repository>
38-
<id>fontawesomefx-repo</id>
39-
<name>FontAwesome Repository</name>
40-
<url>https://dl.bintray.com/jerady/maven</url>
41-
</repository>
42-
43-
<!-- needed to resolve against central first-->
44-
<repository>
45-
<id>central</id>
46-
<name>Maven Central</name>
47-
<layout>default</layout>
48-
<url>https://repo1.maven.org/maven2</url>
49-
</repository>
50-
</repositories>
51-
5234
<properties>
5335
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5436
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@@ -110,20 +92,7 @@
11092
<version>3.3.0</version>
11193
<type>maven-plugin</type>
11294
</dependency>
113-
114-
<dependency>
115-
<groupId>de.jensd</groupId>
116-
<artifactId>fontawesomefx-commons</artifactId>
117-
<version>8.15</version>
118-
</dependency>
119-
120-
<dependency>
121-
<groupId>de.jensd</groupId>
122-
<artifactId>fontawesomefx-fontawesome</artifactId>
123-
<version>4.7.0-5</version>
124-
</dependency>
12595
</dependencies>
126-
12796
<build>
12897
<plugins>
12998
<plugin>
@@ -214,4 +183,4 @@
214183
</plugin>
215184
</plugins>
216185
</reporting>
217-
</project>
186+
</project>

src/main/java/de/doubleslash/keeptime/common/Licenses.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public enum Licenses {
3131
"./licenses/GNU Lesser General Public License (LGPL), Version 3.0.txt",
3232
"GNU Lesser General Public License Version 3.0",
3333
"https://www.gnu.org/licenses/lgpl-3.0.de.html"),
34-
MIT("./licenses/The MIT License.txt", "The MIT License", "https://opensource.org/licenses/MIT");
34+
MIT("./licenses/The MIT License.txt", "The MIT License", "https://opensource.org/licenses/MIT"),
35+
36+
CC_4_0("./licenses/CC BY 4.0 License.txt", "CC BY 4.0 License", "https://creativecommons.org/licenses/by/4.0/");
3537

3638
private final String path;
3739
private final String name;

src/main/java/de/doubleslash/keeptime/common/Resources.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ public enum RESOURCE {
4141
FXML_MANAGE_PROJECT("/layouts/manage-project.fxml"),
4242
FXML_MANAGE_WORK("/layouts/manage-work.fxml"),
4343

44+
SVG_CALENDAR_DAYS_ICON("/svgs/calendar-days.svg"),
45+
46+
SVG_CLOSE_ICON("/svgs/xmark.svg"),
47+
48+
SVG_SETTINGS_ICON("/svgs/gear.svg"),
49+
50+
SVG_MINUS_ICON("/svgs/minus.svg"),
51+
52+
SVG_TRASH_ICON("/svgs/trash-can.svg"),
53+
54+
SVG_PENCIL_ICON("/svgs/pencil.svg"),
55+
56+
SVG_CLIPBOARD("/svgs/clipboard.svg"),
57+
58+
SVG_BUG_ICON("/svgs/bug.svg"),
59+
4460
;
4561

4662
String resourceLocation;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package de.doubleslash.keeptime.common;
2+
3+
import javafx.scene.Node;
4+
import javafx.scene.shape.SVGPath;
5+
import org.w3c.dom.Document;
6+
import org.w3c.dom.NodeList;
7+
import org.xml.sax.SAXException;
8+
9+
import javax.xml.parsers.DocumentBuilder;
10+
import javax.xml.parsers.DocumentBuilderFactory;
11+
import javax.xml.parsers.ParserConfigurationException;
12+
import java.io.IOException;
13+
import java.io.InputStream;
14+
15+
/**
16+
* Class loads SvgPath from a SvgFile because Java can not load the original svg file as it is.
17+
* <p>
18+
* To load the svg the class extracts the path as string and creates a new SvgPath and returns it.
19+
*/
20+
21+
public class SvgNodeProvider {
22+
23+
public static String getSvgPathWithXMl(Resources.RESOURCE resource) {
24+
String svgPath;
25+
Document document;
26+
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
27+
DocumentBuilder db;
28+
29+
try {
30+
db = dbf.newDocumentBuilder();
31+
} catch (ParserConfigurationException e) {
32+
throw new RuntimeException("Tried to build new document", e);
33+
}
34+
35+
try (InputStream inputStream = Resources.getResource(resource).openStream()) {
36+
document = db.parse(inputStream);
37+
NodeList nodeList = document.getElementsByTagName("path");
38+
svgPath = nodeList.item(0).getAttributes().getNamedItem("d").getNodeValue();
39+
} catch (IOException | SAXException e) {
40+
throw new RuntimeException("Could not extract SvgPath from resource " + resource, e);
41+
}
42+
return svgPath;
43+
}
44+
45+
public static Node getSvgNodeWithScale(Resources.RESOURCE resource, Double scaleX, Double scaleY) {
46+
SVGPath iconSvg = new SVGPath();
47+
iconSvg.setContent(getSvgPathWithXMl(resource));
48+
iconSvg.setScaleX(scaleX);
49+
iconSvg.setScaleY(scaleY);
50+
return iconSvg;
51+
}
52+
}

src/main/java/de/doubleslash/keeptime/view/AboutController.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818

1919
import java.util.Comparator;
2020

21+
import de.doubleslash.keeptime.common.*;
22+
import javafx.scene.shape.SVGPath;
2123
import org.slf4j.Logger;
2224
import org.slf4j.LoggerFactory;
2325
import org.springframework.stereotype.Component;
2426

2527
import de.doubleslash.keeptime.ApplicationProperties;
26-
import de.doubleslash.keeptime.Main;
27-
import de.doubleslash.keeptime.common.BrowserHelper;
28-
import de.doubleslash.keeptime.common.FileOpenHelper;
29-
import de.doubleslash.keeptime.common.Licenses;
3028
import de.doubleslash.keeptime.view.license.LicenseTableRow;
3129
import javafx.collections.FXCollections;
3230
import javafx.collections.ObservableList;
@@ -57,6 +55,8 @@ public class AboutController {
5755
@FXML
5856
private Button reportBugButton;
5957

58+
@FXML
59+
private SVGPath bugIcon;
6060
@FXML
6161
private Label versionNumberLabel;
6262

@@ -70,10 +70,10 @@ public class AboutController {
7070

7171
private final ApplicationProperties applicationProperties;
7272

73-
public AboutController (ApplicationProperties applicationProperties) {
74-
this.applicationProperties = applicationProperties;
73+
public AboutController(ApplicationProperties applicationProperties) {
74+
this.applicationProperties = applicationProperties;
7575
}
76-
76+
7777
@FXML
7878
public void initialize() {
7979
LOG.debug("set version label");
@@ -90,6 +90,9 @@ public void initialize() {
9090

9191
nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
9292

93+
//set SvgPath content
94+
bugIcon.setContent(SvgNodeProvider.getSvgPathWithXMl(Resources.RESOURCE.SVG_BUG_ICON));
95+
9396
// licenseColumn
9497
final TableColumn<LicenseTableRow, String> licenseColumn = new TableColumn<>("License");
9598
licenseColumn.setMinWidth(260);
@@ -149,7 +152,7 @@ public ObservableList<LicenseTableRow> loadLicenseRows() {
149152
licenseRows.add(new LicenseTableRow("spring-boot-starter-data-jpa", Licenses.APACHEV2));
150153
licenseRows.add(new LicenseTableRow("mockito-core", Licenses.MIT));
151154
licenseRows.add(new LicenseTableRow("h2", Licenses.EPLV1));
152-
licenseRows.add(new LicenseTableRow("fontawesomefx", Licenses.APACHEV2));
155+
licenseRows.add(new LicenseTableRow("Font Awesome Icons", Licenses.CC_4_0));
153156

154157
licenseRows.sort(Comparator.comparing(LicenseTableRow::getName));
155158

src/main/java/de/doubleslash/keeptime/view/ReportController.java

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import de.doubleslash.keeptime.common.DateFormatter;
3636
import de.doubleslash.keeptime.common.Resources;
3737
import de.doubleslash.keeptime.common.Resources.RESOURCE;
38+
import de.doubleslash.keeptime.common.SvgNodeProvider;
3839
import de.doubleslash.keeptime.controller.Controller;
3940
import de.doubleslash.keeptime.exceptions.FXMLLoaderException;
4041
import de.doubleslash.keeptime.model.Model;
@@ -43,8 +44,6 @@
4344
import de.doubleslash.keeptime.view.worktable.ProjectTableRow;
4445
import de.doubleslash.keeptime.view.worktable.TableRow;
4546
import de.doubleslash.keeptime.view.worktable.WorkTableRow;
46-
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
47-
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView;
4847
import javafx.beans.property.ReadOnlyObjectWrapper;
4948
import javafx.event.ActionEvent;
5049
import javafx.event.EventHandler;
@@ -56,6 +55,7 @@
5655
import javafx.scene.control.Alert.AlertType;
5756
import javafx.scene.control.Button;
5857
import javafx.scene.control.ButtonType;
58+
import javafx.scene.control.ContentDisplay;
5959
import javafx.scene.control.DateCell;
6060
import javafx.scene.control.DatePicker;
6161
import javafx.scene.control.Dialog;
@@ -200,19 +200,22 @@ private void updateReport(final LocalDate dateToShow) {
200200

201201
this.currentDayLabel.setText(DateFormatter.toDayDateString(this.currentReportDate));
202202
final List<Work> currentWorkItems = model.getWorkRepository()
203-
.findByStartDateOrderByStartTimeAsc(this.currentReportDate);
203+
.findByStartDateOrderByStartTimeAsc(this.currentReportDate);
204204

205205
colorTimeLine.update(currentWorkItems, controller.calcSeconds(currentWorkItems));
206206

207-
final SortedSet<Project> workedProjectsSet = currentWorkItems.stream().map(Work::getProject)
208-
.collect(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Project::getIndex))));
207+
final SortedSet<Project> workedProjectsSet = currentWorkItems.stream()
208+
.map(Work::getProject)
209+
.collect(Collectors.toCollection(() -> new TreeSet<>(
210+
Comparator.comparing(Project::getIndex))));
209211

210212
long currentWorkSeconds = 0;
211213
long currentSeconds = 0;
212214

213215
for (final Project project : workedProjectsSet) {
214-
final List<Work> onlyCurrentProjectWork = currentWorkItems.stream().filter(w -> w.getProject() == project)
215-
.collect(Collectors.toList());
216+
final List<Work> onlyCurrentProjectWork = currentWorkItems.stream()
217+
.filter(w -> w.getProject() == project)
218+
.collect(Collectors.toList());
216219

217220
final long projectWorkSeconds = controller.calcSeconds(onlyCurrentProjectWork);
218221

@@ -282,7 +285,12 @@ public void updateItem(final LocalDate item, final boolean empty) {
282285
}
283286

284287
private Button createDeleteWorkButton(final Work w) {
285-
final Button deleteButton = new Button("", new FontAwesomeIconView(FontAwesomeIcon.TRASH));
288+
final Button deleteButton = new Button("",
289+
SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_TRASH_ICON, 0.03, 0.03));
290+
deleteButton.setMaxSize(20, 18);
291+
deleteButton.setMinSize(20, 18);
292+
deleteButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
293+
286294
deleteButton.setOnAction(e -> {
287295
LOG.info("Delete work clicked.");
288296
final Alert alert = new Alert(AlertType.CONFIRMATION);
@@ -304,7 +312,12 @@ private Button createDeleteWorkButton(final Work w) {
304312
}
305313

306314
private Button createEditWorkButton(final Work work) {
307-
final Button editButton = new Button("", new FontAwesomeIconView(FontAwesomeIcon.PENCIL));
315+
final Button editButton = new Button("",
316+
SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_PENCIL_ICON, 0.03, 0.03));
317+
editButton.setMaxSize(20, 18);
318+
editButton.setMinSize(20, 18);
319+
editButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
320+
308321
editButton.setOnAction(e -> {
309322
LOG.info("Edit work clicked.");
310323
final Dialog<Work> dialog = setupEditWorkDialog(work);
@@ -361,7 +374,11 @@ private GridPane setUpEditWorkGridPane(final Work work, final Dialog<Work> dialo
361374
}
362375

363376
private Button createCopyProjectButton(final List<Work> projectWork) {
364-
final Button copyButton = new Button("", new FontAwesomeIconView(FontAwesomeIcon.CLIPBOARD));
377+
final Button copyButton = new Button("", SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_CLIPBOARD, 0.03, 0.03));
378+
copyButton.setMaxSize(20, 18);
379+
copyButton.setMinSize(20, 18);
380+
copyButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
381+
365382
final EventHandler<ActionEvent> eventListener = actionEvent -> {
366383
LOG.debug("Copy to Clipboard clicked.");
367384
final ProjectReport pr = new ProjectReport(projectWork.size());
@@ -381,7 +398,11 @@ private Button createCopyProjectButton(final List<Work> projectWork) {
381398
}
382399

383400
private Node createCopyWorkButton(final Work w) {
384-
final Button copyButton = new Button("", new FontAwesomeIconView(FontAwesomeIcon.CLIPBOARD));
401+
final Button copyButton = new Button("", SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_CLIPBOARD, 0.03, 0.03));
402+
copyButton.setMaxSize(20, 18);
403+
copyButton.setMinSize(20, 18);
404+
copyButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
405+
385406
final EventHandler<ActionEvent> eventListener = actionEvent -> {
386407
LOG.debug("Copy to Clipboard clicked.");
387408
final Clipboard clipboard = Clipboard.getSystemClipboard();

0 commit comments

Comments
 (0)