Skip to content

Commit

Permalink
fix: API & Desktop spring boot autoconf
Browse files Browse the repository at this point in the history
  • Loading branch information
SalathielGenese committed Aug 18, 2024
1 parent cc89864 commit e3e6b35
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 219 deletions.
4 changes: 4 additions & 0 deletions jsgenerator-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
170 changes: 18 additions & 152 deletions jsgenerator-desktop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,179 +9,45 @@
<version>${revision}</version>
</parent>


<modelVersion>4.0.0</modelVersion>

<artifactId>jsgenerator-desktop</artifactId>

<name>jsgenerator-desktop</name>

<properties>
<javafx.version>17.0.2</javafx.version>
<javafx.plugin.version>0.0.8</javafx.plugin.version>
<mainClass>com.osscameroon.jsgenerator.desktop.HelloApplication</mainClass>
<start-class>com.osscameroon.jsgenerator.desktop.autoconfigure.JsGeneratorDesktop</start-class>
</properties>


<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>com.osscameroon</groupId>
<artifactId>jsgenerator-core</artifactId>
</dependency>


<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>11.1.1</version>
</dependency>
<dependency>
<groupId>com.dlsc.formsfx</groupId>
<artifactId>formsfx-core</artifactId>
<version>11.5.0</version>
<exclusions>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.synedra</groupId>
<artifactId>validatorfx</artifactId>
<version>0.4.0</version>
<exclusions>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-javafx</artifactId>
<version>12.3.1</version>
</dependency>
<dependency>
<groupId>org.kordamp.bootstrapfx</groupId>
<artifactId>bootstrapfx-core</artifactId>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>eu.hansolo</groupId>
<artifactId>tilesfx</artifactId>
<version>17.1.9</version>
<exclusions>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Dependency of eu.hansolo.tilesfx
We added it in pom in order to avoid "module not found: eu.hansolo.fx.countries"
-->

<dependency>
<groupId>eu.hansolo.fx</groupId>
<artifactId>countries</artifactId>
<version>17.0.22</version>

</dependency>


<!-- Dependency of eu.hansolo.tilesfx
We added it in pom in order to avoid "module not found: eu.hansolo.fx.heatmap"
-->

<dependency>
<groupId>eu.hansolo.fx</groupId>
<artifactId>heatmap</artifactId>
<version>17.0.9</version>

</dependency>


<!-- Dependency of eu.hansolo.tilesfx
We added it in pom in order to avoid "module not found: eu.hansolo.toolboxfx"
-->
<dependency>
<groupId>eu.hansolo</groupId>
<artifactId>toolboxfx</artifactId>
<version>17.0.28</version>

</dependency>


<!-- Dependency of eu.hansolo.tilesfx
We added it in pom in order to avoid "module not found: eu.hansolo.toolbox"
-->

<dependency>
<groupId>eu.hansolo</groupId>
<artifactId>toolbox</artifactId>
<version>17.0.22</version>

</dependency>

<!-- Dependency of eu.hansolo.tilesfx
We added it in pom in order to avoid "module not found: javafx.swing"
-->


<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>20-ea+4</version>
</dependency>



</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.plugin.version}</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>${mainClass}</mainClass>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>
<jlinkImageName>app</jlinkImageName>
<noManPages>true</noManPages>
<stripDebug>true</stripDebug>
<noHeaderFiles>true</noHeaderFiles>
</configuration>
</execution>
</executions>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>22</source>
<target>22</target>
</configuration>
</plugin>
</plugins>
</build>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.osscameroon.jsgenerator.desktop.autoconfigure;

import com.osscameroon.jsgenerator.core.autoconfigure.JsGeneratorCoreAutoconfigure;
import com.osscameroon.jsgenerator.desktop.controller.FxmlNavigator;
import com.osscameroon.jsgenerator.desktop.controller.FxmlResolver;
import com.osscameroon.jsgenerator.desktop.controller.HelloViewController;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

@ImportAutoConfiguration(JsGeneratorCoreAutoconfigure.class)
@SpringBootApplication(scanBasePackageClasses = HelloViewController.class)
public class JsGeneratorDesktop extends Application {
private static ApplicationContext context;
private static FxmlResolver fxmlResolver;
private static Scene scene;

public static void main(String[] args) {
context = SpringApplication.run(JsGeneratorDesktop.class, args);
fxmlResolver = context.getBean(FxmlResolver.class);
launch(JsGeneratorDesktop.class, args);
}

/**
* Inject this bean to navigate from one view to another, like a router.
*
* @return
*/
@Bean
@Lazy
public FxmlNavigator fxmlNavigator() {
return scene::setRoot;
}

@Bean
public FxmlResolver fxmlResolver() {
return path -> {
path = "com/osscameroon/jsgenerator/desktop/controller/%s.fxml".formatted(path);
final var loader = new FXMLLoader(new ClassPathResource(path).getURL());
loader.setControllerFactory(context::getBean);
return (Parent) loader.load();
};
}

@Override
public void start(Stage stage) throws IOException {
final var parent = fxmlResolver.resolve("hello-view");
stage.setScene(scene = new Scene(parent));
stage.show();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.osscameroon.jsgenerator.desktop.controller;

import javafx.scene.Parent;

@FunctionalInterface
public interface FxmlNavigator {
void navigate(Parent parent);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.osscameroon.jsgenerator.desktop.controller;

import javafx.scene.Parent;

import java.io.IOException;

@FunctionalInterface
public interface FxmlResolver {
Parent resolve(String relativePathWithoutExtension) throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.osscameroon.jsgenerator.desktop.controller;

import com.osscameroon.jsgenerator.core.Converter;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import org.springframework.stereotype.Component;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

@Component
public final class HelloViewController {
private final Converter converter;

@FXML
private TextArea inputArea;
@FXML
private Label outputLabel;

public HelloViewController(Converter converter) {
this.converter = converter;
}

@FXML
private void convert() throws IOException {
try (var stream = new ByteArrayOutputStream()) {
converter.convert(new ByteArrayInputStream(inputArea.textProperty().getValue().getBytes()), stream);
outputLabel.setText(stream.toString(StandardCharsets.UTF_8));
}
}
}
23 changes: 12 additions & 11 deletions jsgenerator-desktop/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module com.osscameroon.jsgenerator.desktop {
exports com.osscameroon.jsgenerator.desktop.autoconfigure;
exports com.osscameroon.jsgenerator.desktop.controller;

opens com.osscameroon.jsgenerator.desktop.controller to javafx.fxml, spring.beans;
opens com.osscameroon.jsgenerator.desktop.autoconfigure to javafx.fxml, spring.beans;

requires com.osscameroon.jsgenerator.core;
requires javafx.controls;
requires javafx.fxml;
requires javafx.web;

requires org.controlsfx.controls;
requires com.dlsc.formsfx;
requires net.synedra.validatorfx;
requires org.kordamp.ikonli.javafx;
requires org.kordamp.bootstrapfx.core;
requires eu.hansolo.tilesfx;
requires spring.boot.autoconfigure;
requires spring.boot;
requires spring.context;

opens com.osscameroon.jsgenerator.desktop to javafx.fxml;
exports com.osscameroon.jsgenerator.desktop;
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
requires spring.core;
}
Loading

0 comments on commit e3e6b35

Please sign in to comment.