01: package net.xoetrope.builder.editor;
02:
03: import net.xoetrope.xui.style.XStyleFactory;
04: import java.awt.Component;
05: import net.xoetrope.xui.style.XStyle;
06:
07: /**
08: * Save the style information for use in the editor when components are created
09: * programatically
10: * <p> Copyright (c) Xoetrope Ltd., 2002-2003</p>
11: * <p> $Revision: 1.12 $</p>
12: * <p> License: see License.txt</p>
13: */
14: public class XEditorStyleFactory extends XStyleFactory {
15: private XPageResource pageResource;
16:
17: /**
18: * Create the StyleFactory and initialise with an XStyleManager.
19: * @param pageRes the page resource/owner object
20: * @param manager the XStyleManager to initialise with
21: */
22: public XEditorStyleFactory(XPageResource pageRes, String packageName) {
23: super (packageName);
24: pageResource = pageRes;
25: }
26:
27: /**
28: * Apply a style to a component, looking up the style name if necessary
29: * @param c the component to style
30: * @param style the style name
31: * @param lookupComp true to lookup the style based on the component class
32: */
33: public void applyStyle(Component c, String style, boolean lookupComp) {
34: super .applyStyle(c, style, lookupComp);
35: pageResource.setStyleName(c, style);
36:
37: if (style == null || style.length() == 0) {
38: String compName = c.getClass().getName();
39: if (compName.compareTo("XLabelProxy") == 0) {
40: XStyle compStyle = this .styleManager.getStyle("XLabel");
41: super.applyStyle(c, compStyle);
42: }
43: }
44: }
45: }
|