Java Doc for PropertyConnector.java in  » Swing-Library » jgoodies-data-binding » com » jgoodies » binding » beans » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » jgoodies data binding » com.jgoodies.binding.beans 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.jgoodies.binding.beans.PropertyConnector

PropertyConnector
final public class PropertyConnector (Code)
Keeps two Java Bean properties in synch. This connector supports bound and unbound, read-only and read-write properties. Write-only properties are not supported; connecting two read-only properties won't work; connecting two unbound properties doesn't make sense.

If one of the bean properties fires a property change, this connector will set the other to the same value. If a bean property is read-only, the PropertyConnector will not listen to the other bean's property and so won't update the read-only property. And if a bean does not provide support for bound properties, it won't be observed. The properties must be single value bean properties as described by the Java Bean Secification.

Constraints: the properties must be type compatible, i. e. values returned by one reader must be accepted by the other's writer, and vice versa.

Examples:

 // Connects a ValueModel and a JFormattedTextField
 JFormattedTextField textField = new JFormattedTextField();
 textField.setEditable(editable);
 PropertyConnector connector =
 new PropertyConnector(valueModel, "value", textField, "value");
 connector.updateProperty2();
 // Connects the boolean property "selectable" with a component enablement
 JComboBox comboBox = new JComboBox();
 ...
 new PropertyConnector(mainModel, "selectable", comboBox, "enabled");
 

author:
   Karsten Lentzsch
version:
   $Revision: 1.16 $
See Also:   PropertyChangeEvent
See Also:   PropertyChangeListener
See Also:   PropertyDescriptor




Method Summary
public static  PropertyConnectorconnect(Object bean1, String property1Name, Object bean2, String property2Name)
     Synchronizes the two bound bean properties as specified by the given pairs of bean and associated property name.
public static  voidconnectAndUpdate(ValueModel valueModel, Object bean2, String property2Name)
     Synchronizes the ValueModel with the specified bound bean property, and updates the bean immediately. If the ValueModel changes, it updates Bean2#property2Name and vice versa.
public  ObjectgetBean1()
     Returns the Java Bean that holds the first property.
public  ObjectgetBean2()
     Returns the Java Bean that holds the first property.
public  StringgetProperty1Name()
     Returns the name of the first Java Bean property.
public  StringgetProperty2Name()
     Returns the name of the second Java Bean property.
public  voidrelease()
     Removes the PropertyChangeHandler from the observed bean, if the bean is not null and if property changes are not observed.
public  voidupdateProperty1()
     Reads the value of the second bean property and sets it as new value of the first bean property.
public  voidupdateProperty2()
     Reads the value of the first bean property and sets it as new value of the second bean property.



Method Detail
connect
public static PropertyConnector connect(Object bean1, String property1Name, Object bean2, String property2Name)(Code)
Synchronizes the two bound bean properties as specified by the given pairs of bean and associated property name. If Bean1#property1Name changes it updates Bean2#property2Name and vice versa. If a bean does not provide support for bound properties, changes will not be observed. If a bean property is read-only, this connector won't listen to the other bean's property and so won't update the read-only property.

Returns the PropertyConnector that is required if one or the other property shall be updated.
Parameters:
  bean1 - the bean that owns the first property
Parameters:
  property1Name - the name of the first property
Parameters:
  bean2 - the bean that owns the second property
Parameters:
  property2Name - the name of the second property the PropertyConnector used to synchronize the properties,required if property1 or property2 shall be updated
throws:
  NullPointerException - if a bean or property name is null
throws:
  IllegalArgumentException - if the beans are identical andthe property name are equal




connectAndUpdate
public static void connectAndUpdate(ValueModel valueModel, Object bean2, String property2Name)(Code)
Synchronizes the ValueModel with the specified bound bean property, and updates the bean immediately. If the ValueModel changes, it updates Bean2#property2Name and vice versa. If the bean doesn't provide support for bound properties, changes will not be observed. If the bean property is read-only, this connector will not listen to the ValueModel and so won't update the read-only property.
Parameters:
  valueModel - the ValueModel that provides a bound value
Parameters:
  bean2 - the bean that owns the second property
Parameters:
  property2Name - the name of the second property
throws:
  NullPointerException - if the ValueModel, bean or property name is null
throws:
  IllegalArgumentException - if the bean is the ValueModeland the property name is "value"
since:
   2.0



getBean1
public Object getBean1()(Code)
Returns the Java Bean that holds the first property. the Bean that holds the first property



getBean2
public Object getBean2()(Code)
Returns the Java Bean that holds the first property. the Bean that holds the first property



getProperty1Name
public String getProperty1Name()(Code)
Returns the name of the first Java Bean property. the name of the first property



getProperty2Name
public String getProperty2Name()(Code)
Returns the name of the second Java Bean property. the name of the second property



release
public void release()(Code)
Removes the PropertyChangeHandler from the observed bean, if the bean is not null and if property changes are not observed. This connector must not be used after calling #release.

To avoid memory leaks it is recommended to invoke this method, if the connected beans live much longer than this connector.

As an alternative you may use event listener lists in the connected beans that are implemented using WeakReference.
See Also:   java.lang.ref.WeakReference




updateProperty1
public void updateProperty1()(Code)
Reads the value of the second bean property and sets it as new value of the first bean property.
See Also:   PropertyConnector.updateProperty2()



updateProperty2
public void updateProperty2()(Code)
Reads the value of the first bean property and sets it as new value of the second bean property.
See Also:   PropertyConnector.updateProperty1()



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.