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.connoisseur.menuapp.client.Authenticate.java

/** This is essentially the main method for the menu app. */
public static void go() {
    storage.clear(); // uncomment to completely reset app

    final DialogBox startupBox = new DialogBox(); // movable box that contains widgets
    startupBox.setAnimationEnabled(true);
    final VerticalPanel startupPanel = new VerticalPanel(); // can contain other widgets
    startupPanel.addStyleName("marginPanel"); // interacts with Menuapp.css
    startupPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    // check to see if storage is supported
    if (storage != null) {

        // load viewer if license key and restID have been submitted before
        if (storage.getLength() > 0) {
            Viewer.loadViewer();//from   www . j  av a2  s. c o  m
        }

        // otherwise load authentication UI in order to receive input
        else {
            final Button submitButton = new Button("Submit"); // "Submit" appears on button
            submitButton.addStyleName("myButton"); // interacts with Menuapp.css
            final HorizontalPanel buttonPanel = new HorizontalPanel(); // used to center button
            buttonPanel.addStyleName("marginlessPanel");

            // license widgets
            final Label licenseErrorLabel = new Label(); // dynamic text
            licenseErrorLabel.addStyleName("errorLabel"); // interacts with Menuapp.css
            final TextBox submitLicense = new TextBox(); // user can input text using this
            submitLicense.setText("license key..."); // default text to be seen on load

            // restaurant ID widgets
            final Label restErrorLabel = new Label();
            restErrorLabel.addStyleName("errorLabel");
            final TextBox submitRestID = new TextBox();
            submitRestID.setText("restaurant ID...");

            // organize UI
            startupPanel.add(new HTML("Please enter your license key:"));
            startupPanel.add(submitLicense);
            startupPanel.add(licenseErrorLabel);
            startupPanel.add(new HTML("<br>Please enter your restaurant ID:"));
            startupPanel.add(submitRestID);
            startupPanel.add(restErrorLabel);
            startupPanel.add(new HTML("<br>"));
            buttonPanel.add(submitButton);
            startupPanel.add(buttonPanel);

            // setup startupBox, which is what will be seen by the user
            startupBox.setWidget(startupPanel); // connects the two widgets
            startupBox.center(); // also shows the box

            // focus the cursor on submitLicense when startupBox appears
            submitLicense.setFocus(true);
            submitLicense.selectAll();

            // create a handler for submitButton, submitLicense and submitRestID
            class MyHandler implements ClickHandler, KeyUpHandler {
                /** Fired when the user clicks submit. */
                public void onClick(ClickEvent event) {
                    submit();
                }

                /** Fired when the user presses Enter in a submit field. */
                public void onKeyUp(KeyUpEvent event) {
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                        submit();
                }

                /** Checks the submitted license key and restaurant ID for validity. Loads Viewer if valid. */
                private void submit() {
                    String license = submitLicense.getText(); // unused for now
                    String restID = submitRestID.getText(); // not sure how to validate yet
                    int returnFlag = 0; // so that both tests can be done
                    licenseErrorLabel.setText("");
                    restErrorLabel.setText("");

                    // validate license
                    String result = FieldVerifier.isValidLicenseKey(license); // from FieldVerifier.java
                    if (!result.equals("")) { // error
                        licenseErrorLabel.setText("You submitted an invalid license key.");
                        submitLicense.selectAll();
                        returnFlag = 1;
                    }

                    // validate restID
                    result = FieldVerifier.isValidRestaurantID(restID);
                    if (!result.equals("")) { // error
                        restErrorLabel.setText("You submitted an invalid restaurant ID.");
                        submitRestID.selectAll();
                        returnFlag = 1;
                    }

                    // don't do anything until the errors are resolved
                    if (returnFlag == 1)
                        return;

                    // clean up
                    submitButton.setEnabled(false);
                    submitLicense.setEnabled(false);
                    submitRestID.setEnabled(false);
                    startupBox.hide();

                    // set up storage
                    storage.setItem("license", license); // secret key for security
                    storage.setItem("restID", restID); // used for almost every call to the backend

                    // show menu
                    Viewer.loadViewer();
                }
            } // MyHandler

            // attach the handler
            final MyHandler handler = new MyHandler();
            submitButton.addClickHandler(handler);
            submitLicense.addKeyUpHandler(handler);
            submitRestID.addKeyUpHandler(handler);
        } // else load authentication UI

    } // if storage supported

    // storage is not supported, so report error
    else {
        startupPanel.add(new HTML("<font color=red>The app will not function because local<br>"
                + "storage is not supported on this platform.</font>"));
        startupBox.setWidget(startupPanel);
        startupBox.center();
    }
}

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);/*from ww w  .  ja v a 2 s. c  o  m*/

    // Create a table to layout the content
    VerticalPanel dialogContents = new VerticalPanel();
    dialogContents.setSpacing(4);
    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

private static Button createButton(String label, final DialogBox dialogBox, final boolean isCancel,
        final Handler handler) {
    return new Button(label, new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            handler.dialogClosed(isCancel);
        }/*from ww  w . j a  va 2  s .c  o m*/
    });
}

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

License:Open Source License

private Button createButton(String label, final DialogBox dialogBox, final boolean isCancel,
        final State originalState) {
    return new Button(label, new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            if (isCancel)
                state = originalState;/*  www .  j ava2  s  . co m*/
            else if (!state.equals(originalState))
                handler.optionsChanged(TreeOptions.this);
        }
    });
}

From source file:com.databasepreservation.visualization.client.common.Dialogs.java

public static void showConfirmDialog(String title, String message, String cancelButtonText,
        String confirmButtonText, final AsyncCallback<Boolean> callback) {
    final DialogBox dialogBox = new DialogBox(false, true);
    dialogBox.setText(title);/*ww  w  .j  a  v  a2  s  . c o  m*/

    FlowPanel layout = new FlowPanel();
    Label messageLabel = new Label(message);
    Button cancelButton = new Button(cancelButtonText);
    Button confirmButton = new Button(confirmButtonText);
    FlowPanel footer = new FlowPanel();

    layout.add(messageLabel);
    layout.add(footer);
    footer.add(cancelButton);
    footer.add(confirmButton);

    dialogBox.setWidget(layout);

    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(false);

    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onSuccess(false);
        }
    });

    confirmButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onSuccess(true);
        }
    });

    dialogBox.addStyleName("wui-dialog-confirm");
    layout.addStyleName("wui-dialog-layout");
    footer.addStyleName("wui-dialog-layout-footer");
    messageLabel.addStyleName("wui-dialog-message");
    cancelButton.addStyleName("btn btn-link");
    confirmButton.addStyleName("btn btn-play");

    dialogBox.center();
    dialogBox.show();
}

From source file:com.databasepreservation.visualization.client.common.Dialogs.java

public static void showInformationDialog(String title, String message, String continueButtonText,
        final AsyncCallback<Void> callback) {
    final DialogBox dialogBox = new DialogBox(false, true);
    dialogBox.setText(title);/*ww  w. j  a v a 2s  . com*/

    FlowPanel layout = new FlowPanel();
    Label messageLabel = new Label(message);
    Button continueButton = new Button(continueButtonText);

    layout.add(messageLabel);
    layout.add(continueButton);

    dialogBox.setWidget(layout);

    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(false);

    continueButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onSuccess(null);
        }
    });

    dialogBox.addStyleName("wui-dialog-information");
    layout.addStyleName("wui-dialog-layout");
    messageLabel.addStyleName("wui-dialog-message");
    continueButton.addStyleName("btn btn-play");

    dialogBox.center();
    dialogBox.show();
}

From source file:com.databasepreservation.visualization.client.common.Dialogs.java

public static void showPromptDialog(String title, String message, String placeHolder, final RegExp validator,
        String cancelButtonText, String confirmButtonText, final AsyncCallback<String> callback) {
    final DialogBox dialogBox = new DialogBox(false, true);
    dialogBox.setText(title);//from  w w w .j av  a2s.co m

    final FlowPanel layout = new FlowPanel();

    if (message != null) {
        final Label messageLabel = new Label(message);
        layout.add(messageLabel);
        messageLabel.addStyleName("wui-dialog-message");
    }

    final TextBox inputBox = new TextBox();

    if (placeHolder != null) {
        inputBox.getElement().setPropertyString("placeholder", placeHolder);
    }

    final Button cancelButton = new Button(cancelButtonText);
    final Button confirmButton = new Button(confirmButtonText);

    layout.add(inputBox);
    layout.add(cancelButton);
    layout.add(confirmButton);

    dialogBox.setWidget(layout);

    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(false);

    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onFailure(null);
        }
    });

    confirmButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onSuccess(inputBox.getText());
        }
    });

    inputBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            boolean isValid = validator.test(inputBox.getText());
            if (isValid) {
                inputBox.addStyleName("error");
            } else {
                inputBox.removeStyleName("error");
            }
        }
    });

    inputBox.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            boolean isValid = validator.test(inputBox.getText());
            confirmButton.setEnabled(isValid);
        }
    });

    inputBox.addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                boolean isValid = validator.test(inputBox.getText());
                if (isValid) {
                    dialogBox.hide();
                    callback.onSuccess(inputBox.getText());
                }
            }
        }

    });

    confirmButton.setEnabled(validator.test(inputBox.getText()));

    dialogBox.addStyleName("wui-dialog-prompt");
    layout.addStyleName("wui-dialog-layout");
    inputBox.addStyleName("form-textbox wui-dialog-message");
    cancelButton.addStyleName("btn btn-link");
    confirmButton.addStyleName("pull-right btn btn-play");

    dialogBox.center();
    dialogBox.show();
    inputBox.setFocus(true);
}

From source file:com.dawg6.gwt.client.ApplicationPanel.java

License:Open Source License

public static DialogBox showDialogBox(String title, IsWidget component, int buttons,
        final DialogBoxResultHandler handler) {
    // Create the popup dialog box
    final DialogBox dialogBox = createDialogBox();
    dialogBox.setText(title);/*from   w w  w.j av  a2s.co  m*/
    dialogBox.setAnimationEnabled(true);
    dialogBox.setModal(false);
    FlexTable table = new FlexTable();
    table.setWidget(0, 0, component);
    dialogBox.setWidget(table);

    HorizontalPanel row = new HorizontalPanel();
    row.setSpacing(5);
    row.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    row.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    table.setWidget(1, 0, row);

    boolean firstButton = true;

    if (buttons == 0)
        buttons = OK;

    for (final ButtonInfo b : allButtons) {
        if ((buttons > 0) && ((buttons & b.id) != 0)) {
            final Button button = createDialogBoxButton(b.label);

            button.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    dialogBox.hide();

                    if (handler != null)
                        handler.dialogBoxResult(b.id);
                }
            });
            row.add(button);

            if (firstButton) {
                button.setFocus(true);
                firstButton = false;
            }
        }
    }

    dialogBox.center();

    return dialogBox;
}

From source file:com.dawg6.gwt.client.ApplicationPanel.java

License:Open Source License

public static AsyncTaskHandler showWaitDialogBox(String title, String message) {

    VerticalPanel panel = new VerticalPanel();
    HorizontalPanel row = new HorizontalPanel();
    row.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    row.setSpacing(5);//w w  w  .j  a v  a2  s  . c  o  m
    panel.add(row);

    Image image = new Image("images/Progressbar.gif");
    image.setSize("64px", "16px");
    row.add(image);

    if (message != null) {
        Label label = new Label(message);
        row.add(label);
    }

    final DialogBox dialogBox = showDialogBox(title, panel, -1, null);

    return new AsyncTaskHandler() {

        @Override
        public void taskCompleted() {
            dialogBox.hide();
        }
    };

}

From source file:com.ephesoft.dcma.gwt.foldermanager.client.view.FolderTableView.java

License:Open Source License

private void performOperationsOnRename(final String fileName, final ContextMenuPanel contextMenu) {
    final DialogBox dialogBox = new DialogBox();
    dialogBox.addStyleName(FolderManagementConstants.CONFIGURABLE_DIALOG_BOX);
    dialogBox.setText(LocaleDictionary.get().getMessageValue(FolderManagementMessages.RENAME_TO));
    final TextBox renameTextBox = new TextBox();
    renameTextBox.setText(fileName);// w w w .  j av  a2s .  c  o  m
    HorizontalPanel renameTextBoxPanel = new HorizontalPanel();
    renameTextBoxPanel.add(renameTextBox);
    HorizontalPanel buttonsPanel = new HorizontalPanel();
    Button okButton = new Button(LocaleDictionary.get().getConstantValue(FolderManagementConstants.OK_STRING),
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    dialogBox.hide();
                    final String newFileName = renameTextBox.getText();
                    presenter.onRename(fileName, newFileName);
                }
            });
    Button cancelButton = new Button(LocaleDictionary.get().getConstantValue(FolderManagementConstants.CANCEL),
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    dialogBox.hide();
                }
            });
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    VerticalPanel layoutPanel = new VerticalPanel();
    layoutPanel.add(renameTextBoxPanel);
    layoutPanel.add(buttonsPanel);
    dialogBox.add(layoutPanel);
    dialogBox.center();
    dialogBox.show();
    renameTextBox.setFocus(true);
    renameTextBox.selectAll();
    contextMenu.hide();
}