Module com.gluonhq.charm.glisten
Class OptionBase<T>
- java.lang.Object
-
- com.gluonhq.charm.glisten.control.settings.OptionBase<T>
-
- Type Parameters:
T
- The type of the property of the OptionBase value
- All Implemented Interfaces:
Option<T>
- Direct Known Subclasses:
DefaultOption
public abstract class OptionBase<T> extends Object implements Option<T>
A wrapper interface for a single option to be displayed in aSettingsPane
control.Typically it contains:
- An optional graphic icon on the left
- A caption
- By default, an editor for viewing and modifying the
Property
associated to thisOption
But this can be modified:
- If
getExtendedDescription()
returns a non empty extended description, the editor and this description will be shown in a secondaryView
- If
getChildren()
is not empty, the observable list ofoptions
will be shown in a secondaryView
- Since:
- 2.0.0
-
-
Field Summary
Fields Modifier and Type Field Description protected String
caption
Private fieldsprotected String
category
protected ObservableList<Option>
children
protected String
description
protected Function<Option<T>,OptionEditor<T>>
editorFactory
protected String
extendedDescription
protected Node
graphic
protected boolean
isEditable
protected Orientation
layout
protected StringConverter<T>
stringConverter
protected Property<T>
value
-
Constructor Summary
Constructors Modifier Constructor Description protected
OptionBase(String caption)
Creates an option instance, without graphic and without editor.protected
OptionBase(String caption, String description, String category)
Creates an option instance, without graphic and without editor, intended to open a new view with a new group of sub-options, that are set callingOption.getChildren()
protected
OptionBase(String caption, String description, String category, Property<T> value, boolean isEditable)
Creates an option instance, without graphic and with default editor, based on the values set for the optionprotected
OptionBase(String caption, String description, String category, Property<T> value, boolean isEditable, Function<Option<T>,OptionEditor<T>> editorFactory)
Creates an option instance, without graphic and with custom editor, based on the values set for the optionprotected
OptionBase(Node graphic, String caption, String description, String category)
Creates an option instance, with graphic and without editor, intended to open a new view with a new group of sub-options, that are set callingOption.getChildren()
protected
OptionBase(Node graphic, String caption, String description, String category, Property<T> value, boolean isEditable)
Creates an option instance, with graphic and with default editor, based on the values set for the optionprotected
OptionBase(Node graphic, String caption, String description, String category, Property<T> value, boolean isEditable, Function<Option<T>,OptionEditor<T>> editorFactory)
Creates an option instance, with graphic and with custom editor, based on the values set for the option
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Optional<Function<Option<T>,OptionEditor<T>>>
editorFactoryProperty()
Returns anOptional
of aFunction
that returns an instance of theOptionEditor
that should be used for editing thisOption
String
getCaption()
Returns the display name of the property associated to theOption
or the name associated to the group of options.String
getCategory()
Returns aString
representation of the category of the property.ObservableList<Option>
getChildren()
Returns theObservableList
ofsub-options
that a given option contains.String
getDescription()
AString
that will be shown to the user as a tooltip.Optional<String>
getExtendedDescription()
A longString
that will be shown to the user in an extended view.Optional<Node>
getGraphic()
Returns anOptional
with the node that will be displayed as a graphic on the left side of the option if not emptyString
getId()
Gets the value of the property id.Orientation
getLayout()
Returns theOrientation
of theOption
, that defines its layout:Orientation.HORIZONTAL
sets an horizontal layout, with an optional graphic on the left, caption and description on the center, and editor on the right.Optional<StringConverter<T>>
getStringConverter()
Returns anOptional
of aStringConverter
that can be applied to the valueStringProperty
idProperty()
The id of thisOption
.boolean
isEditable()
Indicates whether theSettingsPane
control should allow editing this option, or whether it is read-only.void
setExtendedDescription(String value)
void
setId(String id)
Sets the value of the property id.void
setLayout(Orientation layout)
Defines the type of layout to apply to theOption
void
setStringConverter(StringConverter value)
Sets theStringConverter
that can be applied to the used to convert the value of the underlayingProperty
of this optionabstract Property<T>
valueProperty()
Returns the underlyingProperty
, where one exists, that the editor can monitor for changes.static <T> Property<T>
valueProperty(T value)
Allows wrapping primitives into a read-onlyProperty
-
-
-
Property Detail
-
value
public abstract Property<T> valueProperty
Returns the underlyingProperty
, where one exists, that the editor can monitor for changes.- Specified by:
valueProperty
in interfaceOption<T>
-
id
public final StringProperty idProperty
The id of thisOption
. This simple string identifier is useful for finding a specific Option within the scene graph. While the id of a Option should be unique within the scene graph, this uniqueness is not enforced. This is analogous to the "id" attribute on an HTML element (CSS ID Specification).For example, if a Option is given the id of "myId", then the lookup method can be used to find this option as follows:
scene.lookup("#myId");
.- Default value:
- null
- Since:
- 4.2.0
- See Also:
getId()
,setId(String)
-
-
Field Detail
-
caption
protected String caption
Private fields
-
description
protected String description
-
category
protected String category
-
graphic
protected Node graphic
-
isEditable
protected boolean isEditable
-
editorFactory
protected Function<Option<T>,OptionEditor<T>> editorFactory
-
extendedDescription
protected String extendedDescription
-
children
protected ObservableList<Option> children
-
stringConverter
protected StringConverter<T> stringConverter
-
layout
protected Orientation layout
-
-
Constructor Detail
-
OptionBase
protected OptionBase(String caption)
Creates an option instance, without graphic and without editor. Using the captionOption.SEPARATOR
will create a Separator. Otherwise it will create an empty option- Parameters:
caption
- aString
, usuallyOption.SEPARATOR
-
OptionBase
protected OptionBase(String caption, String description, String category)
Creates an option instance, without graphic and without editor, intended to open a new view with a new group of sub-options, that are set callingOption.getChildren()
-
OptionBase
protected OptionBase(Node graphic, String caption, String description, String category)
Creates an option instance, with graphic and without editor, intended to open a new view with a new group of sub-options, that are set callingOption.getChildren()
-
OptionBase
protected OptionBase(String caption, String description, String category, Property<T> value, boolean isEditable)
Creates an option instance, without graphic and with default editor, based on the values set for the option
-
OptionBase
protected OptionBase(String caption, String description, String category, Property<T> value, boolean isEditable, Function<Option<T>,OptionEditor<T>> editorFactory)
Creates an option instance, without graphic and with custom editor, based on the values set for the option- Parameters:
caption
- aString
a short namedescription
- aString
more descriptivecategory
- aString
indicating the category, in case the option belongs to a groupvalue
- the underlyingProperty
that the editor can monitor for changesisEditable
- if the option is editable or read-onlyeditorFactory
- aFunction
that returns a validOptionEditor
for editing thisOption
-
OptionBase
protected OptionBase(Node graphic, String caption, String description, String category, Property<T> value, boolean isEditable)
Creates an option instance, with graphic and with default editor, based on the values set for the option- Parameters:
graphic
- aNode
with a graphiccaption
- aString
a short namedescription
- aString
more descriptivecategory
- aString
indicating the category, in case the option belongs to a groupvalue
- the underlyingProperty
that the editor can monitor for changesisEditable
- if the option is editable or read-only
-
OptionBase
protected OptionBase(Node graphic, String caption, String description, String category, Property<T> value, boolean isEditable, Function<Option<T>,OptionEditor<T>> editorFactory)
Creates an option instance, with graphic and with custom editor, based on the values set for the option- Parameters:
graphic
- aNode
with a graphiccaption
- aString
a short namedescription
- aString
more descriptivecategory
- aString
indicating the category, in case the option belongs to a groupvalue
- the underlyingProperty
that the editor can monitor for changesisEditable
- if the option is editable or read-onlyeditorFactory
- aFunction
that returns a validOptionEditor
for editing thisOption
-
-
Method Detail
-
getGraphic
public Optional<Node> getGraphic()
Returns anOptional
with the node that will be displayed as a graphic on the left side of the option if not empty- Specified by:
getGraphic
in interfaceOption<T>
- Returns:
Optional
with aNode
if not empty
-
getCaption
public String getCaption()
Returns the display name of the property associated to theOption
or the name associated to the group of options. It should be short (i.e. less than two words). This is used to explain to the end user what the option represents.- Specified by:
getCaption
in interfaceOption<T>
- Returns:
String
with the name or caption of theOption
-
getDescription
public String getDescription()
AString
that will be shown to the user as a tooltip. This allows for a longer form of detail than what is possible with theOption.getCaption()
method.- Specified by:
getDescription
in interfaceOption<T>
- Returns:
String
with the description of theOption
-
getExtendedDescription
public Optional<String> getExtendedDescription()
A longString
that will be shown to the user in an extended view. This allows for a longer form of detail than what is possible with theOption.getCaption()
method.- Specified by:
getExtendedDescription
in interfaceOption<T>
- Returns:
String
with an extended description of theOption
if not empty
-
setExtendedDescription
public void setExtendedDescription(String value)
- Parameters:
value
- aString
with a long description
-
getCategory
public String getCategory()
Returns aString
representation of the category of the property. This is relevant when properties with the same category can be grouped together visually.- Specified by:
getCategory
in interfaceOption<T>
- Returns:
String
with the category of theOption
-
valueProperty
public abstract Property<T> valueProperty()
Returns the underlyingProperty
, where one exists, that the editor can monitor for changes.- Specified by:
valueProperty
in interfaceOption<T>
-
editorFactoryProperty
public Optional<Function<Option<T>,OptionEditor<T>>> editorFactoryProperty()
Returns anOptional
of aFunction
that returns an instance of theOptionEditor
that should be used for editing thisOption
- Specified by:
editorFactoryProperty
in interfaceOption<T>
- Returns:
- an
Optional
of aFunction
, if not empty
-
isEditable
public boolean isEditable()
Indicates whether theSettingsPane
control should allow editing this option, or whether it is read-only.- Specified by:
isEditable
in interfaceOption<T>
- Returns:
- boolean if the control is editable or not
-
getChildren
public ObservableList<Option> getChildren()
Returns theObservableList
ofsub-options
that a given option contains.- Specified by:
getChildren
in interfaceOption<T>
- Returns:
ObservableList
withoptions
-
setStringConverter
public void setStringConverter(StringConverter value)
Sets theStringConverter
that can be applied to the used to convert the value of the underlayingProperty
of this option- Parameters:
value
- theStringConverter
-
getStringConverter
public Optional<StringConverter<T>> getStringConverter()
Returns anOptional
of aStringConverter
that can be applied to the value- Specified by:
getStringConverter
in interfaceOption<T>
- Returns:
Optional
with aStringConverter
if not empty
-
valueProperty
public static <T> Property<T> valueProperty(T value)
Allows wrapping primitives into a read-onlyProperty
- Type Parameters:
T
- The primitive type- Parameters:
value
- The value to be set- Returns:
- the wrapper read-only
Property
-
getLayout
public Orientation getLayout()
Returns theOrientation
of theOption
, that defines its layout:-
Orientation.HORIZONTAL
sets an horizontal layout, with an optional graphic on the left, caption and description on the center, and editor on the right. Orientation.VERTICAL
sets a vertical layout, with an optional graphic on the left, caption on top and editor on bottom.
Orientation.HORIZONTAL
- Specified by:
getLayout
in interfaceOption<T>
- Returns:
Orientation
that indicates the layout of theOption
-
-
setLayout
public void setLayout(Orientation layout)
Defines the type of layout to apply to theOption
- Parameters:
layout
- theOrientation
type
-
idProperty
public final StringProperty idProperty()
The id of thisOption
. This simple string identifier is useful for finding a specific Option within the scene graph. While the id of a Option should be unique within the scene graph, this uniqueness is not enforced. This is analogous to the "id" attribute on an HTML element (CSS ID Specification).For example, if a Option is given the id of "myId", then the lookup method can be used to find this option as follows:
scene.lookup("#myId");
.- Default value:
- null
- Since:
- 4.2.0
- See Also:
getId()
,setId(String)
-
setId
public final void setId(String id)
Sets the value of the property id.- Property description:
- The id of this
Option
. This simple string identifier is useful for finding a specific Option within the scene graph. While the id of a Option should be unique within the scene graph, this uniqueness is not enforced. This is analogous to the "id" attribute on an HTML element (CSS ID Specification).For example, if a Option is given the id of "myId", then the lookup method can be used to find this option as follows:
scene.lookup("#myId");
. - Default value:
- null
- Since:
- 4.2.0
-
getId
public final String getId()
Gets the value of the property id.- Property description:
- The id of this
Option
. This simple string identifier is useful for finding a specific Option within the scene graph. While the id of a Option should be unique within the scene graph, this uniqueness is not enforced. This is analogous to the "id" attribute on an HTML element (CSS ID Specification).For example, if a Option is given the id of "myId", then the lookup method can be used to find this option as follows:
scene.lookup("#myId");
. - Default value:
- null
- Since:
- 4.2.0
-
-