001: //** Copyright Statement ***************************************************
002: //The Salmon Open Framework for Internet Applications (SOFIA)
003: // Copyright (C) 1999 - 2002, Salmon LLC
004: //
005: // This program is free software; you can redistribute it and/or
006: // modify it under the terms of the GNU General Public License version 2
007: // as published by the Free Software Foundation;
008: //
009: // This program is distributed in the hope that it will be useful,
010: // but WITHOUT ANY WARRANTY; without even the implied warranty of
011: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: // GNU General Public License for more details.
013: //
014: // You should have received a copy of the GNU General Public License
015: // along with this program; if not, write to the Free Software
016: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017: //
018: // For more information please visit http://www.salmonllc.com
019: //** End Copyright Statement ***************************************************
020: package com.salmonllc.jsp;
021:
022: /////////////////////////
023: //$Archive: /SOFIA/SourceCode/com/salmonllc/jsp/JspTableRow.java $
024: //$Author: Dan $
025: //$Revision: 18 $
026: //$Modtime: 10/21/04 2:40p $
027: /////////////////////////
028:
029: import com.salmonllc.html.*;
030:
031: /**
032: * This class is used to represent on row <TR> in an JSP Table
033: */
034: public class JspTableRow extends JspContainer {
035: private String _align = HtmlTable.ALIGN_NONE;
036: private String _vAlign = HtmlTable.VALIGN_NONE;
037: private String _bgcolor = null;
038: private String _style = null;
039: private String _id = null;
040: private String _onmouseover = null;
041: private String _onmouseout = null;
042: private String _onmousedown = null;
043: private String _onclick = null;
044: private String _inLineStyle = null;
045:
046: public JspTableRow(String name, com.salmonllc.html.HtmlPage p) {
047: super (name, p);
048: }
049:
050: public void generateHTML(TagWriter t, String content,
051: String defaultBackgroundColor, String defaultStyleClass,
052: int rowNo) throws java.io.IOException {
053: if (!getVisible())
054: return;
055:
056: JspDataTable tab = getParentDataTable();
057: HtmlRowHighlighter rowHighligher = null;
058: if (tab != null)
059: rowHighligher = tab.getRowHighlighter();
060:
061: StringBuffer sb = new StringBuffer();
062:
063: sb.append("<TR");
064:
065: if (getAlign() != null) {
066: if (!getAlign().equals(HtmlTable.ALIGN_NONE))
067: sb.append(" ALIGN=\"" + getAlign() + "\"");
068: }
069: if (getVertAlign() != null) {
070: if (!getVertAlign().equals(HtmlTable.VALIGN_NONE))
071: sb.append(" VALIGN=\"" + getVertAlign() + "\"");
072: }
073:
074: if (getStyle() != null)
075: sb.append(" CLASS=\"" + getStyle() + "\"");
076: else if (defaultStyleClass != null)
077: sb.append(" CLASS=\"" + defaultStyleClass + "\"");
078:
079: if (getInLineStyle() != null)
080: sb.append(" STYLE=\"" + getInLineStyle() + "\"");
081:
082: String bgColor = "";
083: if (getBackgroundColor() != null) {
084: if (!getBackgroundColor().equals(""))
085: bgColor = getBackgroundColor();
086: } else if (defaultBackgroundColor != null) {
087: if (!defaultBackgroundColor.equals(""))
088: bgColor = defaultBackgroundColor;
089: }
090:
091: if (tab != null && tab.getRowHighlighter() != null)
092: sb.append(" BGCOLOR=\""
093: + tab.getRowHighlighter().getBgColorForRow(rowNo,
094: bgColor, this ) + "\"");
095: else
096: sb.append(" BGCOLOR=\"" + bgColor + "\"");
097:
098: if (getOnmouseover() != null) {
099: sb.append(" onMouseOver=\"" + getOnmouseover() + "\"");
100: }
101: if (getOnmouseout() != null) {
102: sb.append(" onMouseOut=\"" + getOnmouseout() + "\"");
103: }
104:
105: String onMouseDown = "";
106: if (getOnmousedown() != null)
107: onMouseDown += getOnmousedown();
108: if (rowHighligher != null)
109: onMouseDown += rowHighligher
110: .generateJavaScriptForTrOnMouseDown(rowNo, this );
111: if (onMouseDown.length() > 0)
112: sb.append(" onMouseDown=\"" + onMouseDown + "\"");
113:
114: String onClick = "";
115: if (getOnclick() != null)
116: onClick += getOnclick();
117: if (rowHighligher != null)
118: onClick += rowHighligher.generateJavaScriptForTrOnClick();
119: if (onClick.length() > 0)
120: sb.append(" onClick=\"" + onClick + "\"");
121:
122: sb.append(">");
123:
124: t.print(sb.toString(), TagWriter.TYPE_BEGIN_TAG);
125: t.print(content, TagWriter.TYPE_CONTENT);
126: t.print("</TR>", TagWriter.TYPE_END_TAG);
127:
128: }
129:
130: /**
131: * Returns the alignment of the row
132: */
133: public String getAlign() {
134: return _align;
135: }
136:
137: /**
138: * Returns the background color of the row
139: */
140: public String getBackgroundColor() {
141: return _bgcolor;
142: }
143:
144: /**
145: * Returns the style of the row
146: */
147: public String getStyle() {
148: return _style;
149: }
150:
151: /**
152: * Returns the vertical alignment of the row
153: */
154: public String getVertAlign() {
155: return _vAlign;
156: }
157:
158: /**
159: * Sets the alignment of the row
160: */
161: public void setAlign(String value) {
162: _align = value;
163: }
164:
165: /**
166: * Sets the background color of the row
167: */
168:
169: public void setBackgroundColor(String color) {
170: _bgcolor = color;
171: }
172:
173: /**
174: * Sets the style of the row
175: */
176:
177: public void setStyle(String style) {
178: _style = style;
179: }
180:
181: /**
182: * Sets the vertical alignment of the row
183: */
184:
185: public void setVertAlign(String value) {
186: _vAlign = value;
187: }
188:
189: public void setId(String id) {
190: _id = id;
191: }
192:
193: public String getId() {
194: return _id;
195: }
196:
197: /**
198: * @return
199: */
200: public String getOnclick() {
201: return _onclick;
202: }
203:
204: /**
205: * @return
206: */
207: public String getOnmouseout() {
208: return _onmouseout;
209: }
210:
211: /**
212: * @return
213: */
214: public String getOnmouseover() {
215: return _onmouseover;
216: }
217:
218: /**
219: * @param string
220: */
221: public void setOnclick(String string) {
222: _onclick = string;
223: }
224:
225: /**
226: * @param string
227: */
228: public void setOnmouseout(String string) {
229: _onmouseout = string;
230: }
231:
232: /**
233: * @param string
234: */
235: public void setOnmouseover(String string) {
236: _onmouseover = string;
237: }
238:
239: /**
240: * Gets the in line style of the row
241: */
242: public String getInLineStyle() {
243: return _inLineStyle;
244: }
245:
246: /**
247: * Sets the in line style of the row
248: */
249: public void setInLineStyle(String string) {
250: _inLineStyle = string;
251: }
252:
253: /**
254: * @return Returns the onmousedown.
255: */
256: public String getOnmousedown() {
257: return _onmousedown;
258: }
259:
260: /**
261: * @param onmousedown The onmousedown to set.
262: */
263: public void setOnmousedown(String onmousedown) {
264: _onmousedown = onmousedown;
265: }
266:
267: /**
268: * @return the parent datatable that this component is in
269: */
270: public JspDataTable getParentDataTable() {
271: HtmlComponent parent = getParent();
272: while (parent != null) {
273: if (parent instanceof JspDataTable)
274: return (JspDataTable) parent;
275: parent = parent.getParent();
276: }
277: return null;
278: }
279: }
|