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.palantir.gerrit.gerritci.ui.client.ConfigurationScreen.java

License:Apache License

/**
 * Creates a DialogBox object with the specified header and content and
 * returns it to be displayed.//from   www .  jav a  2  s  .co m
 *
 * @param header
 *            Title for the alert dialog
 * @param content
 *            Inner message content to display
 * @return A DialogBox object configured with the specified strings
 */
public static DialogBox alertWidget(final String header, final String content) {
    final DialogBox dialogBox = new DialogBox();
    final VerticalPanel verticalPanel = new VerticalPanel();

    final Label emptyLabel = new Label("");
    emptyLabel.setSize("auto", "25px");

    dialogBox.setText(header);

    verticalPanel.add(emptyLabel);
    verticalPanel.add(new Label(content));
    verticalPanel.add(emptyLabel);

    final Button buttonClose = new Button("Close", new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            dialogBox.hide();
        }
    });
    buttonClose.setWidth("100px");
    verticalPanel.add(buttonClose);
    verticalPanel.setCellHorizontalAlignment(buttonClose, HasAlignment.ALIGN_CENTER);

    dialogBox.add(verticalPanel);
    return dialogBox;
}

From source file:com.palantir.gerrit.gerritci.ui.client.ProjectConfigurationScreen.java

License:Apache License

public static DialogBox alertWidget(final String header, final String content) {
    final DialogBox dialogBox = new DialogBox();
    final VerticalPanel verticalPanel = new VerticalPanel();

    final Label emptyLabel = new Label("");
    emptyLabel.setSize("auto", "25px");

    dialogBox.setText(header);

    verticalPanel.add(emptyLabel);// ww  w  .j  a  v a2 s.  c o  m
    verticalPanel.add(new Label(content));
    verticalPanel.add(emptyLabel);

    final Button buttonClose = new Button("Close", new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            dialogBox.hide();
        }
    });
    buttonClose.setWidth("100px");
    verticalPanel.add(buttonClose);
    verticalPanel.setCellHorizontalAlignment(buttonClose, HasAlignment.ALIGN_CENTER);

    dialogBox.add(verticalPanel);
    dialogBox.setWidth("400px");
    return dialogBox;
}

From source file:com.piusvelte.mosaic.gwt.client.Mosaic.java

License:Open Source License

public void onModuleLoad() {

    // 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);/* w w w . j  a v a 2s .  c om*/
    dialogBox.setWidget(dialogVPanel);

    // Add a handler to close the DialogBox
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });

    final Button authButton = new Button("Sign in");
    RootPanel.get("authContainer").add(authButton);
    authButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            webClientService.getAuthenticationURL(Window.Location.getHref(), new AsyncCallback<String>() {

                @Override
                public void onFailure(Throwable caught) {
                    dialogBox.setText("Remote Procedure Call - Failure");
                    serverResponseLabel.addStyleName("serverResponseLabelError");
                    serverResponseLabel.setHTML(SERVER_ERROR);
                    dialogBox.center();
                    closeButton.setFocus(true);
                }

                @Override
                public void onSuccess(String result) {
                    Window.Location.replace(result);
                }

            });
        }

    });

    webClientService.getUserNickname(new AsyncCallback<String>() {

        @Override
        public void onFailure(Throwable caught) {
            authButton.setText("Sign in");
        }

        @Override
        public void onSuccess(String result) {
            authButton.setText(result);
            webClientService.getMessages(page, new AsyncCallback<WebClientMessage[]>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onSuccess(WebClientMessage[] result) {
                    // TODO Auto-generated method stub

                }

            });
        }

    });
}

From source file:com.rhizospherejs.gwt.showcase.client.books.BooksTab.java

License:Open Source License

@UiHandler("submitButton")
void searchBooks(ClickEvent event) {
    // Disable the search fields and buttons while a search is already in
    // progress./*from  www. j  ava 2s.c  om*/
    showSearchStarted();

    String query = searchInput.getValue();
    if (query.length() == 0) {
        return;
    }
    if (!searchApiLoaded) {
        DialogBox d = new DialogBox(true, true);
        d.setText("Still loading Book Search APIs...");
        d.center();
        return;
    }
    doNativeSearch(this, query);
}

From source file:com.sun.labs.aura.dbbrowser.client.query.TabbedQueryUI.java

License:Open Source License

public void showError(String msg) {
    final DialogBox err = new DialogBox();
    err.setText("Alert!");
    DockPanel contents = new DockPanel();
    contents.add(new Label(msg), DockPanel.CENTER);
    Button ok = new Button("OK");
    ok.addClickListener(new ClickListener() {
        public void onClick(Widget arg0) {
            err.hide();// w  w w .  j a v a2s . co  m
        }
    });
    contents.add(ok, DockPanel.SOUTH);
    err.setWidget(contents);
    err.show();
}

From source file:com.sun.labs.aura.music.wsitm.client.ui.Popup.java

License:Open Source License

public static void showPopup(Widget w, String title, final DialogBox popup) {

    DockPanel docPanel = new DockPanel();

    Label closeButton = new Label("Close");
    closeButton.setStyleName("clickableLabel");
    closeButton.addStyleName("whiteTxt");
    closeButton.addClickHandler(new ClickHandler() {
        @Override/*from  ww w  .  j ava2 s  .c o  m*/
        public void onClick(ClickEvent ce) {
            popup.hide();
        }
    });

    FlowPanel container = new FlowPanel();
    container.setStyleName("outerpopup");
    container.add(w);

    docPanel.add(container, DockPanel.CENTER);
    docPanel.add(closeButton, DockPanel.SOUTH);
    docPanel.setCellHorizontalAlignment(closeButton, DockPanel.ALIGN_RIGHT);
    popup.add(docPanel);
    popup.setText(title);
    popup.setAnimationEnabled(true);
    popup.center();
}

From source file:com.vo.search.admin.client.content.widgets.CwQueryIndex.java

License:Apache License

/**
 * Initialize this widget./*w w w .jav  a2 s  . c  om*/
 */
@Override
public Widget onInitialize() {

    // initialize search box
    searchBox = new TextBox();
    searchBox.ensureDebugId("cwBasicText-textbox");
    // Set the text box to automatically adjust its direction according
    // to the input text. Use the Any-RTL heuristic, which sets an RTL
    // direction
    // iff the text contains at least one RTL character.
    searchBox.setDirectionEstimator(AnyRtlDirectionEstimator.get());

    // innitialize label
    label = new Label(constants.cwQueryIndexEnterQuery());
    label.ensureDebugId("cwQueryIndex-label");
    // initialize submit button
    submitButton = new Button(constants.cwQueryIndexButtonSubmit());
    submitButton.ensureDebugId("cwBasicButton-normal");

    // Create the popup dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Remote Procedure Call");
    dialogBox.setAnimationEnabled(true);

    // Set a key provider that provides a unique key for each content.
    dataGrid = new DataGrid<ContentInfo>(ContentInfo.KEY_PROVIDER);

    // Set the message to display when the table is empty.
    dataGrid.setWidth("100%");
    dataGrid.setEmptyTableWidget(new Label(constants.cwDataGridEmpty()));
    // Initialize data provider
    if (dataProvider == null) {
        dataProvider = new ListDataProvider<ContentInfo>();
    }
    dataProvider.addDataDisplay(dataGrid);

    // Create a Pager to control the table.
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    pager.setDisplay(dataGrid);

    // Create a handler for the sendButton and nameField
    class MyHandler implements ClickHandler {
        /**
         * Fired when the user clicks on the sendButton.
         */
        public void onClick(ClickEvent event) {
            sendQueryToServer();
        }

        /**
         * Send the name from the nameField to the server and wait for a
         * response.
         */
        private void sendQueryToServer() {
            String queryToServer = searchBox.getText();
            // Then, we send the input to the server.

            greetingService.queryServer(queryToServer, new AsyncCallback<QueryResult>() {
                public void onFailure(Throwable caught) {
                    // Show the RPC error message to the user
                    dialogBox.setText("Remote Procedure Call - Failure");
                    dialogBox.center();
                    submitButton.setEnabled(false);
                }

                public void onSuccess(QueryResult result) {
                    // Initialize the columns.
                    dataProvider.getList().clear();
                    dataProvider.setList(result.getResults());
                    initTableData(result);

                }
            });
        }
    }

    // Add a handler to send the name to the server
    MyHandler handler = new MyHandler();
    submitButton.addClickHandler(handler);

    // Create the UiBinder.
    Binder uiBinder = GWT.create(Binder.class);
    return uiBinder.createAndBindUi(this);

}

From source file:com.webgocommerce.client.view.uimenu.UIMenuImpl.java

@Override
public void showTreeMenuBar() {
    List<MenuBar> lista = new ArrayList<MenuBar>();
    Iterator<MenuBarProxy> iterador = grid.getData().iterator();
    while (iterador.hasNext()) {
        MenuBarProxy beanProxy = iterador.next();
        MenuBar bean = new MenuBar();
        bean.setIdMenuBar(beanProxy.getIdMenuBar());
        bean.setVariable(beanProxy.getVariable());
        bean.setDescripcion(beanProxy.getDescripcion());
        bean.setGrupo(beanProxy.getGrupo());
        bean.setNivel(beanProxy.getNivel());
        bean.setOrden(beanProxy.getOrden());
        bean.setTipo(beanProxy.getTipo());
        bean.setNumSubMenu(beanProxy.getNumSubMenu());
        bean.setIdMenuPadre(beanProxy.getIdMenuPadre());
        lista.add(bean);/*  w  w w.  jav a2  s.  co m*/
    }
    MenuBar root = createTree(lista.get(0), lista);
    DialogBox popup = new DialogBox();
    popup.setText("Vista previa de Menu");
    popup.setAnimationEnabled(true);
    popup.setAutoHideEnabled(true);
    popup.setGlassEnabled(true);
    ScrollPanel scroll = new ScrollPanel();
    TreeMenuModel model = new TreeMenuModel(root);
    CellTree tree = new CellTree(model, root);
    tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    scroll.setSize("500px", "500px");
    scroll.setWidget(tree);
    popup.add(scroll);
    popup.setSize("500px", "500px");
    popup.center();
    popup.show();
}

From source file:edu.ucdenver.bios.glimmpseweb.client.shared.CancelDialogBox.java

License:Open Source License

public Widget cancelDialogBox() {
    DialogBox dialogBox = new DialogBox();
    dialogBox.setGlassEnabled(true);/*  w  w  w. j  a  v a2  s.  co m*/
    dialogBox.setAnimationEnabled(true);
    HTML query = new HTML(GlimmpseWeb.constants.cancelDialogBoxQuery());
    Button saveButton = new Button("Save", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // TODO Auto-generated method stub

        }

    });
    Button discardChangesButton = new Button("Discard Changes", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // TODO Auto-generated method stub

        }

    });
    Button continueButton = new Button("Continue", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // TODO Auto-generated method stub

        }

    });

    saveButton.setStyleName(STYLE_BUTTON);
    discardChangesButton.setStyleName(STYLE_BUTTON);
    continueButton.setStyleName(STYLE_BUTTON);
    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.add(saveButton);
    horizontalPanel.add(discardChangesButton);
    horizontalPanel.add(continueButton);
    horizontalPanel.setSpacing(10);

    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.add(query);
    verticalPanel.add(horizontalPanel);

    dialogBox.setText("Cancel Dialog Box");
    dialogBox.add(verticalPanel);
    dialogBox.show();

    return dialogBox;
}

From source file:eu.cloud4soa.gwt.client.Application.java

License:Apache License

/**
 * This is the entry point method./*from   w w  w . j a va2 s  .c om*/
 */
public void onModuleLoad() {
    final Button sendButton = new Button("Try UC9 Sequence");
    final TextBox nameField = new TextBox();
    nameField.setText("webapp");
    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 application 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);
}