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.*;
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.layouts.*;
30: import net.ar.webonswing.visitor.*;
31: import net.ar.webonswing.wrapping.*;
32:
33: public class ToolBarUIContributor extends
34: AbstractSwingComponentUIContributor {
35: public void doRenderingContribution(
36: RenderingContributionContainer theRenderingContribManager) {
37: JToolBar aToolBar = (JToolBar) getJComponent();
38:
39: Template theTemplate = aToolBar.getLayout() instanceof TemplateLayout ? ((TemplateLayout) aToolBar
40: .getLayout()).getTemplate()
41: : new HtmlDivsTemplate();
42: Component[] theComponents = aToolBar.getComponents();
43:
44: StringBuffer theInitScript = new StringBuffer();
45:
46: for (int i = 0; i < theComponents.length; i++) {
47: Container theSubContainer = (Container) theComponents[i];
48: VisualComponent theChildComponent = WosFramework
49: .getInstance().getHierarchyWrapper()
50: .getComponentWrapper(theSubContainer);
51:
52: if (theSubContainer.isVisible()
53: || theSubContainer instanceof JPanel) {
54: Visitable theRendering = theRenderingContribManager
55: .getContainerRenderer().render(
56: theChildComponent);
57: Tag theIdTag = theRenderingContribManager
58: .getComponentIdTag(theChildComponent);
59:
60: theTemplate.addElement(new IdTagTemplateElement(
61: theChildComponent, theRendering, theIdTag));
62: }
63:
64: theInitScript.append(theRenderingContribManager
65: .getComponentInitScripts(theChildComponent)[0]);
66: }
67:
68: Tag theDiv = new Tag("div").addAttribute("style",
69: "border:10px solid #000000");
70: theDiv.addTextToContainer(new ContentRenderer(theTemplate)
71: .getResult());
72:
73: theRenderingContribManager.doContribution(theComponent, theDiv,
74: null, theInitScript.toString());
75: }
76: }
|