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.gwt.conn.client.Dashboard.java

/**
 * Called by Authenticate.java when successfully authenticated. (multiple
 * menus version)/*from ww  w .ja va2s .  c  om*/
 */
public void loadDashboard() {
    final HTML statusLabel = new HTML(); // dynamic HTML
    final DialogBox dashboardBox = new DialogBox();
    dashboardBox.setAnimationEnabled(true);

    // send the license to the server
    greetingService.greetServer(storage.getItem("license"), new AsyncCallback<String>() {
        public void onFailure(Throwable caught) {
            // show the RPC error message to the user
            dashboardBox.setText("Dashboard - Offline Mode");
            // statusLabel.setHTML(???);

            final DialogBox errorBox = new DialogBox();
            errorBox.setAnimationEnabled(true);

            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 {
                // Fired when the user clicks Continue.
                public void onClick(ClickEvent event) {
                    cont();
                }

                // Fired when the user presses Enter.
                public void onKeyUp(KeyUpEvent event) {
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                        cont();
                }

                private void cont() {
                    errorButton.setEnabled(false);
                    errorBox.hide();
                    finishLoad(dashboardBox, statusLabel); // void
                    // method
                    // below
                }
            }

            // attach the handler
            final ErrorHandler errorHandler = new ErrorHandler();
            errorButton.addClickHandler(errorHandler);
        } // end onFailure

        public void onSuccess(String result) {
            // StorageContainer.synchronizeWithBackend(); //
            // implemented in StorageContainer.java
            dashboardBox.setText("Dashboard");
            statusLabel.setHTML(result);
            finishLoad(dashboardBox, statusLabel); // void method
            // below
        }
    }); // end greetServer
}

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

/** Called when the dashboard needs to be loaded. */
private void finishLoad(final DialogBox dashboardBox, final HTML statusLabel) {
    final VerticalPanel dashboardVPanel = new VerticalPanel();
    dashboardVPanel.addStyleName("marginPanel"); // interacts with
    // Connfrontend.css
    dashboardVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    // addStyleName makes buttons look pretty (interacts with
    // Connfrontend.css)
    final Button newButton = new Button("New");
    final Button editButton = new Button("Edit");
    final Button scheduleButton = new Button("Schedule");
    newButton.addStyleName("myButton");
    editButton.addStyleName("myButton");
    scheduleButton.addStyleName("myButton");

    // setup vertical panel
    dashboardVPanel.add(statusLabel);//  ww w.j a v  a 2 s.  com
    dashboardVPanel.add(newButton);
    dashboardVPanel.add(editButton);
    dashboardVPanel.add(scheduleButton);
    dashboardBox.setWidget(dashboardVPanel);
    dashboardBox.center();

    // handler for newButton
    class NewHandler implements ClickHandler {
        public void onClick(ClickEvent event) {
            dashboardBox.hide();
            newMenu(dashboardBox); // void method below
        }
    }

    // handler for editButton
    class EditHandler implements ClickHandler {
        public void onClick(ClickEvent event) {
            dashboardBox.hide();
            getMenus(dashboardBox); // void method below
        }
    }

    // handler for scheduleButton
    class ScheduleHandler implements ClickHandler {
        public void onClick(ClickEvent event) {
            dashboardBox.hide();
            // scheduler.loadScheduler(dashboardBox); // implemented in
            // Scheduler.java
        }
    }

    // attach the handlers to their respective buttons
    final NewHandler newHandler = new NewHandler();
    final EditHandler editHandler = new EditHandler();
    final ScheduleHandler scheduleHandler = new ScheduleHandler();
    newButton.addClickHandler(newHandler);
    editButton.addClickHandler(editHandler);
    scheduleButton.addClickHandler(scheduleHandler);
}

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

/** Called when the user wants to create a new menu. */
private void newMenu(final DialogBox dashboardBox) {
    // declarations
    final DialogBox submitBox = new DialogBox();
    submitBox.setAnimationEnabled(true);

    final VerticalPanel submitVPanel = new VerticalPanel();
    submitVPanel.addStyleName("marginPanel");
    submitVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    final Label errorLabel = new Label();
    errorLabel.addStyleName("errorLabel");

    final Button sendButton = new Button("Submit");
    sendButton.addStyleName("myButton");

    final Button cancelButton = new Button("Cancel");
    sendButton.addStyleName("myButton");

    final TextBox submitField = new TextBox(); // user can input text using
    // this// w  w  w  .j  av  a 2 s .c o  m
    submitField.setText("menu name..."); // default text to be seen on load

    final HorizontalPanel submitHPanel = new HorizontalPanel();

    // organize UI
    submitVPanel.add(new HTML("Please enter a name for your new menu:"));
    submitHPanel.add(submitField);
    submitHPanel.add(sendButton);
    submitHPanel.add(cancelButton);
    submitVPanel.add(submitHPanel);
    submitVPanel.add(errorLabel);
    submitBox.setWidget(submitVPanel);
    submitBox.center();
    submitField.setFocus(true);
    submitField.selectAll();

    // handler for the sendButton and submitField
    class SubmitHandler implements ClickHandler, KeyUpHandler {
        /** Fired when the user clicks submit. */
        public void onClick(ClickEvent event) {
            submit();
        }

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

        /**
         * Checks the submitted menu name for validity. If valid, loads a
         * new menu object and starts the visual editor.
         */
        private void submit() {
            // validate menu name
            String menuName = submitField.getText();
            String test = FieldVerifier.isValidMenuName(menuName);
            if (!test.equals("")) {
                errorLabel.setText(test);
                submitField.selectAll();
                return;
            }

            String json = "";// createDefaultJSON(); // get default JSON
                             // object
            StorageContainer.addMenu(menuName, json); // to storage
            sendButton.setEnabled(false);
            submitBox.hide();
            // visualEditor.loadVisualEditor(dashboardBox, json); // start
            // editing
        }
    }

    // handler for the cancel button
    class CancelHandler implements ClickHandler {
        /** Fired when the user clicks cancel. */
        public void onClick(ClickEvent event) {
            submitBox.hide();
            dashboardBox.center();
        }
    }

    // attach the handlers
    final SubmitHandler submitHandler = new SubmitHandler();
    final CancelHandler cancelHandler = new CancelHandler();
    sendButton.addClickHandler(submitHandler);
    submitField.addKeyUpHandler(submitHandler);
    cancelButton.addClickHandler(cancelHandler);
}

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

/** Called when the user wants to edit an existing menu. */
private void getMenus(final DialogBox dashboardBox) {
    // declarations
    final DialogBox editBox = new DialogBox();
    editBox.setAnimationEnabled(true);/*from   w  ww .jav a 2  s . co m*/

    final VerticalPanel editVPanel = new VerticalPanel();
    editVPanel.addStyleName("marginPanel");
    editVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    final Button cancelButton = new Button("Cancel");
    cancelButton.addStyleName("myButton");

    // from StorageContainer.java
    int numMenus = StorageContainer.getNumMenus();
    final String[] menus = StorageContainer.getMenus();

    // organize UI
    for (int i = 0; i < numMenus; ++i) {
        final String menuName = menus[i];
        final Button button = new Button(menuName);
        button.addStyleName("myButton");
        editVPanel.add(button);

        // handler for the buttons
        class ButtonHandler implements ClickHandler {
            /** Fired when the user clicks cancel. */
            public void onClick(ClickEvent event) {
                editBox.hide();
                // String json = StorageContainer.getMenu(menuName);
                // visualEditor.loadVisualEditor(dashboardBox, json); //
                // start editing
            }
        }

        // attach handler
        final ButtonHandler buttonHandler = new ButtonHandler();
        button.addClickHandler(buttonHandler);
    }

    editVPanel.add(cancelButton);
    editBox.setWidget(editVPanel);
    editBox.center();

    // handler for the cancel button
    class CancelHandler implements ClickHandler {
        /** Fired when the user clicks cancel. */
        public void onClick(ClickEvent event) {
            editBox.hide();
            dashboardBox.center();
        }
    }

    // attach cancel handler
    final CancelHandler cancelHandler = new CancelHandler();
    cancelButton.addClickHandler(cancelHandler);
}

From source file:com.gwttest.client.Demo.java

License:Open Source License

private void createImageDialog(String imgurl) {
    final DialogBox imageDb = new DialogBox();
    imageDb.setText("Image Capture of Chart");

    VerticalPanel dbContents = new VerticalPanel();
    dbContents.setSpacing(4);// w w  w. ja  v a 2 s .com
    imageDb.setWidget(dbContents);

    Image chartImg = new Image(imgurl);

    chartImg.setSize("250", "200");
    dbContents.add(chartImg);

    Button closeButton = new Button("Close", new ClickHandler() {
        public void onClick(ClickEvent event) {
            imageDb.hide();
        }
    });
    dbContents.add(closeButton);
    dbContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_RIGHT);

    imageDb.center();
    imageDb.show();
}

From source file:com.italianasoftware.echoes.client.Echoes.java

License:Open Source License

private void closeClientSession() {
    final DialogBox dialog = new DialogBox();
    dialog.add(new Label("Exiting..."));
    dialog.center();/*from   ww  w .  jav a2s  . c om*/
    dialog.show();
    Value v = getLocationValue();
    v.getNewChild("sid").setValue(sid);
    JolieService.Util.getInstance().call("closeClientSession", v, new EchoesCallback() {
        @Override
        public void onSuccess(Value response) {
            dialog.hide();
        }
    });
}

From source file:com.italianasoftware.echoes.client.EchoesCallback.java

License:Open Source License

private void displayFault(String faultString) {
    final DialogBox dialog = new DialogBox();
    dialog.add(new Label(faultString));
    Button closeButton = new Button("Close");
    closeButton.addClickListener(new ClickListener() {
        public void onClick(Widget arg0) {
            dialog.hide();
        }/*from  w w w  . ja  v a  2  s  .c  om*/
    });
    dialog.center();
    dialog.show();
}

From source file:com.mcherm.zithiacharsheet.client.GetStringDialog.java

License:Apache License

public GetStringDialog(final Action action) {
    final VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.add(new HTML("<b>Enter a string:</b>"));
    final TextArea textEntry = new TextArea();
    dialogVPanel.add(textEntry);/*from  www .  j  a va2  s  . com*/
    final Button okButton = new Button("OK");
    final DialogBox theDialog = this;
    okButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            theDialog.hide();
        }
    });
    dialogVPanel.add(okButton);
    this.setWidget(dialogVPanel);
    this.addCloseHandler(new CloseHandler<PopupPanel>() {
        public void onClose(CloseEvent<PopupPanel> event) {
            action.doAction(textEntry.getText());
        }
    });
}

From source file:com.mecatran.otp.gwt.client.PlannerWidgetEntryPoint.java

License:Open Source License

private void showIntroDialogBox() {
    if (config.getIntroMessage() == null)
        return;/* w w  w .  j a v  a 2s.c  om*/
    final DialogBox dialogBox = new DialogBox(true, true);
    VerticalPanel dialogBoxContents = new VerticalPanel();
    dialogBox.setText(I18nUtils.tr("welcome"));
    HTML message = new HTML(config.getIntroMessage());
    Button button = new Button(I18nUtils.tr("ok"), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
    dialogBox.setWidth("400px");
    dialogBoxContents.add(message);
    dialogBoxContents.add(button);
    dialogBox.setWidget(dialogBoxContents);
    dialogBox.center();
}

From source file:com.mecatran.otp.gwt.client.view.PlannerFormWidget.java

License:Open Source License

private void linkTo() {
    // Create URL
    String url = new PlannerState(getPlanRequestBean()).getUrl();
    // Display dialog box
    final DialogBox dialogBox = new DialogBox(true, true);
    VerticalPanel dialogBoxContents = new VerticalPanel();
    dialogBoxContents.setWidth("100%");
    dialogBox.setText(I18nUtils.tr("link.to.this.page"));
    Label message = new Label(I18nUtils.tr("copy.paste.link.hint"));
    dialogBoxContents.add(message);/*w  w  w .j a va  2s .c o  m*/
    final TextBox urlTextBox = new TextBox();
    urlTextBox.setText(url);
    urlTextBox.setWidth("100%");
    dialogBoxContents.add(urlTextBox);
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            urlTextBox.selectAll();
            urlTextBox.setFocus(true);
        }
    });
    Button button = new Button(I18nUtils.tr("ok"), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
    dialogBoxContents.add(button);
    dialogBox.setWidth("400px");
    dialogBox.setWidget(dialogBoxContents);
    dialogBox.center();
}