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:org.geosdi.maplite.client.model.LegendBuilder.java

private static DialogBox getCQLDialogBox(final ClientRasterInfo raster, final Map map) {
    // Create a dialog box and set the caption text
    final DialogBox cqlDialogBox = new DialogBox();
    cqlDialogBox.ensureDebugId("cwDialogBox");
    cqlDialogBox.setText("FILTER");

    // Create a table to layout the content
    VerticalPanel dialogContents = new VerticalPanel();
    dialogContents.setSpacing(4);/*w ww.j  a va2 s  . co  m*/
    cqlDialogBox.setWidget(dialogContents);

    // Add some text to the top of the dialog
    HTML details = new HTML("CQL Filter");
    dialogContents.add(details);
    dialogContents.setCellHorizontalAlignment(details, HasHorizontalAlignment.ALIGN_CENTER);

    // Add a text area
    final TextArea textArea = new TextArea();
    textArea.ensureDebugId("cwBasicText-textarea");
    textArea.setVisibleLines(5);

    if (GPSharedUtils.isNotEmpty(raster.getCqlFilter())) {
        textArea.setText(raster.getCqlFilter());
    }

    dialogContents.add(textArea);
    dialogContents.setCellHorizontalAlignment(textArea, HasHorizontalAlignment.ALIGN_CENTER);

    // Add a close button at the bottom of the dialog
    Button closeButton = new Button("Apply", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            logger.info("Applico cql filter su raster: " + raster.getLayerName());
            raster.setCqlFilter(textArea.getText());
            Layer layer = map.getLayer(raster.getWmsLayerId());
            WMS wms = WMS.narrowToLayer(layer.getJSObject());
            WMSParams params;
            if (raster.getCqlFilter() == null || raster.getCqlFilter().trim().equals("")) {
                params = wms.getParams();
                params.removeCQLFilter();
            } else {
                params = new WMSParams();
                params.setCQLFilter(raster.getCqlFilter());
            }
            logger.info("Filtro CQL: " + raster.getCqlFilter());
            wms.mergeNewParams(params);
            cqlDialogBox.hide();
        }
    });
    dialogContents.add(closeButton);
    if (LocaleInfo.getCurrentLocale().isRTL()) {
        dialogContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_LEFT);

    } else {
        dialogContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // Return the dialog box
    cqlDialogBox.setGlassEnabled(true);
    cqlDialogBox.setAnimationEnabled(true);
    cqlDialogBox.center();
    return cqlDialogBox;
}

From source file:org.gss_project.gss.web.client.commands.ViewImageCommand.java

License:Open Source License

@Override
public void execute() {
    containerPanel.hide();/*ww  w .j  a va 2s  .  c  o m*/

    final Image image = new Image();
    // Hook up a load handler, so that we can be informed if the image
    // fails to load.
    image.addLoadHandler(new LoadHandler() {

        @Override
        public void onLoad(LoadEvent event) {
            errorLabel.setText("");
        }
    });
    image.addErrorHandler(new ErrorHandler() {

        @Override
        public void onError(ErrorEvent event) {
            errorLabel.setText("An error occurred while loading.");
        }
    });
    image.setUrl(imageDownloadURL);
    final DialogBox imagePopup = new DialogBox(true, true);
    imagePopup.setAnimationEnabled(true);
    imagePopup.setText("Showing image in actual size");
    VerticalPanel imageViewPanel = new VerticalPanel();
    errorLabel.setText("loading image...");
    imageViewPanel.add(errorLabel);
    imageViewPanel.add(image);
    imagePopup.setWidget(imageViewPanel);
    image.setTitle("Click to close");
    image.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            imagePopup.hide();
        }
    });
    imagePopup.setPopupPosition(0, 0);
    imagePopup.show();
}

From source file:org.jboss.ci.tracker.client.widgets.CustomWidgets.java

License:Open Source License

public static DialogBox alertWidget(final String header, final String content) {
    final DialogBox box = new DialogBox();
    final VerticalPanel panel = new VerticalPanel();
    box.setText(header);

    final Button buttonClose = new Button("Close", new ClickHandler() {
        @Override// ww  w.  jav  a 2 s.  co m
        public void onClick(final ClickEvent event) {
            box.hide();
        }
    });

    panel.add(new Label(content));

    final Label emptyLabel = new Label("");
    emptyLabel.setSize("auto", "80px");
    panel.add(emptyLabel);

    buttonClose.setWidth("90px");
    panel.add(buttonClose);
    panel.setCellHorizontalAlignment(buttonClose, HasAlignment.ALIGN_RIGHT);

    box.setAutoHideEnabled(true);
    box.add(panel);
    return box;
}

From source file:org.jboss.ci.tracker.client.widgets.CustomWidgets.java

License:Open Source License

public static DialogBox filterDialogBox(final ResultList resultList, List<CategorizationDto> categorizations,
        List<CategoryDto> categories, List<PossibleResultDto> possibleResults, FilterDto oldFilter) {
    final DialogBox box = new DialogBox();
    final VerticalPanel panel = new VerticalPanel();

    panel.setSize("20em", "20em");

    box.setText("Filter results");

    // ----------------------- Possible results
    final Label resultsLabel = new Label("Results");
    panel.add(resultsLabel);//  w w  w . ja va2 s. c om

    for (PossibleResultDto possibleResult : possibleResults) {
        final CheckBox checkBox = new CheckBox(possibleResult.getName());
        checkBox.setName(POSSIBLE_RESULT_SEPARATOR_PREFIX + possibleResult.getId().toString());
        panel.add(checkBox);
    }

    // ----------------------- Categorizations and categories
    for (CategorizationDto categorization : categorizations) {
        final Label categorizationLabel = new Label(categorization.getName());
        panel.add(categorizationLabel);

        for (CategoryDto category : categories) {
            if (category.getCategorizationId().equals(categorization.getId())) {
                final CheckBox checkBox = new CheckBox(category.getName());
                checkBox.setName(CATEGORY_SEPARATOR_PREFIX + category.getId().toString());
                panel.add(checkBox);
            }
        }

    }

    // ----------------------- Date from
    final DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("d.M.yyyy");
    final DateBox dateBoxFrom = new DateBox();
    dateBoxFrom.setFormat(new DateBox.DefaultFormat(dateTimeFormat));
    dateBoxFrom.getDatePicker().setYearArrowsVisible(true);

    panel.add(new Label("From"));
    dateBoxFrom.setTitle("Midnight of the day, i.e. time 00:00");
    panel.add(dateBoxFrom);

    // ----------------------- Date to
    final DateBox dateBoxTo = new DateBox();
    dateBoxTo.setFormat(new DateBox.DefaultFormat(dateTimeFormat));
    dateBoxTo.getDatePicker().setYearArrowsVisible(true);

    panel.add(new Label("To"));
    dateBoxTo.setTitle("Midnight of the day, i.e. time 00:00");
    panel.add(dateBoxTo);

    // ----------------------- Set widgets according to filter
    setWidgetValues(panel, oldFilter, dateBoxFrom, dateBoxTo);

    // ----------------------- Filter button
    final Button buttonFilter = new Button("OK", new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {

            FilterDto filter = new FilterDto();

            Iterator<Widget> arrayOfWidgets = panel.iterator();
            while (arrayOfWidgets.hasNext()) {
                Widget widget = arrayOfWidgets.next();

                if (widget instanceof CheckBox) {
                    CheckBox checkBox = (CheckBox) widget;
                    if (checkBox.getValue()) {
                        if (checkBox.getName().startsWith(CATEGORY_SEPARATOR_PREFIX)) {
                            filter.addCategoryId(Integer.parseInt(
                                    checkBox.getName().substring(CATEGORY_SEPARATOR_PREFIX.length())));
                        } else if (checkBox.getName().startsWith(POSSIBLE_RESULT_SEPARATOR_PREFIX)) {
                            filter.addPossibleResultId(Integer.parseInt(
                                    checkBox.getName().substring(POSSIBLE_RESULT_SEPARATOR_PREFIX.length())));
                        }
                    }
                }
            }

            filter.setDateFrom(dateBoxFrom.getValue());
            filter.setDateTo(dateBoxTo.getValue());

            resultList.filterResults(filter);
            box.hide();

        }
    });

    buttonFilter.setWidth("5em");
    panel.add(buttonFilter);
    panel.setCellHorizontalAlignment(buttonFilter, HasAlignment.ALIGN_RIGHT);

    // ----------------------- Show all results button
    final Button buttonShowAll = new Button("Clear", new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            resultList.filterResults(null);
            box.hide();
        }
    });

    buttonShowAll.setWidth("5em");
    panel.add(buttonShowAll);
    panel.setCellHorizontalAlignment(buttonShowAll, HasAlignment.ALIGN_RIGHT);

    // ----------------------- Cancel button
    final Button buttonCancel = new Button("Cancel", new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            box.hide();
        }
    });

    buttonCancel.setWidth("5em");
    panel.add(buttonCancel);
    panel.setCellHorizontalAlignment(buttonCancel, HasAlignment.ALIGN_RIGHT);

    box.add(panel);
    return box;
}

From source file:org.jboss.mjolnir.client.LoginScreen.java

License:Open Source License

private void displayErrorBox(String errorHeader, String message) {
    final DialogBox errorBox = new DialogBox();
    errorBox.setText(errorHeader);
    final HTML errorLabel = new HTML();
    errorLabel.setHTML(message);/*from  w ww  . j av a  2s.c om*/
    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    final Button closeButton = new Button("Close");
    closeButton.setEnabled(true);
    closeButton.getElement().setId("close");
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            errorBox.hide();
            loginButton.setFocus(true);
            loginButton.setEnabled(true);
        }
    });
    verticalPanel.add(errorLabel);
    verticalPanel.add(closeButton);
    errorBox.setWidget(verticalPanel);
    errorBox.center();
}

From source file:org.jboss.mjolnir.client.SubscriptionScreen.java

License:Open Source License

private void displayPopupBox(String header, String message) {
    final DialogBox box = new DialogBox();
    box.setText(header);
    final HTML html = new HTML();
    html.setHTML(message);//from w w  w .ja v a  2 s  . c  o  m
    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    final Button closeButton = buildCloseButton(box);
    verticalPanel.add(html);
    verticalPanel.add(closeButton);
    box.setWidget(verticalPanel);
    box.center();
}

From source file:org.nuxeo.opensocial.container.client.view.ContainerBuilderWidget.java

License:Open Source License

public void showHTMLCode(String codeSource) {
    final DialogBox codePopup = new DialogBox(true, true);
    codePopup.setGlassEnabled(true);/*from   w w w .j a  va  2s. c om*/
    codePopup.setText(constants.showCodeTitle());

    String[] lignesCode = codeSource.split("\n");

    VerticalPanel tab = new VerticalPanel();

    for (String ligneCode : lignesCode) {
        String maLigne = new String(ligneCode);

        String[] ligne = ligneCode.split("\t");
        for (String texte : ligne) {
            if (texte.equals("")) {
                maLigne = "&nbsp;&nbsp;&nbsp;&nbsp;" + maLigne;
            }
        }
        maLigne = maLigne.replace("<", "&lt;");
        maLigne = maLigne.replace("div", "<span style='color: blue;'>div</span>");
        maLigne = maLigne.replace("id=", "<span style='color: red;'>id</span>=");
        maLigne = maLigne.replace("class", "<span style='color: red;'>class</span>");

        int commentBegin = maLigne.indexOf("&lt;!--");

        if (commentBegin != -1) {
            int commentEnd = maLigne.indexOf("-->");
            String comment = maLigne.substring(commentBegin, commentEnd + 3);
            maLigne = maLigne.replace(comment, "<span style='color: #008000;'>" + comment + "</span>");
        }

        HTML htmlLine = new HTML(maLigne);
        htmlLine.setStyleName("builder-source");
        tab.add(htmlLine);
    }

    Button closeButton = new Button(constants.close(), new ClickHandler() {
        public void onClick(ClickEvent event) {
            codePopup.hide();
        }
    });

    tab.add(closeButton);
    tab.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER);

    codePopup.add(tab);
    codePopup.center();
    codePopup.show();
}

From source file:org.opendatakit.dwc.client.DemoWebClient.java

License:Apache License

private void defineDialogIneractions(final TextBox nameField, final Button sendButton, final Label errorLabel,
        final BUTTON_FIELD_ACTION api) {

    // 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.setWidth(Integer.toString(Window.getClientWidth() - 10) + "px");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    dialogVPanel.add(closeButton);//from  www . jav  a 2  s  . c o m
    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("");
            AsyncCallback<String> callback = 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("<verbatim>" + SafeHtmlUtils.htmlEscape(SERVER_ERROR) + "</verbatim>");
                    dialogBox.getWidget().setWidth("90%");
                    dialogBox.center();
                    closeButton.setFocus(true);
                }

                public void onSuccess(String result) {
                    dialogBox.setText("Remote Procedure Call");
                    serverResponseLabel.removeStyleName("serverResponseLabelError");
                    serverResponseLabel
                            .setHTML("<verbatim>" + SafeHtmlUtils.htmlEscape(result) + "</verbatim>");
                    dialogBox.getWidget().setWidth("90%");
                    dialogBox.center();
                    closeButton.setFocus(true);
                }
            };

            if (api == BUTTON_FIELD_ACTION.OAUTH2_FETCH) {
                greetingService.obtainOauth2Data(textToServer, callback);
            } else if (api == BUTTON_FIELD_ACTION.OAUTH1_FETCH) {
                greetingService.obtainOauth1Data(textToServer, callback);
            } else {
                greetingService.greetServer(textToServer, callback);
            }
        }
    }

    // Add a handler to send the name to the server
    MyHandler handler = new MyHandler();
    sendButton.addClickHandler(handler);
    nameField.addKeyUpHandler(handler);
}

From source file:org.opennms.dashboard.client.portlet.Dashboard.java

License:Open Source License

/**
 * <p>/*from www. ja v  a 2s .c  o m*/
 * error
 * </p>
 * 
 * @param err
 *            a {@link java.lang.String} object.
 */
public void error(String err) {
    final DialogBox dialog = new DialogBox();
    dialog.setText("Error Occurred");

    VerticalPanel panel = new VerticalPanel();
    HTMLPanel html = new HTMLPanel(err);
    html.setStyleName("Message");
    panel.add(html);

    Button ok = new Button("OK");
    SimplePanel buttonPanel = new SimplePanel();
    buttonPanel.setWidget(ok);
    buttonPanel.setStyleName("Button");
    panel.add(buttonPanel);

    dialog.setPopupPosition(Window.getScrollLeft() + 100, Window.getScrollTop() + 100);
    dialog.setWidget(panel);

    ok.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            dialog.hide();
        }

    });

    dialog.show();

}

From source file:org.opennms.features.poller.remote.gwt.client.DefaultLocationManager.java

License:Open Source License

/**
 * <p>displayDialog</p>/* w w  w.j  av a 2 s  .c  om*/
 *
 * @param title a {@link java.lang.String} object.
 * @param contents a {@link java.lang.String} object.
 */
protected void displayDialog(final String title, final String contents) {
    final DialogBox db = new DialogBox();
    db.setAutoHideEnabled(true);
    db.setModal(true);
    db.setText(title);
    db.setWidget(new Label(contents, true));
    db.show();
}