litesoft
@ 750
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
/* * Copyright 2010 Daniel Kurka * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package com.googlecode.mgwt.ui.client.dialog; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.ui.HasText; import com.google.gwt.user.client.ui.Label; import com.googlecode.mgwt.dom.client.event.tap.HasTapHandlers; import com.googlecode.mgwt.dom.client.event.tap.TapEvent; import com.googlecode.mgwt.dom.client.event.tap.TapHandler; import com.googlecode.mgwt.ui.client.MGWTStyle; import com.googlecode.mgwt.ui.client.theme.base.DialogCss; /** * A simple alert dialog with an ok button. * * @author Daniel Kurka */ public class AlertDialog implements HasText, HasTitleText, HasTapHandlers, Dialog { private Label textLabel; private PopinDialog popinDialog; private DialogPanel dialogPanel1; /** * Construct an alert dialog * * @param title - the title of the dialog * @param text - the text of the dialog */ public AlertDialog(String title, String text) { this(MGWTStyle.getTheme().getMGWTClientBundle().getDialogCss(), title, text); } /** * Construct an alert dialog * * @param css - the css to use * @param title - the title of the dialog * @param text - the text of the dialog */ public AlertDialog(DialogCss css, String title, String text) { this(css, title, text, "Ok"); } /** * Construct an alert dialog * * @param css - the css to use * @param title - the title of the dialog * @param text - the text of the dialog * @param okButtonText the text of the button of the dialog */ public AlertDialog(DialogCss css, String title, String text, String okButtonText) { css.ensureInjected(); popinDialog = new PopinDialog(css); dialogPanel1 = new DialogPanel(); dialogPanel1.showCancelButton(false); dialogPanel1.showOkButton(true); textLabel = new Label(); dialogPanel1.getContent().add(textLabel); popinDialog.add(dialogPanel1); dialogPanel1.getOkButton().addTapHandler(new TapHandler() { @Override public void onTap(TapEvent event) { popinDialog.hide(); } }); setText(text); setTitleText(title); dialogPanel1.setOkButtonText(okButtonText); } /* * (non-Javadoc) * * @see com.google.gwt.user.client.ui.HasText#getText() */ /** {@inheritDoc} */ @Override public String getText() { return textLabel.getText(); } /* * (non-Javadoc) * * @see com.google.gwt.user.client.ui.HasText#setText(java.lang.String) */ /** {@inheritDoc} */ @Override public void setText(String text) { textLabel.setText(text); } /* * (non-Javadoc) * * @see com.googlecode.mgwt.ui.client.dialog.HasTitleText#setTitleText(java.lang.String) */ /** {@inheritDoc} */ @Override public void setTitleText(String text) { dialogPanel1.getDialogTitle().setText(text); } /* * (non-Javadoc) * * @see com.googlecode.mgwt.ui.client.dialog.HasTitleText#getTitleText() */ /** {@inheritDoc} */ @Override public String getTitleText() { return dialogPanel1.getDialogTitle().getText(); } /* * (non-Javadoc) * * @see com.googlecode.mgwt.ui.client.dialog.Dialog#show() */ /** * <p> * show * </p> */ public void show() { popinDialog.center(); } /* * (non-Javadoc) * * @see * com.googlecode.mgwt.dom.client.event.tap.HasTapEvent#addTapHandler(com.googlecode.mgwt.dom. * client.event.tap.TapHandler) */ /** {@inheritDoc} */ @Override public HandlerRegistration addTapHandler(TapHandler handler) { return dialogPanel1.getOkButton().addTapHandler(handler); } } |
Commits for litesoft/trunk/mobileGWT/mgwt/zOrig_src_main_java_com_googlecode_mgwt_ui_client_dialog/AlertDialog.java
Revision | Author | Commited | Message |
---|---|---|---|
745 Diff | GeorgeS | Thu 28 Jun, 2012 03:56:50 +0000 | |
741 | GeorgeS | Tue 26 Jun, 2012 01:21:28 +0000 | Update Dialogs to support replaceable button text (for i18n) and to isolate the references to the default CSS to JUST the actual Dialog implementations (Alert, Confirm, and Options for now). |