Source Code Cross Referenced for ItsNatHTMLSelectComboBoxImpl.java in  » Ajax » ItsNat » org » itsnat » impl » comp » 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 » Ajax » ItsNat » org.itsnat.impl.comp.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          ItsNat Java Web Application Framework
003:          Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004:          Author: Jose Maria Arranz Santamaria
005:
006:          This program is free software: you can redistribute it and/or modify
007:          it under the terms of the GNU Affero General Public License as published by
008:          the Free Software Foundation, either version 3 of the License, or
009:          (at your option) any later version. See the GNU Affero General Public 
010:          License for more details. See the copy of the GNU Affero General Public License
011:          included in this program. If not, see <http://www.gnu.org/licenses/>.
012:         */
013:
014:        package org.itsnat.impl.comp.html;
015:
016:        import org.itsnat.core.event.CustomParamTransport;
017:        import org.itsnat.comp.html.ItsNatHTMLSelectComboBox;
018:        import org.itsnat.comp.ui.ItsNatComboBoxUI;
019:        import org.itsnat.comp.ui.ItsNatComponentUI;
020:        import org.itsnat.impl.comp.ItsNatComboBoxInternal;
021:        import org.itsnat.impl.comp.ItsNatComboBoxSharedImpl;
022:        import org.itsnat.impl.comp.html.ui.ItsNatHTMLSelectComboBoxUIImpl;
023:        import java.awt.event.ItemEvent;
024:        import java.awt.event.ItemListener;
025:        import javax.swing.ComboBoxModel;
026:        import javax.swing.DefaultComboBoxModel;
027:        import javax.swing.ListModel;
028:        import javax.swing.MutableComboBoxModel;
029:        import javax.swing.event.EventListenerList;
030:        import javax.swing.event.ListDataEvent;
031:        import org.itsnat.core.event.ParamTransport;
032:        import org.itsnat.core.NameValue;
033:        import org.itsnat.core.event.DOMEvent;
034:        import org.w3c.dom.events.Event;
035:        import org.w3c.dom.html.HTMLSelectElement;
036:
037:        /**
038:         * Similar a JComboBox
039:         * @author jmarranz
040:         */
041:        public class ItsNatHTMLSelectComboBoxImpl extends ItsNatHTMLSelectImpl
042:                implements  ItsNatHTMLSelectComboBox, ItsNatComboBoxInternal {
043:            protected Object selectedItemReminder;
044:            protected EventListenerList listenerList = new EventListenerList();
045:
046:            /**
047:             * Creates a new instance of ItsNatHTMLSelectComboBoxImpl
048:             */
049:            public ItsNatHTMLSelectComboBoxImpl(HTMLSelectElement element,
050:                    NameValue[] artifacts,
051:                    ItsNatHTMLComponentManagerImpl componentMgr) {
052:                super (element, artifacts, componentMgr);
053:
054:                // No imponemos así podríamos en teoría asociar al tipo de select que queramos
055:                //getHTMLSelectElement().setMultiple(false); // Para asegurarnos
056:
057:                init();
058:            }
059:
060:            public Object getSelectedItemReminder() {
061:                return selectedItemReminder;
062:            }
063:
064:            public void setSelectedItemReminder(Object obj) {
065:                this .selectedItemReminder = obj;
066:            }
067:
068:            protected ParamTransport[] getParamTransports(String type) {
069:                if (type.equals("change")) {
070:                    // Redefinimos porque es un poco más complicado que el código por defecto            
071:                    CustomParamTransport selectedIndex = new CustomParamTransport(
072:                            "selectedIndex",
073:                            "this.getCurrentTarget().selectedIndex");
074:                    return new ParamTransport[] { selectedIndex };
075:                } else
076:                    return null;
077:            }
078:
079:            public void handleEventOnChange(Event evt) {
080:                // Ejecutado como respuesta al evento "change" en el SELECT en el navegador 
081:                DOMEvent itsNatEvent = (DOMEvent) evt;
082:                int selectedIndex = Integer.parseInt((String) itsNatEvent
083:                        .getExtraParam("selectedIndex"));
084:
085:                setServerUpdatingFromClient(itsNatEvent); // Pues el evento viene del navegador y no se necesita enviar actualizaciones (salvo observers para que vean el cambio del cliente)
086:
087:                try {
088:                    setSelectedIndex(selectedIndex);
089:                } finally {
090:                    setServerUpdatingFromClient(null);
091:                }
092:            }
093:
094:            public ItsNatComboBoxUI getItsNatComboBoxUI() {
095:                return (ItsNatComboBoxUI) compUI;
096:            }
097:
098:            public ItsNatComboBoxUI createDefaultItsNatHTMLSelectComboBoxUI() {
099:                return new ItsNatHTMLSelectComboBoxUIImpl(this );
100:            }
101:
102:            public ItsNatComponentUI createDefaultItsNatComponentUI() {
103:                // Por defecto es mutable
104:                return createDefaultItsNatHTMLSelectComboBoxUI();
105:            }
106:
107:            public void syncUIWithDataModel() {
108:                super .syncUIWithDataModel();
109:
110:                ItsNatComboBoxSharedImpl.syncUIWithDataModel(this );
111:            }
112:
113:            public ComboBoxModel getComboBoxModel() {
114:                return (ComboBoxModel) dataModel;
115:            }
116:
117:            public void setComboBoxModel(ComboBoxModel dataModel) {
118:                setDataModel(dataModel);
119:            }
120:
121:            public ListModel getListModel() {
122:                return getComboBoxModel();
123:            }
124:
125:            public void setListModel(ListModel dataModel) {
126:                setComboBoxModel((ComboBoxModel) dataModel);
127:            }
128:
129:            public void checkMutableComboBoxModel() {
130:                ItsNatComboBoxSharedImpl
131:                        .checkMutableComboBoxModel(getComboBoxModel());
132:            }
133:
134:            public void addElement(Object anObject) {
135:                checkMutableComboBoxModel();
136:                MutableComboBoxModel model = (MutableComboBoxModel) getComboBoxModel();
137:                model.addElement(anObject);
138:            }
139:
140:            public void insertElementAt(int index, Object anObject) {
141:                checkMutableComboBoxModel();
142:                MutableComboBoxModel model = (MutableComboBoxModel) getComboBoxModel();
143:                model.insertElementAt(anObject, index);
144:            }
145:
146:            public void removeElementAt(int anIndex) {
147:                checkMutableComboBoxModel();
148:                MutableComboBoxModel model = (MutableComboBoxModel) getComboBoxModel();
149:                model.removeElementAt(anIndex);
150:            }
151:
152:            public void removeAllElements() {
153:                checkMutableComboBoxModel();
154:                ItsNatComboBoxSharedImpl.removeAllElements(this );
155:            }
156:
157:            public void removeElement(Object anObject) {
158:                checkMutableComboBoxModel();
159:                MutableComboBoxModel model = (MutableComboBoxModel) getComboBoxModel();
160:                model.removeElement(anObject);
161:            }
162:
163:            public int getSelectedIndex() {
164:                return ItsNatComboBoxSharedImpl.getSelectedIndex(this );
165:            }
166:
167:            public void setSelectedIndex(int index) {
168:                ItsNatComboBoxSharedImpl.setSelectedIndex(this , index);
169:            }
170:
171:            public Object getSelectedItem() {
172:                return ItsNatComboBoxSharedImpl.getSelectedItem(this );
173:            }
174:
175:            public void setSelectedItem(Object anObject) {
176:                ItsNatComboBoxSharedImpl.setSelectedItem(this , anObject);
177:            }
178:
179:            public Object[] getSelectedObjects() {
180:                return ItsNatComboBoxSharedImpl.getSelectedObjects(this );
181:            }
182:
183:            public void contentsChanged(ListDataEvent e) {
184:                super .contentsChanged(e);
185:
186:                ItsNatComboBoxSharedImpl.contentsChanged(this , e);
187:            }
188:
189:            public void intervalAdded(ListDataEvent e) {
190:                super .intervalAdded(e);
191:
192:                ItsNatComboBoxSharedImpl.intervalAdded(this , e);
193:            }
194:
195:            public void intervalRemoved(ListDataEvent e) {
196:                super .intervalRemoved(e);
197:
198:                ItsNatComboBoxSharedImpl.intervalRemoved(this , e);
199:            }
200:
201:            public void addItemListener(ItemListener l) {
202:                listenerList.add(ItemListener.class, l);
203:            }
204:
205:            public void removeItemListener(ItemListener l) {
206:                listenerList.remove(ItemListener.class, l);
207:            }
208:
209:            public boolean hasItemListeners() {
210:                return listenerList.getListenerCount() > 0;
211:            }
212:
213:            public ItemListener[] getItemListeners() {
214:                return (ItemListener[]) listenerList
215:                        .getListeners(ItemListener.class);
216:            }
217:
218:            public void fireItemStateChanged(ItemEvent e) {
219:                ItsNatComboBoxSharedImpl.fireItemStateChanged(this , e);
220:            }
221:
222:            public Object createDefaultModelInternal() {
223:                return createDefaultListModel();
224:            }
225:
226:            public ListModel createDefaultListModel() {
227:                return new DefaultComboBoxModel();
228:            }
229:
230:            public boolean isCombo() {
231:                return true;
232:            }
233:
234:            public void setUISelectedIndex(int index) {
235:                ItsNatComboBoxUI compUI = getItsNatComboBoxUI();
236:
237:                boolean wasDisabled = disableSendCodeToRequesterIfServerUpdating(); // Evitamos así que llegue al requester si no debe llegar (pero sí a los observadores)        
238:                try {
239:                    compUI.setSelectedIndex(index);
240:                } finally {
241:                    if (wasDisabled)
242:                        enableSendCodeToRequester();
243:                }
244:            }
245:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.