KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > plaf > css > TemplateLayoutCG


1 /*
2  * $Id: TemplateLayoutCG.java,v 1.2 2005/05/26 14:29:41 neurolabs Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.plaf.css;
15
16 import org.wings.SLayoutManager;
17 import org.wings.STemplateLayout;
18 import org.wings.io.Device;
19 import org.wings.plaf.LayoutCG;
20 import org.wings.template.*;
21 import org.wings.template.parser.PageParser;
22
23 import java.io.IOException JavaDoc;
24
25 /**
26  * @author Achim Derigs
27  * @version $Revision: 1.2 $
28  */

29 public class TemplateLayoutCG implements LayoutCG {
30     /**
31      * The parser looks for the '<OBJECT></OBJECT>' - tags.
32      */

33     static {
34         PageParser parser = PageParser.getInstance();
35         parser.addTagHandler("OBJECT", RangeTagHandler.class);
36         parser.addTagHandler("WINGSOBJECT", RangeTagHandler.class);
37         parser.addTagHandler("TEXTAREA", RangeTagHandler.class);
38         parser.addTagHandler("SELECT", RangeTagHandler.class);
39         parser.addTagHandler("INPUT", SimpleTagHandler.class);
40         parser.addTagHandler("LABEL", LabelTagHandler.class);
41     }
42
43
44     private void write(Device device, STemplateLayout layout)
45             throws IOException JavaDoc {
46         final TemplateSource source = layout.getTemplateSource();
47
48         if (source == null) {
49             device.print("Unable to open template-file <em>'");
50             device.print(source);
51             device.print("'</em>");
52         } else {
53             layout.getPageParser().process(source, new TemplateParseContext(device, layout));
54         }
55     }
56
57     /**
58      * @param device the device to write the code to
59      * @param manager the layout manager
60      * @throws IOException
61      */

62     public void write(Device device, SLayoutManager manager)
63             throws IOException JavaDoc {
64         write(device, (STemplateLayout) manager);
65     }
66 }
67
68
69
Popular Tags