List of usage examples for com.google.gwt.user.client.ui DialogBox DialogBox
public DialogBox()
From source file:com.appspot.socialinquirer.client.util.UiUtils.java
License:Apache License
/** * Show question answer dialog.//from www. j av a 2 s. c o m * * @param result the result * @param constants the constants */ public static void showQuestionAnswerDialog(String result, EverScribeConstants constants) { final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Suggested Answer"); dialogBox.setAnimationEnabled(true); dialogBox.setWidth("400px"); dialogBox.setHeight("200px"); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.add(new HTML(result)); final Button closeButton = new Button(constants.closeButton()); // We can set the id of a widget by accessing its // Element closeButton.getElement().setId("closeButton"); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); dialogBox.center(); }
From source file:com.appspot.socialinquirer.client.util.UiUtils.java
License:Apache License
/** * Show spell check dialog.//from w w w . j a v a 2s .c om * * @param result the result * @param constants the constants */ public static void showSpellCheckDialog(String result, EverScribeConstants constants) { final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Spell Checker"); dialogBox.setAnimationEnabled(true); dialogBox.setWidth("400px"); dialogBox.setHeight("200px"); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.add(new HTML(result)); final Button closeButton = new Button(constants.closeButton()); // We can set the id of a widget by accessing its // Element closeButton.getElement().setId("closeButton"); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); dialogBox.center(); }
From source file:com.appspot.socialinquirer.client.util.UiUtils.java
License:Apache License
/** * Show run code dialog./*from www . j a v a2 s .c om*/ * * @param result the result * @param constants the constants */ public static void showRunCodeDialog(String result, EverScribeConstants constants) { final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Code Evaluation"); dialogBox.setAnimationEnabled(true); dialogBox.setWidth("400px"); dialogBox.setHeight("200px"); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.add(new HTML(result)); final Button closeButton = new Button(constants.closeButton()); // We can set the id of a widget by accessing its // Element closeButton.getElement().setId("closeButton"); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); dialogBox.center(); }
From source file:com.appspot.socialinquirer.client.util.UiUtils.java
License:Apache License
/** * Show speak dialog.// ww w . jav a 2s . c o m * * @param result the result * @param constants the constants */ public static void showSpeakDialog(ArrayList<String> result, EverScribeConstants constants) { final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Speak"); dialogBox.setAnimationEnabled(true); dialogBox.setWidth("400px"); dialogBox.setHeight("500px"); VerticalPanel dialogVPanel = new VerticalPanel(); StringBuilder builder = new StringBuilder(); for (String url : result) { builder.append("<embed src='" + url + "' controller='true' type='audio/wav' height='80px' width='400px' pluginspage='http://www.apple.com/quicktime/download/' />"); builder.append("<br/>"); } dialogVPanel.add(new HTML(builder.toString())); final Button closeButton = new Button(constants.closeButton()); // We can set the id of a widget by accessing its // Element closeButton.getElement().setId("closeButton"); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); dialogBox.center(); }
From source file:com.appspot.socialinquirer.client.util.UiUtils.java
License:Apache License
/** * Show classification dialog./*from ww w . j a v a2 s . c om*/ * * @param result the result * @param constants the constants */ public static void showClassificationDialog(List<Classification> result, EverScribeConstants constants) { final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Classification"); dialogBox.setAnimationEnabled(true); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER); StringBuilder builder = new StringBuilder(); builder.append("<table style='text-align: left; width: 100%;' border='1' cellpadding='2' cellspacing='2'>"); builder.append("<tbody>"); builder.append("<tr><th nowrap='nowrap'>Class</th><th nowrap='nowrap'>Probability</th></tr>"); for (Classification classification : result) { builder.append("<tr><td nowrap='nowrap'>" + classification.getCategory() + "</td><td nowrap='nowrap'>" + classification.getProbability() + "</td></tr>"); } builder.append("</tbody>"); builder.append("</table>"); dialogVPanel.add(new HTML(builder.toString())); final Button closeButton = new Button(constants.closeButton()); closeButton.getElement().setId("closeButton"); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); dialogBox.center(); }
From source file:com.appspot.socialinquirer.client.util.UiUtils.java
License:Apache License
/** * Show translation dialog./*from w w w . j a v a 2 s . c o m*/ * * @param result the result * @param constants the constants */ public static void showTranslationDialog(String result, EverScribeConstants constants) { final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Translation"); dialogBox.setAnimationEnabled(true); dialogBox.setWidth("400px"); dialogBox.setHeight("200px"); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.add(new HTML(result)); final Button closeButton = new Button(constants.closeButton()); // We can set the id of a widget by accessing its // Element closeButton.getElement().setId("closeButton"); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); dialogBox.center(); }
From source file:com.axlight.gbrain.client.MainPane.java
License:Apache License
private void showAlertDialog(String message) { if (GBrain.isIPhone) { Window.alert(message);/*from w ww . j a va 2 s. c o m*/ } else { final DialogBox dialog = new DialogBox(); dialog.setModal(true); dialog.setGlassEnabled(true); dialog.setText("Alert"); Label label = new Label(message); Button close = new Button("Close"); VerticalPanel basePanel = new VerticalPanel(); basePanel.setSpacing(10); basePanel.add(label); basePanel.add(close); dialog.add(basePanel); close.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialog.hide(); } }); dialog.center(); close.setFocus(true); } }
From source file:com.axlight.gbrain.client.MainPane.java
License:Apache License
private void showConfirmDialog(String message, final ClickHandler okHandler) { if (GBrain.isIPhone) { if (Window.confirm(message)) { okHandler.onClick(null);/*from w w w . j av a 2 s. c o m*/ } } else { final DialogBox dialog = new DialogBox(); dialog.setModal(true); dialog.setGlassEnabled(true); dialog.setText("Confirm"); Label label = new Label(message); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.setSpacing(5); Button ok = new Button("OK"); buttonPanel.add(ok); Button cancel = new Button("Cancel"); buttonPanel.add(cancel); VerticalPanel basePanel = new VerticalPanel(); basePanel.setSpacing(10); basePanel.add(label); basePanel.add(buttonPanel); dialog.add(basePanel); ok.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { okHandler.onClick(event); dialog.hide(); } }); cancel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialog.hide(); } }); dialog.center(); } }
From source file:com.axlight.gbrain.client.MainPane.java
License:Apache License
private void showPromptDialog(String message, final PromptHandler promptHandler) { if (GBrain.isIPhone) { String input = Window.prompt(message, ""); if (input != null) { promptHandler.handleResult(input); }/* w ww .j av a 2 s . co m*/ } else { final DialogBox dialog = new DialogBox(); dialog.setModal(true); dialog.setGlassEnabled(true); dialog.setText("Prompt"); Label label = new Label(message); final TextBox textBox = new TextBox(); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.setSpacing(5); Button ok = new Button("OK"); buttonPanel.add(ok); Button cancel = new Button("Cancel"); buttonPanel.add(cancel); VerticalPanel basePanel = new VerticalPanel(); basePanel.setSpacing(10); basePanel.add(label); basePanel.add(textBox); basePanel.add(buttonPanel); dialog.add(basePanel); ok.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { promptHandler.handleResult(textBox.getText()); dialog.hide(); } }); cancel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialog.hide(); } }); dialog.center(); } }
From source file:com.codenvy.example.gwt.client.GWTEntryPoint.java
License:Open Source License
/** * This is the entry point method./* ww w . j a va 2 s . c om*/ */ public void onModuleLoad() { final Button sendButton = new Button(messages.sendButton()); final TextBox nameField = new TextBox(); nameField.setText(messages.nameField()); 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); } }); // 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); }