Source Code Cross Referenced for ColorPalette.java in  » Ajax » gwtext-2.01 » com » gwtext » client » widgets » 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 » gwtext 2.01 » com.gwtext.client.widgets 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * GWT-Ext Widget Library
003:         * Copyright(c) 2007-2008, GWT-Ext.
004:         * licensing@gwt-ext.com
005:         * 
006:         * http://www.gwt-ext.com/license
007:         */
008:
009:        package com.gwtext.client.widgets;
010:
011:        import com.google.gwt.core.client.JavaScriptObject;
012:        import com.google.gwt.user.client.DOM;
013:        import com.gwtext.client.util.JavaScriptObjectHelper;
014:        import com.gwtext.client.widgets.event.ColorPaletteListener;
015:
016:        /**
017:         * Simple color palette class for choosing colors. 
018:         */
019:        public class ColorPalette extends Component {
020:
021:            private static JavaScriptObject configPrototype;
022:
023:            static {
024:                init();
025:            }
026:
027:            private static native void init()/*-{
028:                    var c = new $wnd.Ext.ColorPalette();
029:                    @com.gwtext.client.widgets.ColorPalette::configPrototype = c.initialConfig;
030:                }-*/;
031:
032:            protected JavaScriptObject getConfigPrototype() {
033:                return configPrototype;
034:            }
035:
036:            public String getXType() {
037:                return "colorpalette";
038:            }
039:
040:            /**
041:             * Create a new CollorPalette.
042:             */
043:            public ColorPalette() {
044:            }
045:
046:            public ColorPalette(JavaScriptObject jsObj) {
047:                super (jsObj);
048:            }
049:
050:            protected native JavaScriptObject create(JavaScriptObject config)/*-{
051:                    return new $wnd.Ext.ColorPalette(config);
052:                }-*/;
053:
054:            private static ColorPalette instance(JavaScriptObject jsObj) {
055:                return new ColorPalette(jsObj);
056:            }
057:
058:            /**
059:             * Selects the specified color in the palette (fires the select event).
060:             *
061:             * @param color A valid 6-digit color hex code (# will be stripped if included)
062:             */
063:            public void select(String color) {
064:                if (isRendered()) {
065:                    selectRendered(color);
066:                } else {
067:                    setValue(color);
068:                }
069:            }
070:
071:            private native void selectRendered(String color) /*-{
072:                   var cp = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
073:                   cp.select(color);
074:               }-*/;
075:
076:            /**
077:             * Add a ColorPalette listener.
078:             *
079:             * @param listener the listener
080:             */
081:            public native void addListener(ColorPaletteListener listener) /*-{
082:                   this.@com.gwtext.client.widgets.Component::addListener(Lcom/gwtext/client/widgets/event/ComponentListener;)(listener);
083:                   var componentJ = this;
084:
085:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('select',
086:                           function(cp, color) {
087:                               listener.@com.gwtext.client.widgets.event.ColorPaletteListener::onSelect(Lcom/gwtext/client/widgets/ColorPalette;Ljava/lang/String;)(componentJ, color);
088:                           }
089:                   );
090:               }-*/;
091:
092:            // --- config properties ---
093:
094:            /**
095:             * Return true if reselecting is allowed.
096:             *
097:             * @return true if reselecting is allowed
098:             */
099:            public boolean isAllowReselect() {
100:                return getAttributeAsBoolean("allowReselect");
101:            }
102:
103:            /**
104:             * If set to true then reselecting a color that is already selected fires the selection event.
105:             *
106:             * @param allowReselect true to allow reselect
107:             */
108:            public void setAllowReselect(boolean allowReselect) {
109:                setAttribute("allowReselect", allowReselect, true);
110:            }
111:
112:            /**
113:             * @return the CSS of the containing element
114:             */
115:            public String getItemCls() {
116:                return getAttribute("itemCls");
117:            }
118:
119:            /**
120:             * The CSS class to apply to the containing element (defaults to "x-color-palette").
121:             *
122:             * @param itemCls the item CSS class
123:             */
124:            public void setItemCls(String itemCls) {
125:                if (!isRendered()) {
126:                    setAttribute("itemCls", itemCls, true);
127:                } else {
128:                    DOM.setElementAttribute(getElement(), "className", itemCls);
129:                    setAttribute("itemCls", itemCls, true, true);
130:                }
131:            }
132:
133:            /**
134:             * The highlighted color.
135:             * 
136:             * @return the color value
137:             */
138:            public String getValue() {
139:                return getAttribute("value");
140:            }
141:
142:            /**
143:             * The color to highlight (should be a valid 6-digit color hex code without the # symbol).
144:             * Note that the hex codes are case-sensitive.
145:             *
146:             * @param value the initial color
147:             */
148:            public void setValue(String value) {
149:                if (isRendered()) {
150:                    select(value);
151:                    setAttribute("value", value, true, true);
152:                } else {
153:                    setAttribute("value", value, true);
154:                }
155:            }
156:
157:            /**
158:             * An array of 6-digit color hex code strings (without the # symbol). This array can contain any number of colors,
159:             * and each hex code should be unique. The width of the palette is controlled via CSS by adjusting the width property
160:             * of the 'x-color-palette' class (or assigning a custom class), so you can balance the number of colors with the width
161:             * setting until the box is symmetrical.
162:             *
163:             * @return the colors array
164:             */
165:            public String[] getColors() {
166:                return JavaScriptObjectHelper.getAttributeAsStringArray(config,
167:                        "colors");
168:            }
169:
170:            /**
171:             * Set the colors array.
172:             *
173:             * @param colors the colors array
174:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
175:             */
176:            public void setColors(String[] colors) throws IllegalStateException {
177:                setAttribute("colors", JavaScriptObjectHelper
178:                        .convertToJavaScriptArray(colors), true);
179:            }
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.