01: //WebOnSwing - Web Application Framework
02: //Copyright (C) 2003 Fernando Damian Petrola
03: //
04: //This library is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU Lesser General Public
06: //License as published by the Free Software Foundation; either
07: //version 2.1 of the License, or (at your option) any later version.
08: //
09: //This library is distributed in the hope that it will be useful,
10: //but WITHOUT ANY WARRANTY; without even the implied warranty of
11: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: //Lesser General Public License for more details.
13: //
14: //You should have received a copy of the GNU Lesser General Public
15: //License along with this library; if not, write to the Free Software
16: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17:
18: package net.ar.webonswing.ui;
19:
20: import java.awt.*;
21:
22: import javax.swing.*;
23:
24: import net.ar.webonswing.*;
25: import net.ar.webonswing.helpers.*;
26: import net.ar.webonswing.render.markup.*;
27: import net.ar.webonswing.render.templates.*;
28: import net.ar.webonswing.render.templates.html.*;
29: import net.ar.webonswing.swing.components.*;
30: import net.ar.webonswing.visitor.*;
31: import net.ar.webonswing.wrapping.*;
32:
33: public class EditableUIContributor extends
34: AbstractSwingComponentUIContributor {
35: public void doRenderingContribution(
36: RenderingContributionContainer theContribManager) {
37: JEditable anEditable = (JEditable) getJComponent();
38:
39: Template theTemplate = WosSwingHelper.getTemplateForComponent(
40: "JEditable", anEditable);
41:
42: Component[] theComponents = anEditable.getComponents();
43: StringBuffer theInitScript = new StringBuffer();
44:
45: for (int i = 0; i < theComponents.length; i++) {
46: JComponent theSubComponent = (JComponent) theComponents[i];
47: VisualComponent theChildComponent = WosFramework
48: .getInstance().getHierarchyWrapper()
49: .getComponentWrapper(theSubComponent);
50:
51: if (theSubComponent.isVisible()
52: || theSubComponent instanceof JPanel) {
53: Visitable theRendering = theContribManager
54: .getContainerRenderer().render(
55: theChildComponent);
56: Tag theIdTag = theContribManager
57: .getComponentIdTag(theChildComponent);
58:
59: theTemplate.addElement(new IdTagTemplateElement(
60: theChildComponent, theRendering, theIdTag));
61: }
62:
63: theInitScript.append(theContribManager
64: .getComponentInitScripts(theChildComponent)[0]);
65: }
66:
67: theContribManager.doContribution(theComponent, theTemplate,
68: null, theInitScript.toString());
69: }
70: }
|