001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets.plaf.html;
006:
007: import java.awt.*;
008: import java.awt.event.*;
009: import java.util.*;
010: import java.io.*;
011:
012: import com.javelin.swinglets.*;
013: import com.javelin.swinglets.plaf.*;
014: import com.javelin.swinglets.theme.*;
015:
016: /**
017: * HTMLComponentUI defines a look and feel for HTML.
018: *
019: * @author Robin Sharp
020: */
021:
022: public abstract class HTMLComponentUI implements SComponentUI {
023: public final static String CSS_CLASS = "CSS_CLASS";
024:
025: /**
026: * Get the look and feel class.
027: */
028: public Class getLookAndFeel() {
029: return HTMLLookAndFeel.class;
030: }
031:
032: /**
033: * Utility Method to get the theme.
034: */
035: public STheme getTheme() {
036: SwingletManager sm = SwingletManager.getSwingletManager();
037:
038: if (sm == null) {
039: return SwingletManager.getDefaultTheme();
040: } else {
041: return sm.getTheme();
042: }
043: }
044:
045: /**
046: * Update any FrameSets
047: */
048: public void initFrameSets(SComponent c) {
049: }
050:
051: /**
052: * Render the UI on the Object, in the header part of the Web Page
053: */
054: public void updateHeader(Object out, SComponent c) {
055: updateHeader((PrintWriter) out, c);
056: }
057:
058: /**
059: * Render the script code in the the Header.
060: */
061: public void updateScript(Object out, SComponent c) {
062: updateScript((PrintWriter) out, c);
063: }
064:
065: /**
066: * Update the component header.
067: */
068: public void updateComponentHeader(Object out, SComponent c) {
069: updateComponentHeader((PrintWriter) out, c);
070: };
071:
072: /**
073: * Render the UI on the Object, in the body part of the web page
074: */
075: public void update(Object out, SComponent c) {
076: update((PrintWriter) out, c);
077: }
078:
079: /**
080: * Update the component footer.
081: */
082: public void updateComponentFooter(Object out, SComponent c) {
083: updateComponentFooter((PrintWriter) out, c);
084: }
085:
086: /**
087: * Render the event handling script on the output, in the body part of the
088: * web page
089: */
090: public void updateEvent(Object out, SComponent c) {
091: updateEvent((PrintWriter) out, c);
092: }
093:
094: /**
095: * Render the UI on the output, in the header part of the Web Page
096: */
097: public void updateHeader(PrintWriter out, SComponent c) {
098: }
099:
100: /**
101: * Render the script code in the Header part of the Web Page.
102: */
103: public void updateScript(PrintWriter out, SComponent c) {
104: }
105:
106: /**
107: * Update the component header.
108: */
109: public void updateComponentHeader(PrintWriter out, SComponent c) {
110: };
111:
112: /**
113: * Render the UI on the PrintWriter, in the body part of the web page
114: */
115: public void update(PrintWriter out, SComponent c) {
116: }
117:
118: /**
119: * Update the component footer.
120: */
121: public void updateComponentFooter(PrintWriter out, SComponent c) {
122: }
123:
124: /**
125: * Render the script on the PrintWriter, in the body part of the web page
126: */
127: public void updateEvent(PrintWriter out, SComponent c) {
128: }
129:
130: /**
131: * Tell the underlying UI that the component has been changed.
132: */
133: public void update(SComponent c, int id, int index) {
134: };
135:
136: /**
137: * Tell the underlying UI that the component has been changed.
138: */
139: public void update(SComponent c, int id, Object constraint) {
140: };
141:
142: // EVENTS ///////////////////////////////////////////////////////////////
143:
144: /**
145: * @see com.javelin.swinglets.plaf.SComponentUI.addListener()
146: */
147: public void addListener(EventListener listener) {
148: addInternal(listener);
149: }
150:
151: /**
152: * @see com.javelin.swinglets.plaf.SComponentUI.removeListener()
153: */
154: public void removeListener(EventListener listener) {
155: addInternal(listener);
156: }
157:
158: /**
159: * Adds the listeners to receive component events from
160: * the SComponent at initialisation.
161: */
162: public void addListeners(SComponent component) {
163: }
164:
165: /**
166: * Removes all the listeners that received component events from
167: * the SComponent at initialisation.
168: */
169: public void removeListeners(SComponent component) {
170: }
171:
172: protected void addInternal(EventListener listener) {
173: if (swingletListeners == null) {
174: swingletListeners = new Vector();
175: }
176:
177: swingletListeners.addElement(listener);
178: }
179:
180: protected void removeInternal(EventListener listener) {
181: if (swingletListeners != null) {
182: swingletListeners.removeElement(listener);
183: }
184: }
185:
186: protected Vector swingletListeners;
187: }
|