1   /*
2    * Copyright 2002-2004 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.springframework.richclient.form.binding.swing;
17  
18  import java.util.Map;
19  
20  import javax.swing.JComponent;
21  
22  import org.springframework.binding.form.FormModel;
23  import org.springframework.richclient.form.binding.Binder;
24  import org.springframework.richclient.form.binding.BinderSelectionStrategy;
25  import org.springframework.richclient.form.binding.Binding;
26  
27  /**
28   * @author Oliver Hutchison
29   */
30  public class TestingBinderSelectionStrategy implements BinderSelectionStrategy {
31  
32      public Binder selectBinder(FormModel formModel, String propertyName) {
33          return new TestableBinder(null);
34      }
35  
36      public Binder selectBinder(Class controlType, FormModel formModel, String propertyName) {
37          return new TestableBinder(controlType);
38      }
39      
40      private class TestableBinder implements Binder {
41          private Class controlType; 
42  
43          public TestableBinder(Class controlType) {
44              this.controlType = controlType;
45          }
46  
47          public Binding bind(FormModel formModel, String formPropertyPath, Map context) {
48              return new TestableBinding(controlType, null, formModel,formPropertyPath, context);
49          }
50  
51          public Binding bind(JComponent control, FormModel formModel, String formPropertyPath, Map context) {
52              return new TestableBinding(controlType, control, formModel,formPropertyPath, context);
53          }
54  
55          public Class getRequiredSourceClass() {
56              // TODO Auto-generated method stub
57              return null;
58          }        
59      }
60  }