Source Code Cross Referenced for SForm.java in  » Swing-Library » Swinglets » com » javelin » swinglets » 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 » Swing Library » Swinglets » com.javelin.swinglets 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright Javelin Software, All rights reserved.
003:         */
004:
005:        package com.javelin.swinglets;
006:
007:        import java.awt.*;
008:        import java.awt.event.*;
009:        import java.util.*;
010:        import java.io.*;
011:
012:        import com.javelin.swinglets.event.*;
013:
014:        /**
015:         * SForm defines a Form. 
016:         * 
017:         * @author Robin Sharp
018:         */
019:
020:        public class SForm extends SContainer {
021:            /**
022:             * The following Methods.
023:             */
024:            public final static String GET = "GET";
025:            public final static String POST = "POST";
026:            public final static String PUT = "PUT";
027:            public final static String DELETE = "DELETE";
028:            public final static String TRACE = "TRACE";
029:            public final static String OPTIONS = "OPTIONS";
030:
031:            /**
032:             * Creates a SForm with the following method and action.
033:             */
034:            public SForm(String method, SLink action) {
035:                if (method != null)
036:                    setMethod(method);
037:                if (action != null)
038:                    setAction(action);
039:            }
040:
041:            /**
042:             * Creates a SForm with the following method POST or GET.
043:             */
044:            public SForm(String method) {
045:                this (method, null);
046:            }
047:
048:            /**
049:             * Creates a SForm.
050:             */
051:            public SForm() {
052:                this (POST, null);
053:            }
054:
055:            /**
056:             * Returns the name of the L&F class that renders this component.
057:             */
058:            public Class getUIClass() {
059:                return SForm.class;
060:            }
061:
062:            /**
063:             * Get the method.
064:             */
065:            public String getMethod() {
066:                return method;
067:            }
068:
069:            /**
070:             * Set the method.
071:             */
072:            public SForm setMethod(String method) {
073:                firePropertyChange("method", this .method, this .method = method);
074:                return this ;
075:            }
076:
077:            /**
078:             * Get the action.
079:             */
080:            public SLink getAction() {
081:                return action;
082:            }
083:
084:            /**
085:             * Set the action.
086:             */
087:            public SForm setAction(SLink action) {
088:                firePropertyChange("action", this .action, this .action = action);
089:                return this ;
090:            }
091:
092:            // EVENT /////////////////////////////////////////////////////////
093:
094:            /**
095:             * Add a FormEventListener.
096:             */
097:            public SForm addFormEventListener(FormListener formListener) {
098:                if (formListeners == null)
099:                    formListeners = new Vector();
100:
101:                formListeners.addElement(formListener);
102:
103:                return this ;
104:            }
105:
106:            /**
107:             * Remove a FormEventListener.
108:             */
109:            public SForm removeFormEventListener(FormListener formListener) {
110:                if (formListeners == null)
111:                    return this ;
112:
113:                formListeners.removeElement(formListener);
114:
115:                return this ;
116:            }
117:
118:            /** 
119:             * Processes events occurring on this component. 
120:             */
121:            protected void processEvent(AWTEvent event) {
122:                if (event instanceof  FormEvent) {
123:                    processFormEvent((FormEvent) event);
124:                }
125:            }
126:
127:            /** 
128:             * Process an FormEvent. This will set the values of all the form components
129:             * then notify any listeners that the form have been modified.
130:             */
131:            public void processFormEvent(FormEvent event) {
132:                //DEFAULT CHECK BOXES TO FALSE IF THEY ARE NOT IN THE LIST
133:                resetCheckBoxes(this , event);
134:
135:                //UPDATE FORM COMPONENTS
136:                for (Enumeration names = event.getParameterNames(); names
137:                        .hasMoreElements();) {
138:                    String name = names.nextElement().toString();
139:
140:                    //System.out.println( "name=" + name + " value=" + event.getParameter( name ) );
141:
142:                    SComponent component = getComponent(name);
143:                    if (component != null) {
144:                        component.setValueAsText(event.getParameter(name));
145:
146:                        //send an action event to all components
147:                        component
148:                                .processEvent(new ActionEvent(component,
149:                                        ActionEvent.ACTION_PERFORMED, event
150:                                                .getAction()));
151:                    }
152:                }
153:
154:                //FIRE EVENT OUT TO LISTENERS
155:                for (int index = 0; formListeners != null
156:                        && index < formListeners.size(); index++) {
157:                    if (formListeners.elementAt(index) != null) {
158:                        ((FormListener) formListeners.elementAt(index))
159:                                .formSubmitted(event);
160:                    }
161:                }
162:            }
163:
164:            /**
165:             * Recursively descend all components setting the checkboxes
166:             * to false, IF they are not passed as parameters.
167:             */
168:            protected void resetCheckBoxes(SContainer container, FormEvent event) {
169:                for (int index = 0; index < container.getComponentCount(); index++) {
170:                    if (container.getComponent(index) instanceof  SCheckBox) {
171:                        SCheckBox checkBox = (SCheckBox) container
172:                                .getComponent(index);
173:                        if (event.getParameter(checkBox.getName()) == null) {
174:                            checkBox.setSelected(false);
175:                        }
176:                    } else if (container.getComponent(index) instanceof  STable) {
177:                        resetCheckBoxes((STable) container.getComponent(index),
178:                                event);
179:                    } else if (container.getComponent(index) instanceof  SContainer) {
180:                        resetCheckBoxes((SContainer) container
181:                                .getComponent(index), event);
182:                    }
183:                }
184:            }
185:
186:            /**
187:             * Recursively descend all components setting the checkboxes
188:             * to false, IF they are not passed as parameters.
189:             */
190:            protected void resetCheckBoxes(STable table, FormEvent event) {
191:                for (int row = 0; row < table.getRowCount(); row++) {
192:                    for (int column = 0; column < table.getColumnCount(); column++) {
193:                        if (table.getValueAt(row, column) instanceof  SCheckBox) {
194:                            SCheckBox checkBox = (SCheckBox) table.getValueAt(
195:                                    row, column);
196:                            if (event.getParameter(checkBox.getName()) == null) {
197:                                checkBox.setSelected(false);
198:                            }
199:                        } else if (table.getValueAt(row, column) instanceof  STable) {
200:                            resetCheckBoxes((STable) table.getValueAt(row,
201:                                    column), event);
202:                        } else if (table.getValueAt(row, column) instanceof  SContainer) {
203:                            resetCheckBoxes((SContainer) table.getValueAt(row,
204:                                    column), event);
205:                        }
206:                    }
207:                }
208:
209:            }
210:
211:            // PRIVATE /////////////////////////////////////////////////////////////
212:
213:            protected String method;
214:            protected SLink action;
215:
216:            protected Vector formListeners;
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.