Revision: 1484
          http://svn.sourceforge.net/spring-rich-c/?rev=1484&view=rev
Author:   jhoskens
Date:     2006-10-03 00:45:00 -0700 (Tue, 03 Oct 2006)

Log Message:
-----------
module refactoring: moved binding packages

Added Paths:
-----------
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/BindingErrorMessageProvider.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/CommitListener.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/ConfigurableFormModel.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldFace.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldFaceSource.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldMetadata.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FormModel.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/HierarchicalFormModel.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/ValidatingFormModel.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/RichValidator.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/Severity.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationListener.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationMessage.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationMessageComparator.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationResults.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationResultsModel.java
    
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/Validator.java

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/BindingErrorMessageProvider.java
 (from rev 1468, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/BindingErrorMessageProvider.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/BindingErrorMessageProvider.java
                             (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/BindingErrorMessageProvider.java
     2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.form;
+
+import org.springframework.binding.validation.ValidationMessage;
+
+/**
+ * A class that can generate ValidationMessages for exception that occur
+ * during a form model's binding process.
+ * 
+ * @author  Oliver Hutchison
+ * @see 
org.springframework.binding.form.support.DefaultBindingErrorMessageProvider
+ */
+public interface BindingErrorMessageProvider {
+    
+    /**
+     * Translates the provided exception details into a ValidationMessage that
+     * will be used to provide feedback to the end user. General these 
+     * exceptions results from type conversion problems. 
+     */
+    ValidationMessage getErrorMessage(FormModel formModel, String 
propertyName, Object valueBeingSet, Exception e); 
+
+}


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/BindingErrorMessageProvider.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/CommitListener.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/CommitListener.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/CommitListener.java
                          (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/CommitListener.java
  2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,35 @@
+/* * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.form;
+
+/**
+ * Listener inteface for objects interested in intercepting before and after 
+ * a form model is commited.
+ * 
+ * @author  Keith Donald
+ * @author  Oliver Hutchison
+ */
+public interface CommitListener {
+    
+    /**
+     * Called just before a form model is about to commit.
+     */
+    void preCommit(FormModel formModel);
+
+    /**
+     * Called just after a form model is commited.
+     */
+    void postCommit(FormModel formModel);
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/CommitListener.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/ConfigurableFormModel.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/ConfigurableFormModel.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/ConfigurableFormModel.java
                           (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/ConfigurableFormModel.java
   2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.form;
+
+import org.springframework.binding.value.ValueModel;
+
+/**
+ * Sub-interface implemented by form models that allow for configuration 
+ * of the form's value models, id etc.. 
+ * 
+ * @author Keith Donald
+ * @author Oliver Hutchison
+ */
+public interface ConfigurableFormModel extends FormModel {
+    public void setId(String id);
+    
+    public void setEnabled(boolean enabled);
+    
+    public ValueModel add(String propertyName);
+
+    public ValueModel add(String propertyName, ValueModel valueModel);
+    
+    public ValueModel addMethod(String propertyMethodName, String 
derivedFromProperty);
+    
+    public ValueModel addMethod(String propertyMethodName, String[] 
derivedFromProperties);   
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/ConfigurableFormModel.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldFace.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/FieldFace.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldFace.java
                               (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldFace.java
       2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.form;
+
+import javax.swing.AbstractButton;
+import javax.swing.Icon;
+import javax.swing.JLabel;
+
+import org.springframework.richclient.core.DescribedElement;
+import org.springframework.richclient.core.VisualizedElement;
+import org.springframework.richclient.factory.LabelInfo;
+
+/**
+ * Provides metadata related to the visualization of a form property and 
convenience methods
+ * for configuring GUI components using the metadata.
+ * 
+ * @author Oliver Hutchison
+ */
+public interface FieldFace extends DescribedElement, VisualizedElement {
+
+    /**
+     * The name of the property in human readable form; typically used for 
validation messages.
+     */
+    String getDisplayName();
+
+    /**
+     * A short caption describing the property; typically used for tool tips.
+     */
+    String getCaption();
+
+    /**
+     * A longer caption describing the property.
+     */
+    String getDescription();
+
+    /**
+     * The text, mnemonic and mnemonicIndex for any labels created for the 
property.
+     */
+    LabelInfo getLabelInfo();
+
+    /**
+     * The icon that is used for any labels created for this property.
+     */
+    Icon getIcon();
+
+    /**
+     * Configures the supplied JLabel using LabelInfo and Icon.
+     */
+    void configure(JLabel label);
+
+    /**
+     * Configures the supplied button using LabelInfo and Icon.
+     */
+    void configure(AbstractButton button);
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldFace.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldFaceSource.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/FieldFaceSource.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldFaceSource.java
                         (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldFaceSource.java
 2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.form;
+
+import java.util.Map;
+
+/**
+ * Interface to be implemented by objects that can resolve a FieldFace for a 
given form model or context id and a field path.
+ * 
+ * @author Oliver Hutchison
+ * @author Mathias Broekelmann
+ * @see org.springframework.binding.form.support.MessageSourceFieldFaceSource
+ */
+public interface FieldFaceSource {
+
+    /**
+     * Return the FieldFace for the given form model and form field.
+     * 
+     * @param formModel
+     *            the form model for which the FieldFace is being resolved
+     * @param field
+     *            the form field
+     * @return the FieldFace for the given form model and field (never null).
+     */
+    FieldFace getFieldFace(FormModel formModel, String field);
+
+    /**
+     * Return the FieldFace for the given field name and a context.
+     * 
+     * @param field
+     *            the field name
+     * @param contextId
+     *            optional context id for the field face
+     * @return the FieldFace for the given field (never null).
+     * @throws IllegalArgumentException
+     *             if field is null or empty
+     */
+    FieldFace getFieldFace(String field, String contextId);
+
+    /**
+     * Return the FieldFace for the given field name a context and a map 
containing values to create the field face.
+     * 
+     * @param field
+     *            the field name
+     * @param contextId
+     *            optional context id for the field face
+     * @param context
+     *            contains optional context values
+     * @return the FieldFace for the given field (never null).
+     * @throws IllegalArgumentException
+     *             if field is null or empty
+     */
+    FieldFace getFieldFace(String field, String contextId, Map context);
+}


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldFaceSource.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldMetadata.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/FieldMetadata.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldMetadata.java
                           (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldMetadata.java
   2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.form;
+
+import java.util.Map;
+
+import org.springframework.binding.value.PropertyChangePublisher;
+
+/**
+ * Encapsulates the state of an individual property of a form model.
+ *   
+ * @author Oliver Hutchison
+ */
+public interface FieldMetadata extends PropertyChangePublisher {
+    
+    /**
+     * The name of the bound property <code>enabled</code>.
+     */
+    public static final String ENABLED_PROPERTY = "enabled";
+
+    /**
+     * The name of the bound property <code>readOnly</code>.
+     */
+    public static final String READ_ONLY_PROPERTY = "readOnly";
+    
+    /**
+     * The name of the bound property <code>dirty</code>.
+     */
+    public static final String DIRTY_PROPERTY = "dirty";
+    
+    /**
+     * Return the type of this property.
+     */
+    Class getPropertyType();
+    
+    /**
+     * Returns custom metadata that may be associated with this property. 
+     */
+    Object getUserMetadata(String key);
+  
+    /**
+     * Returns all custom metadata associated with this property in the form
+     * of a Map.
+     *
+     * @return Map containing String keys
+     */
+    Map getAllUserMetadata();
+
+    /**
+     * Sets whether or not this property is read only.
+     * <p>It's expected that controls bound to this form property will 
+     * listen for changes to this value and if possible modify their
+     * display/behaviour to reflect the new state. e.g. When this property 
becomes 
+     * true a text component would grey its self out and prevent any editing. 
+     * <p>This value will be propagated up to any descendants. 
+     * @param readOnly should this property be read only 
+     */
+    void setReadOnly(boolean readOnly);
+    
+    
+    /**
+     * Returns whether or not the property is read only.  
+     * <p>A property is read only if any of the following are true:
+     * <ul>
+     * <li>It is read only at the PropertyAccessStrategy level</li>
+     * <li>It is marked as read only by a call to the setReadOnly method of 
this class</li>
+     * <li>It is marked as read only by a call to the setReadOnly method of 
the metadata of any ancestor
+     * of the form model which contains this property</li>
+     * </ul>
+     */
+    boolean isReadOnly();
+    
+    /**
+     * Sets the enabled value for this property. 
+     * <p>It's expected that controls bound to this form property will 
+     * listen for changes to this value and if possible modify their
+     * display/behaviour to reflect the new state.
+     * <p>This value will be propagated up to any descendants. 
+     * @param enabled should this property be enabled 
+     */
+    void setEnabled(boolean enabled);
+    
+    /**
+     * Returns whether or not the property is enabled. 
+     * <p>A property is enabled if all of the following are true:
+     * <ul>
+     * <li>The owning form model is enabled</li>
+     * <li>It has not been marked as disabled by a call to the setEnabled 
method of this class</li>
+     * <li>It has not been marked as disabled by by a call to the setEnabled 
method of the 
+     * metadata of any ancestor of the form model which contains this 
property</li>
+     * </ul>
+     */
+    boolean isEnabled();
+    
+    /**
+     * Returns whether or not the property is dirty.  
+     */
+    boolean isDirty();       
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FieldMetadata.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FormModel.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/FormModel.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FormModel.java
                               (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FormModel.java
       2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.form;
+
+import org.springframework.beans.InvalidPropertyException;
+import org.springframework.binding.convert.Converter;
+import org.springframework.binding.value.PropertyChangePublisher;
+import org.springframework.binding.value.ValueModel;
+
+/**
+ * A form model represents the state and behavior of a form independently from 
+ * the UI used to present the form.
+ * 
+ * @author Keith Donald
+ * @author Oliver Hutchison
+ */
+public interface FormModel extends PropertyChangePublisher {
+
+    /**
+     * The name of the bound property <em>dirty</em>.
+     */
+    String DIRTY_PROPERTY = "dirty";
+
+    /**
+     * The name of the bound property <em>enabled</em>.       
+     */
+    String ENABLED_PROPERTY = "enabled";
+    
+    /**
+     * The name of the bound property <em>committable</em>.       
+     */
+    String COMMITTABLE_PROPERTY = "committable";
+    
+    /**
+     * Returns the id that is used to identify this form model.
+     */
+    String getId();
+
+    /**
+     * Returns the object currently backing this form. This object is held by 
the 
+     * FormObjectHolder. 
+     */
+    Object getFormObject();
+
+    /**
+     * Sets the object currently backing this form.
+     */
+    void setFormObject(Object formObject);
+    
+
+    /**
+     * Returns the value model which holds the object currently backing this 
+     * form.
+     */
+    ValueModel getFormObjectHolder();
+
+    /**
+     * Returns a value model that holds the value of the specified 
+     * form property.
+     * 
+     * @throws InvalidPropertyException if the form has no such property
+     */
+    ValueModel getValueModel(String formProperty);
+
+    /**
+     * Returns a type converting value model for the given form property. The 
+     * type of the value returned from the returned value model is guaranteed 
to
+     * be of class targetClass.
+     * @throws InvalidPropertyException if the form has no such property
+     * @throws IllegalArgumentException if no suitable converter from the 
original 
+     * property class to the targetClass can be found 
+     */
+    ValueModel getValueModel(String formProperty, Class targetClass);
+    
+    /**
+     * Returns the metadata for the given form field.
+     */
+    FieldMetadata getFieldMetadata(String field);
+    
+    /**
+     * Register converters for a given property name.
+     * @param propertyName name of property on which to register converters
+     * @param toConverter Convert from source to target type
+     * @param fromConverter Convert from target to source type
+     */
+    public void registerPropertyConverter( String propertyName, Converter 
toConverter, Converter fromConverter );
+
+    /**
+     * Returns true if the form has a value model for the provided property 
name.
+     */
+    boolean hasValueModel(String formProperty);
+
+    /**
+     * Commits any changes buffered by the form property value models into the
+     * current form backing object.
+     * 
+     * @throws IllegalStateException if the form model is not committable
+     * @see #isCommittable()
+     */
+    void commit();
+
+    /**
+     * Reverts any dirty value models back to the original values that were 
loaded 
+     * from the current form backing object since last call to either commit 
or revert 
+     * or since the last change of the form backing object. 
+     */
+    void revert();
+    
+    /**
+     * Reset the form by replacing the form object with a newly instantiated 
object of the
+     * type of the current form object. Note that this may lead to NPE's if 
the newly
+     * created object has null sub-objects and this form references any of 
these objects.
+     */
+    void reset();
+
+    /**
+     * Does this form model buffer changes.
+     */
+    boolean isBuffered();
+
+    /**
+     * Returns true if any of the value models holding properties of this form
+     * have been modified since the last call to either commit or revert or 
since 
+     * the last change of the form backing object. 
+     */
+    boolean isDirty();
+
+    /**
+     * Returns true if this form is enabled (an enabled form is one which is 
able to be 
+     * modified).
+     */
+    boolean isEnabled();
+    
+    /**
+     * Returns true if the changes held by this form are able to be committed.
+     * A form is committable when it and it's child form models have no 
validation 
+     * errors.
+     */
+    boolean isCommittable();
+    
+    /**
+     * Adds the specified listener to the list if listeners notified when a 
commit 
+     * happens.
+     */
+    void addCommitListener(CommitListener listener);
+
+    /**
+     * Removes the specified listener to the list if listeners notified when a 
commit 
+     * happens.
+     */
+    void removeCommitListener(CommitListener listener);
+
+    /**
+     * FIXME: this should be on the FieldMetadata class
+     */
+    FieldFace getFieldFace(String field);
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/FormModel.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/HierarchicalFormModel.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/HierarchicalFormModel.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/HierarchicalFormModel.java
                           (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/HierarchicalFormModel.java
   2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.form;
+
+/**
+ * Sub-interface implemented by form models that can be part
+ * of a form model hierarchy.
+ * <p>
+ * In a HierarchicalFormModel:
+ * <ul>
+ * <li>the enabled state of the parent is inherited 
+ * by the children. So if the parent is disabled then the child is
+ * also disabled; however if the child is disabled the parent my not
+ * be disabled. 
+ * <li>the dirty state of the chidren is inherited by 
+ * the parent. So if one or more of the chilren are dirty the parent is
+ * also dirty; however if the parent is dirty the children my not be.
+ * </ul> 
+ * 
+ * @author  Oliver Hutchison
+ */
+public interface HierarchicalFormModel extends FormModel {
+
+    /**
+     * Returns the parent form model or null of there is none.
+     */
+    HierarchicalFormModel getParent();
+    
+    /**
+     * Returns an array of child form models.
+     */
+    FormModel[] getChildren();
+    
+    /**
+     * Sets the parent form model.
+     */
+    void setParent(HierarchicalFormModel parent);
+    
+    /**
+     * Remove the parent form model
+     */
+    void removeParent();
+    
+    /**
+     * Adds a new child to the form model. The child form model will have it's 
+     * parent set to this.
+     */
+    void addChild(HierarchicalFormModel child);
+    
+    /**
+     * Removes a child from this form model.
+     */
+    void removeChild(HierarchicalFormModel child);
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/HierarchicalFormModel.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/ValidatingFormModel.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/ValidatingFormModel.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/ValidatingFormModel.java
                             (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/ValidatingFormModel.java
     2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.form;
+
+import org.springframework.binding.validation.ValidationResultsModel;
+import org.springframework.binding.validation.Validator;
+
+/**
+ * Sub-interface implemented by form models that can validatate the form's 
+ * properties.
+ * 
+ * @author Keith Donald
+ * @author Oliver Hutchison
+ */
+public interface ValidatingFormModel extends ConfigurableFormModel, 
HierarchicalFormModel {
+    
+    public static final String VALIDATING_PROPERTY = "validating";
+    
+    /**
+     * Returns the ValidationResultsModel which encapsulates the set of 
+     * validation messages currently active against this form model. Will
+     * be empty if validation is disabled.
+     */
+    ValidationResultsModel getValidationResults();
+    
+    /**
+     * Is this form model currently validating
+     */
+    boolean isValidating();
+
+    /**
+     * Sets whether or not validation is currently enabled for this 
+     * form model. If validatiuon is enabled the form model will 
+     * immediately validate all form properties; if validation 
+     * is disabled all validation messages held by the 
+     * ValidationResultsModel will be cleared.
+     */
+    void setValidating(boolean validating);
+
+    /**
+     * Forces the form model to validate its self. If validation is disabled 
+     * does nothing.     
+     */
+    public void validate();
+    
+    /**
+     * Get the validator that will be used to validate the form model.
+     * @return validator
+     */
+    public Validator getValidator();
+
+    /**
+     * set the validator that will be used to validate the form model.
+     * @param validator
+     */
+    public void setValidator(Validator validator);
+
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/form/ValidatingFormModel.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/RichValidator.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/RichValidator.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/RichValidator.java
                             (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/RichValidator.java
     2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.binding.validation;
+
+/**
+ * Interface to be implemented by classes capable of incrementally validating 
+ * domain objects. This interface is intended for validators that are able to 
+ * validate a subset of the domain objects properties.
+ *  
+ * @author  Oliver Hutchison
+ */
+public interface RichValidator extends Validator {
+    
+    /**
+     * Validates the provided object.
+     * 
+     * @param object the object to validate (may be an implementation of @link 
org.springframework.binding.PropertyAccessStrategy)
+     * @param property the name of the only property that has changed since 
the 
+     * last call to validate.
+     * @return the results on the validation
+     */
+    ValidationResults validate(Object object, String property);
+}


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/RichValidator.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/Severity.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/Severity.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/Severity.java
                          (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/Severity.java
  2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.validation;
+
+import org.springframework.core.enums.ShortCodedLabeledEnum;
+
+public class Severity extends ShortCodedLabeledEnum {
+
+       public static final Severity INFO = new Severity(0, "info");
+
+       public static final Severity WARNING = new Severity(50, "warning");
+
+       public static final Severity ERROR = new Severity(100, "error");
+
+       protected Severity(int magnitude, String label) {
+               super(magnitude, label);
+       }
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/Severity.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationListener.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/ValidationListener.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationListener.java
                                (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationListener.java
        2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.validation;
+
+/**
+ * @author Keith Donald
+ */
+public interface ValidationListener {
+
+    /**
+     * Fired whenever there is a change to set of validation results.
+     * 
+     * @param results the set of valiation results; this set will incude 
results 
+     * for all properties even if the listener is only listening for changes 
to 
+     * a specific properties results.  
+     */
+    public void validationResultsChanged(ValidationResults results);
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationListener.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationMessage.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/ValidationMessage.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationMessage.java
                         (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationMessage.java
 2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.binding.validation;
+
+public interface ValidationMessage {
+    
+    /**
+     * The property name for messages that have a global scope i.e. do not
+     * apply to a specific property.
+     */
+    public static final String GLOBAL_PROPERTY = null;
+    
+    /**
+     * The time that this validation message was created.
+     */
+    long getTimeStamp();
+
+    /**
+     * The property that this validation message applies to; or 
+     * <code>GLOBAL_PROPERTY</code> if this message does not apply
+     * to a specific property.
+     */
+    String getProperty();
+
+    /**
+     * The severity of this message.
+     */
+    Severity getSeverity();
+
+    /**
+     * The text of this message. If any i18n is applcable this must 
+     * have already been allied to this message.
+     */
+    String getMessage();
+}


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationMessage.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationMessageComparator.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/ValidationMessageComparator.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationMessageComparator.java
                               (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationMessageComparator.java
       2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.binding.validation;
+
+import java.util.Comparator;
+
+import org.springframework.util.comparator.NullSafeComparator;
+
+/**
+ * Comparator that compares ValidationMessages. Comparison 
+ * is done by timestamp (desc) then property name then severity then 
+ * message. 
+ *  
+ * @author  Oliver Hutchison
+ */
+public class ValidationMessageComparator implements Comparator {
+
+    /**
+     * A shared default instance of this comparator.
+     */
+    public static Comparator INSTANCE = new NullSafeComparator(new 
ValidationMessageComparator(), true);
+
+    protected ValidationMessageComparator() {
+    }
+
+    public int compare(Object o1, Object o2) {
+        ValidationMessage m1 = (ValidationMessage)o1;
+        ValidationMessage m2 = (ValidationMessage)o2;
+        int c;
+        if (m1.getTimeStamp() == m2.getTimeStamp()) {
+            c = NullSafeComparator.NULLS_HIGH.compare(m1.getProperty(), 
m2.getProperty());
+            if (c == 0) {
+                c = m1.getSeverity().compareTo(m2.getSeverity());
+                if (c == 0) {
+                    c = m1.getMessage().compareTo(m2.getMessage());
+                }
+            }
+        }
+        else {
+            c = (m1.getTimeStamp() > m2.getTimeStamp()) ? -1 : 1;
+        }
+        return c;
+    }
+
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationMessageComparator.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationResults.java
 (from rev 1476, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/ValidationResults.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationResults.java
                         (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationResults.java
 2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.validation;
+
+import java.util.Set;
+
+/**
+ * Interface to be implemented by objects that hold a list of validation 
results for
+ * a specific object.
+ *   
+ * @author  Oliver Hutchison
+ * @see org.springframework.binding.validation.support.DefaultValidationResults
+ */
+public interface ValidationResults {
+    
+    /**
+     * Returns true of there are any validation messages of 
<code>Severity.ERROR</code>.
+     */
+    boolean getHasErrors();
+    
+    /**
+     * Returns true of there are any validation messages of 
<code>Severity.WARNING</code>.
+     */
+    boolean getHasWarnings();
+    
+    /**
+     * Returns true of there are any validation messages of 
<code>Severity.INFO</code>.
+     */
+    boolean getHasInfo();
+    
+    /** 
+     * Returns the total number of validation messages.
+     */
+    int getMessageCount();
+    
+    /** 
+     * Returns the total number of validation messages of the specified 
Severity.
+     */
+    int getMessageCount(Severity severity);
+    
+    /** 
+     * Returns the total number of validation messages that apply to the 
specified
+     * property name.
+     */
+    int getMessageCount(String propertyName);
+    
+    /** 
+     * Returns a set holding all of the validation messages.
+     */
+    Set getMessages();
+    
+    /** 
+     * Returns a set holding all of the validation messages of the specified 
Severity.
+     */
+    Set getMessages(Severity severity);
+    
+    /** 
+     * Returns a set holding all of the validation messages that apply to the 
specified
+     * property name.
+     */
+    Set getMessages(String propertyName);
+}


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationResults.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationResultsModel.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/ValidationResultsModel.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationResultsModel.java
                            (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationResultsModel.java
    2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.validation;
+
+import org.springframework.binding.value.PropertyChangePublisher;
+
+/**
+ * @author  Oliver Hutchison
+ */
+public interface ValidationResultsModel extends ValidationResults, 
PropertyChangePublisher {
+    
+    /** 
+     * The name of the bound property <em>hasErrors</em>.       
+     */
+    String HAS_ERRORS_PROPERTY = "hasErrors";
+    
+    /** 
+     * The name of the bound property <em>hasWarnings</em>.       
+     */
+    String HAS_WARNINGS_PROPERTY = "hasWarnings";
+    
+    /** 
+     * The name of the bound property <em>hasInfos</em>.       
+     */
+    String HAS_INFO_PROPERTY = "hasInfo";
+    
+    /**
+     * Adds a listener that will be notified when there is any change to the 
set of 
+     * validation messages. 
+     */
+    void addValidationListener(ValidationListener listener);
+
+    /**
+     * Removes the provided validation listener.
+     */
+    void removeValidationListener(ValidationListener listener);    
+    
+    /**
+     * Adds a listener that will be notified when there is any change to the 
set validation 
+     * messages for the specified property.
+     */
+    void addValidationListener(String propertyName, ValidationListener 
listener);
+
+    /**
+     * Removes the provided validation listener.
+     */
+    void removeValidationListener(String propertyName, ValidationListener 
listener);    
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/ValidationResultsModel.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/Validator.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/Validator.java)
===================================================================
--- 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/Validator.java
                         (rev 0)
+++ 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/Validator.java
 2006-10-03 07:45:00 UTC (rev 1484)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.validation;
+
+
+/**
+ * Interface to be implemented by classes capable of validating domain 
objects. 
+ *  
+ * @author  Oliver Hutchison
+ */
+public interface Validator {    
+    /**
+     * Validates the provided object.
+     * 
+     * @param object the object to validate
+     * @return the results on the validation
+     */
+    ValidationResults validate(Object object);
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/binding/src/main/java/org/springframework/binding/validation/Validator.java
___________________________________________________________________
Name: svn:eol-style
   + native


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
spring-rich-c-cvs mailing list
spring-rich-c-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to