List of usage examples for com.google.gwt.user.client.ui DialogBox hide
@Override public void hide()
From source file:com.google.appinventor.client.Ode.java
License:Open Source License
/** * Display a generic warning dialog box. * This method is public because it is intended to be used from other * parts of the client GWT side system./* www . java 2s. c o m*/ * * Note: We expect our caller to internationalize the messages to be * displayed. * * @param title The title for the dialog box * @param message The message to display * @param buttonString the name of the button, i.e., "OK" */ public void warningDialog(String title, String messageString, String buttonString) { // Create the UI elements of the DialogBox final DialogBox dialogBox = new DialogBox(false, true); // DialogBox(autohide, modal) dialogBox.setStylePrimaryName("ode-DialogBox"); dialogBox.setText(title); dialogBox.setHeight("100px"); dialogBox.setWidth("400px"); dialogBox.setGlassEnabled(true); dialogBox.setAnimationEnabled(true); dialogBox.center(); VerticalPanel DialogBoxContents = new VerticalPanel(); HTML message = new HTML("<p>" + messageString + "</p>"); message.setStyleName("DialogBox-message"); FlowPanel holder = new FlowPanel(); Button okButton = new Button(buttonString); okButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialogBox.hide(); } }); holder.add(okButton); DialogBoxContents.add(message); DialogBoxContents.add(holder); dialogBox.setWidget(DialogBoxContents); dialogBox.show(); }
From source file:com.google.appinventor.client.utils.MessageDialog.java
License:Open Source License
/** * Put up a modal dialog box.//from w ww . j a v a 2 s .com * * @param title Title for the dialog, already internationalized * @param message Message box content, already internationalized * @param OK String for OK button, already internationalized * @param Cancel String for Cancel button, null if non, internationalized * @param actions Actions object to call upon completion, can be null */ public static void messageDialog(String title, String message, String OK, String Cancel, final Actions actions) { final DialogBox dialogBox = new DialogBox(false, true); // DialogBox(autohide, modal) dialogBox.setStylePrimaryName("ode-DialogBox"); dialogBox.setText(title); dialogBox.setHeight("100px"); dialogBox.setWidth("400px"); dialogBox.setGlassEnabled(true); dialogBox.setAnimationEnabled(true); dialogBox.center(); VerticalPanel DialogBoxContents = new VerticalPanel(); HTML messageHtml = new HTML("<p>" + message + "</p>"); messageHtml.setStyleName("DialogBox-message"); FlowPanel holder = new FlowPanel(); Button okButton = new Button(OK); okButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialogBox.hide(); if (actions != null) actions.onOK(); } }); holder.add(okButton); if (Cancel != null) { Button cancelButton = new Button(Cancel); cancelButton.addClickListener(new ClickListener() { @Override public void onClick(Widget sender) { dialogBox.hide(); if (actions != null) actions.onCancel(); } }); holder.add(cancelButton); } DialogBoxContents.add(messageHtml); DialogBoxContents.add(holder); dialogBox.setWidget(DialogBoxContents); dialogBox.show(); }
From source file:com.google.appinventor.client.wizards.FileUploadWizard.java
License:Open Source License
private void createErrorDialog(String title, String body, Error e, final FolderNode folderNode, final FileUploadedCallback fileUploadedCallback) { final DialogBox dialogBox = new DialogBox(false, true); HTML message;/* w ww .ja v a 2 s.c om*/ dialogBox.setStylePrimaryName("ode-DialogBox"); dialogBox.setHeight("150px"); dialogBox.setWidth("350px"); dialogBox.setGlassEnabled(true); dialogBox.setAnimationEnabled(true); dialogBox.center(); VerticalPanel DialogBoxContents = new VerticalPanel(); FlowPanel holder = new FlowPanel(); Button ok = new Button("OK"); ok.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialogBox.hide(); new FileUploadWizard(folderNode, fileUploadedCallback).show(); } }); holder.add(ok); dialogBox.setText(title); message = new HTML(body); switch (e) { case AIAMEDIAASSET: Button info = new Button("More Info"); info.addClickListener(new ClickListener() { public void onClick(Widget sender) { Window.open(MESSAGES.aiaMediaAssetHelp(), "AIA Help", ""); } }); holder.add(info); case NOFILESELECETED: case MALFORMEDFILENAME: case FILENAMEBADSIZE: default: break; } message.setStyleName("DialogBox-message"); DialogBoxContents.add(message); DialogBoxContents.add(holder); dialogBox.setWidget(DialogBoxContents); dialogBox.show(); }
From source file:com.google.appinventor.client.youngandroid.YoungAndroidFormUpgrader.java
License:Open Source License
private static void upgradeWarnDialog(String aMessage) { final DialogBox dialogBox = new DialogBox(false, true); dialogBox.setStylePrimaryName("ode-DialogBox"); dialogBox.setText(MESSAGES.warningDialogTitle()); dialogBox.setGlassEnabled(true);/*from w w w.j a v a 2s .co m*/ dialogBox.setAnimationEnabled(true); final HTML message = new HTML(aMessage); message.setStyleName("DialogBox-message"); VerticalPanel vPanel = new VerticalPanel(); Button okButton = new Button("OK"); okButton.addClickListener(new ClickListener() { @Override public void onClick(Widget sender) { dialogBox.hide(); } }); vPanel.add(message); vPanel.add(okButton); dialogBox.setWidget(vPanel); dialogBox.center(); dialogBox.show(); }
From source file:com.google.code.gwt.appcache.sample.helloappcache.client.HelloApplicationCache.java
License:Apache License
/** * This is the entry point method.//from w w w . j a va2s. c o m */ public void onModuleLoad() { Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png"); Button button = new Button("Click me"); VerticalPanel vPanel = new VerticalPanel(); // We can add style names. vPanel.addStyleName("widePanel"); vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); vPanel.add(img); vPanel.add(button); // Add image and button to the RootPanel RootPanel.get().add(vPanel); // Create the dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Welcome to GWT ApplicationCache Demo!"); dialogBox.setAnimationEnabled(true); Button closeButton = new Button("close"); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.setWidth("100%"); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); dialogVPanel.add(closeButton); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); // Set the contents of the Widget dialogBox.setWidget(dialogVPanel); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // Invoke service: HelloServiceAsync service = GWT.create(HelloService.class); service.sayHello("Bart", new AsyncCallback<String>() { public void onFailure(Throwable caught) { dialogBox.setText("Could not invoke 'sayHello' service: " + caught); dialogBox.center(); dialogBox.show(); } public void onSuccess(String result) { dialogBox.setText(result + "! Welcome to GWT ApplicationCache Demo!"); dialogBox.center(); dialogBox.show(); } }); } }); }
From source file:com.google.code.gwt.database.sample.hellodatabase.client.HelloDatabase.java
License:Apache License
/** * This is the entry point method./*from w w w.jav a2 s . c o m*/ */ public void onModuleLoad() { if (!Database.isSupported()) { Window.alert("HTML 5 Database is NOT supported in this browser!"); return; } // Create the dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Welcome to GWT Database Demo!"); dialogBox.setAnimationEnabled(true); Button closeButton = new Button("close", new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.setWidth("100%"); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); final VerticalPanel clickedData = new VerticalPanel(); dialogVPanel.add(clickedData); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png"); Button addClickButton = new Button("Add Click", new ClickHandler() { public void onClick(ClickEvent event) { dbService.insertClick(new Date(), new RowIdListCallback() { public void onFailure(DataServiceException error) { Window.alert("Failed to add click! " + error); } public void onSuccess(final List<Integer> rowIds) { dbService.getClicks(new ListCallback<ClickRow>() { public void onFailure(DataServiceException error) { Window.alert("Failed to query clicks! " + error); } public void onSuccess(List<ClickRow> result) { clickedData.clear(); clickedData.add(new Label("Last click insert ID: " + rowIds.get(0))); for (ClickRow row : result) { clickedData.add(new Label("Clicked on " + row.getClicked())); } dialogBox.center(); dialogBox.show(); } }); } }); } }); Button getCountButton = new Button("Get Counts", new ClickHandler() { public void onClick(ClickEvent event) { getCount(); } }); vPanel = new VerticalPanel(); // We can add style names. vPanel.addStyleName("widePanel"); vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); vPanel.add(img); vPanel.add(addClickButton); vPanel.add(getCountButton); // Add image and button to the RootPanel RootPanel.get().add(vPanel); // Create table 'clickcount' if it doesn't exist already: dbService.initTable(new VoidCallback() { public void onFailure(DataServiceException error) { Window.alert("Failed to initialize table! " + error); } public void onSuccess() { Window.alert("Database initialized successfully."); getCount(); } }); getVersion(); }
From source file:com.google.code.gwt.iui.sample.helloiui.client.HelloiUI.java
License:Apache License
/** * This is the entry point method./*from ww w.j a va2 s .co m*/ */ public void onModuleLoad() { Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png"); Button button = new Button("Click me"); VerticalPanel vPanel = new VerticalPanel(); // We can add style names. vPanel.addStyleName("widePanel"); vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); vPanel.add(img); vPanel.add(button); // Add image and button to the RootPanel RootPanel.get().add(vPanel); // Create the dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Welcome to GWT iUI Demo!"); dialogBox.setAnimationEnabled(true); Button closeButton = new Button("close"); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.setWidth("100%"); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); dialogVPanel.add(closeButton); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); // Set the contents of the Widget dialogBox.setWidget(dialogVPanel); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.center(); dialogBox.show(); } }); }
From source file:com.google.code.gwt.template.sample.hellotemplate.client.HelloTemplate.java
License:Apache License
/** * This is the entry point method./*w w w . j ava 2 s . c o m*/ */ public void onModuleLoad() { Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png"); Button button = new Button("Click me"); VerticalPanel vPanel = new VerticalPanel(); // We can add style names. vPanel.addStyleName("widePanel"); vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); vPanel.add(img); vPanel.add(button); // Add image and button to the RootPanel RootPanel.get().add(vPanel); // Create the dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Welcome to GWT Template Demo!"); dialogBox.setAnimationEnabled(true); Button closeButton = new Button("close"); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.setWidth("100%"); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); dialogVPanel.add(closeButton); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); // Set the contents of the Widget dialogBox.setWidget(dialogVPanel); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.center(); dialogBox.show(); } }); }
From source file:com.google.developers.gdgfirenze.gwt.client.GwtDemoApp.java
License:Apache License
/** * This is the entry point method.//from ww w . j a va 2 s . c o m */ public void onModuleLoad() { final Button sendButton = new Button("Send"); final TextBox nameField = new TextBox(); nameField.setText("GWT User"); final Label errorLabel = new Label(); // We can add style names to widgets sendButton.addStyleName("sendButton"); // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("sendButtonContainer").add(sendButton); RootPanel.get("errorLabelContainer").add(errorLabel); // Focus the cursor on the name field when the app loads nameField.setFocus(true); nameField.selectAll(); // Create the popup dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); final Button closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); final Label textToServerLabel = new Label(); final HTML serverResponseLabel = new HTML(); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(new HTML("<b>Sending name to the server:</b>")); dialogVPanel.add(textToServerLabel); dialogVPanel.add(new HTML("<br><b>Server replies:</b>")); dialogVPanel.add(serverResponseLabel); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); // Add a handler to close the DialogBox closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); sendButton.setEnabled(true); sendButton.setFocus(true); } }); /** * The Class MyHandler. * * Create a handler for the sendButton and nameField */ class MyHandler implements ClickHandler, KeyUpHandler { /** * Fired when the user clicks on the sendButton. */ public void onClick(ClickEvent event) { sendNameToServer(); } /** * Fired when the user types in the nameField. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { sendNameToServer(); } } /** * Send the name from the nameField to the server and wait for a response. */ private void sendNameToServer() { // First, we validate the input. errorLabel.setText(""); String textToServer = nameField.getText(); if (!FieldVerifier.isValidName(textToServer)) { errorLabel.setText("Please enter at least four characters"); return; } // Then, we send the input to the server. sendButton.setEnabled(false); textToServerLabel.setText(textToServer); serverResponseLabel.setText(""); greetingService.greetServer(textToServer, new AsyncCallback<String>() { public void onFailure(Throwable caught) { // Show the RPC error message to the user dialogBox.setText("Remote Procedure Call - Failure"); serverResponseLabel.addStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(SERVER_ERROR); dialogBox.center(); closeButton.setFocus(true); } public void onSuccess(String result) { dialogBox.setText("Remote Procedure Call"); serverResponseLabel.removeStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(result); dialogBox.center(); closeButton.setFocus(true); } }); } } // Add a handler to send the name to the server MyHandler handler = new MyHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); }
From source file:com.google.gwt.gadgets.sample.hellogadgets.client.HelloGadgets.java
License:Apache License
@Override protected void init(final HelloPreferences prefs) { Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png"); Button button = new Button("Click me"); VerticalPanel vPanel = new VerticalPanel(); vPanel.setWidth("100%"); vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); vPanel.add(img);//from ww w. j a v a 2 s . c o m vPanel.add(button); RootPanel.get().add(vPanel); // Create the dialog box final DialogBox dialogBox = new DialogBox(); // The content of the dialog comes from a User specified Preference dialogBox.setText(prefs.promptSomethingElse().getValue()); dialogBox.setAnimationEnabled(true); Button closeButton = new Button("Close"); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.setWidth("100%"); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); dialogVPanel.add(closeButton); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); // Set the contents of the Widget dialogBox.setWidget(dialogVPanel); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.center(); dialogBox.show(); } }); }