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.render.templates.html;
019:
020: import java.awt.*;
021: import java.util.*;
022: import java.util.List;
023:
024: import net.ar.webonswing.render.markup.*;
025: import net.ar.webonswing.render.templates.*;
026: import net.ar.webonswing.visitor.*;
027: import net.ar.webonswing.wrapping.*;
028:
029: public class KeyPositionHtmlTemplate extends HtmlTemplate implements
030: KeyPositionTemplate, PublicCloneable {
031: HashMap theKeys = new HashMap();
032: HtmlTemplate theHtmlTemplate;
033:
034: public KeyPositionHtmlTemplate(HtmlTemplate aHtmlTemplate) {
035: theHtmlTemplate = aHtmlTemplate;
036: }
037:
038: public Rectangle addKey(String aKey, VisualComponent aComponent) {
039: theKeys.put(aComponent, aKey);
040: return aComponent.getBounds(); //TODO: Hacer que tome las dimensiones del template
041: }
042:
043: public void addElement(TemplateElement anElement) {
044: if (theKeys.containsKey(anElement.getId()))
045: anElement.setId(theKeys.get(anElement.getId()));
046:
047: theHtmlTemplate.addElement(anElement);
048: }
049:
050: public void accept(Visitor aVisitor) {
051: theHtmlTemplate.accept(aVisitor);
052: }
053:
054: public boolean equals(Object obj) {
055: return theHtmlTemplate.equals(obj);
056: }
057:
058: public TemplateElement getElementForId(Object anId) {
059: return theHtmlTemplate.getElementForId(anId);
060: }
061:
062: public void setFoundTag(Tag aTag) {
063: theHtmlTemplate.setFoundTag(aTag);
064: }
065:
066: public void removeElement(TemplateElement anElement) {
067: theHtmlTemplate.removeElement(anElement);
068: }
069:
070: public List getElements() {
071: return theHtmlTemplate.getElements();
072: }
073:
074: public void setBody(TemplateBody aBody) {
075: theHtmlTemplate.setBody(aBody);
076: }
077:
078: public Tag getFoundTag() {
079: return theHtmlTemplate.getFoundTag();
080: }
081:
082: public String toString() {
083: return theHtmlTemplate.toString();
084: }
085:
086: public int hashCode() {
087: return theHtmlTemplate.hashCode();
088: }
089:
090: public HtmlTemplateBody getHtmlTemplateBody() {
091: return theHtmlTemplate.getHtmlTemplateBody();
092: }
093:
094: public TemplateBody getBody() {
095: return theHtmlTemplate.getBody();
096: }
097:
098: public Object clone() throws CloneNotSupportedException {
099: KeyPositionHtmlTemplate theClone = new KeyPositionHtmlTemplate(
100: theHtmlTemplate != null ? (HtmlTemplate) theHtmlTemplate
101: .clone()
102: : null);
103: theClone.theKeys = (HashMap) theKeys.clone();
104: return theClone;
105: }
106:
107: }
|