Skip to content

Commit ae1ab99

Browse files
committed
fix examples and name not being used in dirs
1 parent 2f40389 commit ae1ab99

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ In addition, it is also highly beginner-friendly, making it accessible to everyo
1111
vertical().add(text("Hello World!"))
1212
```
1313
<details>
14-
<summary>3 lines example</summary>
14+
<summary>Minimal example</summary>
1515

1616
```java
1717
import com.osiris.desku.App;
1818
import static com.osiris.desku.Statics;
1919
public class Main {
2020
public static void main(String[] args) throws Exception {
21-
App.init(new DesktopUIManager());
21+
App.uis = new DesktopUIManager(); // Not needed when using the Desku-Gradle-Starter-App
2222
App.name = "My-App";
23+
App.init();
2324
App.uis.create(() -> {
2425
return vertical().add(text("Hello World!"));
2526
});
@@ -37,9 +38,10 @@ import static com.osiris.desku.Statics; // Low-code Java UI via static methods
3738
public class Main {
3839
public static void main(String[] args) throws Exception {
3940

40-
// Setup app details.
41-
App.init(new DesktopUIManager()); // Not needed when using the Desku-Gradle-Starter-App
41+
// Setup app details and init.
42+
App.uis = new DesktopUIManager(); // Not needed when using the Desku-Gradle-Starter-App
4243
App.name = "My-App";
44+
App.init();
4345

4446
// Create routes.
4547
// This is only for demonstration.

src/main/java/com/osiris/desku/App.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public static void updateDirs(){
110110
*/
111111
public static Theme theme = new Theme();
112112

113+
113114
public static UIManager uis = null;
114115
public static ExecutorService executor = Executors.newCachedThreadPool();
115116

@@ -127,16 +128,25 @@ public LoggerParams() {
127128
}
128129
}
129130

131+
/**
132+
* Initialize assuming platform-specific {@link UIManager} was already set earlier. <br>
133+
* Meaning {@link App#uis} must be not null when calling this.
134+
*/
135+
public static void init() {
136+
init(null, new LoggerParams());
137+
}
138+
130139
public static void init(UIManager uiManager) {
131140
init(uiManager, new LoggerParams());
132141
}
133142

134143
public static void init(UIManager uiManager, LoggerParams loggerParams) {
135-
if (uiManager == null) {
144+
if (uiManager == null && App.uis == null) {
136145
throw new NullPointerException("Provided UI factory is null!" +
137146
" Make sure to provide an implementation for the platform this app is running in.");
138147
}
139-
App.uis = uiManager;
148+
if(uiManager != null)
149+
App.uis = uiManager;
140150
try {
141151
updateDirs();
142152
Logger.getGlobal().setLevel(Level.SEVERE);

src/test/java/com/osiris/desku/simple_app/AppTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
class AppTest {
1111

1212
public static void main(String[] args) throws Exception {
13-
// Setup details
14-
App.init(new DesktopUIManager());
15-
App.name = "My-App";
16-
// before loading the page
13+
// Setup details before init
14+
App.uis = new DesktopUIManager();
15+
App.name = "My-Example-Desku-App";
16+
App.init();
1717

1818
// Create routes
1919
Route home = new Home();

0 commit comments

Comments
 (0)