Source Code Cross Referenced for Gui4jJComponentFactory.java in  » XML-UI » gui4j » org » gui4j » component » factory » 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 » gui4j » org.gui4j.component.factory 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.gui4j.component.factory;
002:
003:        import java.util.ArrayList;
004:        import java.util.HashSet;
005:        import java.util.List;
006:        import java.util.Set;
007:
008:        import javax.swing.KeyStroke;
009:        import javax.swing.border.Border;
010:
011:        import org.apache.commons.logging.Log;
012:        import org.apache.commons.logging.LogFactory;
013:        import org.dom4j.LElement;
014:        import org.gui4j.component.Gui4jJComponent;
015:        import org.gui4j.core.Gui4jCall;
016:        import org.gui4j.core.Gui4jComponent;
017:        import org.gui4j.core.Gui4jComponentContainer;
018:        import org.gui4j.core.Gui4jComponentContainerManager;
019:        import org.gui4j.core.Gui4jComponentFactory;
020:        import org.gui4j.core.Gui4jMap1;
021:        import org.gui4j.core.Gui4jTypeCheck;
022:        import org.gui4j.core.definition.Attribute;
023:        import org.gui4j.core.definition.AttributeTypeEnumeration;
024:        import org.gui4j.core.definition.AttributeTypeID;
025:        import org.gui4j.core.definition.AttributeTypeMethodCall;
026:        import org.gui4j.core.definition.AttributeTypeString;
027:        import org.gui4j.core.definition.Param;
028:        import org.gui4j.exception.Gui4jUncheckedException;
029:        import org.gui4j.util.Filter;
030:
031:        abstract public class Gui4jJComponentFactory extends
032:                Gui4jComponentFactory {
033:            private static final String BORDER = "border";
034:            private static final String TOOLTIP = "tooltip";
035:            private static final String OPAQUE = "opaque";
036:            private static final String GRABFOCUS = "grabFocus";
037:            private static final String HANDLE_READ_ONLY = "handleReadOnly";
038:            private static final String KEYMAP = "keyMapId";
039:            private static final String FOCUS_KEYS_FORWARD = "focusKeysForward";
040:            private static final String FOCUS_KEYS_BACKWARD = "focusKeysBackward";
041:
042:            private static final Log mLogger = LogFactory
043:                    .getLog(Gui4jJComponentFactory.class);
044:
045:            protected void defineProperties(Gui4jJComponent gui4jJComponent,
046:                    LElement e) {
047:                super .defineProperties(gui4jJComponent, e);
048:                gui4jJComponent.definePropertySetter(OPAQUE,
049:                        getGui4jAccessInstance(Boolean.TYPE, gui4jJComponent,
050:                                e, OPAQUE), false);
051:                gui4jJComponent.definePropertySetter(BORDER,
052:                        getGui4jAccessInstance(Border.class, new Gui4jMap1(
053:                                CONTEXT, Object.class), gui4jJComponent, e,
054:                                BORDER), true);
055:
056:                gui4jJComponent.definePropertySetter(TOOLTIP,
057:                        getGui4jAccessInstance(String.class, new Gui4jMap1(
058:                                CONTEXT, Object.class), gui4jJComponent, e,
059:                                TOOLTIP), true);
060:
061:                Gui4jCall grabFocus = getGui4jAccessInstance(null,
062:                        new Gui4jMap1(CONTEXT, Object.class), gui4jJComponent,
063:                        e, GRABFOCUS);
064:                if (grabFocus != null) {
065:                    Gui4jCall[] dependantProperties = grabFocus
066:                            .getDependantProperties();
067:                    if (dependantProperties == null
068:                            || dependantProperties.length == 0) {
069:                        mLogger.warn("Set of dependant events is empty");
070:                    }
071:                    gui4jJComponent.setGrabFocus(grabFocus);
072:                    if (grabFocus.getResultClass() != null) {
073:                        Gui4jTypeCheck.ensureType(Boolean.TYPE, grabFocus
074:                                .getResultClass(), gui4jJComponent
075:                                .getConfigurationName(), e
076:                                .attributeValue(GRABFOCUS));
077:                    }
078:                }
079:
080:                Set focusKeysForward = extractKeyStrokes(gui4jJComponent, e,
081:                        FOCUS_KEYS_FORWARD);
082:                if (focusKeysForward != null) {
083:                    gui4jJComponent
084:                            .setFocusTraversalKeysForward(focusKeysForward);
085:                }
086:
087:                Set focusKeysBackward = extractKeyStrokes(gui4jJComponent, e,
088:                        FOCUS_KEYS_BACKWARD);
089:                if (focusKeysBackward != null) {
090:                    gui4jJComponent
091:                            .setFocusTraversalKeysBackward(focusKeysBackward);
092:                }
093:
094:                gui4jJComponent.setKeyMapId(e.attributeValue(KEYMAP));
095:                String handleReadOnly = e.attributeValue(HANDLE_READ_ONLY);
096:                gui4jJComponent.setHandleReadOnly(handleReadOnly != null
097:                        && handleReadOnly.equalsIgnoreCase("true"));
098:            }
099:
100:            /**
101:             * Returns a Set of KeyStroke objects created from the specified attribute. The attribute value is
102:             * expected to be a comma separated list of individual KeyStroke definitions. Each definition is converted
103:             * to a KeyStroke using {@link KeyStroke#getKeyStroke(java.lang.String)}.
104:             * @param gui4jJComponent
105:             * @param e element
106:             * @param attr name of the attribute containing the keystroke defintions
107:             * @return Set(KeyStroke)
108:             */
109:            private Set extractKeyStrokes(Gui4jJComponent gui4jJComponent,
110:                    LElement e, String attr) {
111:                String value = e.attributeValue(attr);
112:                if (value == null) {
113:                    return null;
114:                } else {
115:                    Set keyStrokes = new HashSet();
116:                    String[] keyStrings = value.split(",");
117:                    for (int i = 0; i < keyStrings.length; i++) {
118:                        String keyString = keyStrings[i].trim();
119:                        if (keyString.length() > 0) {
120:                            KeyStroke stroke = KeyStroke
121:                                    .getKeyStroke(keyString);
122:                            if (stroke == null) {
123:                                throw new Gui4jUncheckedException.ResourceError(
124:                                        gui4jJComponent.getConfigurationName(),
125:                                        Gui4jComponentContainerManager
126:                                                .getLineNumber(e),
127:                                        RESOURCE_ERROR_invalid_keystroke,
128:                                        new Object[] { keyString });
129:                            } else {
130:                                keyStrokes.add(stroke);
131:                            }
132:                        }
133:                    }
134:                    return keyStrokes;
135:                }
136:            }
137:
138:            public void addToplevelAttributes(List attrList, Filter filter) {
139:                super .addToplevelAttributes(attrList, filter);
140:                if (filter == null
141:                        || filter.takeIt(Gui4jJComponentFactory.class)) {
142:                    List l = new ArrayList();
143:                    l.add(new Param(CONTEXT));
144:                    attrList.add(new Attribute(BORDER,
145:                            new AttributeTypeMethodCall(Border.class, l,
146:                                    EVENT_AWARE), IMPLIED, false));
147:                    attrList.add(new Attribute(TOOLTIP,
148:                            new AttributeTypeMethodCall(String.class, l,
149:                                    EVENT_AWARE), IMPLIED, false));
150:                    attrList.add(new Attribute(OPAQUE,
151:                            new AttributeTypeMethodCall(Boolean.TYPE), IMPLIED,
152:                            false));
153:                    attrList.add(new Attribute(GRABFOCUS,
154:                            new AttributeTypeMethodCall(Boolean.TYPE, l,
155:                                    EVENT_AWARE), IMPLIED, false));
156:                    attrList.add(new Attribute(FOCUS_KEYS_FORWARD,
157:                            new AttributeTypeString(), IMPLIED, false));
158:                    attrList.add(new Attribute(FOCUS_KEYS_BACKWARD,
159:                            new AttributeTypeString(), IMPLIED, false));
160:                    attrList.add(new Attribute(HANDLE_READ_ONLY,
161:                            AttributeTypeEnumeration.getBooleanInstance(),
162:                            false, false));
163:                    attrList.add(new Attribute(KEYMAP, new AttributeTypeID(),
164:                            false, false));
165:                }
166:            }
167:
168:            final public Gui4jComponent defineBy(
169:                    Gui4jComponentContainer gui4jComponentContainer, String id,
170:                    LElement e) {
171:                Gui4jJComponent gui4jJComponent = defineGui4jJComponentBy(
172:                        gui4jComponentContainer, id, e);
173:                defineProperties(gui4jJComponent, e);
174:                return gui4jJComponent;
175:            }
176:
177:            abstract protected Gui4jJComponent defineGui4jJComponentBy(
178:                    Gui4jComponentContainer gui4jComponentContainer, String id,
179:                    LElement e);
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.