Source Code Cross Referenced for SCheckBox.java in  » Swing-Library » wings3 » org » wings » 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 » Swing Library » wings3 » org.wings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2000,2005 wingS development team.
003:         *
004:         * This file is part of wingS (http://wingsframework.org).
005:         *
006:         * wingS is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU Lesser General Public License
008:         * as published by the Free Software Foundation; either version 2.1
009:         * of the License, or (at your option) any later version.
010:         *
011:         * Please see COPYING for the complete licence.
012:         */
013:        package org.wings;
014:
015:        import org.wings.plaf.CheckBoxCG;
016:
017:        import java.util.Arrays;
018:
019:        /*
020:         * Checkboxen sind etwas besondere {@link SFormComponent}, denn
021:         * ihre eigentliche Identitaet ({@link #getUID}) steckt nicht im Name,
022:         * sondern im Value. Das ist deswegen so, weil in HTML Gruppen
023:         * durch den selben Namen generiert werden. Das ist natuerlich
024:         * problematisch. Eine anderes Problem, welches hier auftaucht ist,
025:         * das HTML immer nur rueckmeldet, wenn eine Checkbox markiert ist.
026:         * Deshalb wird hintenan immer ein Hidden Form Element gehaengt,
027:         * welches rueckmeldet, dass die Checkbox bearbeitet wurde.
028:         */
029:
030:        /**
031:         * Checkbox widget.
032:         * <p/>
033:         * May be displayed as a HTML form element or as a clickable icon.
034:         *
035:         * @author <a href="mailto:armin.haaf@mercatis.de">Armin Haaf</a>
036:         */
037:        public class SCheckBox extends SAbstractButton {
038:
039:            /**
040:             * Creates an initially unselected checkbox.
041:             */
042:            public SCheckBox() {
043:                this (false);
044:            }
045:
046:            /**
047:             * Creates an initially unselected checkbox with a text-label.
048:             * 
049:             * @param label Text to display
050:             */
051:            public SCheckBox(String label) {
052:                this (false);
053:                setText(label);
054:            }
055:
056:            /**
057:             * Creates a checkbox with a certain state.
058:             * 
059:             * @param selected Whether the checkbox is initially selected or not.
060:             */
061:            public SCheckBox(boolean selected) {
062:                setSelected(selected);
063:
064:                setHorizontalTextPosition(SConstants.NO_ALIGN);
065:                setVerticalTextPosition(SConstants.NO_ALIGN);
066:
067:                super .setType(CHECKBOX);
068:            }
069:
070:            /**
071:             * Creates a checkbox with a text-label and a state.
072:             * 
073:             * @param label Text to display
074:             * @param selected Whether the checkbox is initially selected or not.
075:             */
076:            public SCheckBox(String label, boolean selected) {
077:                this (selected);
078:                setText(label);
079:            }
080:
081:            protected void setGroup(SButtonGroup g) {
082:                if (g != null) {
083:                    throw new IllegalArgumentException(
084:                            "SCheckBox don`t support button groups, use SRadioButton");
085:                } // end of if ()
086:            }
087:
088:            /**
089:             * You cannot change type of checkbox. <p>
090:             * Accepts only {@link SAbstractButton#CHECKBOX}
091:             */
092:            public final void setType(String t) {
093:                if (!CHECKBOX.equals(t))
094:                    throw new IllegalArgumentException(
095:                            "type change not supported, type is fix: checkbox");
096:
097:                super .setType(t);
098:            }
099:
100:            public void setCG(CheckBoxCG cg) {
101:                super .setCG(cg);
102:            }
103:
104:            public void processLowLevelEvent(String action, String[] values) {
105:                processKeyEvents(values);
106:                if (action.endsWith("_keystroke"))
107:                    return;
108:
109:                delayEvents(true);
110:
111:                boolean requestSelection;
112:                if (Arrays.asList(values).contains("hidden_reset")) {
113:                    // one hidden and one checked event from the form says select
114:                    // it, else deselect it (typically only the hidden event)
115:                    requestSelection = values.length == 2;
116:                } else {
117:                    requestSelection = parseSelectionToggle(values[0]);
118:                }
119:
120:                if (requestSelection != isSelected()) {
121:                    setSelected(requestSelection);
122:                    // got an event, that is a select...
123:                    SForm.addArmedComponent(this );
124:                } // end of if ()
125:
126:                delayEvents(false);
127:            }
128:
129:            /**
130:             * in form components the parameter value of an button is the button
131:             * text. So just toggle selection, in process request, if it is a request
132:             * for me.
133:             */
134:            protected boolean parseSelectionToggle(String toggleParameter) {
135:                // a button/image in a form has no value, so just toggle selection...
136:                if (getShowAsFormComponent()) {
137:                    return !isSelected();
138:                } // end of if ()
139:
140:                if ("1".equals(toggleParameter))
141:                    return true;
142:                else if ("0".equals(toggleParameter))
143:                    return false;
144:
145:                // don't change...
146:                return isSelected();
147:            }
148:
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.