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.html;
021:
022: /////////////////////////
023: //$Archive: /SOFIA/SourceCode/com/salmonllc/html/HtmlTableCellProperties.java $
024: //$Author: Dan $
025: //$Revision: 15 $
026: //$Modtime: 4/13/04 9:51a $
027: /////////////////////////
028:
029: /**
030: * This is used in conjunction with HtmlTable to set the properties for a particular cell
031: * @see HtmlTable#setComponentAt
032: */
033: public class HtmlTableCellProperties implements java.io.Serializable {
034: private String _align = HtmlTable.ALIGN_NONE;
035: private String _vAlign = HtmlTable.VALIGN_NONE;
036: private String _bgColor = null;
037: private boolean _wrap = true;
038: private int _colSpan = 1;
039: private int _rowSpan = 1;
040: //
041: private int _cellWidth = -1;
042: private int _cellHeight = -1;
043: //
044: private int _cellWidthSizeOption = HtmlTable.SIZE_PIXELS;
045: private int _cellHeightSizeOption = HtmlTable.SIZE_PIXELS;
046: HtmlStyle _style;
047: String _onMouseDown;
048: String _onMouseOut;
049: String _onMouseOver;
050: String _onMouseUp;
051: String _onClick;
052:
053: /** The following constants cover most uses of HtmlTableCellProperties.
054: * They are to be used instead of creating local instances page after page.
055: */
056:
057: public static HtmlTableCellProperties TOP_LEFT;
058: public static HtmlTableCellProperties TOP_LEFT_NO_WRAP;
059: public static HtmlTableCellProperties TOP_CENTER;
060: public static HtmlTableCellProperties TOP_CENTER_NO_WRAP;
061: public static HtmlTableCellProperties TOP_RIGHT;
062: public static HtmlTableCellProperties TOP_RIGHT_NO_WRAP;
063: public static HtmlTableCellProperties MIDDLE_LEFT;
064: public static HtmlTableCellProperties MIDDLE_LEFT_NO_WRAP;
065: public static HtmlTableCellProperties MIDDLE_CENTER;
066: public static HtmlTableCellProperties MIDDLE_CENTER_NO_WRAP;
067: public static HtmlTableCellProperties MIDDLE_RIGHT;
068: public static HtmlTableCellProperties MIDDLE_RIGHT_NO_WRAP;
069: public static HtmlTableCellProperties BOTTOM_LEFT;
070: public static HtmlTableCellProperties BOTTOM_LEFT_NO_WRAP;
071: public static HtmlTableCellProperties BOTTOM_CENTER;
072: public static HtmlTableCellProperties BOTTOM_CENTER_NO_WRAP;
073: public static HtmlTableCellProperties BOTTOM_RIGHT;
074: public static HtmlTableCellProperties BOTTOM_RIGHT_NO_WRAP;
075:
076: static {
077: TOP_LEFT = new HtmlTableCellProperties();
078: TOP_LEFT.setVertAlign(HtmlTable.VALIGN_TOP);
079: TOP_LEFT.setAlign(HtmlTable.ALIGN_LEFT);
080:
081: TOP_LEFT_NO_WRAP = new HtmlTableCellProperties();
082: TOP_LEFT_NO_WRAP.setVertAlign(HtmlTable.VALIGN_TOP);
083: TOP_LEFT_NO_WRAP.setAlign(HtmlTable.ALIGN_LEFT);
084: TOP_LEFT_NO_WRAP.setWrap(false);
085:
086: TOP_CENTER = new HtmlTableCellProperties();
087: TOP_CENTER.setVertAlign(HtmlTable.VALIGN_TOP);
088: TOP_CENTER.setAlign(HtmlTable.ALIGN_CENTER);
089:
090: TOP_CENTER_NO_WRAP = new HtmlTableCellProperties();
091: TOP_CENTER_NO_WRAP.setVertAlign(HtmlTable.VALIGN_TOP);
092: TOP_CENTER_NO_WRAP.setAlign(HtmlTable.ALIGN_CENTER);
093: TOP_CENTER_NO_WRAP.setWrap(false);
094:
095: TOP_RIGHT = new HtmlTableCellProperties();
096: TOP_RIGHT.setVertAlign(HtmlTable.VALIGN_TOP);
097: TOP_RIGHT.setAlign(HtmlTable.ALIGN_RIGHT);
098:
099: TOP_RIGHT_NO_WRAP = new HtmlTableCellProperties();
100: TOP_RIGHT_NO_WRAP.setVertAlign(HtmlTable.VALIGN_TOP);
101: TOP_RIGHT_NO_WRAP.setAlign(HtmlTable.ALIGN_RIGHT);
102: TOP_RIGHT_NO_WRAP.setWrap(false);
103:
104: MIDDLE_LEFT = new HtmlTableCellProperties();
105: MIDDLE_LEFT.setVertAlign(HtmlTable.VALIGN_MIDDLE);
106: MIDDLE_LEFT.setAlign(HtmlTable.ALIGN_LEFT);
107:
108: MIDDLE_LEFT_NO_WRAP = new HtmlTableCellProperties();
109: MIDDLE_LEFT_NO_WRAP.setVertAlign(HtmlTable.VALIGN_MIDDLE);
110: MIDDLE_LEFT_NO_WRAP.setAlign(HtmlTable.ALIGN_LEFT);
111: MIDDLE_LEFT_NO_WRAP.setWrap(false);
112:
113: MIDDLE_CENTER = new HtmlTableCellProperties();
114: MIDDLE_CENTER.setVertAlign(HtmlTable.VALIGN_MIDDLE);
115: MIDDLE_CENTER.setAlign(HtmlTable.ALIGN_CENTER);
116:
117: MIDDLE_CENTER_NO_WRAP = new HtmlTableCellProperties();
118: MIDDLE_CENTER_NO_WRAP.setVertAlign(HtmlTable.VALIGN_MIDDLE);
119: MIDDLE_CENTER_NO_WRAP.setAlign(HtmlTable.ALIGN_CENTER);
120: MIDDLE_CENTER_NO_WRAP.setWrap(false);
121:
122: MIDDLE_RIGHT = new HtmlTableCellProperties();
123: MIDDLE_RIGHT.setVertAlign(HtmlTable.VALIGN_MIDDLE);
124: MIDDLE_RIGHT.setAlign(HtmlTable.ALIGN_RIGHT);
125:
126: MIDDLE_RIGHT_NO_WRAP = new HtmlTableCellProperties();
127: MIDDLE_RIGHT_NO_WRAP.setVertAlign(HtmlTable.VALIGN_MIDDLE);
128: MIDDLE_RIGHT_NO_WRAP.setAlign(HtmlTable.ALIGN_RIGHT);
129: MIDDLE_RIGHT_NO_WRAP.setWrap(false);
130:
131: BOTTOM_LEFT = new HtmlTableCellProperties();
132: BOTTOM_LEFT.setVertAlign(HtmlTable.VALIGN_BOTTOM);
133: BOTTOM_LEFT.setAlign(HtmlTable.ALIGN_LEFT);
134:
135: BOTTOM_LEFT_NO_WRAP = new HtmlTableCellProperties();
136: BOTTOM_LEFT_NO_WRAP.setVertAlign(HtmlTable.VALIGN_BOTTOM);
137: BOTTOM_LEFT_NO_WRAP.setAlign(HtmlTable.ALIGN_LEFT);
138: BOTTOM_LEFT_NO_WRAP.setWrap(false);
139:
140: BOTTOM_CENTER = new HtmlTableCellProperties();
141: BOTTOM_CENTER.setVertAlign(HtmlTable.VALIGN_BOTTOM);
142: BOTTOM_CENTER.setAlign(HtmlTable.ALIGN_CENTER);
143:
144: BOTTOM_CENTER_NO_WRAP = new HtmlTableCellProperties();
145: BOTTOM_CENTER_NO_WRAP.setVertAlign(HtmlTable.VALIGN_BOTTOM);
146: BOTTOM_CENTER_NO_WRAP.setAlign(HtmlTable.ALIGN_CENTER);
147: BOTTOM_CENTER_NO_WRAP.setWrap(false);
148:
149: BOTTOM_RIGHT = new HtmlTableCellProperties();
150: BOTTOM_RIGHT.setVertAlign(HtmlTable.VALIGN_BOTTOM);
151: BOTTOM_RIGHT.setAlign(HtmlTable.ALIGN_RIGHT);
152:
153: BOTTOM_RIGHT_NO_WRAP = new HtmlTableCellProperties();
154: BOTTOM_RIGHT_NO_WRAP.setVertAlign(HtmlTable.VALIGN_BOTTOM);
155: BOTTOM_RIGHT_NO_WRAP.setAlign(HtmlTable.ALIGN_RIGHT);
156: BOTTOM_RIGHT_NO_WRAP.setWrap(false);
157: }
158:
159: /**
160: * Constructs a new empty object
161: */
162: public HtmlTableCellProperties() {
163: super ();
164: }
165:
166: /**
167: * Constructs a new object with all the properties set
168: * @param align Valid values are HtmlTable.ALIGN_LEFT,HtmlTable.ALIGN_CENTER,HtmlTable.ALIGN_RIGHT,HtmlTable.ALIGN_NONE
169: * @param vAlign Valid values are HtmlTable.VALIGN_BASELINE,HtmlTable.VALIGN_BOTTOM,HtmlTable.VALIGN_MIDDLE and HtmlTable.VALIGN_TOP.
170: * @param backGroundColor The background color for the cell.
171: * @param wrap True if the contents of the cell should word wrap.
172: */
173: public HtmlTableCellProperties(String align, String vAlign,
174: String backGroundColor, boolean wrap) {
175: super ();
176: _align = align;
177: _vAlign = vAlign;
178: _bgColor = backGroundColor;
179: _wrap = wrap;
180: }
181:
182: /**
183: * Returns the alignment for the cell. Values are HtmlTable.ALIGN_CENTER, HtmlTable.ALIGN_RIGHT, HtmlTable.ALIGN_LEFT, HtmlTable.ALIGN_NONE
184: */
185:
186: public String getAlign() {
187:
188: return _align;
189: }
190:
191: /**
192: * Returns the background color for the cell
193: */
194: public String getBackgroundColor() {
195: return _bgColor;
196: }
197:
198: /**
199: * This method gets the height of the table cell.
200: */
201: public int getCellHeight() {
202: return _cellHeight;
203: }
204:
205: /**
206: * This method gets the height size option of the table cell.
207: */
208: public int getCellHeightSizeOption() {
209: return _cellHeightSizeOption;
210: }
211:
212: /**
213: * This method gets the width of the table cell.
214: */
215: public int getCellWidth() {
216: return _cellWidth;
217: }
218:
219: /**
220: * This method gets the width size option of the table cell.
221: */
222: public int getCellWidthSizeOption() {
223: return _cellWidthSizeOption;
224: }
225:
226: /**
227: * This method gets the column span for a table cell
228: */
229: public int getColumnSpan() {
230: return _colSpan;
231: }
232:
233: /**
234: * Use this method to get the javascript that will be executed when the user clicks on one of the components in the link.
235: */
236: public String getOnClick() {
237: return _onClick;
238: }
239:
240: /**
241: * Use this method to get the javascript that will be executed when mouse clicks on the components with either mouse button
242: */
243: public String getOnMouseDown() {
244: return _onMouseDown;
245: }
246:
247: /**
248: * Use this method to get the javascript that will be executed when the mouse passes over out of all the components
249: */
250: public String getOnMouseOut() {
251: return _onMouseOut;
252: }
253:
254: /**
255: * Use this method to get the javascript that will be executed when the mouse passes over any component in the link
256: */
257: public String getOnMouseOver() {
258: return _onMouseOver;
259: }
260:
261: /**
262: * Use this method to get the javascript that will be executed when releases a mouse button while the mouse is over the component
263: */
264: public String getOnMouseUp() {
265: return _onMouseUp;
266: }
267:
268: /**
269: * This method gets the column span for a table cell
270: */
271: public int getRowSpan() {
272: return _rowSpan;
273: }
274:
275: /**
276: * This method was created in VisualAge.
277: * @return com.salmonllc.html.HtmlStyle
278: */
279: public HtmlStyle getStyle() {
280: return _style;
281: }
282:
283: /**
284: * Sets the vertical align property for the page. Valid values are HtmlTable.VALIGN_BASELINE,HtmlTable.VALIGN_BOTTOM,HtmlTable.VALIGN_MIDDLE,HtmlTable.VALIGN_TOP,HtmlTable.VALIGN_NONE
285: */
286: public String getVertAlign() {
287: return _vAlign;
288: }
289:
290: /**
291: * true false indicating whether the text in the component should wrap or not
292: */
293: public boolean getWrap() {
294: return _wrap;
295: }
296:
297: /**
298: * Sets the alignment for the cell. Values are HtmlTable.ALIGN_CENTER, HtmlTable.ALIGN_RIGHT, HtmlTable.ALIGN_LEFT, HtmlTable.ALIGN_NONE
299: */
300: public void setAlign(String value) {
301: _align = value;
302: }
303:
304: /**
305: * Sets the bacground color for the cell.
306: */
307: public void setBackgroundColor(String color) {
308: _bgColor = color;
309: }
310:
311: /**
312: * This method sets the height of the table cell. Overerides table column height.
313: * @param cellHeight the height of the cell
314: */
315: public void setCellHeight(int cellHeight) {
316: _cellHeight = cellHeight;
317: }
318:
319: /**
320: * This method sets the height of the table cell. Overerides table column height.
321: * @param cellHeight the height of the cell
322: * @param sizeOption SIZE_PIXELS or SIZE_PERCENT
323: */
324: public void setCellHeight(int cellHeight, int sizeOption) {
325: _cellHeight = cellHeight;
326: _cellHeightSizeOption = sizeOption;
327: }
328:
329: /**
330: * This method sets the height size option for the cell
331: * @param sizeOption SIZE_PIXELS or SIZE_PERCENT
332: */
333: public void setCellHeightSizeOption(int sizeOption) {
334: _cellHeightSizeOption = sizeOption;
335: }
336:
337: /**
338: * This method sets the width of the table cell. Overerides table column width.
339: * @param cellWidth the width of the cell
340: */
341: public void setCellWidth(int cellWidth) {
342: _cellWidth = cellWidth;
343: }
344:
345: /**
346: * This method sets the width of the table cell. Overerides table column width.
347: * @param cellWidth the width of the cell
348: * @param sizeOption SIZE_PIXELS or SIZE_PERCENT
349: */
350: public void setCellWidth(int cellWidth, int sizeOption) {
351: _cellWidth = cellWidth;
352: _cellWidthSizeOption = sizeOption;
353: }
354:
355: /**
356: * This method sets the width size option for the cell
357: * @param sizeOption SIZE_PIXELS or SIZE_PERCENT
358: */
359: public void setCellWidthSizeOption(int sizeOption) {
360: _cellHeightSizeOption = sizeOption;
361: }
362:
363: /**
364: * This method sets the column span for a table cell
365: * @param colSpan the number of columns to span
366: */
367: public void setColumnSpan(int colSpan) {
368: _colSpan = colSpan;
369: }
370:
371: /**
372: * Use this method to set the javascript that will be executed when the user clicks on one of the components in the link.
373: */
374: public void setOnClick(String onClick) {
375: _onClick = onClick;
376: }
377:
378: /**
379: * Use this method to get the javascript that will be executed when mouse clicks on the components with either mouse button
380: */
381: public void setOnMouseDown(String onMouseDown) {
382: _onMouseDown = onMouseDown;
383: }
384:
385: /**
386: * Use this method to set the javascript that will be executed when the mouse passes over out of all the components
387: */
388: public void setOnMouseOut(String onMouseOut) {
389: _onMouseOut = onMouseOut;
390: }
391:
392: /**
393: * Use this method to set the javascript that will be executed when the mouse passes over any component in the link
394: */
395: public void setOnMouseOver(String onMouseOver) {
396: _onMouseOver = onMouseOver;
397: }
398:
399: /**
400: * Use this method to get the javascript that will be executed when releases a mouse button while the mouse is over the component
401: */
402: public void setOnMouseUp(String onMouseUp) {
403: _onMouseUp = onMouseUp;
404: }
405:
406: /**
407: * This method sets the column span for a table cell
408: * @param colSpan the number of columns to span
409: */
410: public void setRowSpan(int rowSpan) {
411: _rowSpan = rowSpan;
412: }
413:
414: /**
415: * This method was created in VisualAge.
416: * @param style com.salmonllc.html.HtmlStyle
417: */
418: public void setStyle(HtmlStyle style) {
419: _style = style;
420: }
421:
422: /**
423: * Sets the vertical align property for the page. Valid values are HtmlTable.VALIGN_BASELINE,HtmlTable.VALIGN_BOTTOM,HtmlTable.VALIGN_MIDDLE,HtmlTable.VALIGN_TOP,HtmlTable.VALIGN_NONE
424: */
425:
426: public void setVertAlign(String value) {
427: _vAlign = value;
428: }
429:
430: /**
431: * Sets whether or not the text in the cell should wrap if there isn't enough room to display it.
432: */
433: public void setWrap(boolean value) {
434: _wrap = value;
435: }
436: }
|