Source Code Cross Referenced for Dialog.java in  » Ajax » MyGWT » net » mygwt » ui » client » widget » 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 » MyGWT » net.mygwt.ui.client.widget 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *     Darrell Meyer <darrell@mygwt.net> - derived implementation
011:         *******************************************************************************/package net.mygwt.ui.client.widget;
012:
013:        import net.mygwt.ui.client.Events;
014:        import net.mygwt.ui.client.MyGWT;
015:        import net.mygwt.ui.client.Style;
016:        import net.mygwt.ui.client.event.BaseEvent;
017:        import net.mygwt.ui.client.event.Listener;
018:        import net.mygwt.ui.client.event.SelectionListener;
019:
020:        import com.google.gwt.user.client.DOM;
021:        import com.google.gwt.user.client.ui.HorizontalPanel;
022:        import com.google.gwt.user.client.ui.WidgetHelper;
023:
024:        /**
025:         * A <code>Shell</code> with a button bar.
026:         * 
027:         * <dl>
028:         * <dt><b>Styles:</b></dt>
029:         * <dd>CLOSE, RESIZE, MODAL</dd>
030:         * <dd>OK, OK_CANCEL, YES_NO, YES_NO_CANCEL</dd>
031:         * </dl>
032:         */
033:        public class Dialog extends Shell {
034:
035:            /**
036:             * Button id for a "Cancel" button (value 1).
037:             */
038:            public static final int CANCEL_ID = 1;
039:
040:            /**
041:             * Button id for a "No" button (value 3).
042:             */
043:            public static final int NO_ID = 3;
044:
045:            /**
046:             * Button id for an "Ok" button (value 0).
047:             */
048:            public static final int OK_ID = 0;
049:
050:            /**
051:             * Button id for a "Yes" button (value 2).
052:             */
053:            public static final int YES_ID = 2;
054:
055:            private boolean closeOnButtonClick = false;
056:            private HorizontalPanel footerPanel;
057:            private Item status;
058:            private ButtonBar buttonBar;
059:            private String statusText, statusIconStyle;
060:
061:            /**
062:             * Creates a dialog that can be closed and resized.
063:             */
064:            public Dialog() {
065:                this (Style.CLOSE | Style.RESIZE);
066:            }
067:
068:            /**
069:             * Creates a new dialog with the given style.
070:             * 
071:             * @param style the style information
072:             */
073:            public Dialog(int style) {
074:                super (style);
075:
076:                buttonBar = new ButtonBar(Style.RIGHT);
077:
078:                if ((style & Style.OK) != 0) {
079:                    createButton(OK_ID, MyGWT.MESSAGES.ok());
080:                }
081:                if ((style & Style.OK_CANCEL) != 0) {
082:                    createButton(OK_ID, MyGWT.MESSAGES.ok());
083:                    createButton(CANCEL_ID, MyGWT.MESSAGES.cancel());
084:                }
085:                if ((style & Style.YES_NO) != 0) {
086:                    createButton(YES_ID, MyGWT.MESSAGES.yes());
087:                    createButton(NO_ID, MyGWT.MESSAGES.no());
088:                }
089:                if ((style & Style.YES_NO_CANCEL) != 0) {
090:                    createButton(YES_ID, MyGWT.MESSAGES.yes());
091:                    createButton(NO_ID, MyGWT.MESSAGES.no());
092:                    createButton(CANCEL_ID, MyGWT.MESSAGES.cancel());
093:                }
094:            }
095:
096:            /**
097:             * Adds a button to the dialog.
098:             * 
099:             * @param button the button to be added
100:             */
101:            public void addButton(Button button) {
102:                buttonBar.add(button);
103:            }
104:
105:            /**
106:             * Adds a button to the dialog.
107:             * 
108:             * @param text the button text
109:             * @param listener the click listener
110:             * 
111:             * @return the new button
112:             */
113:            public Button addButton(String text, SelectionListener listener) {
114:                Button btn = new Button(text);
115:                btn.addSelectionListener(listener);
116:                addButton(btn);
117:                return btn;
118:            }
119:
120:            /**
121:             * Clears the dialog's status area.
122:             */
123:            public void clearStatus() {
124:                status.setText("");
125:                status.setIconStyle("none");
126:            }
127:
128:            /**
129:             * Returns the dialog's button bar.
130:             * 
131:             * @return the button bar
132:             */
133:            public ButtonBar getButtonBar() {
134:                return buttonBar;
135:            }
136:
137:            /**
138:             * Returns the button with the specified button id.
139:             * 
140:             * @param buttonId the button id
141:             * @return the button or <code>null</code> if no match
142:             */
143:            public Button getButtonById(int buttonId) {
144:                return buttonBar.getButtonById(buttonId);
145:            }
146:
147:            /**
148:             * Returns the last pressed button.
149:             * 
150:             * @return the button or <code>null</code> if no button pressed
151:             */
152:            public Button getButtonPressed() {
153:                return buttonBar.getButtonPressed();
154:            }
155:
156:            /**
157:             * Returns <code>true</code> if the dialog will be closed on any button
158:             * click.
159:             * 
160:             * @return the close on click state
161:             */
162:            public boolean getCloseOnButtonClick() {
163:                return closeOnButtonClick;
164:            }
165:
166:            /**
167:             * Removes the button.
168:             * 
169:             * @param button the button to be removed
170:             */
171:            public void removeButton(Button button) {
172:                buttonBar.remove(button);
173:            }
174:
175:            /**
176:             * Sets the close on button click state. When <code>true</code>, the dialog
177:             * will be closed after a button is clicked. Default value is
178:             * <code>false</code>.
179:             * 
180:             * @param closeOnButtonClick the close on button state
181:             */
182:            public void setCloseOnButtonClick(boolean closeOnButtonClick) {
183:                this .closeOnButtonClick = closeOnButtonClick;
184:            }
185:
186:            /**
187:             * Sets the dialog's status text and an optional icon.
188:             * 
189:             * @param text the status text
190:             * @param iconStyle the icon style
191:             */
192:            public void setStatus(String text, String iconStyle) {
193:                statusText = text;
194:                statusIconStyle = iconStyle;
195:                if (rendered) {
196:                    status.setText(text);
197:                    if (iconStyle != null) {
198:                        status.setIconStyle(iconStyle);
199:                    }
200:                }
201:            }
202:
203:            protected void afterRender() {
204:                if (statusText != null) {
205:                    setStatus(statusText, statusIconStyle);
206:                }
207:            }
208:
209:            protected void doAttachChildren() {
210:                super .doAttachChildren();
211:                WidgetHelper.doAttach(footerPanel);
212:            }
213:
214:            protected void doDetachChildren() {
215:                super .doDetachChildren();
216:                WidgetHelper.doDetach(footerPanel);
217:            }
218:
219:            /**
220:             * Called after a button in the button bar is selected. Default implementation
221:             * closes the dialog if closeOnButtonClick = true.
222:             * 
223:             * @param be the base event
224:             */
225:            protected void onButtonPressed(BaseEvent be) {
226:                if (closeOnButtonClick) {
227:                    close();
228:                }
229:            }
230:
231:            protected void onRender() {
232:                super .onRender();
233:                if (!buttonBar.isRendered()) {
234:                    buttonBar.render();
235:                }
236:                buttonBar.addListener(Events.Click, new Listener() {
237:                    public void handleEvent(BaseEvent be) {
238:                        onButtonPressed(be);
239:                    }
240:                });
241:
242:                footerPanel = new HorizontalPanel();
243:                footerPanel.setWidth("100%");
244:
245:                status = new Item("my-dialog-status");
246:                footerPanel.add(status);
247:                footerPanel.setCellWidth(status, "100%");
248:
249:                footerPanel.add(buttonBar);
250:                DOM.appendChild(footerElem, footerPanel.getElement());
251:            }
252:
253:            protected void createButton(int id, String text) {
254:                Button btn = new Button(text);
255:                btn.setButtonId(id);
256:                addButton(btn);
257:            }
258:
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.