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:com.google.gwt.gwtai.demo.client.CounterAppletTab.java

License:Apache License

private DialogBox createDialogBox(Object currentValue) {
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Current...");

    VerticalPanel panelContent = new VerticalPanel();
    panelContent.setWidth("100%");
    panelContent.setSpacing(4);/* w w  w  .j av a 2s.c  o m*/
    dialogBox.setWidget(panelContent);

    HTML labelCurrentValue = new HTML("The current count is : " + currentValue);
    panelContent.add(labelCurrentValue);
    panelContent.setCellHorizontalAlignment(labelCurrentValue, VerticalPanel.ALIGN_CENTER);

    Button buttonCloseDlg = new Button("Close");
    buttonCloseDlg.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });

    panelContent.add(buttonCloseDlg);
    panelContent.setCellHorizontalAlignment(buttonCloseDlg, VerticalPanel.ALIGN_RIGHT);

    return dialogBox;
}

From source file:com.google.gwt.sample.mobilewebapp.client.desktop.MobileWebAppShellDesktop.java

License:Apache License

/**
 * Show a tutorial video./* ww w.ja  v a2  s .  c o m*/
 */
private void showTutorial() {
    // Reuse the tutorial dialog if it is already created.
    if (tutoralPopup != null) {
        // Reset the video.
        // TODO(jlabanca): Is cache-control=private making the video non-seekable?
        if (tutorialVideo != null) {
            tutorialVideo.setSrc(tutorialVideo.getCurrentSrc());
        }

        tutoralPopup.center();
        return;
    }

    /*
     * Forward the use to YouTube if video is not supported or if none of the
     * source formats are supported.
     */
    tutorialVideo = Video.createIfSupported();
    if (tutorialVideo == null) {
        Label label = new Label("Click the link below to view the tutoral:");
        Anchor anchor = new Anchor(EXTERNAL_TUTORIAL_URL, EXTERNAL_TUTORIAL_URL);
        anchor.setTarget("_blank");
        FlowPanel panel = new FlowPanel();
        panel.add(label);
        panel.add(anchor);

        tutoralPopup = new PopupPanel(true, false);
        tutoralPopup.setWidget(panel);
        tutoralPopup.setGlassEnabled(true);

        // Hide the popup when the user clicks the link.
        anchor.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                tutoralPopup.hide();
            }
        });

        tutoralPopup.center();
        return;
    }

    // Add the video sources.
    tutorialVideo.addSource("video/tutorial.ogv", VideoElement.TYPE_OGG);
    tutorialVideo.addSource("video/tutorial.mp4", VideoElement.TYPE_MP4);

    // Setup the video player.
    tutorialVideo.setControls(true);
    tutorialVideo.setAutoplay(true);

    // Put the video in a dialog.
    final DialogBox popup = new DialogBox(false, false);
    popup.setText("Tutorial");
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(tutorialVideo);
    vPanel.add(new Button("Close", new ClickHandler() {
        public void onClick(ClickEvent event) {
            tutorialVideo.pause();
            popup.hide();
        }
    }));
    popup.setWidget(vPanel);
    tutoralPopup = popup;
    popup.center();
}

From source file:com.google.gwt.sample.showcase.client.content.popups.CwDialogBox.java

License:Apache License

/**
 * Create the dialog box for this example.
 *
 * @return the new dialog box//from  www.  ja v a  2s  .c  om
 */
@ShowcaseSource
private DialogBox createDialogBox() {
    // Create a dialog box and set the caption text
    final DialogBox dialogBox = new DialogBox();
    dialogBox.ensureDebugId("cwDialogBox");
    dialogBox.setText(constants.cwDialogBoxCaption());

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

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

    // Add an image to the dialog
    Image image = new Image(Showcase.images.jimmy());
    dialogContents.add(image);
    dialogContents.setCellHorizontalAlignment(image, HasHorizontalAlignment.ALIGN_CENTER);

    // Add a close button at the bottom of the dialog
    Button closeButton = new Button(constants.cwDialogBoxClose(), new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.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
    return dialogBox;
}

From source file:com.google.gwt.sample.starter.client.Starter.java

/**
 * This is the entry point method./*from  w  ww.ja v a 2  s .  c o  m*/
 */
public void onModuleLoad() {
    final Button sendButton = new Button("Send");
    final TextBox nameField = new TextBox();
    nameField.setText("GWT User");
    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.google.lotrepls.client.CommandPrompt.java

License:Apache License

/**
 * This creates an immutable copy of the prompt and input area suitable for
 * adding to the page.//from  ww  w .  ja  va  2  s.c o m
 */
public Widget createImmutablePanel() {
    HorizontalPanel panelCopy = new HorizontalPanel();

    Label promptCopy = new Label(prompt.getText());
    promptCopy.setStyleName(prompt.getStyleName());
    promptCopy.getElement().getStyle().setProperty("width",
            prompt.getElement().getStyle().getProperty("width"));
    panelCopy.add(promptCopy);

    final InterpreterType t = type;
    final String scriptText = inputArea.getText();

    TextArea inputAreaCopy = new TextArea() {
        {
            this.addDomHandler(new DoubleClickHandler() {
                public void onDoubleClick(DoubleClickEvent event) {
                    final DialogBox box = new DialogBox();
                    VerticalPanel boxPanel = new VerticalPanel();

                    boxPanel.add(new Label("Use the following URL to share this script with friends:"));

                    String url = buildUrl(t, scriptText);

                    boxPanel.add(new Anchor(trimUrl(url), url));

                    Button close = new Button("Close");
                    close.addClickHandler(new ClickHandler() {
                        public void onClick(ClickEvent event) {
                            box.hide();
                        }
                    });
                    close.setStyleName("closeButton");

                    boxPanel.add(close);
                    box.add(boxPanel);

                    box.getElement().getStyle().setProperty("border", "1px solid");
                    box.getElement().getStyle().setProperty("borderColor", "green");
                    box.getElement().getStyle().setProperty("backgroundColor", "black");
                    box.center();
                }
            }, DoubleClickEvent.getType());
        }
    };
    inputAreaCopy.setStyleName(inputArea.getStyleName());
    resizeInputArea(true);
    inputAreaCopy.setText(scriptText);
    inputAreaCopy.setVisibleLines(inputArea.getVisibleLines());
    inputAreaCopy.setReadOnly(true);

    SimplePanel inputAreaDivCopy = new SimplePanel();

    inputAreaDivCopy.add(inputAreaCopy);

    inputAreaDivCopy.getElement().setAttribute("style", inputAreaDiv.getElement().getAttribute("style"));

    panelCopy.add(inputAreaDivCopy);
    panelCopy.setCellWidth(inputAreaDivCopy, "100%");

    return panelCopy;
}

From source file:com.googlecode.konamigwt.hadoken.client.Hadoken.java

License:BEER-WARE LICENSE

/**
 * This is the entry point method.//from  w  w  w.  ja va2 s  .c o  m
 */
public void onModuleLoad() {

    final Button sendButton = new Button("Send");
    final TextBox nameField = new TextBox();
    nameField.setText("GWT User");
    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);
        }
    });

    // Quick and Dirty implementation
    new Konami(new KonamiHandler() {
        @Override
        public void onKonamiCodePerformed() {
            final Image image = new Image("media/ryu.gif");
            DOM.appendChild(RootPanel.get().getElement(), image.getElement());

            final Audio audio = Audio.createIfSupported();
            if (audio != null) {
                audio.setSrc("media/hadoken.ogg");
                DOM.appendChild(RootPanel.get().getElement(), audio.getElement());
                audio.play();
            }
            Timer timer = new Timer() {

                @Override
                public void run() {
                    DOM.removeChild(RootPanel.get().getElement(), image.getElement());
                    if (audio != null) {
                        DOM.removeChild(RootPanel.get().getElement(), audio.getElement());
                    }
                }

            };
            timer.schedule(1100);

        }
    }).start();

    // 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("");
            serverResponseLabel.removeStyleName("serverResponseLabelError");
            serverResponseLabel.setHTML("Hello " + textToServer);
            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.googlecode.simplegwt.tbg.client.TbgEntryPoint.java

License:Apache License

/**
 * @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
 *///  www.j  ava  2  s  .  c om
public void onModuleLoad() {
    final ButtonGrid buttonGrid = new ButtonGrid(DEFAULT_GRID_HEIGHT, DEFAULT_GRID_WIDTH);
    final GridControls gridControls = new GridControls(buttonGrid);

    final DialogBox dialog = new DialogBox(false, false);
    dialog.setWidget(new Label(
            "Click a button to toggle it on/off. " + "Adjacent buttons will also reverse their state.", true));
    dialog.setText("Help - ToggleButtonGame");
    dialog.addStyleName("tbg-help-dialog");
    final FlowPanel gridHeaderBar = new FlowPanel();
    final Label helpLabel = new CommandLabel("Help", new Command() {
        boolean shownOnce = false;

        public void execute() {
            if (dialog.isShowing()) {
                dialog.hide();
            } else {
                if (shownOnce) {
                    dialog.show();
                } else {
                    dialog.center();
                    shownOnce = true;
                }
            }
        }
    });
    helpLabel.setStylePrimaryName("tbg-help");
    gridHeaderBar.add(new LoginWidget(gridControls));
    gridHeaderBar.add(helpLabel);

    final DecoratorPanel decoration = new DecoratorPanel();
    final FlowPanel wrapper = new FlowPanel();

    wrapper.add(gridHeaderBar);
    wrapper.add(gridControls);
    wrapper.add(buttonGrid);

    decoration.add(wrapper);

    RootPanel.get("gwt").add(decoration);

    Window.addResizeHandler(new ResizeHandler() {
        public void onResize(ResizeEvent event) {
            resize(event.getHeight(), event.getWidth());
        }
    });

    resize(Window.getClientHeight(), Window.getClientWidth());
}

From source file:com.gwt.conn.client.Communicate.java

public static void showDialog(String text) {
    final DialogBox errorBox = new DialogBox();
    errorBox.setAnimationEnabled(true);//w  w w  .j  ava2 s  . com
    final VerticalPanel errorVPanel = new VerticalPanel();
    errorVPanel.addStyleName("marginPanel"); // interacts with Connfrontend.css
    errorVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    final Button errorButton = new Button("Continue");
    errorButton.addStyleName("myButton");
    final HorizontalPanel errorHPanel = new HorizontalPanel();
    errorVPanel.add(new HTML(text));
    errorHPanel.add(errorButton);
    errorVPanel.add(errorHPanel);
    errorBox.setWidget(errorVPanel);
    errorBox.center();
    errorButton.setFocus(true);

    class ErrorHandler implements ClickHandler, KeyUpHandler {
        public void onClick(ClickEvent event) { // button clicked
            cont();
        }

        public void onKeyUp(KeyUpEvent event) { // ENTER key
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                cont();
        }

        private void cont() {
            errorButton.setEnabled(false);
            errorBox.hide();
        }
    }
    final ErrorHandler errorHandler = new ErrorHandler();
    errorButton.addClickHandler(errorHandler);
}

From source file:com.gwt.conn.client.Communicate.java

public static void authenticate(final String restID, final String license, final HTML commError,
        final DialogBox startupBox, final Button submitButton, final TextBox submitLicense,
        final TextBox submitRestID) {
    // attempt to sync with server
    storage.setItem("authenticated?", "null");
    String result = sync("menu", restID, true); // true because authenticating
    if (!result.equals("")) {
        commError.setText("<br>No internet connection detected.");
        return;/* ww w .ja va 2s  .c o  m*/
    }

    // hide authentication submission form and replace with an "Authenticating..." message
    submitButton.setEnabled(false);
    submitLicense.setEnabled(false);
    submitRestID.setEnabled(false);
    startupBox.hide();
    final DialogBox authBox = new DialogBox();
    authBox.setAnimationEnabled(true);
    final VerticalPanel authPanel = new VerticalPanel();
    authPanel.addStyleName("marginPanel"); // interacts with Connfrontend.css
    authPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    authPanel.add(new HTML("Authenticating..."));
    authBox.setWidget(authPanel);
    authBox.center();

    // repeat a timer until the value of "authenticated?" changes
    final Timer timer = new Timer() {
        public void run() {
            // authentication unsuccessful
            if (storage.getItem("authenticated?").equals("no")) {
                // report error and show authentication form again
                authBox.hide();
                commError.setText("<br>Something went wrong. Please try again.");
                submitButton.setEnabled(true);
                submitLicense.setEnabled(true);
                submitRestID.setEnabled(true);
                startupBox.center();
                this.cancel();
            }

            // authentication successful
            else if (storage.getItem("authenticated?").equals("yes")) {
                // save license and restaurant id and setup storage
                authBox.hide();
                storage.setItem("license", license); // secret key for security
                storage.setItem("restID", restID); // used for almost every call to the backend
                storage.setItem("numMenus", Integer.toString(0));
                StorageContainer.initStorage();

                // go to dashboard (true meaning there is internet since we were able to authenticate)
                // "firstTime" causes a popup box to appear explaining how to use Connoisseur
                this.cancel();
                Dashboard.loadMenu(deserialize(storage.getItem("menu")), "firstTime", true);

            }
        }
    };

    // repeat once every half second
    timer.scheduleRepeating(500); // 500 milliseconds
}

From source file:com.gwt.conn.client.Dashboard.java

/** Called when no internet connection is detected in order to inform the user. */
public static void showNoInternetError() {
    // put everything in a popup dialog box
    final DialogBox errorBox = new DialogBox();
    errorBox.setAnimationEnabled(true);// w w w.  j  av a 2  s  .  c om
    final VerticalPanel errorVPanel = new VerticalPanel();
    errorVPanel.addStyleName("marginPanel"); // interacts with
    // Connfrontend.css
    errorVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    final Button errorButton = new Button("Continue");
    errorButton.addStyleName("myButton");
    final HorizontalPanel errorHPanel = new HorizontalPanel();
    errorVPanel.add(new HTML(SERVER_ERROR));
    errorHPanel.add(errorButton);
    errorVPanel.add(errorHPanel);
    errorBox.setWidget(errorVPanel);
    errorBox.center();
    errorButton.setFocus(true);

    // handler for errorButton
    class ErrorHandler implements ClickHandler, KeyUpHandler {
        public void onClick(ClickEvent event) { // button clicked
            cont();
        }

        public void onKeyUp(KeyUpEvent event) { // ENTER key
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                cont();
        }

        private void cont() {
            errorButton.setEnabled(false);
            errorBox.hide();
        }
    }
    final ErrorHandler errorHandler = new ErrorHandler();
    errorButton.addClickHandler(errorHandler);
    errorButton.addKeyUpHandler(errorHandler);
}