1 /* 
2  * Copyright 2005 Paul Hinds
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 */
16package org.tp23.antinstaller.renderer.swing;
17
18import javax.swing.JPanel;
19
20import org.tp23.antinstaller.InstallerContext;
21import org.tp23.antinstaller.input.OutputField;
22import org.tp23.gui.GBCF;
23/**
24 *
25 * <p>Instances of this interface should have a no args constructor.
26* They sould
27* be Swing JComponent (e.g. subclass JPanel) and render normally responding
28* to update paint and requests to change Look & Feel in a normal way. </p>
29 * <p>Instances of this class should follow the naming convention. for each OutputField
30* Xxx in the package org.tp23.antinstaller.input  there should exist a SwingOutputFieldRenderer
31* called org.tp23.antinstaller.renderer.swing.XxxRenderer</p>
32 * <p>Copyright: Copyright (c) 2004</p>
33 * <p>Company: tp23</p>
34 * @author Paul Hinds
35 * @version $Id: SwingOutputFieldRenderer.java,v 1.5 2007/01/04 22:57:17 teknopaul Exp $
36 */
37public abstract class SwingOutputFieldRenderer{
38
39    //TODO From FindBugs - sometimes this field is not used in subclasses to avoid casting
40    // replace with for example, getInputField() that casts in InputRenderers
41    // requires work in ConditionalFieldRenderer
42    protected OutputField outputField;
43    protected InstallerContext ctx;
44    
45    /**
46     * this should hold a local reference and set the input fields default value
47     * if one exists
48     * @param inputField InputField
49     */
50    public void setOutputField(OutputField outputField){
51        this.outputField = outputField;
52    }
53    /**
54     * Init the swing components
55     */
56    public abstract void initComponent(JPanel parent);
57    /**
58     * Called by the Page prior to firing pagecompletion events
59     */
60    public abstract void updateInputField();
61    /**
62     * Called to update the defaults from the ResultContainer
63     */
64    public abstract void updateDefaultValue();
65
66    /**
67     * Called when validation fails
68     */
69    public abstract void renderError();
70    /**
71     * Called when the renderer should add itself to the content pane;
72     * @param content the panel to which the Renderer should add itself
73     * @param GridBagConstraintsFactory
74     * @param row the current row index in the table
75     * @param components should adjust preferred size when the overflow flag is set
76     * to compensate for width loss due to the scroll bar
77     * @return the row index after adding all its components
78     */
79    public abstract int addSelf(JPanel content, GBCF cf, int row, boolean overflow);
80
81    public void setInstallerContext(InstallerContext ctx){
82        this.ctx = ctx;
83    }
84
85
86}
87