Skip to content
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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies {
implementation('org.springframework.boot:spring-boot-starter-webflux') {
exclude group: 'io.netty', module: 'netty-transport-native-epoll'
}
implementation 'net.rgielen:javafx-weaver-spring-boot-starter:2.0.1'
implementation 'commons-io:commons-io:2.19.0'
implementation 'com.google.code.gson:gson:2.13.1'
implementation 'org.apache.commons:commons-lang3:3.17.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.synops.replayreader.about;

import com.synops.replayreader.core.window.WindowController;
import com.synops.replayreader.core.window.WindowManager;
import com.synops.replayreader.ui.util.UiUtil;
import javafx.application.HostServices;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Hyperlink;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
import net.rgielen.fxweaver.core.FxmlView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.info.BuildProperties;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;

@Component
@FxmlView(value = "/views/about/about.fxml")
public class AboutWindowController implements WindowController {

private static final Logger LOGGER = LoggerFactory.getLogger(AboutWindowController.class);
private static final String GITHUB_REPOSITORY = "https://github.com/synopss/replay-reader";
private static final String AUTHOR_GITHUB_PROFILE = "https://github.com/synopss";
private final HostServices hostServices;
private final BuildProperties buildProperties;
private final WindowManager windowManager;
@FXML
public Text titleText;
@FXML
public Hyperlink repositoryLink;
@FXML
public Hyperlink openSourceLink;
@FXML
public Hyperlink authorLink;
@FXML
public Button closeButton;
@FXML
public AnchorPane root;

public AboutWindowController(@Nullable HostServices hostServices, BuildProperties buildProperties,
WindowManager windowManager) {
this.hostServices = hostServices;
this.buildProperties = buildProperties;
this.windowManager = windowManager;
}

@Override
public void initialize() {
titleText.setText(buildProperties.getName() + " " + buildProperties.getVersion());
repositoryLink.setOnAction(_ -> openUrl(GITHUB_REPOSITORY));
openSourceLink.setOnAction(_ -> windowManager.openSoftwareUsed(UiUtil.getWindow(root)));
authorLink.setOnAction(_ -> openUrl(AUTHOR_GITHUB_PROFILE));
closeButton.setOnAction(UiUtil::closeWindow);
LOGGER.debug("Initializing AboutWindowController");
}

private void openUrl(String url) {
if (hostServices == null) {
return;
}
hostServices.showDocument(url);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.synops.replayreader.about;

import com.synops.replayreader.about.model.SoftwareInfo;
import com.synops.replayreader.core.window.WindowController;
import com.synops.replayreader.core.window.WindowManager;
import com.synops.replayreader.ui.util.UiUtil;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.HBox;
import net.rgielen.fxweaver.core.FxmlView;
import org.springframework.stereotype.Component;

@Component
@FxmlView(value = "/views/about/software-used.fxml")
public class SoftwareUsedWindowController implements WindowController {

private final WindowManager windowManager;
private final ObservableList<SoftwareInfo> softwareData = FXCollections.observableArrayList();
@FXML
public Button closeButton;
@FXML
private TableView<SoftwareInfo> softwareTableView;
@FXML
private TableColumn<SoftwareInfo, SoftwareInfo> softwareColumn;
@FXML
private TableColumn<SoftwareInfo, SoftwareInfo> licenseColumn;

public SoftwareUsedWindowController(WindowManager windowManager) {
this.windowManager = windowManager;
}

@Override
public void initialize() {
softwareData.addAll(new SoftwareInfo("Apache Commons Collections",
"https://commons.apache.org/proper/commons-collections/", "2.19.0", "Apache 2.0",
"https://www.apache.org/licenses/LICENSE-2.0"),
new SoftwareInfo("Apache Commons IO", "https://commons.apache.org/proper/commons-lang/",
"2.19.0", "Apache 2.0", "https://www.apache.org/licenses/LICENSE-2.0"),
new SoftwareInfo("Apache Commons Lang", "https://commons.apache.org/proper/commons-lang/",
"2.19.0", "Apache 2.0", "https://www.apache.org/licenses/LICENSE-2.0"),
new SoftwareInfo("AtlantaFX", "https://mkpaz.github.io/atlantafx", "2.0.1", "MIT",
"https://github.com/mkpaz/atlantafx/blob/master/LICENSE"),
new SoftwareInfo("Ikonli", "https://github.com/kordamp/ikonli", "12.4.0", "Apache 2.0",
"https://www.apache.org/licenses/LICENSE-2.0"),
new SoftwareInfo("Java", "https://www.oracle.com/java/", "24",
"GPLv2 + classpath exception", "https://openjdk.org/legal/gplv2+ce.html"),
new SoftwareInfo("JavaFX", "https://openjfx.io/", "24.0.1", "GPLv2 + classpath exception",
"https://openjdk.org/legal/gplv2+ce.html"),
new SoftwareInfo("JavaFX-Weaver", "https://github.com/rgielen/javafx-weaver", "2.0.1",
"Apache 2.0", "https://www.apache.org/licenses/LICENSE-2.0"),
new SoftwareInfo("jSystemThemeDetector",
"https://github.com/Dansoftowner/jSystemThemeDetector", "3.9.1", "MIT",
"https://github.com/microsoft/fluentui/blob/master/LICENSE"),
new SoftwareInfo("Spring Boot", "https://spring.io/", "3.4.5", "Apache 2.0",
"https://www.apache.org/licenses/LICENSE-2.0"));

softwareTableView.setItems(softwareData);

softwareColumn.setCellValueFactory(cellData -> new SimpleObjectProperty<>(cellData.getValue()));
softwareColumn.setCellFactory(_ -> new TableCell<>() {
@Override
protected void updateItem(SoftwareInfo item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(null);
setGraphic(null);
return;
}

var link = new Hyperlink(item.getSoftware());
link.setOnAction(e -> windowManager.openUrl(item.getSoftwareUrl()));
var version = new Label(" " + item.getVersion());

var hbox = new HBox(link, version);
hbox.setAlignment(Pos.CENTER_LEFT);
hbox.setSpacing(5);
setGraphic(hbox);
setText(null);
}
});
licenseColumn.setCellValueFactory(cellData -> new SimpleObjectProperty<>(cellData.getValue()));
licenseColumn.setCellFactory(_ -> new TableCell<>() {
@Override
protected void updateItem(SoftwareInfo item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(null);
setGraphic(null);
return;
}

var link = new Hyperlink(item.getLicense());
link.setOnAction(e -> windowManager.openUrl(item.getLicenseUrl()));

var hbox = new HBox(link);
hbox.setAlignment(Pos.CENTER_LEFT);
setGraphic(hbox);
setText(null);
}
});

closeButton.setOnAction(UiUtil::closeWindow);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.synops.replayreader.about.model;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

public class SoftwareInfo {

private final StringProperty software;
private final StringProperty softwareUrl;
private final StringProperty version;
private final StringProperty license;
private final StringProperty licenseUrl;

public SoftwareInfo(String software, String softwareUrl, String version, String license,
String licenseUrl) {
this.software = new SimpleStringProperty(software);
this.softwareUrl = new SimpleStringProperty(softwareUrl);
this.version = new SimpleStringProperty(version);
this.license = new SimpleStringProperty(license);
this.licenseUrl = new SimpleStringProperty(licenseUrl);
}

public StringProperty softwareProperty() {
return software;
}

public StringProperty softwareUrlProperty() {
return softwareUrl;
}

public StringProperty versionProperty() {
return version;
}

public StringProperty licenseProperty() {
return license;
}

public StringProperty licenseUrlProperty() {
return licenseUrl;
}

public String getSoftware() {
return software.get();
}

public void setSoftware(String software) {
this.software.set(software);
}

public String getSoftwareUrl() {
return softwareUrl.get();
}

public void setSoftwareUrl(String softwareUrl) {
this.softwareUrl.set(softwareUrl);
}

public String getVersion() {
return version.get();
}

public void setVersion(String version) {
this.version.set(version);
}

public String getLicense() {
return license.get();
}

public void setLicense(String license) {
this.license.set(license);
}

public String getLicenseUrl() {
return licenseUrl.get();
}

public void setLicenseUrl(String licenseUrl) {
this.licenseUrl.set(licenseUrl);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.synops.replayreader.common.util;

public class Constants {
public static final String APP_NAME = "Replay Reader";
public static final String CLAN_ALL = "<all>";
public static final String CLAN_LESS = "<clanless>";
public static final String OVERALL = "<overall>";
Expand Down
46 changes: 6 additions & 40 deletions src/main/java/com/synops/replayreader/core/StageInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,24 @@
import atlantafx.base.theme.PrimerDark;
import atlantafx.base.theme.PrimerLight;
import com.jthemedetecor.OsThemeDetector;
import com.synops.replayreader.common.i18n.I18nUtils;
import com.synops.replayreader.ui.util.UiUtil;
import java.io.IOException;
import java.util.ResourceBundle;
import com.synops.replayreader.core.window.WindowManager;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;

@Component
public class StageInitializer implements ApplicationListener<StageReadyEvent> {

private final ApplicationContext applicationContext;
private final ResourceBundle resourceBundle;
private final WindowManager windowManager;

@Value("${replay-reader.ui.height}")
private int applicationHeight;

@Value("${replay-reader.ui.width}")
private int applicationWidth;

@Value("classpath:/views/main.fxml")
private Resource mainResource;

public StageInitializer(ApplicationContext applicationContext, ResourceBundle resourceBundle) {
this.applicationContext = applicationContext;
this.resourceBundle = resourceBundle;
public StageInitializer(WindowManager windowManager) {
this.windowManager = windowManager;
}

@Override
public void onApplicationEvent(StageReadyEvent event) {
try {
var bundle = I18nUtils.getBundle();
var fxmlLoader = new FXMLLoader(mainResource.getURL(), bundle);
fxmlLoader.setControllerFactory(applicationContext::getBean);
Parent parent = fxmlLoader.load();
var stage = event.getStage();
handleDarkMode();
stage.setScene(new Scene(parent, applicationWidth, applicationHeight));
stage.setResizable(false);
stage.setTitle(resourceBundle.getString("main.title"));
UiUtil.setDefaultIcon(stage);
UiUtil.setDefaultStyle(stage);
stage.show();
} catch (IOException e) {
throw new RuntimeException(e);
}
handleDarkMode();
windowManager.openMain(event.getStage());
}

private void handleDarkMode() {
Expand Down
Loading