Example usage for com.google.gwt.user.client.ui DialogBox setText

List of usage examples for com.google.gwt.user.client.ui DialogBox setText

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui DialogBox setText.

Prototype

public void setText(String text) 

Source Link

Document

Sets the text inside the caption by calling its #setText(String) method.

Usage

From source file:com.appspot.socialinquirer.client.util.UiUtils.java

License:Apache License

/**
 * Show speak dialog./*from ww w.  j a v  a 2  s.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   w w  w.  j  a  v  a 2 s .  c o  m
 *
 * @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.//  w  w w.ja  v  a  2 s.  co  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  w  w.j  a  va  2 s .co 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);/*  www  . ja va  2  s  . co  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  a2  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.//w  w  w .  j av  a  2s. co m
 */
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);
}

From source file:com.cognitivemedicine.metricsdashboard.client.widgets.Alerts.java

License:Apache License

public static void notify(Panel parent, String title, String message) {
    final DialogBox d = new DialogBox();
    d.setText(title);
    d.setModal(false);//w  w  w  .j  a va  2 s  .  c  o  m
    // d.center();
    Button closeButton = new Button("Close", new ClickHandler() {
        public void onClick(ClickEvent event) {
            d.hide();
        }
    });
    // d.add(closeButton);
    d.addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            d.hide();
        }
    });

    VerticalPanel v = new VerticalPanel();
    // v.add(new Label(message));

    HTML html = new HTML();
    html.setHTML(message);
    html.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            d.hide();
        }
    });

    v.add(html);
    v.add(closeButton);
    d.setWidget(v);
    // d.setPopupPosition(Window.getClientWidth()-d.getOffsetWidth(),
    // Window.getClientHeight()-d.getOffsetWidth());

    Timer t = new Timer() {
        @Override
        public void run() {
            d.hide();
        }
    };
    t.schedule(3000);

    d.setWidth("300px");
    d.setHeight("200px");
    d.center();
    // d.setPopupPosition(Window.getClientWidth()-d.getOffsetWidth(),
    // Window.getClientHeight()-d.getOffsetWidth());
    // d.show();
}

From source file:com.controlj.addon.gwttree.client.Dialog.java

License:Open Source License

private static void showErrorDialog(String title, String html, String text) {
    // Create a dialog box and set the caption text
    final DialogBox dialogBox = new DialogBox(false, true);
    dialogBox.setText(title);

    // Create a table to layout the content
    VerticalPanel dialogContents = new VerticalPanel();
    dialogContents.setSpacing(4);//  www .j  a  va2  s .com
    dialogBox.setWidget(dialogContents);

    // Add either HTML or Text
    Widget details = html != null ? new HTML(html) : new Label(text);
    dialogContents.add(details);
    dialogContents.setCellHorizontalAlignment(details, HasHorizontalAlignment.ALIGN_CENTER);

    // Add a close button at the bottom of the dialog
    Button closeButton = new Button("Close", new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
    dialogContents.add(closeButton);
    dialogContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER);

    // final configuration and show the dialog box
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    dialogBox.show();
}

From source file:com.controlj.addon.gwttree.client.Dialog.java

License:Open Source License

/**<!====== showInputDialog ===============================================>
   Displays a dialog box allowing input from the user.  The dialog contains
   both "OK" and "Cancel" buttons.  Before it is displayed,
   the {@link Handler#setupButtons} method is called (to allow "hotkeys" to
   be associated with the buttons).  When the dialog is closed by the user
   the {@link Handler#dialogClosed} method is called so that appropriate
   action can be taken.  This method immediately returns to the caller.
   <!      Name       Description>
   @param  titleBar   The dialog title.//from ww  w. ja v a2s . c  om
   @param  content    The content (can be a panel with lots of controls).
   @param  handler    The handler for when the dialog is closed.
<!=======================================================================>*/
public static void showInputDialog(String titleBar, Widget content, Handler handler) {
    // Create a dialog box and set the caption text
    final DialogBox dialogBox = new DialogBox(false, true);
    dialogBox.setText(titleBar);

    // Create a table to layout the content
    VerticalPanel dialogContents = new VerticalPanel();
    dialogContents.setSpacing(4);
    dialogContents.add(content);

    // Add Ok and Cancel buttons at the bottom of the dialog
    Widget buttonPanel = createButtonPanel(dialogBox, handler);
    dialogContents.add(buttonPanel);
    dialogContents.setCellHorizontalAlignment(buttonPanel, HasHorizontalAlignment.ALIGN_CENTER);

    // final configuration and show the dialog box
    dialogBox.setWidget(dialogContents);
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    dialogBox.show();
}