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.render.markup.*;
26: import net.ar.webonswing.render.templates.*;
27: import net.ar.webonswing.render.templates.html.*;
28: import net.ar.webonswing.swing.layouts.*;
29: import net.ar.webonswing.visitor.*;
30: import net.ar.webonswing.wrapping.*;
31:
32: public class PanelUIContributor extends
33: AbstractSwingComponentUIContributor {
34: public void doRenderingContribution(
35: RenderingContributionContainer theRenderingContribManager) {
36: JComponent aPanel = getJComponent();
37:
38: Template theTemplate = aPanel.getLayout() instanceof TemplateLayout ? ((TemplateLayout) aPanel
39: .getLayout()).getTemplate()
40: : new HtmlDivsTemplate();
41:
42: Component[] theComponents = aPanel.getComponents();
43:
44: StringBuffer theInitScript = new StringBuffer();
45:
46: for (int i = 0; i < theComponents.length; i++) {
47: Container theSubContainer = (Container) theComponents[i];
48: JComponent theSubComponent = (JComponent) theSubContainer;
49: VisualComponent theChildComponent = WosFramework
50: .getInstance().getHierarchyWrapper()
51: .getComponentWrapper(theSubComponent);
52:
53: if (theSubContainer.isVisible()
54: || theSubContainer instanceof JPanel
55: || theSubContainer instanceof JInternalFrame) {
56: Visitable theRendering = theRenderingContribManager
57: .getContainerRenderer().render(
58: theChildComponent);
59: Tag theIdTag = theRenderingContribManager
60: .getComponentIdTag(theChildComponent);
61: theTemplate.addElement(new IdTagTemplateElement(
62: theChildComponent, theRendering, theIdTag));
63: }
64:
65: theInitScript.append(theRenderingContribManager
66: .getComponentInitScripts(theChildComponent)[0]);
67: }
68:
69: theRenderingContribManager.doContribution(theComponent,
70: theTemplate, null, theInitScript.toString());
71: }
72: }
|