001    /*
002     * Copyright 2002-2004 the original author or authors.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.springframework.richclient.form.binding;
017    
018    import java.util.Map;
019    
020    import javax.swing.JComponent;
021    
022    import org.springframework.binding.form.FormModel;
023    
024    /**
025     * A Binder is responsible for creating a binding between a form model's property and
026     * a control that may be used to visualize and/or edit that property.
027     * 
028     * @author Oliver Hutchison
029     */
030    public interface Binder {
031        
032        /**
033         * Returns a binding between a form model's property and a control that will be
034         * created by this Binder.
035         * @param formModel the form model that this binding is for
036         * @param formModel the property that this binding is for
037         * @param context additional context that may be used by this binder. 
038         * @return a Binding (never null). 
039         * @throws UnsupportedOperationException if this binder is unable to create its 
040         * own control
041         */
042        Binding bind(FormModel formModel, String formPropertyPath, Map context);
043        
044        /**
045         * Returns a binding between a form model's property and the provided control.
046         * @param control the visual control that will be bound to the form model's property. 
047         * @param formModel the form model that this binding is for
048         * @param formModel the property that this binding is for
049         * @param context additional context that may be used by this binder
050         * @return a Binding (never null). 
051         * @throws UnsupportedOperationException if this binder is unable to bind the 
052         * provided control or if this binder is unable to bind a provided control
053         */
054        Binding bind(JComponent control, FormModel formModel, String formPropertyPath, Map context);
055    }