Source Code Cross Referenced for HtmlText.java in  » J2EE » Sofia » com » salmonllc » html » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Sofia » com.salmonllc.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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/HtmlText.java $
024:        //$Author: Dan $
025:        //$Revision: 32 $
026:        //$Modtime: 8/20/03 12:53p $
027:        /////////////////////////
028:
029:        import com.salmonllc.localizer.LanguagePreferences;
030:        import com.salmonllc.localizer.LanguageResourceFinder;
031:        import com.salmonllc.properties.Props;
032:        import com.salmonllc.sql.DataStoreBuffer;
033:        import com.salmonllc.sql.DataStoreEvaluator;
034:        import com.salmonllc.sql.DataStoreExpression;
035:
036:        /**
037:         * This type can be used to add text to your page.
038:         */
039:        public class HtmlText extends HtmlComponent {
040:            public static final String FONT_NONE = "None";
041:            public static final String FONT_DEFAULT = Props.FONT_DEFAULT;
042:            public static final String FONT_TEXT_EDIT = Props.FONT_TEXT_EDIT;
043:            public static final String FONT_BUTTON = Props.FONT_BUTTON;
044:            public static final String FONT_PAGE_HEADING = Props.FONT_PAGE_HEADING;
045:            public static final String FONT_SECTION_HEADING = Props.FONT_SECTION_HEADING;
046:            public static final String FONT_TABLE_HEADING = Props.FONT_TABLE_HEADING;
047:            public static final String FONT_COLUMN_CAPTION = Props.FONT_COLUMN_CAPTION;
048:            public static final String FONT_EMPHASIS = Props.FONT_EMPHASIS;
049:            public static final String FONT_ERROR = Props.FONT_ERROR;
050:            public static final String FONT_LINK = Props.FONT_LINK;
051:            public static final String FONT_LARGE_LINK = Props.FONT_LARGE_LINK;
052:            public static final String FONT_SMALL = Props.FONT_SMALL;
053:            public static final String FONT_DEFAULT_LABEL_TEXT = Props.FONT_DEFAULT_LABEL_TEXT;
054:            public static final String FONT_DEFAULT_DISPLAY_DATA = Props.FONT_DEFAULT_DISPLAY_DATA;
055:
056:            public boolean _center = false;
057:
058:            public static final int AGGREGATE_SUM = DataStoreEvaluator.AGGREGATE_SUM;
059:            public static final int AGGREGATE_COUNT = DataStoreEvaluator.AGGREGATE_COUNT;
060:            public static final int AGGREGATE_AVERAGE = DataStoreEvaluator.AGGREGATE_AVERAGE;
061:
062:            private String _font;
063:            private String _fontStartTag;
064:            private String _fontEndTag;
065:            private String _text;
066:            private int _aggregateType = -1;
067:
068:            private DataStoreEvaluator _dsEval = null;
069:            private boolean _fixSpecialHtml = true;
070:            private String _theme;
071:            private HtmlStyle _style;
072:            private String _onMouseOut;
073:            private String _onMouseOver;
074:
075:            private String _textLocaleKey;
076:            private String _formatLocaleKey;
077:            private String _displayFormat;
078:            private boolean _updateLocale;
079:
080:            /**
081:             * Constructs an html text object for the page using the default font.
082:             * @param text The text to place in the page.
083:             * @param p The page to put the text in.
084:             */
085:            public HtmlText(String text, HtmlPage p) {
086:                super ("", p);
087:                _text = text;
088:                _font = FONT_DEFAULT;
089:
090:                setTheme(null);
091:
092:            }
093:
094:            /**
095:             * This method was created in VisualAge.
096:             * @param text java.lang.String
097:             * @param style com.salmonllc.html.HtmlStyle
098:             * @param p com.salmonllc.html.HtmlPage
099:             */
100:            public HtmlText(String text, HtmlStyle style, HtmlPage p) {
101:                super ("", p);
102:                _text = text;
103:                _style = style;
104:
105:                setTheme(null);
106:
107:            }
108:
109:            /**
110:             * Constructs an html text object
111:             * @param text The text to place in the page.
112:             * @param font The font to use (See the constants at the top of the class).
113:             * @param p The page to put the text in.
114:             */
115:            public HtmlText(String text, String font, HtmlPage p) {
116:                super ("", p);
117:                _text = text;
118:                _font = font;
119:
120:                setTheme(null);
121:            }
122:
123:            /**
124:             * Constructs an html text object
125:             * @param text The text to place in the page.
126:             * @param font The font to use (See the constants at the top of the class).
127:             * @param p The page to put the text in.
128:             * @param theme The theme to use for loading properties
129:             */
130:            public HtmlText(String text, String font, HtmlPage p, String theme) {
131:                super ("", p);
132:                _text = text;
133:                _font = font;
134:
135:                setTheme(theme);
136:            }
137:
138:            /**
139:             * Constructs an html text object
140:             * @param name java.lang.String
141:             * @param text java.lang.String
142:             * @param style com.salmonllc.html.HtmlStyle
143:             * @param p com.salmonllc.html.HtmlPage
144:             */
145:            public HtmlText(String name, String text, HtmlStyle style,
146:                    HtmlPage p) {
147:                super (name, p);
148:                _text = text;
149:                _style = style;
150:                setTheme(null);
151:            }
152:
153:            /**
154:             * Constructs an html text object
155:             * @param name java.lang.String
156:             * @param text java.lang.String
157:             * @param style com.salmonllc.html.HtmlStyle
158:             * @param p com.salmonllc.html.HtmlPage
159:             * @param theme java.lang.String
160:             */
161:            public HtmlText(String name, String text, HtmlStyle style,
162:                    HtmlPage p, String theme) {
163:                super (name, p);
164:                _text = text;
165:                _style = style;
166:
167:                setTheme(theme);
168:            }
169:
170:            /**
171:             * Constructs an html text object
172:             * @param text The text to place in the page.
173:             * @param font The font to use (See the constants at the top of the class).
174:             * @param p The page to put the text in.
175:             */
176:            public HtmlText(String name, String text, String font, HtmlPage p) {
177:                super (name, p);
178:                _text = text;
179:                _font = font;
180:
181:                setTheme(null);
182:            }
183:
184:            /**
185:             * Constructs an html text object for the page
186:             * @param text The text to place in the page.
187:             * @param font The font to use (See the constants at the top of the class).
188:             * @param p The page to put the text in.
189:             * @param theme The theme to use for loading properties
190:             */
191:            public HtmlText(String name, String text, String font, HtmlPage p,
192:                    String theme) {
193:                super (name, p);
194:                _text = text;
195:                _font = font;
196:
197:                setTheme(theme);
198:            }
199:
200:            public void generateHTML(java.io.PrintWriter p, int rowNo)
201:                    throws Exception {
202:                if (!getVisible())
203:                    return;
204:
205:                processLocaleInfo();
206:
207:                if (_dsEval != null) {
208:                    if (_aggregateType != -1) {
209:                        _text = _dsEval.evaluateAggregateFormat(_aggregateType);
210:                    } else {
211:                        if (rowNo > -1)
212:                            _text = _dsEval.evaluateRowFormat(rowNo);
213:                        else
214:                            _text = _dsEval.evaluateRowFormat();
215:                    }
216:                }
217:
218:                String out = _text;
219:
220:                if (_fixSpecialHtml)
221:                    out = fixSpecialHTMLCharacters(out);
222:
223:                //-----------------------------------------------------------------------------------------------
224:                // Author: Bruno Y. Decaudin
225:                // Date: 12/06/00 - 4:30pm
226:                // Feedback Item#890: table cell background incorrectly displayed in Netscape (non-issue in IE)
227:                // I added the 2nd part of the 'if' statement to solve the problem. However the ' ' creates
228:                // another problem in the HtmlTable component when a column heading is empty. Indeed the ' '
229:                // causes an underlined space to appear that enables an unintended JavaScript clicksort for that
230:                // column. Hence the second part of the fix must be implemented in the aforementioned component.
231:                // The second part takes place in the HtmlDataTable component in the 'generateHtmlForBand' method.
232:                if ((out == null) || (out.trim().equals("")))
233:                    out = " ";
234:                //-----------------------------------------------------------------------------------------------
235:                StringBuffer sbOut = new StringBuffer();
236:                sbOut.append(out);
237:
238:                if (_center) {
239:                    sbOut.insert(0, "<CENTER>");
240:                    sbOut.append("</CENTER>");
241:                }
242:
243:                //		if (_center)
244:                //			out = "<CENTER>" + out + "</CENTER>";
245:
246:                String style = null;
247:                if (_style != null)
248:                    style = _style.getStyleName();
249:                else if (getClassName() != null)
250:                    style = getClassName();
251:
252:                if (style == null) {
253:                    if (_fontStartTag != null) {
254:                        sbOut.insert(0, _fontStartTag);
255:                        sbOut.append(_fontEndTag);
256:                    }
257:                    p.print(sbOut.toString());
258:                    /*			if (_fontStartTag != null)
259:                     p.print(_fontStartTag + out + _fontEndTag);
260:                     else
261:                     p.print(out);*/
262:                } else {
263:                    StringBuffer sbSpan = new StringBuffer();
264:                    sbSpan.append("<SPAN CLASS=\"");
265:                    sbSpan.append(style);
266:                    sbSpan.append('"');
267:                    if (!getName().trim().equals("")) {
268:                        sbSpan.append(" ID=\"");
269:                        sbSpan.append(getName());
270:                        sbSpan.append('"');
271:                    }
272:                    if (_onMouseOver != null && !_onMouseOver.trim().equals("")) {
273:                        sbSpan.append(" ONMOUSEOVER=\"");
274:                        sbSpan.append(_onMouseOver);
275:                        sbSpan.append('"');
276:                    }
277:                    if (_onMouseOut != null && !_onMouseOut.trim().equals("")) {
278:                        sbSpan.append(" ONMOUSEOUT=\"");
279:                        sbSpan.append(_onMouseOut);
280:                        sbSpan.append('"');
281:                    }
282:                    sbSpan.append('>');
283:                    sbOut.insert(0, sbSpan);
284:                    sbOut.append("</SPAN>");
285:                    p.print(sbOut.toString());
286:                    /*			p.print("<SPAN CLASS=\"" + style + "\"");
287:                     if (!getName().trim().equals(""))
288:                     p.print(" ID=\"" + getName() + "\"");
289:                     if (_onMouseOver != null && !_onMouseOver.trim().equals(""))
290:                     p.print(" ONMOUSEOVER=\"" + _onMouseOver + "\"");
291:                     if (_onMouseOut != null && !_onMouseOut.trim().equals(""))
292:                     p.print(" ONMOUSEOUT=\"" + _onMouseOut + "\"");
293:                     p.print(">" + out + "</SPAN>");*/
294:                }
295:
296:            }
297:
298:            public void generateHTML(java.io.PrintWriter p, int rowStart,
299:                    int rowEnd) throws Exception {
300:                if (!getVisible())
301:                    return;
302:
303:                processLocaleInfo();
304:
305:                if (_dsEval != null) {
306:                    if (_aggregateType != -1) {
307:                        _text = _dsEval.evaluateAggregateFormat(_aggregateType,
308:                                rowStart, rowEnd);
309:                    } else {
310:                        if (rowStart > -1)
311:                            _text = _dsEval.evaluateRowFormat(rowStart);
312:                        else
313:                            _text = _dsEval.evaluateRowFormat();
314:                    }
315:                }
316:
317:                String out = _text;
318:
319:                if (_fixSpecialHtml)
320:                    out = fixSpecialHTMLCharacters(out);
321:
322:                //-----------------------------------------------------------------------------------------------
323:                // Author: Bruno Y. Decaudin
324:                // Date: 12/06/00 - 4:30pm
325:                // Feedback Item#890: table cell background incorrectly displayed in Netscape (non-issue in IE)
326:                // I added the 2nd part of the 'if' statement to solve the problem. However the '&nbsp;' creates
327:                // another problem in the HtmlTable component when a column heading is empty. Indeed the '&nbsp;'
328:                // causes an underlined space to appear that enables an unintended JavaScript clicksort for that
329:                // column. Hence the second part of the fix must be implemented in the aforementioned component.
330:                // The second part takes place in the HtmlDataTable component in the 'generateHtmlForBand' method.
331:                if ((out == null) || (out.trim().equals("")))
332:                    out = "&nbsp;";
333:                //-----------------------------------------------------------------------------------------------
334:                StringBuffer sbOut = new StringBuffer();
335:                sbOut.append(out);
336:
337:                if (_center) {
338:                    sbOut.insert(0, "<CENTER>");
339:                    sbOut.append("</CENTER>");
340:                }
341:                //			out = "<CENTER>" + out + "</CENTER>";
342:
343:                String style = null;
344:                if (_style != null)
345:                    style = _style.getStyleName();
346:                else if (getClassName() != null)
347:                    style = getClassName();
348:
349:                if (style == null) {
350:                    if (_fontStartTag != null) {
351:                        sbOut.insert(0, _fontStartTag);
352:                        sbOut.append(_fontEndTag);
353:                    }
354:                    p.print(sbOut.toString());
355:                } else {
356:                    StringBuffer sbSpan = new StringBuffer();
357:                    sbSpan.append("<SPAN CLASS=\"");
358:                    sbSpan.append(style);
359:                    sbSpan.append('"');
360:                    if (!getName().trim().equals("")) {
361:                        sbSpan.append(" ID=\"");
362:                        sbSpan.append(getName());
363:                        sbSpan.append('"');
364:                    }
365:                    if (_onMouseOver != null && !_onMouseOver.trim().equals("")) {
366:                        sbSpan.append(" ONMOUSEOVER=\"");
367:                        sbSpan.append(_onMouseOver);
368:                        sbSpan.append('"');
369:                    }
370:                    if (_onMouseOut != null && !_onMouseOut.trim().equals("")) {
371:                        sbSpan.append(" ONMOUSEOUT=\"");
372:                        sbSpan.append(_onMouseOut);
373:                        sbSpan.append('"');
374:                    }
375:                    sbSpan.append('>');
376:                    sbOut.insert(0, sbSpan);
377:                    sbOut.append("</SPAN>");
378:                    p.print(sbOut.toString());
379:                    //			p.print("<SPAN CLASS=\"" + style + "\"");
380:                    //			if (!getName().trim().equals(""))
381:                    //				p.print(" ID=\"" + getName() + "\"");
382:                    //			if (_onMouseOver != null && !_onMouseOver.trim().equals(""))
383:                    //				p.print(" ONMOUSEOVER=\"" + _onMouseOver + "\"");
384:                    //			if (_onMouseOut != null && !_onMouseOut.trim().equals(""))
385:                    //				p.print(" ONMOUSEOUT=\"" + _onMouseOut + "\"");
386:                    //			p.print(">" + out + "</SPAN>");
387:                }
388:            }
389:
390:            /**
391:             * Use this method to find out if the that the text will be centered.
392:             */
393:            public boolean getCenter() {
394:                return _center;
395:            }
396:
397:            /**
398:             * This method returns the DataStore Evaluator used to parse and evaluate the expression set in the setExpression method.
399:             */
400:            public DataStoreEvaluator getExpressionEvaluator() {
401:                return _dsEval;
402:            }
403:
404:            /**
405:             * Returns whether special html characters (<,>,&,; etc..) should be converted to Html Escape Sequences before being generated.
406:             */
407:            public boolean getFixSpecialHtmlCharacters() {
408:                return _fixSpecialHtml;
409:            }
410:
411:            /**
412:             * This method will return the font type used by this control.See the Constants at the top of the class for valid font types.
413:             */
414:            public String getFont() {
415:                return _font;
416:            }
417:
418:            /**
419:             * Use this method to get the javascript that will be executed when the mouse passes over out of all the components
420:             */
421:            public String getOnMouseOut() {
422:                return _onMouseOut;
423:            }
424:
425:            /**
426:             * Use this method to get the javascript that will be executed when the mouse passes over any component in the link
427:             */
428:            public String getOnMouseOver() {
429:                return _onMouseOver;
430:            }
431:
432:            /**
433:             * Gets the CSS Style used to display this text
434:             */
435:            public HtmlStyle getStyle() {
436:                return _style;
437:            }
438:
439:            /**
440:             * This method returns the text in the component.
441:             */
442:            public String getText() {
443:                return _text;
444:            }
445:
446:            /**
447:             * This method returns the property theme for the component.
448:             * @return
449:             */
450:            public String getTheme() {
451:                return _theme;
452:            }
453:
454:            public boolean processParms(java.util.Hashtable h, int row) {
455:                return false;
456:            }
457:
458:            /**
459:             * Use this method to indicate that the text should be centered.
460:             */
461:            public void setCenter(boolean center) {
462:                _center = center;
463:            }
464:
465:            /**
466:             * Use this method to bind this component to an expression in a DataStore
467:             * @param ds The DataStore to bind to.
468:             * @param expression The expression to bind to.
469:             * @see DataStoreEvaluator
470:             */
471:            public void setExpression(DataStoreBuffer ds,
472:                    DataStoreExpression expression) throws Exception {
473:                _dsEval = new DataStoreEvaluator(ds, expression);
474:            }
475:
476:            /**
477:             * Use this method to bind this component to an expression in a DataStoreBuffer. The expression will be evaluated for all rows in the datastore.
478:             * @param ds The DataStore to bind to.
479:             * @param expression The expression to bind to.
480:             * @param aggregateType valid values are AGGREGATE_SUM and AGGREGATE_COUNT
481:             * @see DataStoreEvaluator
482:             */
483:            public void setExpression(DataStoreBuffer ds,
484:                    DataStoreExpression expression, int aggregateType)
485:                    throws Exception {
486:                _aggregateType = aggregateType;
487:                _dsEval = new DataStoreEvaluator(ds, expression);
488:            }
489:
490:            /**
491:             * Use this method to bind this component to an expression in a DataStoreBuffer. The expression will be evaluated for all rows in the datastore.
492:             * @param ds The DataStore to bind to.
493:             * @param expression The expression to bind to.
494:             * @param aggregateType valid values are AGGREGATE_SUM and AGGREGATE_COUNT
495:             * @param format The patter to use to format the result
496:             * @see com.salmonllc.sql.DataStore#setFormat
497:             * @see DataStoreEvaluator
498:             */
499:            public void setExpression(DataStoreBuffer ds,
500:                    DataStoreExpression expression, int aggregateType,
501:                    String format) throws Exception {
502:                _aggregateType = aggregateType;
503:                _dsEval = new DataStoreEvaluator(ds, expression, format);
504:            }
505:
506:            /**
507:             * Use this method to bind this component to an expression in a DataStoreBuffer. The resulting expression wil be formatted according to the pattern specified.
508:             * @param ds The DataStore to bind to.
509:             * @param expression The expression to bind to.
510:             * @param format The patter to use to format the result
511:             * @see com.salmonllc.sql.DataStore#setFormat
512:             * @see DataStoreEvaluator
513:             */
514:            public void setExpression(DataStoreBuffer ds,
515:                    DataStoreExpression expression, String format)
516:                    throws Exception {
517:                _dsEval = new DataStoreEvaluator(ds, expression, format);
518:            }
519:
520:            /**
521:             * Use this method to bind this component to an expression in a DataStore
522:             * @param ds The DataStore to bind to.
523:             * @param expression The expression to bind to.
524:             * @see DataStoreEvaluator
525:             */
526:            public void setExpression(DataStoreBuffer ds, String expression)
527:                    throws Exception {
528:                _dsEval = new DataStoreEvaluator(ds, expression);
529:            }
530:
531:            /**
532:             * Use this method to bind this component to an expression in a DataStoreBuffer. The expression will be evaluated for all rows in the datastore.
533:             * @param ds The DataStore to bind to.
534:             * @param expression The expression to bind to.
535:             * @param aggregateType valid values are AGGREGATE_SUM and AGGREGATE_COUNT
536:             * @see DataStoreEvaluator
537:             */
538:            public void setExpression(DataStoreBuffer ds, String expression,
539:                    int aggregateType) throws Exception {
540:                _aggregateType = aggregateType;
541:                _dsEval = new DataStoreEvaluator(ds, expression);
542:            }
543:
544:            /**
545:             * Use this method to bind this component to an expression in a DataStoreBuffer. The expression will be evaluated for all rows in the datastore.
546:             * @param ds The DataStore to bind to.
547:             * @param expression The expression to bind to.
548:             * @param aggregateType valid values are AGGREGATE_SUM and AGGREGATE_COUNT
549:             * @param format The patter to use to format the result
550:             * @see com.salmonllc.sql.DataStore#setFormat
551:             * @see DataStoreEvaluator
552:             */
553:            public void setExpression(DataStoreBuffer ds, String expression,
554:                    int aggregateType, String format) throws Exception {
555:                _aggregateType = aggregateType;
556:                _dsEval = new DataStoreEvaluator(ds, expression, format);
557:            }
558:
559:            /**
560:             * Use this method to bind this component to an expression in a DataStoreBuffer. The resulting expression wil be formatted according to the pattern specified.
561:             * @param ds The DataStore to bind to.
562:             * @param expression The expression to bind to.
563:             * @param format The patter to use to format the result
564:             * @see com.salmonllc.sql.DataStore#setFormat
565:             * @see DataStoreEvaluator
566:             */
567:            public void setExpression(DataStoreBuffer ds, String expression,
568:                    String format) throws Exception {
569:                _dsEval = new DataStoreEvaluator(ds, expression, format);
570:            }
571:
572:            /**
573:             * Specify whether special html characters (<,>,&,; etc..) should be converted to Html Escape Sequences before being generated.
574:             */
575:            public void setFixSpecialHtmlCharacters(boolean fix) {
576:                _fixSpecialHtml = fix;
577:            }
578:
579:            /**
580:             * This method will load the font start and end tags from the page properties object.See the Constants at the top of the class for valid values to pass to this method.
581:             */
582:            public void setFont(String font) {
583:                _font = font;
584:                setTheme(_theme);
585:            }
586:
587:            /**
588:             * This method sets the end font tag for the component.
589:             */
590:            public void setFontEndTag(String value) {
591:                _fontEndTag = value;
592:            }
593:
594:            /**
595:             * This method sets the start font tag for the component.
596:             */
597:            public void setFontStartTag(String value) {
598:                _fontStartTag = value;
599:            }
600:
601:            /**
602:             * Use this method to set the javascript that will be executed when the mouse passes over out of all the components
603:             */
604:            public void setOnMouseOut(String onMouseOut) {
605:                _onMouseOut = onMouseOut;
606:            }
607:
608:            /**
609:             * Use this method to set the javascript that will be executed when the mouse passes over any component in the link
610:             */
611:            public void setOnMouseOver(String onMouseOver) {
612:                _onMouseOver = onMouseOver;
613:            }
614:
615:            /**
616:             * Sets the CSS Style used to display this text
617:             * @param style com.salmonllc.html.HtmlStyle
618:             */
619:            public void setStyle(HtmlStyle style) {
620:                _style = style;
621:            }
622:
623:            /**
624:             * This method sets the text that the componnt will generate.
625:             */
626:            public void setText(String text) {
627:                _text = text;
628:            }
629:
630:            /**
631:             * This method sets the property theme for the component.
632:             * @param theme The theme to use.
633:             */
634:            public void setTheme(String theme) {
635:                Props props = getPage().getPageProperties();
636:
637:                if (_font != null) {
638:                    _fontStartTag = props.getThemeProperty(theme, _font
639:                            + Props.TAG_START);
640:                    _fontEndTag = props.getThemeProperty(theme, _font
641:                            + Props.TAG_END);
642:                } else {
643:                    _fontStartTag = props.getThemeProperty(theme, FONT_DEFAULT
644:                            + Props.TAG_START);
645:                    _fontEndTag = props.getThemeProperty(theme, FONT_DEFAULT
646:                            + Props.TAG_END);
647:                }
648:
649:                _theme = theme;
650:            }
651:
652:            /**
653:             * This method returns the text in the component.
654:             */
655:            public String getText(int rowNo) {
656:                try {
657:                    if (_dsEval != null) {
658:                        if (_aggregateType != -1) {
659:                            _text = _dsEval
660:                                    .evaluateAggregateFormat(_aggregateType);
661:                        } else {
662:                            if (rowNo > -1)
663:                                _text = _dsEval.evaluateRowFormat(rowNo);
664:                            else
665:                                _text = _dsEval.evaluateRowFormat();
666:                        }
667:                    }
668:                } catch (Exception e) {
669:                    com.salmonllc.util.MessageLog.writeErrorMessage(e, this );
670:                }
671:                return _text;
672:            }
673:
674:            /**
675:             * Returns the Locale key used for display format
676:             */
677:            public String getDisplayFormatLocaleKey() {
678:                return _formatLocaleKey;
679:            }
680:
681:            /**
682:             * Returns the Locale key used for the text of this component
683:             */
684:            public String getTextLocaleKey() {
685:                return _textLocaleKey;
686:            }
687:
688:            /**
689:             * Sets the Locale key used for display format
690:             */
691:            public void setDisplayFormatLocaleKey(String formatLocaleKey) {
692:                _formatLocaleKey = formatLocaleKey;
693:                _updateLocale = true;
694:
695:            }
696:
697:            /**
698:             * Returns the Locale key used for text
699:             */
700:            public void setTextLocaleKey(String textLocaleKey) {
701:                _textLocaleKey = textLocaleKey;
702:                _updateLocale = true;
703:            }
704:
705:            /**
706:             * Updates the text and format for the current local
707:             */
708:            public void updateLocale() {
709:                _updateLocale = true;
710:            }
711:
712:            private void processLocaleInfo() {
713:                if (_updateLocale) {
714:                    _updateLocale = false;
715:                    LanguagePreferences p = getPage().getLanguagePreferences();
716:                    if (_textLocaleKey != null) {
717:                        String newText = LanguageResourceFinder.getResource(
718:                                getPage().getApplicationName(), _textLocaleKey,
719:                                p);
720:                        if (newText != null)
721:                            setText(newText);
722:                    }
723:
724:                    if (_displayFormat != null && _dsEval != null)
725:                        _dsEval.setFormat(_displayFormat);
726:
727:                    if (_formatLocaleKey != null && _dsEval != null) {
728:                        String newFormat = LanguageResourceFinder.getResource(
729:                                getPage().getApplicationName(),
730:                                _formatLocaleKey, p);
731:                        if (newFormat != null)
732:                            _dsEval.setFormat(newFormat);
733:                    }
734:                }
735:            }
736:
737:            /**
738:             * Gets the default display format for the text
739:             * @return String
740:             */
741:            public String getDisplayFormat() {
742:                return _displayFormat;
743:            }
744:
745:            /**
746:             * Sets the default display format for the text. This only works for components bound to a datastore expression.
747:             * @param displayFormat The displayFormat to set
748:             */
749:            public void setDisplayFormat(String displayFormat) {
750:                if (displayFormat != null) {
751:                    //Retrieve format string from page properties             
752:                    Props props = getPage().getPageProperties();
753:                    String newFormat = props.getThemeProperty(_theme,
754:                            displayFormat);
755:                    if (newFormat != null)
756:                        displayFormat = newFormat;
757:                }
758:                _displayFormat = displayFormat;
759:                _updateLocale = true;
760:            }
761:
762:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.