|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.joseluismartin.gui.AbstractView<T>
public abstract class AbstractView<T>
Template class that simplifies View implementation.
The central method is buildPanel that builds the JComponent
that hold the view controls. You may use custom binding of the view overwriting the methods
doUpdate and doRefresh.
For common binding code, you usually use autobinding facitility, that is, using
the same name to the field control and model property name, and setting autobinding to true.
When using autobinding, you may exclude model properties from binding using some
of ignoreProperty methods.
Manual binding is also supported via bind methods. When binding a control, a
StateChangeListener is added to the control for setting dirty property on control
changes.
Only org.springframework.util.validation.Validator validators are supported
The validateView method calls configured
ErrorProcessors to process errors found in validation.
BinderFactory,
ControlAccessorFactory,
ErrorProcessor| Field Summary | |
|---|---|
static String |
DEFAULT_BINDER_FACTORY_NAME
|
protected org.springframework.validation.BindingResult |
errors
Validation Errors |
protected int |
height
|
protected org.springframework.context.MessageSource |
messageSource
message source for internationalization |
protected int |
width
|
| Constructor Summary | |
|---|---|
AbstractView()
Default ctor |
|
AbstractView(T model)
Create the view and set the model |
|
| Method Summary | |
|---|---|
void |
addView(View<T> view)
Add a subview, the subview is refreshed, updated and hold the same model that this view, for adding views with other models, use bind() |
void |
autobind()
Bind Controls with the same name that a property in the model. |
void |
bind(Object component,
String propertyName)
add a binding for control and model property name |
void |
bind(Object component,
String propertyName,
boolean readOnly)
add a binding for control and model property name |
protected abstract JComponent |
buildPanel()
Build the JComponent that hold controls. |
void |
clear()
Reset view state to default values |
void |
controlChange(ControlEvent e)
Notify that the value of the control has changed |
protected void |
doRefresh()
Callback method for refresh() |
protected void |
doUpdate()
Callback method on update() |
void |
enableView(boolean enabled)
Enable/Disable All controls |
PropertyBinder |
getBinder(String propertyName)
Lookup for a binder by property name |
BinderFactory |
getBinderFactory()
Gets the binder factory |
org.springframework.validation.BindingResult |
getBindingResult()
Get binding result |
ControlAccessorFactory |
getControlAccessorFactory()
|
String |
getErrorMessage()
Build a error message with all errors. |
List<ErrorProcessor> |
getErrorProcessors()
|
int |
getHeight()
|
Set<String> |
getIgnoredProperties()
|
protected String |
getMessage(org.springframework.context.MessageSourceResolvable msr)
I18n Support |
protected String |
getMessage(String code)
I18n Support |
org.springframework.context.MessageSource |
getMessageSource()
|
T |
getModel()
Gets model |
String |
getName()
Gets the view name |
JComponent |
getPanel()
Gets the view JComponent |
org.springframework.validation.Validator |
getValidator()
|
int |
getWidth()
|
void |
ignoreProperties(Collection<? extends String> c)
Add a Collection of property names to ignore on binding |
void |
ignoreProperty(String propertyName)
Add a property name to ignore on binding. |
boolean |
isAutobinding()
|
boolean |
isDirty()
Check if user change any controls of view |
void |
listen(Object control)
Listen control for changes. |
protected void |
onSetModel(T model)
Callback method to handle model changes |
void |
refresh()
Update Component from model |
void |
setAutobinding(boolean autobinding)
|
void |
setBinderFactory(BinderFactory binderFactory)
Sets the binder factory, propagate it to composite binder. |
void |
setControlAccessorFactory(ControlAccessorFactory controlAccessorFactory)
|
void |
setDirty(boolean dirty)
|
void |
setErrorProcessors(List<ErrorProcessor> errorProcessors)
|
void |
setHeight(int height)
|
void |
setIgnoredProperties(Set<String> ignoredProperties)
|
void |
setMessageSource(org.springframework.context.MessageSource messageSource)
|
void |
setModel(T model)
Sets model |
void |
setName(String name)
|
void |
setValidator(org.springframework.validation.Validator validator)
|
void |
setWidth(int width)
|
void |
update()
Update Model from Component |
boolean |
validateView()
validate model |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_BINDER_FACTORY_NAME
@Autowired protected org.springframework.context.MessageSource messageSource
protected org.springframework.validation.BindingResult errors
protected int width
protected int height
| Constructor Detail |
|---|
public AbstractView()
public AbstractView(T model)
model - model to set| Method Detail |
|---|
public void bind(Object component,
String propertyName,
boolean readOnly)
component - controlpropertyName - the model property path to bindreadOnly - if true, binding only do refresh()
public void bind(Object component,
String propertyName)
component - controlpropertyName - the model property path to bindpublic JComponent getPanel()
getPanel in interface View<T>protected abstract JComponent buildPanel()
public T getModel()
getModel in interface ModelHolder<T>public final void setModel(T model)
setModel in interface ModelHolder<T>protected void onSetModel(T model)
model - the new modelpublic final void update()
update in interface Binder<T>protected void doUpdate()
public void addView(View<T> view)
view - public final void refresh()
refresh in interface Binder<T>protected void doRefresh()
public void listen(Object control)
public void controlChange(ControlEvent e)
controlChange in interface ControlChangeListenere - ControlEvent with control change infopublic BinderFactory getBinderFactory()
public void setBinderFactory(BinderFactory binderFactory)
binderFactory - to setpublic boolean validateView()
validateView in interface View<T>public String getErrorMessage()
getErrorMessage in interface View<T>public void clear()
clear in interface View<T>public void enableView(boolean enabled)
enableView in interface View<T>public void autobind()
protected String getMessage(String code)
code - message code
protected String getMessage(org.springframework.context.MessageSourceResolvable msr)
msr - message source resolvable
public void ignoreProperty(String propertyName)
propertyName - property name to ignorepublic Set<String> getIgnoredProperties()
public void setIgnoredProperties(Set<String> ignoredProperties)
ignoredProperties - the ignoredProperties to setpublic void ignoreProperties(Collection<? extends String> c)
c - Collection of property names.public org.springframework.validation.Validator getValidator()
public void setValidator(org.springframework.validation.Validator validator)
validator - the validator to setpublic org.springframework.context.MessageSource getMessageSource()
public void setMessageSource(org.springframework.context.MessageSource messageSource)
messageSource - the messageSource to setpublic int getWidth()
public void setWidth(int width)
width - the width to setpublic int getHeight()
public void setHeight(int height)
height - the height to setpublic String getName()
View
getName in interface View<T>public void setName(String name)
name - the name to setpublic List<ErrorProcessor> getErrorProcessors()
public void setErrorProcessors(List<ErrorProcessor> errorProcessors)
errorProcessors - the errorProcessors to setpublic boolean isDirty()
View
isDirty in interface View<T>public void setDirty(boolean dirty)
dirty - the dirty to setpublic ControlAccessorFactory getControlAccessorFactory()
public void setControlAccessorFactory(ControlAccessorFactory controlAccessorFactory)
controlAccessorFactory - the controlAccessorFactory to setpublic boolean isAutobinding()
public void setAutobinding(boolean autobinding)
autobinding - the autobinding to setpublic org.springframework.validation.BindingResult getBindingResult()
getBindingResult in interface Binder<T>public PropertyBinder getBinder(String propertyName)
getBinder in interface BinderHolderpropertyName - property name
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||