Source Code Cross Referenced for Hyperlink.java in  » Ajax » GWT » com » google » gwt » user » client » ui » 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 » GWT » com.google.gwt.user.client.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Google Inc.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License. You may obtain a copy of
006:         * the License at
007:         * 
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013:         * License for the specific language governing permissions and limitations under
014:         * the License.
015:         */
016:        package com.google.gwt.user.client.ui;
017:
018:        import com.google.gwt.user.client.DOM;
019:        import com.google.gwt.user.client.Element;
020:        import com.google.gwt.user.client.Event;
021:        import com.google.gwt.user.client.History;
022:
023:        /**
024:         * A widget that serves as an "internal" hyperlink. That is, it is a link to
025:         * another state of the running application. When clicked, it will create a new
026:         * history frame using {@link com.google.gwt.user.client.History#newItem}, but
027:         * without reloading the page.
028:         * 
029:         * <p>
030:         * Being a true hyperlink, it is also possible for the user to "right-click,
031:         * open link in new window", which will cause the application to be loaded in a
032:         * new window at the state specified by the hyperlink.
033:         * </p>
034:         * 
035:         * <p>
036:         * <img class='gallery' src='Hyperlink.png'/>
037:         * </p>
038:         * 
039:         * <h3>CSS Style Rules</h3>
040:         * <ul class='css'>
041:         * <li>.gwt-Hyperlink { }</li>
042:         * </ul>
043:         * 
044:         * <p>
045:         * <h3>Example</h3> {@example com.google.gwt.examples.HistoryExample}
046:         * </p>
047:         */
048:        public class Hyperlink extends Widget implements  HasHTML,
049:                SourcesClickEvents {
050:
051:            private Element anchorElem;
052:            private ClickListenerCollection clickListeners;
053:            private String targetHistoryToken;
054:
055:            /**
056:             * Creates an empty hyperlink.
057:             */
058:            public Hyperlink() {
059:                setElement(DOM.createDiv());
060:                DOM.appendChild(getElement(), anchorElem = DOM.createAnchor());
061:                sinkEvents(Event.ONCLICK);
062:                setStyleName("gwt-Hyperlink");
063:            }
064:
065:            /**
066:             * Creates a hyperlink with its text and target history token specified.
067:             * 
068:             * @param text the hyperlink's text
069:             * @param asHTML <code>true</code> to treat the specified text as html
070:             * @param targetHistoryToken the history token to which it will link
071:             * @see #setTargetHistoryToken
072:             */
073:            public Hyperlink(String text, boolean asHTML,
074:                    String targetHistoryToken) {
075:                this ();
076:                if (asHTML) {
077:                    setHTML(text);
078:                } else {
079:                    setText(text);
080:                }
081:                setTargetHistoryToken(targetHistoryToken);
082:            }
083:
084:            /**
085:             * Creates a hyperlink with its text and target history token specified.
086:             * 
087:             * @param text the hyperlink's text
088:             * @param targetHistoryToken the history token to which it will link
089:             */
090:            public Hyperlink(String text, String targetHistoryToken) {
091:                this ();
092:                setText(text);
093:                setTargetHistoryToken(targetHistoryToken);
094:            }
095:
096:            public void addClickListener(ClickListener listener) {
097:                if (clickListeners == null) {
098:                    clickListeners = new ClickListenerCollection();
099:                }
100:                clickListeners.add(listener);
101:            }
102:
103:            public String getHTML() {
104:                return DOM.getInnerHTML(anchorElem);
105:            }
106:
107:            /**
108:             * Gets the history token referenced by this hyperlink.
109:             * 
110:             * @return the target history token
111:             * @see #setTargetHistoryToken
112:             */
113:            public String getTargetHistoryToken() {
114:                return targetHistoryToken;
115:            }
116:
117:            public String getText() {
118:                return DOM.getInnerText(anchorElem);
119:            }
120:
121:            @Override
122:            public void onBrowserEvent(Event event) {
123:                if (DOM.eventGetType(event) == Event.ONCLICK) {
124:                    if (clickListeners != null) {
125:                        clickListeners.fireClick(this );
126:                    }
127:                    History.newItem(targetHistoryToken);
128:                    DOM.eventPreventDefault(event);
129:                }
130:            }
131:
132:            public void removeClickListener(ClickListener listener) {
133:                if (clickListeners != null) {
134:                    clickListeners.remove(listener);
135:                }
136:            }
137:
138:            public void setHTML(String html) {
139:                DOM.setInnerHTML(anchorElem, html);
140:            }
141:
142:            /**
143:             * Sets the history token referenced by this hyperlink. This is the history
144:             * token that will be passed to {@link History#newItem} when this link is
145:             * clicked.
146:             * 
147:             * @param targetHistoryToken the new target history token
148:             */
149:            public void setTargetHistoryToken(String targetHistoryToken) {
150:                this .targetHistoryToken = targetHistoryToken;
151:                DOM.setElementProperty(anchorElem, "href", "#"
152:                        + targetHistoryToken);
153:            }
154:
155:            public void setText(String text) {
156:                DOM.setInnerText(anchorElem, text);
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.