001: //WebOnSwing - Web Application Framework
002: //Copyright (C) 2003 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.wrapping;
019:
020: import java.awt.*;
021: import java.io.*;
022: import java.util.List;
023:
024: import net.ar.webonswing.helpers.*;
025: import net.ar.webonswing.managers.contributors.*;
026: import net.ar.webonswing.managers.persistence.*;
027: import net.ar.webonswing.visitor.*;
028:
029: public class VirtualWindow implements VisualWindow, Serializable,
030: Virtualizable {
031: protected PersistenceContributionContainer thePersistenceContainer;
032: protected String theWindowClassName;
033: protected transient VisualWindow theOriginalWindow;
034: protected String theVirtualName;
035:
036: public VirtualWindow(VisualWindow aWindow, String aWindowName,
037: String aWindowClassName,
038: PersistenceContributionContainer aPersistenceContainer) {
039: theOriginalWindow = aWindow;
040: theVirtualName = aWindowName;
041: theOriginalWindow.setName(aWindowName);
042: theWindowClassName = aWindowClassName;
043: thePersistenceContainer = aPersistenceContainer;
044: }
045:
046: protected void restoreOriginal() {
047: if (theOriginalWindow == null) {
048: theOriginalWindow = (VisualWindow) WosHelper
049: .createClassInstance(theWindowClassName);
050: new ComponentStandardizer()
051: .standardizeWindowHierarchy(theOriginalWindow);
052: thePersistenceContainer.restoreAllValues(theOriginalWindow
053: .getRootComponent());
054: }
055: }
056:
057: public void accept(Visitor aVisitor) {
058: restoreOriginal();
059: theOriginalWindow.accept(aVisitor);
060: }
061:
062: public void addChild(VisualComponent aChild) {
063: restoreOriginal();
064: theOriginalWindow.addChild(aChild);
065: }
066:
067: public void doLayout() {
068: restoreOriginal();
069: theOriginalWindow.doLayout();
070: }
071:
072: public boolean equals(Object obj) {
073: restoreOriginal();
074: return theOriginalWindow.equals(obj);
075: }
076:
077: public VisualComponent findComponent(String aComponentName) {
078: restoreOriginal();
079: return theOriginalWindow.findComponent(aComponentName);
080: }
081:
082: public Rectangle getBounds() {
083: restoreOriginal();
084: return theOriginalWindow.getBounds();
085: }
086:
087: public VisualComponent getChildAt(int aPosition) {
088: restoreOriginal();
089: return theOriginalWindow.getChildAt(aPosition);
090: }
091:
092: public int getChildCount() {
093: restoreOriginal();
094: return theOriginalWindow.getChildCount();
095: }
096:
097: public List getChilds() {
098: restoreOriginal();
099: return theOriginalWindow.getChilds();
100: }
101:
102: public Object getClientProperty(Object aKey) {
103: restoreOriginal();
104: return theOriginalWindow.getClientProperty(aKey);
105: }
106:
107: public ComponentContributor getContributor() {
108: restoreOriginal();
109: return theOriginalWindow.getContributor();
110: }
111:
112: public Object getLockObject() {
113: restoreOriginal();
114: return theOriginalWindow.getLockObject();
115: }
116:
117: public String getName() {
118: return theVirtualName;
119: }
120:
121: public VisualComponent getParent() {
122: restoreOriginal();
123: return theOriginalWindow.getParent();
124: }
125:
126: public VisualComponent getRootComponent() {
127: restoreOriginal();
128: return theOriginalWindow.getRootComponent();
129: }
130:
131: public VisualComponent getTopParent() {
132: restoreOriginal();
133: return theOriginalWindow.getTopParent();
134: }
135:
136: public String getTypeId() {
137: restoreOriginal();
138: return theOriginalWindow.getTypeId();
139: }
140:
141: public String getUIClassID() {
142: restoreOriginal();
143: return theOriginalWindow.getUIClassID();
144: }
145:
146: public int hashCode() {
147: restoreOriginal();
148: return theOriginalWindow.hashCode();
149: }
150:
151: public void putClientProperty(Object aKey, Object aValue) {
152: restoreOriginal();
153: theOriginalWindow.putClientProperty(aKey, aValue);
154: }
155:
156: public void removeChild(VisualComponent aChild) {
157: restoreOriginal();
158: theOriginalWindow.removeChild(aChild);
159: }
160:
161: public void setBounds(Rectangle aRectangle) {
162: restoreOriginal();
163: theOriginalWindow.setBounds(aRectangle);
164: }
165:
166: public void setChilds(List list) {
167: restoreOriginal();
168: theOriginalWindow.setChilds(list);
169: }
170:
171: public void setContributor(ComponentContributor contributor) {
172: restoreOriginal();
173: theOriginalWindow.setContributor(contributor);
174: }
175:
176: public void setName(String string) {
177: restoreOriginal();
178: theOriginalWindow.setName(string);
179: }
180:
181: public void setParent(VisualComponent id) {
182: restoreOriginal();
183: theOriginalWindow.setParent(id);
184: }
185:
186: public void setRootComponent(VisualComponent aRootComponent) {
187: restoreOriginal();
188: theOriginalWindow.setRootComponent(aRootComponent);
189: }
190:
191: public String toString() {
192: restoreOriginal();
193: return theOriginalWindow.toString();
194: }
195:
196: public VisualWindow newInstance() {
197: restoreOriginal();
198: return theOriginalWindow.newInstance();
199: }
200:
201: public Object getVirtualInstance(
202: PersistenceContributionContainer aPersistenceContainer) {
203: restoreOriginal();
204: return ((Virtualizable) theOriginalWindow)
205: .getVirtualInstance(aPersistenceContainer);
206: }
207: }
|