01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings.plaf.css;
14:
15: import java.io.IOException;
16:
17: import org.wings.*;
18: import org.wings.io.Device;
19: import org.wings.plaf.LayoutCG;
20: import org.wings.template.LabelTagHandler;
21: import org.wings.template.RangeTagHandler;
22: import org.wings.template.SimpleTagHandler;
23: import org.wings.template.TemplateParseContext;
24: import org.wings.template.TemplateSource;
25: import org.wings.template.parser.PageParser;
26:
27: /**
28: * @author Achim Derigs
29: */
30: public class TemplateLayoutCG implements LayoutCG {
31: /**
32: *
33: */
34: private static final long serialVersionUID = 1L;
35:
36: /**
37: * The parser looks for the '<OBJECT></OBJECT>' - tags.
38: */
39: static {
40: PageParser parser = PageParser.getInstance();
41: parser.addTagHandler("OBJECT", RangeTagHandler.class);
42: parser.addTagHandler("WINGSOBJECT", RangeTagHandler.class);
43: parser.addTagHandler("TEXTAREA", RangeTagHandler.class);
44: parser.addTagHandler("SELECT", RangeTagHandler.class);
45: parser.addTagHandler("INPUT", SimpleTagHandler.class);
46: parser.addTagHandler("LABEL", LabelTagHandler.class);
47: }
48:
49: private void write(Device device, STemplateLayout layout)
50: throws IOException {
51: final TemplateSource source = layout.getTemplateSource();
52:
53: if (source == null) {
54: device
55: .print("Unable to open template-file <em>null</em> in '"
56: + layout);
57: } else {
58: layout.getPageParser().process(source,
59: new TemplateParseContext(device, layout));
60: }
61: }
62:
63: /**
64: * @param device the device to write the code to
65: * @param manager the layout manager
66: * @throws IOException
67: */
68: public void write(Device device, SLayoutManager manager)
69: throws IOException {
70: write(device, (STemplateLayout) manager);
71: }
72: }
|