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.swing;
017    
018    import java.util.Map;
019    
020    import javax.swing.JComponent;
021    
022    import org.springframework.binding.form.FormModel;
023    import org.springframework.richclient.form.binding.Binder;
024    import org.springframework.richclient.form.binding.BinderSelectionStrategy;
025    import org.springframework.richclient.form.binding.Binding;
026    
027    /**
028     * @author Oliver Hutchison
029     */
030    public class TestingBinderSelectionStrategy implements BinderSelectionStrategy {
031    
032        public Binder selectBinder(FormModel formModel, String propertyName) {
033            return new TestableBinder(null);
034        }
035    
036        public Binder selectBinder(Class controlType, FormModel formModel, String propertyName) {
037            return new TestableBinder(controlType);
038        }
039        
040        private class TestableBinder implements Binder {
041            private Class controlType; 
042    
043            public TestableBinder(Class controlType) {
044                this.controlType = controlType;
045            }
046    
047            public Binding bind(FormModel formModel, String formPropertyPath, Map context) {
048                return new TestableBinding(controlType, null, formModel,formPropertyPath, context);
049            }
050    
051            public Binding bind(JComponent control, FormModel formModel, String formPropertyPath, Map context) {
052                return new TestableBinding(controlType, control, formModel,formPropertyPath, context);
053            }
054    
055            public Class getRequiredSourceClass() {
056                // TODO Auto-generated method stub
057                return null;
058            }        
059        }
060    }