Package se.datadosen.util
Class MapBinder
java.lang.Object
se.datadosen.util.MapBinder
Utility class for synchronizing a Swing GUI with a Map object. Synchronization is performed when calling getMap() and
syncUI(). Matching is done where the name of a map key corresponds to the name of a GUI element. Currently handles
JText components, JCheckBox, JComboBox and JColorSelector
This is a successor to PropertyBinder that keeps the datatypes of component values instead of converting all to strings like PropertyBinder does Copyright (c) 2003, David Ekholm Datadosen
This is a successor to PropertyBinder that keeps the datatypes of component values instead of converting all to strings like PropertyBinder does Copyright (c) 2003, David Ekholm Datadosen
- Since:
- 8.8.1
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Add support for other component types -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetMap
(JComponentHolder jComponentHolder) Read properties from a UI.getMap
(JComponentHolder jComponentHolder, Map<String, Object> existing) Read properties from a UI.static MapBinder.ComponentBinder
registerComponentBinder
(Class componentClass, MapBinder.ComponentBinder binder) Add support for other component types (subclasses of JComponent)static void
syncUI
(Map<String, Object> props, JComponentHolder jComponentHolder) Update a UI from a Map object.
-
Constructor Details
-
MapBinder
public MapBinder()
-
-
Method Details
-
getMap
Read properties from a UI.- Parameters:
jComponentHolder
- object containing Swing type member variables/components- Returns:
- A property object where the keys have the same names as the member components
-
getMap
public static Map<String,Object> getMap(JComponentHolder jComponentHolder, Map<String, Object> existing) Read properties from a UI.- Parameters:
jComponentHolder
- object containing Swing type member variables/componentsexisting
- Properties object to add properties to- Returns:
- A property object where the keys have the same names as the member components
- Throws:
RuntimeException
-
syncUI
Update a UI from a Map object.- Parameters:
props
- Properties to pass to UIjComponentHolder
- object containing Swing type member variables/components to be synchronized.- Throws:
RuntimeException
-
registerComponentBinder
public static MapBinder.ComponentBinder registerComponentBinder(Class componentClass, MapBinder.ComponentBinder binder) Add support for other component types (subclasses of JComponent)- Parameters:
componentClass
-binder
-- Returns:
- Since:
- 8.4
-