001    /*
002     * Copyright 2002-2006 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     */
017    
018    package org.springframework.richclient.form;
019    
020    import javax.swing.JComponent;
021    
022    import org.springframework.richclient.factory.ControlFactory;
023    import org.springframework.richclient.form.binding.BindingFactory;
024    
025    /**
026     * Allows pre-generated form UIs to easily integrate with Spring Rich's form
027     * and binding framework.  Typically, these pre-generated form UIs are from
028     * 3rd party form designers (Matisse, JFormDesigner, etc).
029     *
030     * @author Andy DePue
031     * @author Peter De Bruycker
032     * @author Christophe GADAIX
033     */
034    public interface FormUIProvider extends ControlFactory {
035    
036      /**
037       * Produces the pre-generated form as a single Swing component.
038       */
039      JComponent getControl();
040    
041      /**
042       * Binds the fields and other components in this pre-generated form to a
043       * Spring {@link Form form} by using the specified {@link BindingFactory}.
044       * 
045       * @param factory the <code>BindingFactory</code> this form provider should
046       *        use to bind the provided form.
047       * @param form the <code>Form</code> being bound.
048       */
049      void bind(BindingFactory factory, Form form);
050    
051      /**
052       * Provides access to individual components of this pre-generated form.
053       * Components are referenced by id.  The "id" of a component can be any
054       * arbitrary String agreed upon between the designer and the developer, but
055       * typically these IDs will be the same as the property names of the
056       * object backing the form.
057       *
058       * @param componentId component id to lookup
059       *
060       * @return component with the specified id, or <code>null</code> if no
061       *         component exists in this pre-generated form with the given id.
062       */
063      JComponent getComponent(String componentId);
064    }