public class BeansBindingProcessor extends Object implements AdvancedWidgetProcessor<JComponent,SwingMetawidget>, BindingConverter
This implementation recognizes the following SwingMetawidget.setParameter
parameters:
UpdateStrategy.class
- as defined by
org.jdesktop.beansbinding.AutoBinding.UpdateStrategy
. Defaults to
READ_ONCE
. If set to READ
or READ_WRITE
, the object being
inspected must provide PropertyChangeSupport
. If set to READ
, there is
no need to call BeansBindingProcessor.rebind
. If set to READ_WRITE
,
there is no need to call BeansBindingProcessor.save
.
Note: BeansBinding
does not bind actions, such as invoking a method when a
JButton
is pressed. For that, see ReflectionBindingProcessor
and
MetawidgetActionStyle
or SwingAppFrameworkActionStyle
.
Modifier and Type | Class and Description |
---|---|
protected static class |
BeansBindingProcessor.State
Simple, lightweight structure for saving state.
|
Constructor and Description |
---|
BeansBindingProcessor() |
BeansBindingProcessor(BeansBindingProcessorConfig config) |
Modifier and Type | Method and Description |
---|---|
Object |
convertFromString(String value,
Class<?> expectedType)
Convert the given String to the given expected type, if possible.
|
protected <S,V,W> org.jdesktop.beansbinding.Converter<V,W> |
getConverter(org.jdesktop.beansbinding.BeanProperty<S,V> propertySource,
S source,
Class<W> targetClass,
Map<String,String> attributes)
Get a converter for the given source class.
|
protected BeansBindingProcessor.State |
getState(SwingMetawidget metawidget) |
void |
onEndBuild(SwingMetawidget metawidget)
Event called at the end of widget building, after all widgets have been built and added to
the
Layout . |
void |
onStartBuild(SwingMetawidget metawidget)
Event called at the start of the widget building process, before the
WidgetBuilder is called. |
protected <S,V,T extends Component,W> |
processBinding(org.jdesktop.beansbinding.Binding<S,V,T,W> binding,
SwingMetawidget metawidget)
Process the given Binding prior to calling
binding.bind() . |
JComponent |
processWidget(JComponent component,
String elementName,
Map<String,String> attributes,
SwingMetawidget metawidget)
Process the given widget.
|
void |
rebind(Object toRebind,
SwingMetawidget metawidget)
Rebinds the Metawidget to the given Object.
|
void |
save(SwingMetawidget metawidget) |
protected <S,V,T extends Component,W> |
typesafeAdd(T component,
String elementName,
Map<String,String> attributes,
SwingMetawidget metawidget) |
public BeansBindingProcessor()
public BeansBindingProcessor(BeansBindingProcessorConfig config)
public void onStartBuild(SwingMetawidget metawidget)
AdvancedWidgetProcessor
WidgetBuilder
is called. WidgetProcessor
s may wish to act on this
event to initialize themselves ready for processing. This event is only called once per
inspection, not once per widget built.onStartBuild
in interface AdvancedWidgetProcessor<JComponent,SwingMetawidget>
metawidget
- the parent Metawidget. Never nullpublic JComponent processWidget(JComponent component, String elementName, Map<String,String> attributes, SwingMetawidget metawidget)
WidgetProcessor
WidgetBuilder
, and before it is added to the Layout
.processWidget
in interface WidgetProcessor<JComponent,SwingMetawidget>
component
- the widget to process. Never nullelementName
- XML node name of the business field. Typically 'entity', 'property' or 'action'.
Never nullattributes
- attributes of the widget to process. Never null. This Map is modifiable - changes
will be passed to subsequent WidgetProcessors and Layoutsmetawidget
- the parent Metawidget. Never nullpublic void rebind(Object toRebind, SwingMetawidget metawidget)
This method is an optimization that allows clients to load a new object into the binding without calling setToInspect, and therefore without reinspecting the object or recreating the components. It is the client's responsbility to ensure the rebound object is compatible with the original setToInspect.
public void save(SwingMetawidget metawidget)
public Object convertFromString(String value, Class<?> expectedType)
BindingConverter
convertFromString
in interface BindingConverter
public void onEndBuild(SwingMetawidget metawidget)
AdvancedWidgetProcessor
Layout
. WidgetProcessor
s may wish to act on this event to clean
themselves up after processing. This event is only called once per inspection, not once per
widget built.onEndBuild
in interface AdvancedWidgetProcessor<JComponent,SwingMetawidget>
metawidget
- the parent Metawidget. Never nullprotected <S,V,T extends Component,W> org.jdesktop.beansbinding.Binding<S,V,T,W> processBinding(org.jdesktop.beansbinding.Binding<S,V,T,W> binding, SwingMetawidget metawidget)
binding.bind()
. Source, target and
converters will have already been initialized.
Clients can subclass this WidgetProcessor
and override this method to manipulate
the binding, for example to add a BindingListener
.
metawidget
- the owning Metawidget. May be useful for clientsprotected <S,V,T extends Component,W> org.jdesktop.beansbinding.Binding typesafeAdd(T component, String elementName, Map<String,String> attributes, SwingMetawidget metawidget)
protected <S,V,W> org.jdesktop.beansbinding.Converter<V,W> getConverter(org.jdesktop.beansbinding.BeanProperty<S,V> propertySource, S source, Class<W> targetClass, Map<String,String> attributes)
attributes
- the attributes of the given business property. May be useful if you want to
lookup, say, 'actual-class'protected BeansBindingProcessor.State getState(SwingMetawidget metawidget)
Copyright © 2015. All Rights Reserved.