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