Skip to content
This repository was archived by the owner on Nov 25, 2022. It is now read-only.

Commit 173bbc3

Browse files
committed
Merge branch 'master' of git@github.com:XDean/CSS-Editor-FX
2 parents 4e684c1 + 7dacb3a commit 173bbc3

7 files changed

Lines changed: 44 additions & 11 deletions

File tree

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
<mainClass>xdean.css.editor.CSSMain</mainClass>
1616
</properties>
1717

18+
<dependencyManagement>
19+
<dependencies>
20+
<dependency>
21+
<groupId>io.reactivex.rxjava2</groupId>
22+
<artifactId>rxjava</artifactId>
23+
<version>2.1.13</version>
24+
</dependency>
25+
</dependencies>
26+
</dependencyManagement>
27+
1828
<dependencies>
1929
<dependency>
2030
<groupId>com.github.XDean</groupId>

src/main/java/xdean/css/editor/FxCssApplication.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import javax.inject.Inject;
1010
import javax.inject.Named;
1111

12-
import org.controlsfx.glyphfont.Glyph;
1312
import org.springframework.stereotype.Component;
1413

1514
import javafx.beans.property.ObjectProperty;
@@ -59,9 +58,6 @@ public FxCssApplication(@Named(FxContext.FX_PRIMARY_STAGE) Stage stage) {
5958

6059
@Override
6160
public void start(Stage stage) throws Exception {
62-
// To ensure font awesome loaded
63-
new Glyph().setFontFamily("FontAwesome");
64-
6561
Scene scene = skinService.bind(new Scene(mainFrame.getRoot()));
6662
scene.getStylesheets().add("/css/global.css");
6763
stage.setScene(scene);

src/main/java/xdean/css/editor/FxCssEntrance.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package xdean.css.editor;
22

33
import org.springframework.boot.SpringApplication;
4-
import org.springframework.context.annotation.Import;
54

6-
import xdean.css.editor.context.Context;
5+
import xdean.jfx.spring.annotation.Splash;
76
import xdean.jfx.spring.annotation.SpringFxApplication;
87

8+
@Splash
99
@SpringFxApplication
10-
@Import(Context.class)
1110
public class FxCssEntrance {
1211
public static void main(String[] args) {
1312
SpringApplication.run(FxCssEntrance.class, args);

src/main/java/xdean/css/editor/context/Config.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@
88
import java.util.Properties;
99
import java.util.concurrent.TimeUnit;
1010

11+
import javax.annotation.PostConstruct;
12+
import javax.inject.Inject;
13+
1114
import org.springframework.stereotype.Service;
1215

1316
import io.reactivex.subjects.Subject;
1417
import io.reactivex.subjects.UnicastSubject;
1518
import xdean.jex.log.Logable;
19+
import xdean.jfx.spring.splash.PreloadReporter;
20+
import xdean.jfx.spring.splash.PreloadReporter.SubReporter;
1621

1722
@Service
1823
public class Config implements Logable {
@@ -21,18 +26,25 @@ public class Config implements Logable {
2126

2227
private final Properties properties = new Properties();
2328
private final Subject<String> saveSubject = UnicastSubject.create();
29+
private @Inject PreloadReporter preload;
2430

25-
public Config() {
31+
@PostConstruct
32+
public void init() {
2633
try {
34+
SubReporter sub = preload.load("Loading settings...");
35+
sub.setCount(3);
36+
sub.load("Check user setting");
2737
if (Files.notExists(CONFIG_FILE)) {
2838
if (Files.exists(DEFAULT_CONFIG_PATH)) {
2939
Files.copy(DEFAULT_CONFIG_PATH, CONFIG_FILE);
3040
} else {
3141
Files.createFile(CONFIG_FILE);
3242
}
3343
}
44+
sub.load("Loading settings file");
3445
properties.load(Files.newBufferedReader(CONFIG_FILE));
3546
debug("Load last config: " + properties.toString());
47+
sub.load("Apply settings");
3648
saveSubject
3749
.debounce(1000, TimeUnit.MILLISECONDS)
3850
.subscribe(e -> saveToFile());

src/main/java/xdean/css/editor/context/Context.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
import javax.inject.Inject;
99

10-
import org.springframework.boot.context.event.ApplicationStartingEvent;
10+
import org.controlsfx.glyphfont.FontAwesome;
11+
import org.controlsfx.glyphfont.GlyphFontRegistry;
12+
import org.springframework.boot.context.event.ApplicationPreparedEvent;
1113
import org.springframework.context.ApplicationListener;
1214
import org.springframework.context.annotation.Configuration;
1315

@@ -23,7 +25,7 @@
2325

2426
@Configuration
2527
@AutoSpringFactories(ApplicationListener.class)
26-
public class Context implements FxContextPostProcessor, ApplicationListener<ApplicationStartingEvent>,
28+
public class Context implements FxContextPostProcessor, ApplicationListener<ApplicationPreparedEvent>,
2729
UncaughtExceptionHandler, Logable {
2830
public static final Path HOME_PATH = Paths.get(System.getProperty("user.home"), ".xdean", "css");
2931
public static final Path TEMP_PATH = HOME_PATH.resolve("temp");
@@ -32,7 +34,7 @@ public class Context implements FxContextPostProcessor, ApplicationListener<Appl
3234
private @Inject DialogService messageService;
3335

3436
@Override
35-
public void onApplicationEvent(ApplicationStartingEvent event) {
37+
public void onApplicationEvent(ApplicationPreparedEvent event) {
3638
debug("Setup Css Editor Environment");
3739
// create directories
3840
try {
@@ -43,6 +45,10 @@ public void onApplicationEvent(ApplicationStartingEvent event) {
4345
}
4446
// close CSS logger
4547
Logging.getCSSLogger().setLevel(Level.OFF);
48+
49+
// To ensure font awesome loaded
50+
GlyphFontRegistry.register(new FontAwesome(getClass().getResourceAsStream("/fontawesome.ttf")));
51+
GlyphFontRegistry.font("FontAwesome");
4652
}
4753

4854
@Override

src/main/java/xdean/css/editor/service/SkinService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import xdean.jex.log.Logable;
1818
import xdean.jex.util.string.StringUtil;
1919
import xdean.jfx.spring.annotation.FxReady;
20+
import xdean.jfx.spring.splash.PreloadReporter;
21+
import xdean.jfx.spring.splash.PreloadReporter.SubReporter;
2022
import xdean.jfxex.support.skin.SkinManager;
2123
import xdean.jfxex.support.skin.SkinStyle;
2224

@@ -30,10 +32,15 @@ public class SkinService extends SkinManager implements Logable {
3032
@Inject
3133
private DialogService dialogService;
3234

35+
@Inject
36+
private PreloadReporter preload;
37+
3338
@PostConstruct
3439
public void init() throws Exception {
40+
SubReporter sub = preload.load("Loading skins...");
3541
// load default skins
3642
for (SkinStyle ss : DefaultSkin.values()) {
43+
sub.load("Loading " + ss.getName());
3744
addSkin(ss);
3845
}
3946
// load skin files in /skin
@@ -47,6 +54,7 @@ public void init() throws Exception {
4754
if (!Files.isDirectory(path) && (fileName.endsWith(".css") || fileName.endsWith(".bss"))) {
4855
String url = path.toUri().toString();
4956
String name = StringUtil.upperFirst(fileName.substring(0, fileName.length() - 4));
57+
sub.load("Loading " + name);
5058
addSkin(new SkinStyle() {
5159
@Override
5260
public String getURL() {
@@ -69,6 +77,7 @@ public String getName() {
6977
}
7078
getSkinList().stream().map(SkinStyle::getURL).map(s -> "loaded skin: " + s).forEach(this::debug);
7179

80+
sub.load("Read skin setting");
7281
String configSkin = skinOption.getValue();
7382
if (configSkin != null) {
7483
getSkinList().stream()
@@ -78,6 +87,7 @@ public String getName() {
7887
} else {
7988
changeSkin(DefaultSkin.CLASSIC);
8089
}
90+
sub.load("Apply skin setting");
8191
JavaFxObservable.valuesOf(skinProperty())
8292
.subscribe(skin -> skinOption.setValue(skin.getName()));
8393
}

src/main/resources/fontawesome.ttf

119 KB
Binary file not shown.

0 commit comments

Comments
 (0)