Source Code Cross Referenced for Style.java in  » Ajax » zk » org » zkoss » zul » 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 » zk » org.zkoss.zul 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Style.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Thu Jul 20 15:17:40     2006, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2006 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        }}IS_RIGHT
016:         */
017:        package org.zkoss.zul;
018:
019:        import java.util.Iterator;
020:
021:        import org.zkoss.lang.Objects;
022:        import org.zkoss.util.media.Media;
023:        import org.zkoss.util.media.AMedia;
024:        import org.zkoss.xml.HTMLs;
025:
026:        import org.zkoss.zk.ui.AbstractComponent;
027:        import org.zkoss.zk.ui.UiException;
028:        import org.zkoss.zk.ui.ext.render.DynamicMedia;
029:
030:        import org.zkoss.zul.impl.Utils;
031:
032:        /**
033:         * The style component used to specify CSS styles for the owner desktop.
034:         *
035:         * <p>Note: a style component can appear anywhere in a ZUML page, but it
036:         * affects all components in the same desktop.
037:         *
038:         * <p>Note: unlike HTML STYLE, this component can be added and removed
039:         * dynamically and the rules will be attached and detached accordingly.
040:         *
041:         * <p>There are three formats when used in a ZUML page:
042:         *
043:         * <p>Method 1: Specify the URL of the CSS file
044:         * <pre><code>&lt;style src="my.css"/&gt;
045:         * </code></pre>
046:         *
047:         * <p>Method 2: Specify the CSS directly
048:         * <pre><code>&lt;style&gt;
049:         * .mycls {
050:         *  border: 1px outset #777;
051:         * }
052:         *&lt;/style&gt;
053:         * </code></pre>
054:         *
055:         * <p>Method 3: Specify the CSS by use of the content
056:         * property ({@link #setContent}).
057:         * <pre><code>&lt;style&gt;
058:         * &lt;attribute name="content"&gt;
059:         * .mycls {
060:         *  border: 1px outset #777;
061:         * }
062:         * &lt;/attribute&gt;
063:         *&lt;/style&gt;
064:         * </code></pre>
065:         *
066:         * <p>Note: if the src and content properties are both set,
067:         * the content property is ignored.
068:         *
069:         * @author tomyeh
070:         */
071:        public class Style extends AbstractComponent {
072:            private String _src;
073:            private String _content;
074:            /** Count the version of {@link #_content}. */
075:            private int _cntver;
076:
077:            public Style() {
078:                super .setVisible(false);
079:            }
080:
081:            /**
082:             * @param src the URI of an external style sheet.
083:             */
084:            public Style(String src) {
085:                this ();
086:                setSrc(src);
087:            }
088:
089:            /** Returns the URI of an external style sheet.
090:             *
091:             * <p>Default: null. If null, the children's
092:             * (must be instances of {@link Label}) value ({@link Label#getValue})
093:             * is used as the content of styles.
094:             * If not null, the HTML LINK tag is generated to ask the browser
095:             * to load the specified style sheet.
096:             *
097:             * <p>Note: If not null, the content of children are ignored.
098:             */
099:            public String getSrc() {
100:                return _src;
101:            }
102:
103:            /** Sets the URI of an external style sheet.
104:             *
105:             * @param src the URI of an external style sheet, or null to use
106:             * the content of children ({@link Label#getValue}) instead.
107:             */
108:            public void setSrc(String src) {
109:                if (src != null && src.length() == 0)
110:                    src = null;
111:                if (!Objects.equals(_src, src)) {
112:                    _src = src;
113:                    invalidate();
114:                }
115:            }
116:
117:            /** Returns the content of the style element.
118:             * By content we mean the CSS rules that will be sent to the client.
119:             * Note: if {@link #setSrc} is called with a non-empty value,
120:             * this method is ignored, i.e., {@link #getSrc} has the higher priority.
121:             *
122:             * <p>Default: null.
123:             *
124:             * @since 3.0.0
125:             */
126:            public String getContent() {
127:                return _content;
128:            }
129:
130:            /** Sets the content of the style element.
131:             * By content we mean the CSS rules that will be sent to the client.
132:             *
133:             * @since 3.0.0
134:             */
135:            public void setContent(String content) {
136:                if (content != null && content.length() == 0)
137:                    content = null;
138:
139:                if (!Objects.equals(_content, content)) {
140:                    _content = content;
141:                    ++_cntver;
142:                    invalidate();
143:                }
144:            }
145:
146:            /** Returns the attributes for generating the HTML tags.
147:             */
148:            public String getOuterAttrs() {
149:                final StringBuffer sb = new StringBuffer(64);
150:                HTMLs.appendAttribute(sb, "z.src", _src != null ? getDesktop()
151:                        .getExecution().encodeURL(_src) : Utils
152:                        .getDynamicMediaURI(this , _cntver, "css", "css"));
153:                return sb.toString();
154:            }
155:
156:            //Component//
157:            /** Not allowd. */
158:            public boolean setVisible(boolean visible) {
159:                throw new UnsupportedOperationException(
160:                        "style is always invisible");
161:            }
162:
163:            /** Not childable. */
164:            public boolean isChildable() {
165:                return false;
166:            }
167:
168:            //-- ComponentCtrl --//
169:            protected Object newExtraCtrl() {
170:                return new ExtraCtrl();
171:            }
172:
173:            /** A utility class to implement {@link #getExtraCtrl}.
174:             * It is used only by component developers.
175:             */
176:            protected class ExtraCtrl implements  DynamicMedia {
177:                //-- DynamicMedia --//
178:                public Media getMedia(String pathInfo) {
179:                    return new AMedia("css", "css", "text/css;charset=UTF-8",
180:                            _content);
181:                }
182:            }
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.