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

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

Introduction

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

Prototype

@Override
    public void hide() 

Source Link

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);//from  w ww.  j a v a 2  s  .  c  om
    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.admin.client.ui.UsersTable.java

License:Open Source License

public DialogBox createDialogBox(UserDTO m, StatsDTO s) {

    // Create a dialog box and set the caption text
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setHTML("User Details: " + m.getUsername());

    // Create a table to layout the content
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogBox.setSize("50%", "50%");

    ClickHandler cancelHandler = new ClickHandler() {
        @Override//from w w  w. j  a  va  2s  .  co  m
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    };

    dialogBox.setWidget(dialogVPanel);
    dialogVPanel.add(new Label("Username: " + m.getUsername()));
    dialogVPanel.add(new Label("Email: " + m.getEmail()));
    dialogVPanel.add(new Label("Name: " + m.getName()));
    if (m.getUserClass() != null)
        dialogVPanel.add(new Label("Quota: " + m.getUserClass().getQuotaAsString()));
    dialogVPanel.add(new Label("File Count: " + s.getFileCount()));
    dialogVPanel.add(new Label("File Size: " + s.getFileSizeAsString()));
    dialogVPanel.add(new Label("Quota Left: " + s.getQuotaLeftAsString()));

    Button close = new Button("Close");
    close.addClickHandler(cancelHandler);
    dialogVPanel.add(close);

    // Return the dialog box
    return dialogBox;
}

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

License:Open Source License

@Override
public void execute() {
    containerPanel.hide();/*  w w  w.j av  a 2 s .  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);//w  w  w .  ja  v  a2s.co m

    final Button buttonClose = new Button("Close", new ClickHandler() {
        @Override
        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  . j  a  v a  2  s .com

    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);//from  ww w.j  ava2 s . com
    final HTML errorLabel = new HTML();
    errorLabel.setHTML(message);
    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 Button buildCloseButton(final DialogBox box) {
    final Button closeButton = new Button("Close");
    closeButton.setEnabled(true);/*from ww  w .  ja  v a2  s  . co  m*/
    closeButton.getElement().setId("Close");
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            box.hide();
        }
    });
    return closeButton;
}

From source file:org.nightcode.gwt.selectio.client.Selector.java

License:Apache License

private static DialogBox createDialogBox(final String url, final RootPanel input, final String function,
        final String selection, final String title) {
    final DialogBox dialogBox = new DialogBox(new SelectorHeader());
    dialogBox.setStyleName("modal-content");
    if (title != null) {
        dialogBox.getCaption().setText(title);
    }//from   w ww  . j av  a  2 s.  com

    SelectorRequestFactory requestFactory = new SelectorRequestFactoryJson(url);
    final ItemSelector itemSelector = new ItemSelector(requestFactory, 490);

    if (selection != null) {
        SelectionJso selectionJso = SelectionJso.selectionFromJson(selection);
        itemSelector.setSelection(selectionJso);
    }

    VerticalPanel dialogContents = new VerticalPanel();
    dialogContents.setSize("300px", "500px");
    dialogContents.setStyleName("selectio");
    dialogBox.setWidget(dialogContents);

    dialogContents.add(itemSelector);
    dialogContents.setCellHeight(itemSelector, "490px");

    Button doneButton = new Button(MESSAGES.done(), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final SelectionJso selection = SelectionJso.create();
            itemSelector.fillSelection(selection);
            input.getElement().setAttribute("value", new JSONObject(selection).toString());
            onChange(function, input.getElement());
            dialogBox.hide();
        }
    });
    doneButton.setStyleName("btn btn-primary");

    Button cancelButton = new Button(MESSAGES.cancel(), new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            dialogBox.hide();
        }
    });
    cancelButton.setStyleName("btn btn-default");

    Panel buttonPanel = new FlowPanel();
    buttonPanel.setStyleName("btn-toolbar pull-right");
    buttonPanel.add(doneButton);
    buttonPanel.add(cancelButton);

    dialogContents.add(buttonPanel);
    dialogContents.setCellHeight(buttonPanel, "20px");
    dialogContents.setCellHorizontalAlignment(buttonPanel, HasHorizontalAlignment.ALIGN_RIGHT);

    return dialogBox;
}

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  o  m
    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. j a  va2s .  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);
}