- java.lang.Object
-
- org.controlsfx.property.BeanProperty
-
- All Implemented Interfaces:
PropertySheet.Item
public class BeanProperty extends Object implements PropertySheet.Item
A convenience class for creating aPropertySheet.Item
for use in thePropertySheet
control based on a property belonging to a JavaBean - simply provide aPropertyDescriptor
and the rest will be taken care of automatically.- See Also:
PropertySheet.Item
,PropertySheet
,PropertyDescriptor
-
-
Field Summary
Fields Modifier and Type Field Description static String
CATEGORY_LABEL_KEY
Unique identifier to provide a custom category label withinPropertySheet.Item.getCategory()
.
-
Constructor Summary
Constructors Constructor Description BeanProperty(Object bean, PropertyDescriptor propertyDescriptor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getBean()
String
getCategory()
Returns a String representation of the category of the property.String
getDescription()
A String that will be shown to the user as a tooltip.String
getName()
Returns the display name of the property, which should be short (i.e.Optional<ObservableValue<? extends Object>>
getObservableValue()
Returns the underlying ObservableValue, where one exists, that the editor can monitor for changes.PropertyDescriptor
getPropertyDescriptor()
Optional<Class<? extends PropertyEditor<?>>>
getPropertyEditorClass()
Returns an Optional wrapping the class of the PropertyEditor that should be used for editing this item.Class<?>
getType()
Returns the class type of the property.Object
getValue()
Returns the current value of the property.boolean
isEditable()
Indicates whether the PropertySheet should allow editing of this property, or whether it is read-only.void
setEditable(boolean editable)
void
setValue(Object value)
Sets the current value of the property.
-
-
-
Field Detail
-
CATEGORY_LABEL_KEY
public static final String CATEGORY_LABEL_KEY
Unique identifier to provide a custom category label withinPropertySheet.Item.getCategory()
. How to use it: with a PropertyDescriptor, provide the custom category through a a named attributeFeatureDescriptor.setValue(String, Object)
.final PropertyDescriptor propertyDescriptor = new PropertyDescriptor("yourProperty", YourBean.class); propertyDescriptor.setDisplayName("Your Display Name"); propertyDescriptor.setShortDescription("Your explanation about this property."); // then provide a custom category propertyDescriptor.setValue(BeanProperty.CATEGORY_LABEL_KEY, "Your custom category");
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BeanProperty
public BeanProperty(Object bean, PropertyDescriptor propertyDescriptor)
-
-
Method Detail
-
getName
public String getName()
Returns the display name of the property, which should be short (i.e. less than two words). This is used to explain to the end user what the property represents and is displayed beside thePropertyEditor
. If you need to explain more detail to the user, consider placing it in thePropertySheet.Item.getDescription()
.- Specified by:
getName
in interfacePropertySheet.Item
-
getDescription
public String getDescription()
A String that will be shown to the user as a tooltip. This allows for a longer form of detail than what is possible with thePropertySheet.Item.getName()
method.- Specified by:
getDescription
in interfacePropertySheet.Item
-
getType
public Class<?> getType()
Returns the class type of the property.- Specified by:
getType
in interfacePropertySheet.Item
-
getValue
public Object getValue()
Returns the current value of the property.- Specified by:
getValue
in interfacePropertySheet.Item
-
setValue
public void setValue(Object value)
Sets the current value of the property.- Specified by:
setValue
in interfacePropertySheet.Item
-
getCategory
public String getCategory()
Returns a String representation of the category of the property. This is relevant when thePropertySheet
mode property
is set toPropertySheet.Mode.CATEGORY
- as then all properties with the same category will be grouped together visually.- Specified by:
getCategory
in interfacePropertySheet.Item
-
getBean
public Object getBean()
- Returns:
- The object passed in to the constructor of the BeanProperty.
-
getPropertyDescriptor
public PropertyDescriptor getPropertyDescriptor()
- Returns:
- The
PropertyDescriptor
passed in to the constructor of the BeanProperty.
-
getPropertyEditorClass
public Optional<Class<? extends PropertyEditor<?>>> getPropertyEditorClass()
Returns an Optional wrapping the class of the PropertyEditor that should be used for editing this item. The default implementation returns Optional.empty() The class must have a constructor that can accept a single argument of type PropertySheet.Item- Specified by:
getPropertyEditorClass
in interfacePropertySheet.Item
-
isEditable
public boolean isEditable()
Indicates whether the PropertySheet should allow editing of this property, or whether it is read-only. The default implementation returns true.- Specified by:
isEditable
in interfacePropertySheet.Item
-
setEditable
public void setEditable(boolean editable)
- Parameters:
editable
- Whether this property should be editable in the PropertySheet.
-
getObservableValue
public Optional<ObservableValue<? extends Object>> getObservableValue()
Returns the underlying ObservableValue, where one exists, that the editor can monitor for changes.- Specified by:
getObservableValue
in interfacePropertySheet.Item
-
-