001: package com.salmonllc.jsp;
002:
003: /////////////////////////
004: //$Archive: /SOFIA/SourceCode/com/salmonllc/jsp/JspBox.java $
005: //$Author: Dan $
006: //$Revision: 9 $
007: //$Modtime: 12/19/03 1:07p $
008: /////////////////////////
009: import com.salmonllc.html.HtmlPage;
010: import com.salmonllc.properties.Props;
011:
012: /**
013: * This container draws a box around the components inside
014: */
015:
016: public class JspBox extends JspContainer {
017: private String _lineWidth, _bgColor, _lineColor, _theme, _width,
018: _margin, _height;
019:
020: /**
021: * Creates a new JSP Box
022: */
023: public JspBox(String name, HtmlPage p) {
024: this (name, p, null);
025: }
026:
027: /**
028: * Creates a new JSP Box with the specified theme
029: */
030: public JspBox(String name, HtmlPage p, String theme) {
031: super (name, p);
032: setTheme(theme);
033: }
034:
035: /**
036: *Generates the Html for the component. This method is called by the framework and should not be called directly
037: */
038: public void generateHTML(TagWriter t, String box)
039: throws java.io.IOException {
040: StringBuffer sb = new StringBuffer();
041:
042: if (_lineColor.toUpperCase().equals("NONE"))
043: sb.append("<table border=\"0\"");
044: else {
045: sb.append("<table border=\"0\" bgcolor=\"");
046: sb.append(_lineColor);
047: }
048: if (_width != null) {
049: sb.append("\" width=\"");
050: sb.append(_width);
051: }
052: if (_height != null) {
053: sb.append("\" height=\"");
054: sb.append(_height);
055: }
056: sb.append("\" cellpadding=\"");
057: sb.append(_lineWidth);
058: sb.append("\" cellspacing=\"0\"><tr><td>");
059: sb
060: .append("<table height=\"100%\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"");
061: sb.append(_margin);
062: sb.append("\">");
063: if (_bgColor.toUpperCase().equals("NONE"))
064: sb.append("<tr>");
065: else {
066: sb.append("<tr bgcolor=\"");
067: sb.append(_bgColor);
068: sb.append("\">");
069: }
070: sb.append("<td>");
071:
072: t.print(sb.toString(), TagWriter.TYPE_BEGIN_TAG);
073: t.print(box, TagWriter.TYPE_CONTENT);
074: t.print("</td></tr></table></td></tr></table>",
075: TagWriter.TYPE_END_TAG);
076:
077: }
078:
079: /**
080: * Returns the background color of the box contents
081: */
082:
083: public String getBgColor() {
084: return _bgColor;
085: }
086:
087: /**
088: * Returns the line color for the line surrounding the box
089: */
090:
091: public String getLineColor() {
092: return _lineColor;
093: }
094:
095: /**
096: * Returns the width of the line of the box in pixels
097: */
098: public String getLineWidth() {
099: return _lineWidth;
100: }
101:
102: /**
103: * Returns the gap in pixels between the border line and the contents of the box
104: */
105:
106: public String getMargin() {
107: return _margin;
108: }
109:
110: /**
111: * This method returns the property theme for the component.
112: * @param theme The theme to use.
113: */
114: public String getTheme() {
115: return _theme;
116: }
117:
118: /**
119: * Returns the width of the table
120: */
121: public String getWidth() {
122: return _width;
123: }
124:
125: /**
126: * Sets the background color of the box contents
127: */
128:
129: public void setBgColor(String bgColor) {
130: _bgColor = bgColor;
131: }
132:
133: /**
134: * Sets the line color for the line surrounding the box
135: */
136:
137: public void setLineColor(String lineColor) {
138: _lineColor = lineColor;
139: }
140:
141: /**
142: * Sets the width of the line of the box in pixels
143: */
144:
145: public void setLineWidth(String lineWidth) {
146: _lineWidth = lineWidth;
147: }
148:
149: /**
150: * Sets the gap in pixels between the border line and the contents of the box
151: */
152: public void setMargin(String borderSpacing) {
153: _margin = borderSpacing;
154: }
155:
156: /**
157: * This method sets the property theme for the component.
158: * @param theme The theme to use.
159: */
160: public void setTheme(String theme) {
161: Props prop = getPage().getPageProperties();
162:
163: _lineWidth = prop.getThemeProperty(theme, Props.BOX_LINE_WIDTH);
164: if (_lineWidth == null)
165: _lineWidth = "1";
166: _margin = prop.getThemeProperty(theme, Props.BOX_MARGIN);
167: if (_margin == null)
168: _margin = "1";
169:
170: _lineColor = prop.getThemeProperty(theme, Props.BOX_LINE_COLOR);
171: if (_lineColor == null)
172: _lineColor = "black";
173:
174: _bgColor = prop.getThemeProperty(theme, Props.BOX_BG_COLOR);
175: if (_bgColor == null)
176: _bgColor = "white";
177:
178: _theme = theme;
179: }
180:
181: /**
182: * Sets the width of the table
183: */
184: public void setWidth(String width) {
185: _width = width;
186: }
187:
188: /**
189: * @return the height of the table
190: */
191: public String getHeight() {
192: return _height;
193: }
194:
195: /**
196: * Sets the height of the table
197: */
198: public void setHeight(String string) {
199: _height = string;
200: }
201:
202: }
|