001: /*
002: * Copyright (c) 2004 JETA Software, Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without modification,
005: * are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of JETA Software nor the names of its contributors may
015: * be used to endorse or promote products derived from this software without
016: * specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
021: * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
022: * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
023: * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
024: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
025: * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
026: * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028: */
029:
030: package com.jeta.forms.gui.components;
031:
032: import java.awt.Component;
033:
034: import com.jeta.forms.gui.beans.JETABean;
035: import com.jeta.forms.gui.common.FormException;
036: import com.jeta.forms.gui.common.FormUtils;
037: import com.jeta.forms.gui.form.GridComponent;
038: import com.jeta.forms.gui.form.GridView;
039: import com.jeta.forms.gui.form.StandardComponent;
040:
041: /**
042: * A <code>StandardCompnentFactory</code> is a base class for creating and
043: * initializing StandardComponent instances when in design mode. A
044: * StandardComponent is a type of GridComponent that contains a Swing component.
045: *
046: * See: {@link com.jeta.forms.gui.form.StandardComponent }
047: *
048: * @author Jeff Tassin
049: */
050: abstract public class StandardComponentFactory extends
051: AbstractComponentFactory {
052: /**
053: * Creates a <code>StandardComponentFactory</code> instance.
054: */
055: public StandardComponentFactory() {
056: }
057:
058: /**
059: * Creates a <code>StandardComponentFactory</code> instance with the
060: * specified component source.
061: *
062: * @param compsrc
063: * the component source associated with this factory.
064: */
065: public StandardComponentFactory(ComponentSource compsrc) {
066: super (compsrc);
067: }
068:
069: /**
070: * Helper method that creates and initializes a StandardComponent.
071: *
072: * @param compsrc
073: * the component source.
074: * @param comp
075: * the Swing component that will be contained by the newly
076: * created GridComponent
077: * @param view
078: * the view that will contain the newly created GridComponent.
079: * @return the grid component.
080: */
081: public GridComponent create(ComponentSource compsrc,
082: Component comp, GridView view) throws FormException {
083: FormUtils.safeAssert(compsrc != null);
084:
085: if (comp == null) {
086: StandardComponent gc = new StandardComponent(null, view);
087: installHandlers(gc);
088: return gc;
089: } else {
090: StandardComponent gc = new StandardComponent(new JETABean(
091: comp), view);
092: installHandlers(gc);
093: return gc;
094: }
095: }
096:
097: /**
098: * ComponentFactory implementation Creates a GridComponent instances with
099: * the given name and the given parent view. However, the GridComponent is
100: * not added to the view in this call.
101: *
102: * @param compName
103: * the name of the component.
104: * @param parentView
105: * the parent view for the new grid component. This value is
106: * needed mainly for installing event listeners to the
107: * GridComponent in design mode.
108: */
109: public GridComponent createComponent(Component comp, GridView view)
110: throws FormException {
111: return create(getComponentSource(), comp, view);
112: }
113:
114: }
|