Source Code Cross Referenced for XLocalisedListBinding.java in  » XML-UI » XUI » net » xoetrope » optional » data » 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 » XUI » net.xoetrope.optional.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.optional.data;
002:
003:        import java.util.ResourceBundle;
004:        import java.util.Vector;
005:
006:        import java.awt.Component;
007:
008:        import net.xoetrope.xml.XmlElement;
009:        import net.xoetrope.xui.XListHolder;
010:        import net.xoetrope.xui.XProjectManager;
011:        import net.xoetrope.xui.XResourceManager;
012:        import net.xoetrope.xui.data.XCustomDataBinding;
013:        import net.xoetrope.xui.data.XListBinding;
014:        import net.xoetrope.xui.data.XListModelAdapter;
015:        import net.xoetrope.xui.data.XModel;
016:
017:        /**
018:         * A list binding that supports localization of the list content
019:         * <p>Copyright Xoetrope (c) 2001-2004</p>
020:         * $Revision: 1.7 $
021:         */
022:        public class XLocalisedListBinding extends XListBinding implements 
023:                XCustomDataBinding {
024:            protected ResourceBundle languageResourceBundle;
025:            protected Vector keys;
026:
027:            public XLocalisedListBinding() {
028:                keys = new Vector();
029:            }
030:
031:            /**
032:             * Used to setup custom components where the constructor. The properties of the
033:             * binding are specified by the xmlElement and the date pointed to by the
034:             * dataElement path is bound to the component
035:             * @param c the component to bind to
036:             * @param xmlElement the XML element which contains the binding configuration
037:             */
038:            public void setup(Component c, XmlElement xmlElement) {
039:                languageResourceBundle = XResourceManager
040:                        .getResourceBundle(XProjectManager.getCurrentProject()
041:                                .getStartupParam("Language"));
042:                srcPath = xmlElement.getAttribute("source");
043:                String destElement = xmlElement.getAttribute("output");
044:                outputPath = XModel.prefixOutputPath(destElement);
045:                XModel srcModel = null;
046:                XModel dstModel = null;
047:                if (srcPath != null)
048:                    srcModel = (XModel) XProjectManager.getModel().get(srcPath);
049:                if (destElement == null)
050:                    outputPath = XModel.prefixOutputPath(srcPath);
051:                outputNode = dstModel;
052:                if ((dstModel == null) && (destElement != null))
053:                    outputNode = (XModel) XProjectManager.getModel().get(
054:                            outputPath);
055:                if ((srcModel == null) && (srcPath != null))
056:                    srcModel = (XModel) XProjectManager.getModel().get(srcPath);
057:
058:                model = new XListModelAdapter(srcModel);
059:                comp = (XListHolder) c;
060:                useUnique = false;
061:                bDirty = true;
062:            }
063:
064:            /**
065:             * Construct a new data binding
066:             * @param c the component to be bound
067:             * @param dataElement the name of the data in the model
068:             */
069:            public XLocalisedListBinding(Component c, String dataElement) {
070:                this (c, dataElement, null, null, null);
071:            }
072:
073:            /**
074:             * Construct a new data binding
075:             * @param c the component to be bound
076:             * @param dataElement the name of the data in the model
077:             * @param destElement the name of the destination data in the model
078:             * @param srcModel the model node that acts as the data source for this node
079:             * @param dstModel the model node to which the selection is saved
080:             */
081:            public XLocalisedListBinding(Component c, String dataElement,
082:                    String destElement, XModel srcModel, XModel dstModel) {
083:                this (c, dataElement, destElement, srcModel, dstModel, true);
084:            }
085:
086:            /**
087:             * Construct a new data binding
088:             * @param c the component to be bound
089:             * @param dataElement the name of the data in the model
090:             * @param srcModel the model node that acts as the data source for this node
091:             */
092:            public XLocalisedListBinding(Component c, String dataElement,
093:                    String destElement) {
094:                this (c, dataElement, destElement, null, null, true);
095:            }
096:
097:            /**
098:             * Construct a new data binding, and set the languageResourceBundle for text
099:             * to be translated
100:             * @param c the component to be bound
101:             * @param dataElement the name of the data in the model
102:             * @param destElement the name of the destination data in the model
103:             * @param srcModel the model node that acts as the data source for this node
104:             * @param dstModel the model node to which the selection is saved
105:             * @param saveToSource true to save the selected value as the value of the source node, false to save only to the output node
106:             */
107:            public XLocalisedListBinding(Component c, String dataElement,
108:                    String destElement, XModel srcModel, XModel dstModel,
109:                    boolean saveToSource) {
110:                super (c, dataElement, destElement, srcModel, dstModel,
111:                        saveToSource);
112:                if ((model.getModel().get() == null) && (outputNode != null))
113:                    model.getModel().set((String) outputNode.get());
114:                keys = new Vector();
115:                languageResourceBundle = XResourceManager
116:                        .getResourceBundle(XProjectManager.getCurrentProject()
117:                                .getStartupParam("Language"));
118:            }
119:
120:            /**
121:             * Translate the text being added to the list.
122:             * @param key the key to be look up in the resourcebundle
123:             * @return the translated key or the key itself if no translation found
124:             */
125:            protected String translate(String key) {
126:                String ret = key;
127:                while (key.indexOf(' ') >= 0)
128:                    key = key.replace(' ', '_');
129:
130:                try {
131:                    ret = languageResourceBundle.getString(key);
132:                } catch (Exception ex) {
133:                }
134:
135:                return ret;
136:            }
137:
138:            /**
139:             * translate the text at this point
140:             * @param s the text to be translated
141:             */
142:            protected String addItem(String s) {
143:                keys.add(s);
144:                String item = translate(s);
145:                comp.addItem(item);
146:                return item;
147:            }
148:
149:            /**
150:             * Get the untranslated key for a list item
151:             * @param idx the list index
152:             */
153:            public String getKey(int idx) {
154:                return (String) keys.elementAt(idx);
155:            }
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.