Skip to content

Commit 4a92c96

Browse files
author
mplieske
committed
added about screen and licenses
1 parent 3e1f14a commit 4a92c96

21 files changed

+1498
-122
lines changed

src/main/java/de/doubleslash/keeptime/Main.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,13 @@ public void start(final Stage primaryStage) {
115115
}
116116

117117
private void loadFonts() {
118-
List<RESOURCE> fontResources = Arrays.asList(
119-
RESOURCE.FONT_BOLD,
120-
RESOURCE.FONT_SEMI_BOLD,
121-
RESOURCE.FONT_REGULAR
122-
);
118+
final List<RESOURCE> fontResources = Arrays.asList(RESOURCE.FONT_BOLD, RESOURCE.FONT_SEMI_BOLD,
119+
RESOURCE.FONT_REGULAR);
123120
LOG.info("Loading fonts '{}'", fontResources);
124121

125-
for (RESOURCE fontResource: fontResources) {
122+
for (final RESOURCE fontResource : fontResources) {
126123
LOG.info("Loading font '{}'", fontResource);
127-
Font font = Font.loadFont(Resources.getResource(fontResource).toExternalForm(), 12);
124+
final Font font = Font.loadFont(Resources.getResource(fontResource).toExternalForm(), 12);
128125
LOG.info("Font with name '{}' loaded.", font.getName());
129126
}
130127
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package de.doubleslash.keeptime.common;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
public class BrowserHelper {
7+
public static final Logger LOG = LoggerFactory.getLogger(BrowserHelper.class);
8+
9+
private BrowserHelper() {
10+
11+
}
12+
13+
public static void openURL(final String url) {
14+
final Runtime rt = Runtime.getRuntime();
15+
if (System.getProperty("os.name").contains("Windows")) {
16+
try {
17+
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
18+
} catch (final Exception e) {
19+
LOG.error(e.getMessage());
20+
}
21+
} else if (System.getProperty("os.name").contains("Linux")) {
22+
try {
23+
final String[] browsers = {
24+
"epiphany", "firefox", "mozilla", "konqueror", "netscape", "opera", "links", "lynx"
25+
};
26+
27+
final StringBuilder cmd = new StringBuilder();
28+
for (int i = 0; i < browsers.length; i++) {
29+
if (i == 0) {
30+
cmd.append(String.format("%s \"%s\"", browsers[i], url));
31+
} else {
32+
cmd.append(String.format(" || %s \"%s\"", browsers[i], url));
33+
}
34+
}
35+
36+
rt.exec(new String[] {
37+
"sh", "-c", cmd.toString()
38+
});
39+
} catch (final Exception e) {
40+
LOG.error(e.getMessage());
41+
}
42+
} else {
43+
try {
44+
rt.exec("open " + url);
45+
} catch (final Exception e) {
46+
LOG.error(e.getMessage());
47+
}
48+
}
49+
}
50+
}

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
import javafx.scene.text.Font;
44

55
public class FontProvider {
6-
private static final Font defaultFont = Font.font("Open Sans Regular");
7-
private static final Font boldFont = Font.font("Open Sans Bold");
8-
9-
private FontProvider() {
10-
// no instances allowed
11-
}
12-
13-
public static Font getDefaultFont() {
14-
return defaultFont;
15-
}
16-
17-
public static Font getBoldFont() {
18-
return boldFont;
19-
}
6+
private static final Font defaultFont = Font.font("Open Sans Regular");
7+
private static final Font boldFont = Font.font("Open Sans Bold");
8+
9+
private FontProvider() {
10+
// no instances allowed
11+
}
12+
13+
public static Font getDefaultFont() {
14+
return defaultFont;
15+
}
16+
17+
public static Font getBoldFont() {
18+
return boldFont;
19+
}
2020
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ private Resources() {
1010

1111
public enum RESOURCE {
1212
/** FONTS **/
13-
FONT_BOLD("/font/OpenSans-Bold.ttf"),
13+
FONT_BOLD("/font/OpenSans-Bold.ttf"),
1414
FONT_SEMI_BOLD("/font/OpenSans-SemiBold.ttf"),
1515
FONT_REGULAR("/font/OpenSans-Regular.ttf"),
16-
16+
1717
/** LAYOUTS **/
1818
// main
1919
FXML_VIEW_LAYOUT("/layouts/ViewLayout.fxml"),
2020
FXML_PROJECT_LAYOUT("/layouts/ProjectDetailLayout.fxml"),
2121
FXML_SETTINGS("/layouts/settings.fxml"),
2222
FXML_VIEW_POPUP_LAYOUT("/layouts/ViewLayoutPopup.fxml"),
2323
FXML_REPORT("/layouts/report.fxml"),
24+
FXML_ABOUT("/layouts/about.fxml"),
2425

2526
// icon
2627
ICON_MAIN("/icons/icon.png"),

src/main/java/de/doubleslash/keeptime/controller/Controller.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ public void editProject(final Project p, final String newName, final Color newCo
164164
* Changes the indexes of the originalList parameter to have a consistent order.
165165
*
166166
* @param originalList
167-
* list of all projects to adapt the indexes for
167+
* list of all projects to adapt the indexes for
168168
* @param changedProject
169-
* the project which has changed which already has the new index
169+
* the project which has changed which already has the new index
170170
* @param oldIndex
171-
* the old index of the changed project
171+
* the old index of the changed project
172172
* @param newIndex
173-
* the new index of the changed project (which the projects also already has)
173+
* the new index of the changed project (which the projects also already has)
174174
* @return all projects whose index has been adapted
175175
*/
176176
List<Project> resortProjectIndexes(final List<Project> originalList, final Project changedProject,
@@ -207,9 +207,9 @@ List<Project> resortProjectIndexes(final List<Project> originalList, final Proje
207207
* Decreases all indexes by one, after the removed index
208208
*
209209
* @param originalList
210-
* list of all projects to adapt the indexes for
210+
* list of all projects to adapt the indexes for
211211
* @param removedIndex
212-
* the index which has been removed
212+
* the index which has been removed
213213
* @return all projects whose index has been adapted
214214
*/
215215
List<Project> adaptProjectIndexesAfterRemoving(final List<Project> originalList, final int removedIndex) {

src/main/java/de/doubleslash/keeptime/exceptions/FXMLLoaderException.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@ public FXMLLoaderException() {
66
// XXX Auto-generated constructor stub
77
}
88

9-
public FXMLLoaderException(String message) {
9+
public FXMLLoaderException(final String message) {
1010
super(message);
1111
// XXX Auto-generated constructor stub
1212
}
1313

14-
public FXMLLoaderException(Throwable cause) {
14+
public FXMLLoaderException(final Throwable cause) {
1515
super(cause);
1616
// XXX Auto-generated constructor stub
1717
}
1818

19-
public FXMLLoaderException(String message, Throwable cause) {
19+
public FXMLLoaderException(final String message, final Throwable cause) {
2020
super(message, cause);
2121
// XXX Auto-generated constructor stub
2222
}
2323

24-
public FXMLLoaderException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
24+
public FXMLLoaderException(final String message, final Throwable cause, final boolean enableSuppression,
25+
final boolean writableStackTrace) {
2526
super(message, cause, enableSuppression, writableStackTrace);
2627
// XXX Auto-generated constructor stub
2728
}

src/main/java/de/doubleslash/keeptime/model/LicenceTableColumn.java

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package de.doubleslash.keeptime.model;
2+
3+
public class LicenceTableRow {
4+
private String name;
5+
private String license;
6+
7+
public LicenceTableRow(final String softwareName, final String licenceName) {
8+
this.license = licenceName;
9+
this.name = softwareName;
10+
}
11+
12+
public String getName() {
13+
return name;
14+
}
15+
16+
public void setName(final String name) {
17+
this.name = name;
18+
}
19+
20+
public String getLicense() {
21+
return license;
22+
}
23+
24+
public void setLicense(final String license) {
25+
this.license = license;
26+
}
27+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package de.doubleslash.keeptime.view;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
import de.doubleslash.keeptime.Main;
7+
import de.doubleslash.keeptime.common.BrowserHelper;
8+
import de.doubleslash.keeptime.model.LicenceTableRow;
9+
import javafx.collections.FXCollections;
10+
import javafx.collections.ObservableList;
11+
import javafx.fxml.FXML;
12+
import javafx.scene.control.Button;
13+
import javafx.scene.control.Hyperlink;
14+
import javafx.scene.control.Label;
15+
import javafx.scene.control.TableColumn;
16+
import javafx.scene.control.TableRow;
17+
import javafx.scene.control.TableView;
18+
import javafx.scene.control.cell.PropertyValueFactory;
19+
import javafx.scene.input.MouseButton;
20+
21+
public class AboutController {
22+
23+
private static final String GITHUB_PAGE = "https://www.github.com/doubleSlashde/KeepTime";
24+
private static final String GITHUB_ISSUE_PAGE = "/issues";
25+
26+
private static final String APACHE_LICENSE_NAME = "Apache License 2.0";
27+
private static final String GPL_LICENSE_NAME = "GPL 3.0";
28+
29+
private static final String LICENSE_PATH = "/licenses/";
30+
31+
TableColumn<LicenceTableRow, String> nameColumn;
32+
TableColumn<LicenceTableRow, String> licenseColumn;
33+
34+
@FXML
35+
private Hyperlink gitHubHyperlink;
36+
37+
@FXML
38+
private Button reportBugButton;
39+
40+
@FXML
41+
private Label versionNumberLabel;
42+
43+
@FXML
44+
private TableView<LicenceTableRow> licenseTableView;
45+
46+
public static final Logger LOG = LoggerFactory.getLogger(AboutController.class);
47+
48+
@FXML
49+
public void initialize() {
50+
LOG.debug("set version label");
51+
versionNumberLabel.setText(Main.VERSION);
52+
53+
LOG.debug("set up table");
54+
// name column
55+
nameColumn = new TableColumn<>("Name");
56+
nameColumn.setMinWidth(100);
57+
nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
58+
59+
// licenseColumn
60+
licenseColumn = new TableColumn<>("License");
61+
licenseColumn.setMinWidth(200);
62+
licenseColumn.setCellValueFactory(new PropertyValueFactory<>("license"));
63+
64+
final ObservableList<LicenceTableRow> licenses = FXCollections.observableArrayList();
65+
licenses.add(new LicenceTableRow("jnativehook", "GNU General Public License (GPL), Version 3.0"));
66+
licenses.add(new LicenceTableRow("jnativehook", "GNU Lesser General Public License (LGPL), Version 3.0"));
67+
licenses.add(new LicenceTableRow("commons-lang3", "Apache License, Version 2.0"));
68+
licenses.add(new LicenceTableRow("flyway-maven-plugin", "Apache License, Version 2.0"));
69+
licenses.add(new LicenceTableRow("spring-boot-starter-data-jpa", "Apache License, Version 2.0"));
70+
licenses.add(new LicenceTableRow("mockito-core", "The MIT License"));
71+
licenses.add(new LicenceTableRow("h2", "EPL 1.0"));
72+
73+
licenseTableView.setItems(licenses);
74+
75+
licenseTableView.getColumns().add(nameColumn);
76+
licenseTableView.getColumns().add(licenseColumn);
77+
78+
LOG.debug("tablerow setonaction");
79+
licenseTableView.setRowFactory(tv -> {
80+
LOG.info("table row clicked");
81+
final TableRow<LicenceTableRow> row = new TableRow<>();
82+
row.setOnMouseClicked(event -> {
83+
if (!row.isEmpty() && event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 2) {
84+
final LicenceTableRow clickedRow = row.getItem();
85+
final String license = clickedRow.getLicense();
86+
LOG.debug("License file name: " + license + ".txt");
87+
LOG.debug("full path: " + LICENSE_PATH + license + ".txt");
88+
LOG.debug(AboutController.class.getResource(LICENSE_PATH + license + ".txt").toString());
89+
LOG.debug(
90+
AboutController.class.getResource(LICENSE_PATH + license + ".txt").toExternalForm().toString());
91+
BrowserHelper.openURL(AboutController.class.getResource(LICENSE_PATH + license + ".txt").toString());
92+
}
93+
});
94+
return row;
95+
});
96+
97+
LOG.debug("hyperlink setonaction");
98+
gitHubHyperlink.setOnAction(ae -> {
99+
LOG.debug("hyperlink clicked");
100+
BrowserHelper.openURL("C:/Users/mplieske/Documents/haha.txt");
101+
});
102+
103+
LOG.debug("roportbugbutton setonaction");
104+
reportBugButton.setOnAction(ae -> {
105+
LOG.info("Clicked reportBugButton");
106+
BrowserHelper.openURL(GITHUB_PAGE + GITHUB_ISSUE_PAGE);
107+
});
108+
}
109+
110+
public ObservableList<LicenceTableRow> loadRows() {
111+
final ObservableList<LicenceTableRow> rows = FXCollections.observableArrayList();
112+
113+
rows.add(new LicenceTableRow("KeepTime", GPL_LICENSE_NAME));
114+
rows.add(new LicenceTableRow("jnativehook", GPL_LICENSE_NAME));
115+
rows.add(new LicenceTableRow("commons-lang3", APACHE_LICENSE_NAME));
116+
rows.add(new LicenceTableRow("flyway-maven-plugin", APACHE_LICENSE_NAME));
117+
rows.add(new LicenceTableRow("spring-boot-starter-data-jpa", APACHE_LICENSE_NAME));
118+
rows.add(new LicenceTableRow("mockito-core", "MIT License"));
119+
rows.add(new LicenceTableRow("h2", "EPL 1.0"));
120+
121+
return rows;
122+
}
123+
124+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package de.doubleslash.keeptime.view;
22

3-
import org.slf4j.Logger;
4-
import org.slf4j.LoggerFactory;
5-
63
import static de.doubleslash.keeptime.view.ReportController.EMPTY_NOTE;
74
import static de.doubleslash.keeptime.view.ReportController.NOTE_DELIMETER;
85

96
import java.lang.invoke.MethodHandles;
107

8+
import org.slf4j.Logger;
9+
import org.slf4j.LoggerFactory;
10+
1111
public class ProjectReport {
1212

1313
/** The slf4j-logger for this class. */

0 commit comments

Comments
 (0)