Source Code Cross Referenced for HtmlDisplayBox.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/HtmlDisplayBox.java $
024:        //$Author: Dan $ 
025:        //$Revision: 21 $ 
026:        //$Modtime: 1/22/04 11:18a $ 
027:        /////////////////////////
028:
029:        import com.salmonllc.properties.*;
030:
031:        import java.util.*;
032:        import java.io.*;
033:
034:        /**
035:         * This container can be used to create a display box in a page. The display box has a heading caption, components in the heading band and one component inside the box.
036:         */
037:        public class HtmlDisplayBox extends HtmlContainer {
038:            public static final int SIZE_PERCENT = 0;
039:            public static final int SIZE_PIXELS = 1;
040:            //
041:            String _headingCaption;
042:            HtmlContainer _box;
043:            //
044:            private String _font;
045:            private String _fontStartTag;
046:            private String _fontEndTag;
047:            private String _headingBackgroundColor;
048:            private String _backgroundColor;
049:            private int _border = 0;
050:            private String _headingClassname;
051:            private String _bodyClassname;
052:            //
053:            private int _sizeOption = SIZE_PERCENT;
054:            private int _containerWidth = 100;
055:            //
056:            private boolean _suppressHeading = false;
057:
058:            private int _cellPadding = -1;
059:            private int _cellSpacing = -1;
060:
061:            private String _theme = null;
062:
063:            /**
064:             * Constructs an HtmlDisplayBox using the default theme.
065:             * @param name The name of the component
066:             * @param p The page that it goies in.
067:             */
068:            public HtmlDisplayBox(String name, HtmlPage p) {
069:                this (name, null, p);
070:
071:            }
072:
073:            /**
074:             * Constructs an HtmlDisplayBox using the default theme.
075:             * @param name The name of the component
076:             * @param theme The theme to use for loading properties.
077:             * @param p The page that it goes in.
078:             */
079:            public HtmlDisplayBox(String name, String theme, HtmlPage p) {
080:                super (name, p);
081:
082:                _font = Props.FONT_DISPLAY_BOX_HEADING;
083:
084:                setTheme(theme);
085:
086:            }
087:
088:            /**
089:             * This method will add a component (usually a button) to the heading of the box.
090:             */
091:            public void addHeadingComponent(HtmlComponent h) {
092:                add(h);
093:            }
094:
095:            public boolean executeEvent(int eventType) throws Exception {
096:                if (eventType == HtmlComponent.EVENT_OTHER) {
097:                    if (_componentsVec != null) {
098:                        HtmlComponent h = null;
099:                        int componentsSize = _componentsVec.size();
100:                        for (int i = 0; i < componentsSize; i++) {
101:                            h = (HtmlComponent) _componentsVec.elementAt(i);
102:                            if (!h.executeEvent(eventType))
103:                                return false;
104:                        }
105:                    }
106:                    if (_box != null) {
107:                        if (!_box.executeEvent(eventType))
108:                            return false;
109:                    }
110:                } else if (_submit != null
111:                        && eventType == HtmlComponent.EVENT_SUBMIT) {
112:                    boolean retVal = _submit.executeEvent(eventType);
113:                    _submit = null;
114:                    return retVal;
115:                }
116:                return true;
117:            }
118:
119:            public void generateHTML(PrintWriter p, int rowNo) throws Exception {
120:                if (!_visible)
121:                    return;
122:                if (_center)
123:                    p.print("<CENTER>");
124:                String boxColor = "";
125:                if (_suppressHeading == false) {
126:                    int cellPadding = _cellPadding > -1 ? _cellPadding : 0;
127:                    int cellSpacing = _cellSpacing > -1 ? _cellSpacing : 0;
128:
129:                    //do the heading
130:                    String heading = "<TABLE BORDER=\"" + _border
131:                            + "\" CELLSPACING=\"" + cellSpacing
132:                            + "\" CELLPADDING=\"" + cellPadding + "\"";
133:                    if (_containerWidth > -1) {
134:                        heading += " WIDTH=\"" + _containerWidth;
135:                        if (_sizeOption == SIZE_PERCENT)
136:                            heading += "%";
137:                        heading += "\"";
138:                    }
139:                    heading += ">";
140:                    p.println(heading);
141:                    String headingColor = "";
142:                    if (_headingBackgroundColor != null)
143:                        headingColor = " BGCOLOR=\"" + _headingBackgroundColor
144:                                + "\"";
145:                    if (_backgroundColor != null)
146:                        boxColor = " BGCOLOR=\"" + _backgroundColor + "\"";
147:
148:                    String headingStyle = "";
149:                    if (_headingClassname != null)
150:                        headingStyle = " class=\"" + _headingClassname + "\"";
151:                    p
152:                            .println("<TR><TD"
153:                                    + headingColor
154:                                    + " "
155:                                    + headingStyle
156:                                    + "><TABLE WIDTH=\"100%\" CELLSPACING=\"0\" CELLPADDING=\"2\">");
157:                    p.println("<TR><TD" + headingColor + " ALIGN=\"LEFT\">"
158:                            + _fontStartTag + _headingCaption + _fontEndTag
159:                            + "</TD><TD" + headingColor
160:                            + " ALIGN=\"RIGHT\" NOWRAP>");
161:                    if (_componentsVec != null) {
162:                        HtmlComponent h = null;
163:                        int componentsSize = _componentsVec.size();
164:                        for (int i = 0; i < componentsSize; i++) {
165:                            h = (HtmlComponent) _componentsVec.elementAt(i);
166:                            if (h != null)
167:                                h.generateHTML(p, rowNo);
168:                        }
169:                    }
170:                    p.println("</TD></TR></TABLE></TD></TR>");
171:                }
172:                //do the box
173:                String bodyStyle = "";
174:                if (_bodyClassname != null)
175:                    bodyStyle = " class=\"" + _bodyClassname + "\"";
176:                p.println("<TR " + bodyStyle + "><TD" + boxColor + ">");
177:
178:                if (_box != null)
179:                    _box.generateHTML(p, rowNo);
180:                p.println("</TD></TR></TABLE>");
181:                if (_center)
182:                    p.print("<CENTER>");
183:            }
184:
185:            public void generateInitialHTML(PrintWriter p) throws Exception {
186:                if (!_visible)
187:                    return;
188:                if (_componentsVec != null) {
189:                    HtmlComponent h = null;
190:                    int componentsSize = _componentsVec.size();
191:                    for (int i = 0; i < componentsSize; i++) {
192:                        h = (HtmlComponent) _componentsVec.elementAt(i);
193:                        if (h != null)
194:                            h.generateInitialHTML(p);
195:                    }
196:                }
197:                if (_box != null)
198:                    _box.generateInitialHTML(p);
199:            }
200:
201:            /**
202:             * This method gets the border width for component
203:             */
204:            public int getBorder() {
205:                return _border;
206:            }
207:
208:            /**
209:             * This method will get the component that will be displayed in the display box
210:             */
211:            public HtmlContainer getBoxComponent() {
212:                return _box;
213:            }
214:
215:            /**
216:             * Gets the cell padding for the table.
217:             */
218:            public int getCellPadding() {
219:                return _cellPadding;
220:            }
221:
222:            /**
223:             * Gets the cell spacing for the table.
224:             */
225:            public int getCellSpacing() {
226:                return _cellSpacing;
227:            }
228:
229:            /**
230:             * This method will return a list of all components in the container.
231:             */
232:            public Enumeration getComponents() {
233:                Vector v = new Vector();
234:                if (_componentsVec != null) {
235:                    int componentsSize = _componentsVec.size();
236:                    for (int i = 0; i < componentsSize; i++)
237:                        v.addElement(_componentsVec.elementAt(i));
238:                }
239:                if (_box != null)
240:                    v.addElement(_box);
241:                return v.elements();
242:            }
243:
244:            /**
245:             * This method will return the font type used by this control.
246:             */
247:            public String getFont() {
248:                return _font;
249:            }
250:
251:            /**
252:             * This method gets the background color for the heading on the component
253:             */
254:            public String getHeadingBackgroundColor() {
255:                return _headingBackgroundColor;
256:            }
257:
258:            /**
259:             * This method returns the heading caption for the component.
260:             */
261:            public String getHeadingCaption() {
262:                return _headingCaption;
263:            }
264:
265:            /**
266:             * This method returns the size option for the table and each cell in it. Valid return values are SIZE_PIXELS or SIZE_PERCENT.
267:             */
268:            public int getSizeOption() {
269:                return _sizeOption;
270:            }
271:
272:            /**
273:             * This method returns the property theme for the component.
274:             * @param theme The theme to use.
275:             */
276:            public String getTheme() {
277:                return _theme;
278:            }
279:
280:            /**
281:             * This method returns the width of the table.
282:             */
283:            public int getWidth() {
284:                return _containerWidth;
285:            }
286:
287:            public boolean processParms(Hashtable parms, int rowNo)
288:                    throws Exception {
289:                if (_componentsVec != null) {
290:                    int componentsSize = _componentsVec.size();
291:                    for (int i = 0; i < componentsSize; i++) {
292:                        if (((HtmlComponent) _componentsVec.elementAt(i))
293:                                .processParms(parms, rowNo))
294:                            _submit = (HtmlComponent) _componentsVec
295:                                    .elementAt(i);
296:                    }
297:                }
298:                if (_box != null) {
299:                    if (_box.processParms(parms, rowNo))
300:                        _submit = _box;
301:                }
302:                if (_submit != null)
303:                    return true;
304:                else
305:                    return false;
306:            }
307:
308:            /**
309:             * This method will remove a component (usually a button) from the heading of the box.
310:             */
311:            public void removeHeadingComponent(HtmlComponent h) {
312:                remove(h);
313:            }
314:
315:            /**
316:             * This method sets the border width for component
317:             */
318:            public void setBorder(int border) {
319:                _border = border;
320:            }
321:
322:            /**
323:             * This method will set the component that will be displayed in the display box
324:             */
325:            public void setBoxComponent(HtmlContainer cont) {
326:                _box = cont;
327:                cont.setParent(this );
328:            }
329:
330:            /**
331:             * Sets the cell padding for the table.
332:             */
333:            public void setCellPadding(int value) {
334:                _cellPadding = value;
335:            }
336:
337:            /**
338:             * Sets the cell spacing for the table.
339:             */
340:            public void setCellSpacing(int value) {
341:                _cellSpacing = value;
342:            }
343:
344:            /**
345:             * This method will load the font start and end tags from the page properties object.
346:             */
347:            public void setFont(String font) {
348:                _font = font;
349:                Props p = getPage().getPageProperties();
350:                _fontStartTag = p.getThemeProperty(_theme, font
351:                        + Props.TAG_START);
352:                _fontEndTag = p.getThemeProperty(_theme, font + Props.TAG_END);
353:            }
354:
355:            /**
356:             * This method sets the end font tag for the component.
357:             */
358:            public void setFontEndTag(String value) {
359:                _fontEndTag = value;
360:            }
361:
362:            /**
363:             * This method sets the start font tag for the component.
364:             */
365:            public void setFontStartTag(String value) {
366:                _fontStartTag = value;
367:            }
368:
369:            /**
370:             * This method sets the background color for the heading on the component
371:             */
372:            public void setHeadingBackgroundColor(String color) {
373:                _headingBackgroundColor = color;
374:            }
375:
376:            /**
377:             * This method sets the text for the heading on the component
378:             */
379:            public void setHeadingCaption(String text) {
380:                _headingCaption = text;
381:            }
382:
383:            /**
384:             * This method sets the size option for the table and each cell in it. Valid return values are SIZE_PIXELS or SIZE_PERCENT.
385:             */
386:            public void setSizeOption(int option) {
387:                _sizeOption = option;
388:            }
389:
390:            /**
391:             * This method sets the property theme for the component.
392:             * @param theme The theme to use.
393:             */
394:            public void setTheme(String theme) {
395:
396:                Props props = getPage().getPageProperties();
397:
398:                _fontStartTag = props.getThemeProperty(theme, _font
399:                        + Props.TAG_START);
400:                _fontEndTag = props.getThemeProperty(theme, _font
401:                        + Props.TAG_END);
402:                _headingBackgroundColor = props.getThemeProperty(theme,
403:                        Props.DISPLAY_BOX_HEADING_BACKGROUND_COLOR);
404:                _backgroundColor = props.getThemeProperty(theme,
405:                        Props.DISPLAY_BOX_BACKGROUND_COLOR);
406:                _border = props.getThemeIntProperty(theme,
407:                        Props.DISPLAY_BOX_BORDER);
408:                _cellPadding = props.getThemeIntProperty(theme,
409:                        Props.DISPLAY_BOX_CELLPADDING);
410:                _cellSpacing = props.getThemeIntProperty(theme,
411:                        Props.DISPLAY_BOX_CELLSPACING);
412:
413:                _theme = theme;
414:            }
415:
416:            /**
417:             * This method sets the minimum width of the table in either pixels or percent depending on size option.
418:             */
419:            public void setWidth(int width) {
420:                _containerWidth = width;
421:            }
422:
423:            /**
424:             * This method sets the border width for component
425:             */
426:            public void suppressHeading(boolean supHead) {
427:                _suppressHeading = supHead;
428:            }
429:
430:            /**
431:             * @returns the style sheet class name used for the heading
432:             */
433:            public String getHeadingClassname() {
434:                return _headingClassname;
435:            }
436:
437:            /**
438:             * @param sets the style sheet class name for the heading
439:             */
440:            public void setHeadingClassname(String string) {
441:                _headingClassname = string;
442:            }
443:
444:            /**
445:             * @returns the style sheet class name used for the body
446:             */
447:            public String getBodyClassname() {
448:                return _bodyClassname;
449:            }
450:
451:            /**
452:             * @param sets the style sheet class name for the body
453:             */
454:            public void setBodyClassname(String string) {
455:                _bodyClassname = string;
456:            }
457:
458:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.