Source Code Cross Referenced for EventUtil.java in  » XML-UI » SwingML » org » swingml » event » 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 » XML UI » SwingML » org.swingml.event 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SwingML Copyright (C) 2002 Robert Morris.
003:         * 
004:         * This library is free software; you can redistribute it and/or modify it under
005:         * the terms of the GNU Lesser General Public License as published by the Free
006:         * Software Foundation; either version 2 of the License, or (at your option) any
007:         * later version.
008:         * 
009:         * This library is distributed in the hope that it will be useful, but WITHOUT
010:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011:         * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012:         * details.
013:         * 
014:         * You should have received a copy of the GNU Lesser General Public License
015:         * along with this library; if not, write to the Free Software Foundation, Inc.,
016:         * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017:         * 
018:         * Authors: Robert Morris <robertj@morris.net>
019:         * 
020:         */
021:
022:        package org.swingml.event;
023:
024:        import java.awt.*;
025:        import java.util.*;
026:
027:        import javax.swing.*;
028:
029:        import org.swingml.*;
030:        import org.swingml.model.*;
031:        import org.swingml.system.*;
032:
033:        /**
034:         * This class provides utility functions for implementers of the InvokableEvent
035:         * class. Generally, this class is the super class of most InvokableEvent
036:         * implementations
037:         * 
038:         * @author Robert J. Morris
039:         * 
040:         * @see org.swingml.event.InvokableEventHandler
041:         * @see org.swingml.model.ActionParamModel
042:         */
043:        public class EventUtil {
044:
045:            /**
046:             * This method expects the objects in the params argument to be instances of
047:             * the ActionParamModel object.
048:             * 
049:             * @param params
050:             *            A reference to an array of Object instances.
051:             * 
052:             * @return A valid reference to a Map object. null if an error occurred.
053:             * 
054:             * @see org.swingml.model.ActionParamModel
055:             */
056:            protected Map buildActionParametersMap(Object[] aParams) {
057:                Map theReturnMap = null;
058:                ActionParamModel theParam = null;
059:                if (aParams != null && aParams.length > 0) {
060:                    theReturnMap = new HashMap(aParams.length);
061:                    for (int i = 0; i < aParams.length; i++) {
062:                        if (aParams[i] instanceof  ActionParamModel) {
063:                            theParam = (ActionParamModel) aParams[i];
064:                            theReturnMap.put(theParam.getName(), theParam);
065:                        }
066:                    }
067:                }
068:                return theReturnMap;
069:            }
070:
071:            private Component findComponent(Component[] aComponents,
072:                    String aComponentName) {
073:                Component theRetComp = null;
074:                Component theFoundComp = null;
075:                if (aComponents != null && aComponents.length > 0) {
076:                    for (int i = 0; i < aComponents.length; i++) {
077:                        if (aComponents[i].getName() != null
078:                                && aComponents[i].getName().equalsIgnoreCase(
079:                                        aComponentName)) {
080:                            theRetComp = aComponents[i];
081:                            break;
082:                        }
083:                        if (aComponents[i] instanceof  Container) {
084:                            theFoundComp = this .findComponent(
085:                                    ((Container) aComponents[i])
086:                                            .getComponents(), aComponentName);
087:                            if (theFoundComp != null) {
088:                                theRetComp = theFoundComp;
089:                                break;
090:                            }
091:                        }
092:                    }
093:                }
094:                return theRetComp;
095:            }
096:
097:            private SwingMLRenderer findRenderer(Component[] aComponents) {
098:                SwingMLRenderer theRetComp = null;
099:                SwingMLRenderer theFoundComp = null;
100:                if (aComponents != null && aComponents.length > 0) {
101:                    for (int i = 0; i < aComponents.length; i++) {
102:                        if (aComponents[i] instanceof  SwingMLRenderer) {
103:                            theRetComp = (SwingMLRenderer) aComponents[i];
104:                            break;
105:                        }
106:                        if (aComponents[i] instanceof  Container) {
107:                            theFoundComp = this 
108:                                    .findRenderer(((Container) aComponents[i])
109:                                            .getComponents());
110:                            if (theFoundComp != null) {
111:                                theRetComp = theFoundComp;
112:                                break;
113:                            }
114:                        }
115:                    }
116:                }
117:                return theRetComp;
118:            }
119:
120:            /**
121:             * This function returns a reference to the component specified by the
122:             * componentName argument. The component argument does not need to contain
123:             * the requested object, it only needs to be in the same document as the
124:             * component argument.
125:             * 
126:             * @param component
127:             *            A reference to the Component instance specified in the
128:             *            COMPONENT attribute of the &lt;EXTERNAL-ACTION&gt; tag.
129:             * 
130:             * @param componentName
131:             *            A String representing the name of the component to return.
132:             * 
133:             * @return A reference to the named component, or null if the name does not
134:             *         exist within the document hierarchy.
135:             */
136:            public Component getComponent(Component aComponent,
137:                    String aComponentName) {
138:                Component theRet = null;
139:                Container theRootComponent = this .getRootComponent(aComponent);
140:                theRet = this .findComponent(theRootComponent.getComponents(),
141:                        aComponentName);
142:                return theRet;
143:            }
144:
145:            /**
146:             * This method returns a reference to the Renderer instance within which the
147:             * Component referenced by the component argument resides.
148:             * 
149:             * @param component
150:             *            A refernce to the component specified by the COMPONENT
151:             *            attribute of the &lt;EXTERNAL-ACTION&gt; tag.
152:             * 
153:             * @return A reference to the SwingMLRender within which the InvokableEvent
154:             *         instance resides.
155:             */
156:            protected SwingMLRenderer getRenderer(Component aComponent) {
157:                SwingMLRenderer theRet = null;
158:                try {
159:                    Container theRootComponent = this 
160:                            .getRootComponent(aComponent);
161:                    if (!(theRootComponent instanceof  SwingMLRenderer)) {
162:                        theRet = this .findRenderer(theRootComponent
163:                                .getComponents());
164:                    } else {
165:                        theRet = (SwingMLRenderer) theRootComponent;
166:                    }
167:                } catch (Exception e) {
168:                    SwingMLLogger
169:                            .getInstance()
170:                            .log(
171:                                    ILogCapable.ERROR,
172:                                    "Syntax Error: There is a problem resolving the SwingMLRenderer for the referenced component.");
173:                }
174:                return theRet;
175:            }
176:
177:            private Container getRootComponent(Component aComponent) {
178:                Container theRetComp = null;
179:                if (aComponent instanceof  JComponent) {
180:                    theRetComp = ((JComponent) aComponent)
181:                            .getTopLevelAncestor();
182:                } else if (aComponent.getParent() == null
183:                        && aComponent instanceof  Container) {
184:                    theRetComp = (Container) aComponent;
185:                } else if (aComponent != null) {
186:                    theRetComp = getRootComponent(aComponent.getParent());
187:                }
188:                return theRetComp;
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.