Class DesignerUtil
- java.lang.Object
-
- net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil
-
public final class DesignerUtil extends java.lang.Object
- Since:
- 6.0.0
- Author:
- Clément Fournier
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DESIGNER_DOC_URL
static java.lang.String
DESIGNER_NEW_ISSUE_URL
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addCustomStyleSheets(javafx.scene.Parent target, java.lang.String... styleSheetSimpleName)
static javafx.util.Callback<java.lang.Class<?>,java.lang.Object>
controllerFactoryKnowing(java.lang.Object... controllers)
static javafx.util.BuilderFactory
customBuilderFactory(@NonNull DesignerRoot owner)
static java.lang.String
defaultXPathVersion()
static java.net.URL
getCss(java.lang.String simpleName)
Gets the URL to an css file from its simple name.static java.net.URL
getFxml(java.lang.String simpleName)
Gets the URL to an fxml file from its simple name.static java.util.List<net.sourceforge.pmd.lang.symboltable.NameOccurrence>
getNameOccurrences(net.sourceforge.pmd.lang.symboltable.ScopedNode node)
static java.util.Optional<java.lang.Class<?>>
getResolvedType(net.sourceforge.pmd.lang.ast.Node node)
Attempts to retrieve the type of a java TypeNode reflectively.static java.net.URL
getResource(java.lang.String resRelativeToDesignerDir)
Gets the URL to a file from its simple name.static <T> org.reactfx.value.Var<T>
mapToggleGroupToUserData(javafx.scene.control.ToggleGroup toggleGroup, java.util.function.Supplier<T> defaultValue)
Given a toggle group whose toggles all have user data of type T, maps the selected toggle property to a Var<T>static <T> java.util.Optional<T>
or(java.util.Optional<T> base, java.util.function.Supplier<java.util.Optional<T>> fallback)
Was added in java 9...static void
printShortStackTrace(java.lang.Throwable e)
static void
printShortStackTrace(java.lang.Throwable e, java.io.PrintStream stream)
static <T> org.reactfx.Subscription
rewire(javafx.beans.property.Property<T> underlying, javafx.beans.value.ObservableValue<? extends T> source)
Like rewireInit, with no initialisation.static <T> org.reactfx.Subscription
rewireInit(javafx.beans.property.Property<T> underlying, javafx.beans.property.Property<T> ui)
Like the other overload, using the setter of the ui property.static <T> org.reactfx.Subscription
rewireInit(javafx.beans.property.Property<T> underlying, javafx.beans.value.ObservableValue<? extends T> ui, java.util.function.Consumer<? super T> setter)
Binds the underlying property to a source of values (UI property).static java.lang.String
sanitizeExceptionMessage(java.lang.Throwable exception)
static <T> java.util.Optional<T>
selectFirst(java.util.function.Supplier<java.util.Optional<T>>... opts)
Returns the first non-empty optional in the arguments, or else Optional.empty.static <T> java.util.Set<T>
setOf()
static <T> java.util.Set<T>
setOf(T ts)
static <T> java.util.Set<T>
setOf(T... ts)
static <T> javafx.util.Callback<javafx.scene.control.ListView<T>,javafx.scene.control.ListCell<T>>
simpleListCellFactory(java.util.function.Function<T,java.lang.String> converter, java.util.function.Function<T,java.lang.String> toolTipMaker)
static java.util.Optional<java.lang.String>
stackTraceToXPath(java.lang.String stackTrace)
Works out an xpath query that matches the node which was being visited during the failure.static java.util.Optional<java.lang.String>
stackTraceToXPath(java.lang.Throwable e)
Works out an xpath query that matches the node which was being visited during the failure.static <T> javafx.util.StringConverter<T>
stringConverter(java.util.function.Function<T,java.lang.String> toString, java.util.function.Function<java.lang.String,T> fromString)
static org.reactfx.Subscription
updateProgressOnConsole(java.util.function.Supplier<java.lang.Double> progressGetter)
-
-
-
Field Detail
-
DESIGNER_DOC_URL
public static final java.lang.String DESIGNER_DOC_URL
- See Also:
- Constant Field Values
-
DESIGNER_NEW_ISSUE_URL
public static final java.lang.String DESIGNER_NEW_ISSUE_URL
- See Also:
- Constant Field Values
-
-
Method Detail
-
setOf
public static <T> java.util.Set<T> setOf(T... ts)
-
setOf
public static <T> java.util.Set<T> setOf(T ts)
-
setOf
public static <T> java.util.Set<T> setOf()
-
or
public static <T> java.util.Optional<T> or(java.util.Optional<T> base, java.util.function.Supplier<java.util.Optional<T>> fallback)
Was added in java 9...
-
defaultXPathVersion
public static java.lang.String defaultXPathVersion()
-
getFxml
public static java.net.URL getFxml(java.lang.String simpleName)
Gets the URL to an fxml file from its simple name.- Parameters:
simpleName
- Simple name of the file, i.e. with no directory prefixes or extension- Returns:
- A URL to an fxml file
-
getResource
public static java.net.URL getResource(java.lang.String resRelativeToDesignerDir)
Gets the URL to a file from its simple name.- Returns:
- A URL to a file
-
getCss
public static java.net.URL getCss(java.lang.String simpleName)
Gets the URL to an css file from its simple name.- Parameters:
simpleName
- Simple name of the file, i.e. with no directory prefixes or extension- Returns:
- A URL to a css file
-
addCustomStyleSheets
public static void addCustomStyleSheets(javafx.scene.Parent target, java.lang.String... styleSheetSimpleName)
-
simpleListCellFactory
public static <T> javafx.util.Callback<javafx.scene.control.ListView<T>,javafx.scene.control.ListCell<T>> simpleListCellFactory(java.util.function.Function<T,java.lang.String> converter, java.util.function.Function<T,java.lang.String> toolTipMaker)
-
stringConverter
public static <T> javafx.util.StringConverter<T> stringConverter(java.util.function.Function<T,java.lang.String> toString, java.util.function.Function<java.lang.String,T> fromString)
-
mapToggleGroupToUserData
public static <T> org.reactfx.value.Var<T> mapToggleGroupToUserData(javafx.scene.control.ToggleGroup toggleGroup, java.util.function.Supplier<T> defaultValue)
Given a toggle group whose toggles all have user data of type T, maps the selected toggle property to a Var<T>
-
selectFirst
@SafeVarargs public static <T> java.util.Optional<T> selectFirst(java.util.function.Supplier<java.util.Optional<T>>... opts)
Returns the first non-empty optional in the arguments, or else Optional.empty.
-
rewireInit
public static <T> org.reactfx.Subscription rewireInit(javafx.beans.property.Property<T> underlying, javafx.beans.property.Property<T> ui)
Like the other overload, using the setter of the ui property.
-
rewireInit
public static <T> org.reactfx.Subscription rewireInit(javafx.beans.property.Property<T> underlying, javafx.beans.value.ObservableValue<? extends T> ui, java.util.function.Consumer<? super T> setter)
Binds the underlying property to a source of values (UI property). The UI property is also initialised using a setter.- Type Parameters:
T
- Type of values- Parameters:
underlying
- The underlying propertyui
- The property exposed to the user (the one in this wizard)setter
- Setter to initialise the UI value
-
rewire
public static <T> org.reactfx.Subscription rewire(javafx.beans.property.Property<T> underlying, javafx.beans.value.ObservableValue<? extends T> source)
Like rewireInit, with no initialisation.
-
stackTraceToXPath
public static java.util.Optional<java.lang.String> stackTraceToXPath(java.lang.String stackTrace)
Works out an xpath query that matches the node which was being visited during the failure.The query selects nodes that have exactly the same ancestors than the node in which the last call from the stack trace.
- Parameters:
stackTrace
- full stack trace- Returns:
- An xpath expression if possible
-
printShortStackTrace
public static void printShortStackTrace(java.lang.Throwable e)
-
printShortStackTrace
public static void printShortStackTrace(java.lang.Throwable e, java.io.PrintStream stream)
-
sanitizeExceptionMessage
public static java.lang.String sanitizeExceptionMessage(java.lang.Throwable exception)
-
stackTraceToXPath
public static java.util.Optional<java.lang.String> stackTraceToXPath(java.lang.Throwable e)
Works out an xpath query that matches the node which was being visited during the failure.- Parameters:
e
- Exception- Returns:
- A query, if possible.
- See Also:
stackTraceToXPath(String)
-
getNameOccurrences
public static java.util.List<net.sourceforge.pmd.lang.symboltable.NameOccurrence> getNameOccurrences(net.sourceforge.pmd.lang.symboltable.ScopedNode node)
-
controllerFactoryKnowing
public static javafx.util.Callback<java.lang.Class<?>,java.lang.Object> controllerFactoryKnowing(java.lang.Object... controllers)
-
updateProgressOnConsole
public static org.reactfx.Subscription updateProgressOnConsole(java.util.function.Supplier<java.lang.Double> progressGetter)
-
getResolvedType
public static java.util.Optional<java.lang.Class<?>> getResolvedType(net.sourceforge.pmd.lang.ast.Node node)
Attempts to retrieve the type of a java TypeNode reflectively.
-
customBuilderFactory
public static javafx.util.BuilderFactory customBuilderFactory(@NonNull DesignerRoot owner)
-
-