001: //WebOnSwing - Web Application Framework
002: //Copyright (C) 2004 Fernando Damian Petrola
003: //
004: //This library is free software; you can redistribute it and/or
005: //modify it under the terms of the GNU Lesser General Public
006: //License as published by the Free Software Foundation; either
007: //version 2.1 of the License, or (at your option) any later version.
008: //
009: //This library is distributed in the hope that it will be useful,
010: //but WITHOUT ANY WARRANTY; without even the implied warranty of
011: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: //Lesser General Public License for more details.
013: //
014: //You should have received a copy of the GNU Lesser General Public
015: //License along with this library; if not, write to the Free Software
016: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017:
018: package net.ar.webonswing.ui;
019:
020: import java.awt.*;
021:
022: import javax.swing.*;
023:
024: import net.ar.webonswing.*;
025: import net.ar.webonswing.managers.script.*;
026: import net.ar.webonswing.remote.*;
027: import net.ar.webonswing.remote.js.*;
028: import net.ar.webonswing.render.*;
029: import net.ar.webonswing.render.markup.*;
030: import net.ar.webonswing.visitor.*;
031: import net.ar.webonswing.wrapping.*;
032:
033: public class InternalFrameUIContributor extends
034: AbstractSwingComponentUIContributor {
035: public void doRenderingContribution(
036: RenderingContributionContainer aRenderingContribManager) {
037: JInternalFrame internalFrame = (JInternalFrame) getJComponent();
038:
039: VisualComponent contentPane = WosFramework.getInstance()
040: .getHierarchyWrapper().getComponentWrapper(
041: internalFrame.getContentPane());
042: Visitable rendering = aRenderingContribManager
043: .getContainerRenderer().render(contentPane);
044:
045: if (internalFrame.getContentPane().getWidth() == 0)
046: internalFrame.getContentPane().setBounds(0, 0, 640, 480);
047:
048: JsConstructorCall contentConstruction = new JsConstructorCall(
049: "DynLayer", new JsStatement[] {
050: new StringValue(new ContentRenderer(rendering)
051: .getResult()),
052: new ValuesFromGetters(internalFrame
053: .getContentPane(), new String[] { "x",
054: "y", "width", "height" }),
055: new StringValue("grey") }, true);
056:
057: JsBuilder jsWC = new JsBuilder();
058: jsWC.add(new JsInstance(getName(), new JsConstructorCall(
059: "VisualWindow", new JsStatement[] {
060: new ValuesFromGetters(internalFrame,
061: new String[] { "x", "y", "width",
062: "height", "title" }),
063: contentConstruction }, false)));
064: jsWC.addDynApiComponentInit(getName());
065:
066: Tag scriptTag = new Tag("script");
067: scriptTag.addTextToContainer(jsWC.renderJs());
068:
069: Tag span = new Tag("span");
070: span.addElementToContainer(scriptTag);
071:
072: StringBuffer initScript = new StringBuffer(RemoteHelper
073: .getListenersAdds(theComponent));
074: initScript.append(aRenderingContribManager
075: .getComponentInitScripts(contentPane)[0]);
076:
077: aRenderingContribManager.doContribution(theComponent, span,
078: span, initScript.toString());
079: }
080:
081: private String getBoundsString(Component aComponent) {
082: return aComponent.getX() + ", " + aComponent.getY() + ", "
083: + aComponent.getWidth() + ", " + aComponent.getHeight();
084: }
085:
086: private String getName() {
087: JInternalFrame internalFrame = (JInternalFrame) getJComponent();
088: return WosFramework.getInstance().getHierarchyWrapper()
089: .getComponentWrapper(internalFrame).getName();
090: }
091:
092: public void doScriptContribution(
093: ScriptContributionContainer aContributionManager) {
094: RemoteHelper.addDynApiInitCode(aContributionManager);
095:
096: aContributionManager
097: .addCodeOnce("dynapi.library.add('dynapi.widgets.VisualWindow','window.js','DynLayer');");
098: aContributionManager
099: .addCodeOnce("dynapi.library.include('ViewPane');");
100: aContributionManager
101: .addCodeOnce("dynapi.library.include('VisualWindow');");
102: }
103: }
|