Source Code Cross Referenced for DialogBox.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.Event;
020:
021:        /**
022:         * A form of popup that has a caption area at the top and can be dragged by the
023:         * user. Unlike a PopupPanel, calls to {@link #setWidth(String)} and
024:         * {@link #setHeight(String)} will set the width and height of the dialog box
025:         * itself, even if a widget has not been added as yet.
026:         * <p>
027:         * <img class='gallery' src='DialogBox.png'/>
028:         * </p>
029:         * <h3>CSS Style Rules</h3>
030:         * <ul class='css'>
031:         * <li>.gwt-DialogBox { the outside of the dialog }</li>
032:         * <li>.gwt-DialogBox .Caption { the caption }</li>
033:         * </ul>
034:         * <p>
035:         * <h3>Example</h3>
036:         * {@example com.google.gwt.examples.DialogBoxExample}
037:         * </p>
038:         */
039:        public class DialogBox extends PopupPanel implements  HasHTML,
040:                MouseListener {
041:
042:            private HTML caption = new HTML();
043:            private Widget child;
044:            private boolean dragging;
045:            private int dragStartX, dragStartY;
046:            private FlexTable panel = new FlexTable();
047:
048:            /**
049:             * Creates an empty dialog box. It should not be shown until its child widget
050:             * has been added using {@link #add(Widget)}.
051:             */
052:            public DialogBox() {
053:                this (false);
054:            }
055:
056:            /**
057:             * Creates an empty dialog box specifying its "auto-hide" property. It should
058:             * not be shown until its child widget has been added using
059:             * {@link #add(Widget)}.
060:             * 
061:             * @param autoHide <code>true</code> if the dialog should be automatically
062:             *          hidden when the user clicks outside of it
063:             */
064:            public DialogBox(boolean autoHide) {
065:                this (autoHide, true);
066:            }
067:
068:            /**
069:             * Creates an empty dialog box specifying its "auto-hide" property. It should
070:             * not be shown until its child widget has been added using
071:             * {@link #add(Widget)}.
072:             * 
073:             * @param autoHide <code>true</code> if the dialog should be automatically
074:             *          hidden when the user clicks outside of it
075:             * @param modal <code>true</code> if keyboard and mouse events for widgets
076:             *          not contained by the dialog should be ignored
077:             */
078:            public DialogBox(boolean autoHide, boolean modal) {
079:                super (autoHide, modal);
080:                panel.setWidget(0, 0, caption);
081:                panel.setHeight("100%");
082:                panel.setBorderWidth(0);
083:                panel.setCellPadding(0);
084:                panel.setCellSpacing(0);
085:                panel.getCellFormatter().setHeight(1, 0, "100%");
086:                panel.getCellFormatter().setWidth(1, 0, "100%");
087:                panel.getCellFormatter().setAlignment(1, 0,
088:                        HasHorizontalAlignment.ALIGN_CENTER,
089:                        HasVerticalAlignment.ALIGN_MIDDLE);
090:                super .setWidget(panel);
091:
092:                setStyleName("gwt-DialogBox");
093:                caption.setStyleName("Caption");
094:                caption.addMouseListener(this );
095:            }
096:
097:            public String getHTML() {
098:                return caption.getHTML();
099:            }
100:
101:            public String getText() {
102:                return caption.getText();
103:            }
104:
105:            @Override
106:            public Widget getWidget() {
107:                return child;
108:            }
109:
110:            @Override
111:            public boolean onEventPreview(Event event) {
112:                // We need to preventDefault() on mouseDown events (outside of the
113:                // DialogBox content) to keep text from being selected when it
114:                // is dragged.
115:                if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
116:                    if (DOM.isOrHasChild(caption.getElement(), DOM
117:                            .eventGetTarget(event))) {
118:                        DOM.eventPreventDefault(event);
119:                    }
120:                }
121:
122:                return super .onEventPreview(event);
123:            }
124:
125:            public void onMouseDown(Widget sender, int x, int y) {
126:                dragging = true;
127:                DOM.setCapture(caption.getElement());
128:                dragStartX = x;
129:                dragStartY = y;
130:            }
131:
132:            public void onMouseEnter(Widget sender) {
133:            }
134:
135:            public void onMouseLeave(Widget sender) {
136:            }
137:
138:            public void onMouseMove(Widget sender, int x, int y) {
139:                if (dragging) {
140:                    int absX = x + getAbsoluteLeft();
141:                    int absY = y + getAbsoluteTop();
142:                    setPopupPosition(absX - dragStartX, absY - dragStartY);
143:                }
144:            }
145:
146:            public void onMouseUp(Widget sender, int x, int y) {
147:                dragging = false;
148:                DOM.releaseCapture(caption.getElement());
149:            }
150:
151:            @Override
152:            public boolean remove(Widget w) {
153:                if (child != w) {
154:                    return false;
155:                }
156:
157:                panel.remove(w);
158:                return true;
159:            }
160:
161:            public void setHTML(String html) {
162:                caption.setHTML(html);
163:            }
164:
165:            public void setText(String text) {
166:                caption.setText(text);
167:            }
168:
169:            @Override
170:            public void setWidget(Widget w) {
171:                // If there is already a widget, remove it.
172:                if (child != null) {
173:                    panel.remove(child);
174:                }
175:
176:                // Add the widget to the center of the cell.
177:                if (w != null) {
178:                    panel.setWidget(1, 0, w);
179:                }
180:
181:                child = w;
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.