Package ca.corbett.extras.properties
Class CollapsiblePanelProperty
java.lang.Object
ca.corbett.extras.properties.AbstractProperty
ca.corbett.extras.properties.CollapsiblePanelProperty
This property wraps an empty CollapsiblePanelField and allows you to add
subfields dynamically to it when the property's FormField is created.
Example usage:
// Create a CollapsiblePanelProperty:
CollapsiblePanelProperty panelProp = new CollapsiblePanelProperty("propId", "Panel label", new BorderLayout());
panelProp.setInitiallyExpanded(false); // if you want it to start collapsed (default is expanded)
// Register a FormFieldGenerationListener to populate it with something:
panelProp.addFormFieldGenerationListener((prop, formField) -> {
CollapsiblePanelField panelField = (CollapsiblePanelField) formField;
panelField.setShouldExpandHorizontally(true); // use the width of the parent form panel if you wish
panelField.getPanel().setBorder(BorderFactory.createLoweredBevelBorder()); // override default border if you wish
FormPanel subForm = new FormPanel();
subForm.add(new LabelField("Additional help text goes here."));
subForm.add(new LabelField("You can add whatever static fields you like."));
subForm.add(new LabelField("Images, help text, whatever."));
subForm.add(new LabelField("Just be aware that nothing here gets saved to properties."));
panelField.getPanel().add(subForm, BorderLayout.CENTER);
});
// Now add panelProp to your application properties with the rest of your properties.
// It will get rendered on the application properties dialog automatically!
- Since:
- swing-extras 2.6
- Author:
- scorbo2
-
Field Summary
Fields inherited from class ca.corbett.extras.properties.AbstractProperty
categoryName, DEFAULT_CATEGORY, DEFAULT_PROPERTY_NAME, extraAttributes, fullyQualifiedName, helpText, isEnabled, isExposed, isInitiallyEditable, isInitiallyVisible, marginPadding, propertyLabel, propertyName, subCategoryName -
Constructor Summary
ConstructorsConstructorDescriptionCollapsiblePanelProperty(String id, String fieldLabel) CollapsiblePanelProperty(String id, String fieldLabel, LayoutManager layoutManager) -
Method Summary
Modifier and TypeMethodDescriptionprotected FormFieldDescendant classes must implement this method to generate a FormField associated with this property.booleanMost properties generate FormField instances that allow user input, but we do not:booleanvoidloadFromFormField(FormField field) Populates this Property's value(s) from the given form field, assuming the field is of the correct type.voidloadFromProps(Properties props) Loads the value(s) for this property from the given Properties instance, overwriting any current value.voidsaveToProps(Properties props) Saves the current value(s) of this property to the given Properties instance.setInitiallyExpanded(boolean initiallyExpanded) setLayoutManager(LayoutManager layoutManager) Methods inherited from class ca.corbett.extras.properties.AbstractProperty
addAllExtraAttributes, addBottomPadding, addFormFieldChangeListener, addFormFieldGenerationListener, addInnerPadding, addLeftPadding, addPadding, addRightPadding, addTopPadding, clearExtraAttribute, clearExtraAttributes, equals, fireFormFieldChangedEvent, fireFormFieldGeneratedEvent, generateFormField, generateFormField, getCategoryName, getExtraAttribute, getFullyQualifiedName, getHelpText, getMarginPadding, getPropertyLabel, getPropertyName, getSubCategoryName, hashCode, isEnabled, isExposed, isInitiallyEditable, isInitiallyVisible, removeAllFormFieldChangeListeners, removeAllFormFieldGenerationListeners, removeFormFieldChangeListener, removeFormFieldGenerationListener, setAllExtraAttributes, setEnabled, setExposed, setExtraAttribute, setHelpText, setInitiallyEditable, setInitiallyVisible, setPropertyLabel
-
Constructor Details
-
CollapsiblePanelProperty
-
CollapsiblePanelProperty
-
-
Method Details
-
isAllowsUserInput
public boolean isAllowsUserInput()Most properties generate FormField instances that allow user input, but we do not:- Overrides:
isAllowsUserInputin classAbstractProperty- Returns:
- false, to indicate that we are effectively read-only.
-
getLayoutManager
-
setLayoutManager
-
isInitiallyExpanded
public boolean isInitiallyExpanded() -
setInitiallyExpanded
-
saveToProps
Description copied from class:AbstractPropertySaves the current value(s) of this property to the given Properties instance.- Specified by:
saveToPropsin classAbstractProperty- Parameters:
props- Any Properties instance which will receive the value(s) of this property.
-
loadFromProps
Description copied from class:AbstractPropertyLoads the value(s) for this property from the given Properties instance, overwriting any current value. The current value of this property will be used as a default value in the event that this property does not exist in the given Properties instance.- Specified by:
loadFromPropsin classAbstractProperty- Parameters:
props- Any Properties instance which contains value(s) for this property.
-
generateFormFieldImpl
Description copied from class:AbstractPropertyDescendant classes must implement this method to generate a FormField associated with this property. The generateFormField() method in this class will call this abstract method to create the FormField, which will then be augmented with our fully qualified name, read-only state, help text, and extra attributes.- Specified by:
generateFormFieldImplin classAbstractProperty- Returns:
- A FormField associated with this property.
-
loadFromFormField
Description copied from class:AbstractPropertyPopulates this Property's value(s) from the given form field, assuming the field is of the correct type.- Specified by:
loadFromFormFieldin classAbstractProperty- Parameters:
field- The FormField containing a value for this property.
-