Skip to content

Commit 4d700ba

Browse files
author
de
committed
Merge master into develop
2 parents 7356725 + 33a2a80 commit 4d700ba

File tree

17 files changed

+259
-6
lines changed

17 files changed

+259
-6
lines changed

pom.xml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<encoding>UTF-8</encoding>
2222
<project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
2323
<java.version>17</java.version>
24+
<java.vendor>gluon</java.vendor>
2425
<maven.compiler.source>${java.version}</maven.compiler.source>
2526
<maven.compiler.target>${java.version}</maven.compiler.target>
2627
<top.dir>.</top.dir>
@@ -154,6 +155,28 @@
154155
</reporting>
155156

156157
<profiles>
158+
<profile>
159+
<id>test-support</id>
160+
<activation>
161+
<file>
162+
<exists>src/test/java</exists>
163+
</file>
164+
</activation>
165+
<dependencies>
166+
<dependency>
167+
<groupId>org.junit.jupiter</groupId>
168+
<artifactId>junit-jupiter-api</artifactId>
169+
<version>5.9.0</version>
170+
<scope>test</scope>
171+
</dependency>
172+
<dependency>
173+
<groupId>org.junit.jupiter</groupId>
174+
<artifactId>junit-jupiter-engine</artifactId>
175+
<version>5.9.0</version>
176+
<scope>test</scope>
177+
</dependency>
178+
</dependencies>
179+
</profile>
157180
<profile>
158181
<id>site-support</id>
159182
<activation>
@@ -231,7 +254,21 @@
231254
<groupId>org.apache.maven.plugins</groupId>
232255
<artifactId>maven-toolchains-plugin</artifactId>
233256
<version>3.1.0</version>
234-
<configuration></configuration>
257+
<configuration>
258+
<toolchains>
259+
<jdk>
260+
<version>${java.version}</version>
261+
<vendor>${java.vendor}</vendor>
262+
</jdk>
263+
</toolchains>
264+
</configuration>
265+
<executions>
266+
<execution>
267+
<goals>
268+
<goal>toolchain</goal>
269+
</goals>
270+
</execution>
271+
</executions>
235272
</plugin>
236273
</plugins>
237274
</build>

src/main/java/ifml3/app/Ifml3App.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
package ifml3.app;
22

3+
import ifml3.app.i18n.AppMessage;
4+
import ifml3.app.i18n.AppTranslation;
5+
import ifml3.app.i18n.Translation;
6+
import ifml3.app.view.MainView;
7+
import ifml3.app.view.View;
8+
import java.util.ResourceBundle;
39
import javafx.application.Application;
4-
import javafx.scene.Scene;
5-
import javafx.scene.layout.BorderPane;
610
import javafx.stage.Stage;
711

812
public class Ifml3App extends Application {
913

14+
private Translation translation;
15+
private View view;
16+
17+
@Override
18+
public void init() {
19+
this.translation = new AppTranslation(ResourceBundle.getBundle("lang/ifml3"));
20+
this.view = new MainView(translation);
21+
}
22+
1023
@Override
1124
public void start(final Stage stage) throws Exception {
12-
BorderPane pane = new BorderPane();
13-
Scene scene = new Scene(pane, 800.0, 600.0);
14-
stage.setScene(scene);
25+
stage.setScene(view.scene());
26+
stage.setTitle(translation.message(AppMessage.APP_TITLE));
1527
stage.show();
1628
}
1729

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ifml3.app.file;
2+
3+
import java.nio.file.Path;
4+
5+
public interface AppFolders {
6+
7+
Path userFolder();
8+
9+
Path currentFolder();
10+
11+
Path applicationFolder();
12+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Filesystem operations.
3+
*/
4+
package ifml3.app.file;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package ifml3.app.i18n;
2+
3+
import ifml3.app.i18n.Translation.Message;
4+
5+
public enum AppMessage implements Message {
6+
APP_TITLE("app.title"),
7+
APP_MENU_FILE("app.menu.file");
8+
9+
private final String key;
10+
11+
AppMessage(final String key) {
12+
this.key = key;
13+
}
14+
15+
@Override
16+
public String key() {
17+
return key;
18+
}
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package ifml3.app.i18n;
2+
3+
import java.util.Objects;
4+
import java.util.ResourceBundle;
5+
6+
public class AppTranslation implements Translation {
7+
8+
private final ResourceBundle bundle;
9+
10+
public AppTranslation(final ResourceBundle bundle) {
11+
this.bundle = bundle;
12+
}
13+
14+
@Override
15+
public String message(final Message message) {
16+
return bundle.getString(Objects.requireNonNull(message, "The message cannot be NULL").key());
17+
}
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package ifml3.app.i18n;
2+
3+
@FunctionalInterface
4+
public interface Translation {
5+
6+
String message(Message message);
7+
8+
@FunctionalInterface
9+
interface Message {
10+
11+
String key();
12+
}
13+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* I18N tools.
3+
*/
4+
package ifml3.app.i18n;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package ifml3.app.view;
2+
3+
import ifml3.app.i18n.AppMessage;
4+
import ifml3.app.i18n.Translation;
5+
import javafx.scene.Scene;
6+
import javafx.scene.control.ComboBox;
7+
import javafx.scene.control.Label;
8+
import javafx.scene.control.Menu;
9+
import javafx.scene.control.MenuBar;
10+
import javafx.scene.control.TreeView;
11+
import javafx.scene.layout.BorderPane;
12+
13+
public class MainView implements View {
14+
15+
private final Translation translation;
16+
private final Scene scene;
17+
18+
public MainView(final Translation translation) {
19+
this.translation = translation;
20+
final var pane = new BorderPane(label("center"), menuBar(), label("right"), inputLine(), treeView());
21+
scene = new Scene(pane, 800.0, 600.0);
22+
}
23+
24+
@Override
25+
public Scene scene() {
26+
return scene;
27+
}
28+
29+
private Label label(final String text) {
30+
return new Label(text);
31+
}
32+
33+
private TreeView treeView() {
34+
return new TreeView();
35+
}
36+
37+
private MenuBar menuBar() {
38+
return new MenuBar(new Menu(translation.message(AppMessage.APP_MENU_FILE)));
39+
}
40+
41+
private ComboBox<String> inputLine() {
42+
final var comboBox = new ComboBox<String>();
43+
comboBox.setEditable(true);
44+
return comboBox;
45+
}
46+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package ifml3.app.view;
2+
3+
import javafx.scene.Scene;
4+
5+
public interface View {
6+
7+
Scene scene();
8+
}

0 commit comments

Comments
 (0)