DESY ACOP Beans Home

com.cosylab.gui.util
Class UserSettingsProtection

java.lang.Object
  extended by com.cosylab.gui.util.UserSettingsProtection
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener

public final class UserSettingsProtection
extends java.lang.Object
implements java.beans.PropertyChangeListener

This class implements pattern, which protects Java bean properties from undesigred changes. For example user setting are protected from data source characteristics override.

Setting properties to bean with this class should have minimum performance overhead if bean is not protected.

Warning! This class is not synchronized. It expects tht only one thread will access GUI Java Beans at a time. Otherwise precations must be taken.

Author:
Igor Kriznar (igor.kriznarATcosylab.com)

Method Summary
 void clearProtections()
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
static void setProtection(javax.swing.JComponent bean, java.lang.String[] properties, boolean protection)
          Sets up or down property protection for provided JavaBean and properties.
 void setProtection(java.lang.String[] properties, boolean protection)
           
static boolean setUnprotected(javax.swing.JComponent bean, java.lang.String property, java.lang.Object value)
          Sets to a bean a Java Bean property with new value only if property is not protected.
 boolean setUnprotected(java.lang.String property, java.lang.Object value)
          Sets to a bean a Java Bean property with new value only if property is not protected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setProtection

public static void setProtection(javax.swing.JComponent bean,
                                 java.lang.String[] properties,
                                 boolean protection)
Sets up or down property protection for provided JavaBean and properties.

Parameters:
bean - Java Bean
properties - the properties to be protected
protection - if true properties are proteccted, othervise protection is removed

clearProtections

public void clearProtections()

setProtection

public void setProtection(java.lang.String[] properties,
                          boolean protection)

setUnprotected

public static boolean setUnprotected(javax.swing.JComponent bean,
                                     java.lang.String property,
                                     java.lang.Object value)
                              throws java.lang.NoSuchMethodException,
                                     java.lang.reflect.InvocationTargetException,
                                     java.lang.IllegalAccessException
Sets to a bean a Java Bean property with new value only if property is not protected.

Parameters:
bean - a bean on which property is to be set
property - a property name
value - new property value to be set
Returns:
true if value was set, otherwise false (property was protected)
Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

setUnprotected

public boolean setUnprotected(java.lang.String property,
                              java.lang.Object value)
                       throws java.lang.NoSuchMethodException,
                              java.lang.reflect.InvocationTargetException,
                              java.lang.IllegalAccessException
Sets to a bean a Java Bean property with new value only if property is not protected.

Parameters:
property - a property name
value - new property value to be set
Returns:
true if value was set, otherwise false (property was protected)
Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener


Copyright © 2010. All Rights Reserved.