-
Notifications
You must be signed in to change notification settings - Fork 12
Added has started, which adds way to check, whether CSSFX has been st… #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,9 @@ | |
| import java.util.Set; | ||
| import java.util.concurrent.Callable; | ||
|
|
||
| import javafx.beans.property.BooleanProperty; | ||
| import javafx.beans.property.ReadOnlyBooleanProperty; | ||
| import javafx.beans.property.SimpleBooleanProperty; | ||
| import javafx.collections.FXCollections; | ||
| import javafx.collections.ObservableList; | ||
| import javafx.scene.Node; | ||
|
|
@@ -40,7 +43,29 @@ | |
|
|
||
| public class CSSFX { | ||
| // prevent multiple global starts of CSSFX | ||
| private static boolean isCssFXStarted = false; | ||
| private static boolean isGlobalCssFXStarted = false; | ||
|
|
||
| private static boolean isAnyCssFXStarted = false; | ||
|
|
||
|
|
||
| private static BooleanProperty cssFXStarted = new SimpleBooleanProperty(false); | ||
|
|
||
|
|
||
| /** | ||
| * A property which indicates if CSSFX is started or not. | ||
| * @return the property | ||
| */ | ||
| public static ReadOnlyBooleanProperty cssFXStartedProperty() { | ||
| return cssFXStarted; | ||
| } | ||
|
|
||
| /** | ||
| * @return Indicates if CSSFX is started or not. | ||
| */ | ||
| public static boolean isCSSFXStarted() { | ||
| return cssFXStarted.get(); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Directly start monitoring the CSS of the application using defaults: | ||
|
|
@@ -51,8 +76,8 @@ public class CSSFX { | |
| * @return a Runnable object to stop CSSFX monitoring | ||
| */ | ||
| synchronized public static Runnable start() { | ||
| if(!isCssFXStarted) { | ||
| isCssFXStarted = true; | ||
| if(!isGlobalCssFXStarted) { | ||
| isGlobalCssFXStarted = true; | ||
| return new CSSFXConfig().start(); | ||
| } else { | ||
| return () -> {}; | ||
|
|
@@ -199,11 +224,14 @@ public CSSFXConfig addConverter(URIToPathConverter converter) { | |
| * @return a Runnable object to stop CSSFX monitoring | ||
| */ | ||
| public Runnable start() { | ||
|
|
||
| if(Boolean.getBoolean("cssfx.disable")) { | ||
| System.out.println("CSSFX was not started, because it's disabled via the system property 'cssfx.disable'"); | ||
| return () -> {}; | ||
| } | ||
|
|
||
| cssFXStarted.set(true); | ||
|
|
||
|
Comment on lines
+233
to
+234
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we lack a cleanup of this state change during stop action
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The stop mechanism doesn't really work. |
||
| if (!CSSFXLogger.isInitialized()) { | ||
| if (Boolean.getBoolean("cssfx.log")) { | ||
| LogLevel toActivate = LogLevel.INFO; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the purpose of keeping several states? isn't only one enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isGlobalCssFXStarted prevents starting
CSSFX.start()twice - which would end in twice as many listeners.isAnyCssFXStarted just tells us, whether CSSFX was started in any way.
It's worth noting, that It's not really possible to start CSSFX.