KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: AbstractComponentCG.java,v 1.34 2005/06/08 10:07:09 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.apache.commons.logging.Log;
17 import org.apache.commons.logging.LogFactory;
18 import org.wings.SComponent;
19 import org.wings.SConstants;
20 import org.wings.io.Device;
21 import org.wings.plaf.ComponentCG;
22 import org.wings.session.SessionManager;
23 import org.wings.style.CSSSelector;
24
25 import java.io.IOException JavaDoc;
26 import java.io.Serializable JavaDoc;
27
28 /**
29  * Partial CG implementation that is common to all ComponentCGs.
30  *
31  * @author <a HREF="mailto:engels@mercatis.de">Holger Engels</a>
32  * @version $Revision: 1.34 $
33  */

34 public abstract class AbstractComponentCG implements ComponentCG, SConstants, Serializable JavaDoc {
35     private final static transient Log log = LogFactory.getLog(AbstractComponentCG.class);
36     
37     protected AbstractComponentCG() {
38     }
39
40     /**
41      * Install the appropriate CG for <code>component</code>.
42      *
43      * @param component the component
44      */

45     public void installCG(SComponent component) {
46         Class JavaDoc clazz = component.getClass();
47         while ("org.wings".equals(clazz.getPackage().getName()) == false)
48             clazz = clazz.getSuperclass();
49         String JavaDoc style = clazz.getName();
50         style = style.substring(style.lastIndexOf('.') + 1);
51         component.setStyle(style); // set default style name to component class (ie. SLabel).
52
}
53
54     /**
55      * Uninstall the CG from <code>component</code>.
56      *
57      * @param component the component
58      */

59     public void uninstallCG(SComponent component) {
60     }
61
62     public void write(Device device, SComponent component) throws IOException JavaDoc {
63         if (!component.isVisible())
64             return;
65         writePrefix(device, component);
66         writeContent(device, component);
67         writeSuffix(device, component);
68     }
69     
70     
71     protected void writePrefix(Device device, SComponent component) throws IOException JavaDoc {
72         SessionManager.getSession().getCGManager().getPrefixSuffixDelegate().writePrefix(device, component);
73     }
74     
75     protected void writeSuffix(Device device, SComponent component) throws IOException JavaDoc {
76         SessionManager.getSession().getCGManager().getPrefixSuffixDelegate().writeSuffix(device, component);
77     }
78
79     public CSSSelector mapSelector(SComponent addressedComponent, CSSSelector selector) {
80         // Default: Do not map/modify the passed CSS selector.
81
return selector;
82     }
83
84     protected void writeContent(Device device, SComponent component) throws IOException JavaDoc {
85     }
86 }
87
Popular Tags