001    /*
002     * Copyright 2002-2004 the original author or authors.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005     * use this file except in compliance with the License. You may obtain a copy of
006     * 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, WITHOUT
012     * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013     * License for the specific language governing permissions and limitations under
014     * the License.
015     */
016    package org.springframework.binding.value.swing;
017    
018    import javax.swing.JComponent;
019    
020    import org.springframework.richclient.form.builder.FormComponentInterceptor;
021    
022    /**
023     * @author Peter De Bruycker
024     */
025    public class TestableFormComponentInterceptor implements FormComponentInterceptor {
026    
027        private JComponent component;
028    
029        private int componentCount;
030    
031        private String componentProperty;
032    
033        private JComponent label;
034    
035        private int labelCount;
036    
037        private String labelProperty;
038    
039        public JComponent getComponent() {
040            return component;
041        }
042    
043        public int getComponentCount() {
044            return componentCount;
045        }
046    
047        public String getComponentProperty() {
048            return componentProperty;
049        }
050    
051        public JComponent getLabel() {
052            return label;
053        }
054    
055        public int getLabelCount() {
056            return labelCount;
057        }
058    
059        public String getLabelProperty() {
060            return labelProperty;
061        }
062    
063        public void processComponent(String propertyName, JComponent component) {
064            componentCount++;
065            componentProperty = propertyName;
066            this.component = component;
067        }
068    
069        public void processLabel(String propertyName, JComponent label) {
070            labelCount++;
071            labelProperty = propertyName;
072            this.label = label;
073        }
074    }