Source Code Cross Referenced for ListBoxControl.java in  » Web-Framework » jWic » de » jwic » controls » 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 » Web Framework » jWic » de.jwic.controls 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 07.11.2004
003:         */
004:        package de.jwic.controls;
005:
006:        import java.util.ArrayList;
007:        import java.util.Iterator;
008:        import java.util.List;
009:
010:        import de.jwic.base.IControlContainer;
011:        import de.jwic.events.SelectionEvent;
012:        import de.jwic.events.SelectionListener;
013:
014:        /**
015:         * This control renders a listbox using the HTML select tag.
016:         * 
017:         * @author Florian Lippisch
018:         * @version $Revision: 1.3 $
019:         */
020:        public class ListBoxControl extends ListControl {
021:
022:            public final static int NO_SELECTION = 0;
023:            public final static int CLICK_SELECTION = 1;
024:            public final static int DBLCLICK_SELECTION = 2;
025:
026:            private static final long serialVersionUID = 2L;
027:
028:            private boolean multiple = false;
029:            private String confirmMsg = "";
030:            protected int size = 1;
031:
032:            protected int selectionMode = NO_SELECTION;
033:            protected List listeners = null;
034:
035:            /**
036:             * @param container
037:             */
038:            public ListBoxControl(IControlContainer container) {
039:                super (container, null);
040:            }
041:
042:            /**
043:             * @param container
044:             * @param name
045:             */
046:            public ListBoxControl(IControlContainer container, String name) {
047:                super (container, name);
048:            }
049:
050:            /**
051:             * Register a listener that will be notified when the listbox has been
052:             * selected (i.e. doubleClick). The event is only triggered if the
053:             * selectionMode property is not NO_SELECTION.
054:             * @param listener
055:             */
056:            public void addSelectionListener(SelectionListener listener) {
057:                if (listeners == null) {
058:                    listeners = new ArrayList();
059:                }
060:                listeners.add(listener);
061:            }
062:
063:            /**
064:             * Removes the specified listener.
065:             * @param listener
066:             */
067:            public void removeSelectionListener(SelectionListener listener) {
068:                if (listeners != null) {
069:                    listeners.remove(listener);
070:                }
071:            }
072:
073:            /**
074:             * Send the element selected event to the registerd listeners.
075:             */
076:            protected void sendSelectionEvent() {
077:
078:                if (listeners != null) {
079:                    SelectionEvent e = new SelectionEvent(this );
080:                    for (Iterator it = listeners.iterator(); it.hasNext();) {
081:                        SelectionListener osl = (SelectionListener) it.next();
082:                        osl.objectSelected(e);
083:                    }
084:                }
085:
086:            }
087:
088:            /**
089:             * The action method that handles if the user selects the control, depending on
090:             * how the selectionMode is set. 
091:             */
092:            public void actionSelected() {
093:                sendSelectionEvent();
094:            }
095:
096:            /**
097:             * @return Returns the multiple.
098:             */
099:            public boolean isMultiple() {
100:                return multiple;
101:            }
102:
103:            /**
104:             * @param multiple The multiple to set.
105:             */
106:            public void setMultiple(boolean multiple) {
107:                if (this .multiple && !multiple) {
108:                    // changed from multi-selection to single selection
109:                    if (field.getValues().length > 1) {
110:                        // if more then one entry is selected, select the first one
111:                        field.setValue(field.getValues()[0]);
112:                    }
113:                }
114:                this .multiple = multiple;
115:
116:                requireRedraw();
117:            }
118:
119:            /**
120:             * @return Returns the confirmMsg.
121:             */
122:            public String getConfirmMsg() {
123:                return confirmMsg;
124:            }
125:
126:            /**
127:             * If the confirm message is not an empty string, the user will be prompted with a  
128:             * message box and the specified message. He may then answer 'ok' or 'cancel'. If the
129:             * user presses ok, the change will be done. Otherwise the old value is restored 
130:             * and no event happens.
131:             * 
132:             * @param confirmMsg The confirmMsg to set.
133:             */
134:            public void setConfirmMsg(String confirmMsg) {
135:                this .confirmMsg = confirmMsg;
136:                requireRedraw();
137:            }
138:
139:            /**
140:             * @return Returns the size.
141:             */
142:            public int getSize() {
143:                return size;
144:            }
145:
146:            /**
147:             * Set the size of the control. A value of 1 will display a combo-box, other
148:             * values display a list. 
149:             *
150:             * @param size The size to set.
151:             */
152:            public void setSize(int size) {
153:                this .size = size;
154:                requireRedraw();
155:            }
156:
157:            /**
158:             * @return Returns the selectionMode.
159:             */
160:            public int getSelectionMode() {
161:                return selectionMode;
162:            }
163:
164:            /**
165:             * @param selectionMode The selectionMode to set.
166:             */
167:            public void setSelectionMode(int selectionMode) {
168:                if (selectionMode != NO_SELECTION && isChangeNotification()) {
169:                    // the submit initiated by the onChange event would conflict with the following onDblClick event,
170:                    // therefor it can not be allowed to enable both.
171:                    throw new IllegalArgumentException(
172:                            "You can not activate selectionMode if the changeNotification is on");
173:                }
174:                this .selectionMode = selectionMode;
175:                requireRedraw();
176:            }
177:
178:            /* (non-Javadoc)
179:             * @see de.jwic.controls.ListControl#setChangeNotification(boolean)
180:             */
181:            public void setChangeNotification(boolean changeNotification) {
182:                if (selectionMode != NO_SELECTION && changeNotification) {
183:                    // the submit initiated by the onChange event would conflict with the following onDblClick event,
184:                    // therefor it can not be allowed to enable both.
185:                    throw new IllegalArgumentException(
186:                            "You can not activate changeNotifaction if the selectionMode is activated");
187:                }
188:                super.setChangeNotification(changeNotification);
189:            }
190:
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.