org.openpermis.editor.policy.gui.binding
Class ErrorBindingListener

java.lang.Object
  extended by org.jdesktop.beansbinding.AbstractBindingListener
      extended by org.openpermis.editor.policy.gui.binding.ErrorBindingListener
All Implemented Interfaces:
EventListener, org.jdesktop.beansbinding.BindingListener

public class ErrorBindingListener
extends org.jdesktop.beansbinding.AbstractBindingListener

Binding listener that updates the background of a component if a sync fails.

Also sets a component property to indicate that there was an error.

See Also:
hasError(JComponent), hasAnyError(JComponent)
Since:
0.1.0

Field Summary
private  Color backgroundColor
          The original background color of the component.
private  JComponent component
          The component this error binding listener modifies.
private static String ERROR_MESSAGE_PROPERTY_KEY
          Property of type String set at components if they have an error.
private static String ERROR_STATE_PROPERTY_KEY
          Property of type Boolean set at components to indicate an error.
private  Color errorColor
          The error color to use.
private  String errorMessage
          The error message in case of a failure.
private  ErrorReporter errorReporter
          The error reporter to use.
 
Constructor Summary
ErrorBindingListener(ErrorReporter reporter, org.jdesktop.application.ResourceMap resourceMap, JComponent component, String errorKey)
          Creates a new error binding listener for the specified component.
 
Method Summary
private static void clearError(JComponent component)
          Clears the synchronization error state of a component.
static String getErrorMessage(JComponent component)
          Returns the error message of a component that has an error.
static boolean hasAnyError(JComponent component)
          Check if the specified or any child component has a synchronization error.
static boolean hasError(JComponent component)
          Check if the specified component has a synchronization error.
private static void markError(JComponent component, String message)
          Marks the component with a synchronization error state.
private static boolean primHasAnyError(Container container)
          Primitive to traverse the child list of the specified container and check for errors.
 void synced(org.jdesktop.beansbinding.Binding binding)
           
 void syncFailed(org.jdesktop.beansbinding.Binding binding, org.jdesktop.beansbinding.Binding.SyncFailure failure)
           
 
Methods inherited from class org.jdesktop.beansbinding.AbstractBindingListener
bindingBecameBound, bindingBecameUnbound, sourceChanged, sourceEdited, targetChanged, targetEdited
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_STATE_PROPERTY_KEY

private static final String ERROR_STATE_PROPERTY_KEY
Property of type Boolean set at components to indicate an error.

Constant Field Value:
"bindingSyncErrorState"
Since:
0.1.0

ERROR_MESSAGE_PROPERTY_KEY

private static final String ERROR_MESSAGE_PROPERTY_KEY
Property of type String set at components if they have an error.

Constant Field Value:
"bindingSyncErrorMessage"
Since:
0.1.0

component

private final JComponent component
The component this error binding listener modifies.

Since:
0.1.0

errorColor

private final Color errorColor
The error color to use.

Since:
0.1.0

errorMessage

private final String errorMessage
The error message in case of a failure.

Since:
0.1.0

errorReporter

private final ErrorReporter errorReporter
The error reporter to use.

Since:
0.1.0

backgroundColor

private Color backgroundColor
The original background color of the component.

Since:
0.1.0
Constructor Detail

ErrorBindingListener

public ErrorBindingListener(ErrorReporter reporter,
                            org.jdesktop.application.ResourceMap resourceMap,
                            JComponent component,
                            String errorKey)
Creates a new error binding listener for the specified component.

Parameters:
reporter - the error reporter to use if not null.
resourceMap - resource map used to configure display properties.
component - the component this error binding listener modifies.
errorKey - key in the resource map to a translation of the error type, may be null for a generic error message.
Since:
0.1.0
Method Detail

getErrorMessage

public static String getErrorMessage(JComponent component)
Returns the error message of a component that has an error.

Parameters:
component - the component for wich to retrieve the error message.
Returns:
the error message or null if the component has no error.
Since:
0.1.0

hasAnyError

public static boolean hasAnyError(JComponent component)
Check if the specified or any child component has a synchronization error.

Parameters:
component - the component to check.
Returns:
true if at least one component has an error, false otherwise.
Since:
0.1.0

primHasAnyError

private static boolean primHasAnyError(Container container)
Primitive to traverse the child list of the specified container and check for errors.

Parameters:
container - the container to traverse.
Returns:
true if at least one component has an error, false otherwise.
Since:
0.1.0

hasError

public static boolean hasError(JComponent component)
Check if the specified component has a synchronization error.

Parameters:
component - the component to check.
Returns:
true if it has an error, false otherwise.
Since:
0.1.0

markError

private static void markError(JComponent component,
                              String message)
Marks the component with a synchronization error state.

Parameters:
component - the component to set the state for.
message - the message describing the error.
Since:
0.1.0

clearError

private static void clearError(JComponent component)
Clears the synchronization error state of a component.

Parameters:
component - the component to clear the state for.
Since:
0.1.0

synced

public void synced(org.jdesktop.beansbinding.Binding binding)
Specified by:
synced in interface org.jdesktop.beansbinding.BindingListener
Overrides:
synced in class org.jdesktop.beansbinding.AbstractBindingListener
Since:
0.1.0

syncFailed

public void syncFailed(org.jdesktop.beansbinding.Binding binding,
                       org.jdesktop.beansbinding.Binding.SyncFailure failure)
Specified by:
syncFailed in interface org.jdesktop.beansbinding.BindingListener
Overrides:
syncFailed in class org.jdesktop.beansbinding.AbstractBindingListener
Since:
0.1.0


PERMIS Role Based Access Control 0.3.0 (Build 14)
2009/05/08 09:06:48
Copyright (c) 2002-2007 Ergon Informatik AG