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

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

Introduction

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

Prototype

@Override
    public void show() 

Source Link

Usage

From source file:com.google.appinventor.client.Ode.java

License:Open Source License

/**
 * This dialog is showned if an account is disabled. It is
 * completely modal with no escape. The provided URL is displayed in
 * an iframe, so it can be tailored to each person whose account is
 * disabled.//from   w  w w.j a v  a 2s  . co m
 *
 * @param Url the Url to display in the dialog box.
 */

public void disabledAccountDialog(String Url) {
    // Create the UI elements of the DialogBox
    final DialogBox dialogBox = new DialogBox(false, true); // DialogBox(autohide, modal)
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(MESSAGES.accountDisabledMessage());
    dialogBox.setHeight("700px");
    dialogBox.setWidth("700px");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    VerticalPanel DialogBoxContents = new VerticalPanel();
    HTML message = new HTML(
            "<iframe src=\"" + Url + "\" style=\"border: 0; width: 680px; height: 660px;\"></iframe>");
    message.setStyleName("DialogBox-message");
    DialogBoxContents.add(message);
    dialogBox.setWidget(DialogBoxContents);
    dialogBox.show();
}

From source file:com.google.appinventor.client.Ode.java

License:Open Source License

/**
 * Display a generic warning dialog box.
 * This method is public because it is intended to be used from other
 * parts of the client GWT side system./*from  ww w  .j a  v  a  2 s  .  co m*/
 *
 * Note: We expect our caller to internationalize the messages to be
 * displayed.
 *
 * @param title The title for the dialog box
 * @param message The message to display
 * @param buttonString the name of the button, i.e., "OK"
 */

public void warningDialog(String title, String messageString, String buttonString) {
    // Create the UI elements of the DialogBox
    final DialogBox dialogBox = new DialogBox(false, true); // DialogBox(autohide, modal)
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(title);
    dialogBox.setHeight("100px");
    dialogBox.setWidth("400px");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    VerticalPanel DialogBoxContents = new VerticalPanel();
    HTML message = new HTML("<p>" + messageString + "</p>");
    message.setStyleName("DialogBox-message");
    FlowPanel holder = new FlowPanel();
    Button okButton = new Button(buttonString);
    okButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
        }
    });
    holder.add(okButton);
    DialogBoxContents.add(message);
    DialogBoxContents.add(holder);
    dialogBox.setWidget(DialogBoxContents);
    dialogBox.show();
}

From source file:com.google.appinventor.client.utils.MessageDialog.java

License:Open Source License

/**
 * Put up a modal dialog box.// w  w  w.j  a  v  a2 s. c o  m
 *
 * @param title Title for the dialog, already internationalized
 * @param message Message box content, already internationalized
 * @param OK String for OK button, already internationalized
 * @param Cancel String for Cancel button, null if non, internationalized
 * @param actions Actions object to call upon completion, can be null
 */
public static void messageDialog(String title, String message, String OK, String Cancel,
        final Actions actions) {
    final DialogBox dialogBox = new DialogBox(false, true); // DialogBox(autohide, modal)
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(title);
    dialogBox.setHeight("100px");
    dialogBox.setWidth("400px");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    VerticalPanel DialogBoxContents = new VerticalPanel();
    HTML messageHtml = new HTML("<p>" + message + "</p>");
    messageHtml.setStyleName("DialogBox-message");
    FlowPanel holder = new FlowPanel();
    Button okButton = new Button(OK);
    okButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            if (actions != null)
                actions.onOK();
        }
    });
    holder.add(okButton);
    if (Cancel != null) {
        Button cancelButton = new Button(Cancel);
        cancelButton.addClickListener(new ClickListener() {
            @Override
            public void onClick(Widget sender) {
                dialogBox.hide();
                if (actions != null)
                    actions.onCancel();
            }
        });
        holder.add(cancelButton);
    }
    DialogBoxContents.add(messageHtml);
    DialogBoxContents.add(holder);
    dialogBox.setWidget(DialogBoxContents);
    dialogBox.show();
}

From source file:com.google.appinventor.client.wizards.FileUploadWizard.java

License:Open Source License

private void createErrorDialog(String title, String body, Error e, final FolderNode folderNode,
        final FileUploadedCallback fileUploadedCallback) {
    final DialogBox dialogBox = new DialogBox(false, true);
    HTML message;//  w  w  w.  j a  v a  2s  . c  om
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setHeight("150px");
    dialogBox.setWidth("350px");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    VerticalPanel DialogBoxContents = new VerticalPanel();
    FlowPanel holder = new FlowPanel();
    Button ok = new Button("OK");
    ok.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            new FileUploadWizard(folderNode, fileUploadedCallback).show();
        }
    });
    holder.add(ok);
    dialogBox.setText(title);
    message = new HTML(body);

    switch (e) {
    case AIAMEDIAASSET:
        Button info = new Button("More Info");
        info.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                Window.open(MESSAGES.aiaMediaAssetHelp(), "AIA Help", "");
            }
        });
        holder.add(info);
    case NOFILESELECETED:
    case MALFORMEDFILENAME:
    case FILENAMEBADSIZE:
    default:
        break;
    }

    message.setStyleName("DialogBox-message");
    DialogBoxContents.add(message);
    DialogBoxContents.add(holder);
    dialogBox.setWidget(DialogBoxContents);
    dialogBox.show();
}

From source file:com.google.appinventor.client.youngandroid.YoungAndroidFormUpgrader.java

License:Open Source License

private static void upgradeWarnDialog(String aMessage) {
    final DialogBox dialogBox = new DialogBox(false, true);
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(MESSAGES.warningDialogTitle());
    dialogBox.setGlassEnabled(true);/* ww  w.j a  v a  2s  .co m*/
    dialogBox.setAnimationEnabled(true);
    final HTML message = new HTML(aMessage);
    message.setStyleName("DialogBox-message");
    VerticalPanel vPanel = new VerticalPanel();
    Button okButton = new Button("OK");
    okButton.addClickListener(new ClickListener() {
        @Override
        public void onClick(Widget sender) {
            dialogBox.hide();
        }
    });
    vPanel.add(message);
    vPanel.add(okButton);
    dialogBox.setWidget(vPanel);
    dialogBox.center();
    dialogBox.show();
}

From source file:com.google.caliper.cloud.client.BenchmarkDataViewer.java

License:Apache License

public void rebuildResultsTable() {
    if (plainText) {
        Label label = new Label();
        label.setStyleName("plaintext");
        label.setText(gridToString(toGrid()));

        resultsDiv.clear();//from  w ww.  j ava 2s  .  c  om
        resultsDiv.add(label);
        resultsDiv.add(new PlainTextEditor().getWidget());
        HTML dash = new HTML(" - ", false);
        dash.setStyleName("inline");
        resultsDiv.add(dash);
        resultsDiv.add(new SnapshotCreator().getWidget());
        return;
    }

    FlexTable table = new FlexTable();
    table.setStyleName("data");
    int r = 0;
    int c = 0;
    int evenRowMod = 0;

    // results header #1: cValue variables
    if (cVariable != null) {
        evenRowMod = 1;
        table.insertRow(r);
        table.getRowFormatter().setStyleName(r, "valueRow");
        table.getRowFormatter().addStyleName(r, "headerRow");

        table.addCell(r);
        table.getFlexCellFormatter().setColSpan(r, 0, rVariables.size());
        c++;
        for (Value cValue : cValues) {
            table.addCell(r);
            table.getFlexCellFormatter().setColSpan(r, c, 3);
            table.getCellFormatter().setStyleName(r, c, "parameterKey");

            Widget contents = newVariableLabel(cVariable, cValue.getLabel(), rVariables.size());
            contents.setStyleName("valueHeader");

            table.setWidget(r, c++, contents);
        }
        r++;
    }

    // results header 2: rValue variables, followed by "nanos/barchart" column pairs
    c = 0;
    table.insertRow(r);
    table.getRowFormatter().setStyleName(r, "evenRow");
    table.getRowFormatter().addStyleName(r, "headerRow");
    for (Variable variable : rVariables) {
        table.addCell(r);
        table.getCellFormatter().setStyleName(r, c, "parameterKey");
        table.setWidget(r, c, newVariableLabel(variable, variable.getName(), c));
        c++;
    }
    for (Value unused : cValues) {
        table.addCell(r);
        table.getCellFormatter().setStyleName(r, c, "parameterKey");
        table.setWidget(r, c++, newUnitLabel(unitMap.get(selectedType).trim()));

        table.addCell(r);
        table.getCellFormatter().setStyleName(r, c, "parameterKey");
        table.setWidget(r, c++, newRuntimeLabel());

        table.addCell(r);
        table.getCellFormatter().setStyleName(r, c, "parameterKey");
        table.setWidget(r, c++, new InlineLabel("%"));
    }
    r++;

    Key key = newDefaultKey();
    for (RowsIterator rows = new RowsIterator(rVariables); rows.nextRow();) {
        rows.updateKey(key);

        table.insertRow(r);
        table.getRowFormatter().setStyleName(r, r % 2 == evenRowMod ? "evenRow" : "oddRow");
        c = 0;
        for (int v = 0, size = rVariables.size(); v < size; v++) {
            table.addCell(r);
            table.setWidget(r, c++, new Label(rows.getRValue(v).getLabel()));
        }

        for (Value value : cValues) {
            table.addCell(r);
            table.addCell(r);

            if (cVariable != null) {
                key.set(cVariable, value);
            }

            final Datapoint datapoint = keysToDatapoints.get(key);
            table.getCellFormatter().setStyleName(r, c, "numericCell");
            table.getCellFormatter().setStyleName(r, c + 1, "bar");
            table.getCellFormatter().setStyleName(r, c + 2, "numericCell");
            MeasurementSet measurementSet;
            if (datapoint != null
                    && (measurementSet = datapoint.scenarioResults.getMeasurementSet(selectedType)) != null) {
                double rawMedian = getMedian(selectedType, measurementSet);
                String displayedValue = numberFormatMap.get(selectedType)
                        .format(rawMedian / divideByMap.get(selectedType));
                Anchor valueAnchor = new Anchor(displayedValue, false);
                valueAnchor.setStyleName("subtleLink");
                valueAnchor.setStyleName("nanos", true);

                final DialogBox eventLogPopup = new DialogBox(true);
                eventLogPopup.setText("");

                valueAnchor.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent clickEvent) {
                        // Do this lazily since it takes quite a bit of time to render these popups for all
                        // the scenarios shown, and quite often they won't even be used.
                        if (eventLogPopup.getText().isEmpty()) {
                            eventLogPopup.setText("Event Log");
                            String eventLog = datapoint.scenarioResults.getEventLog(selectedType);
                            if (eventLog == null || eventLog.isEmpty()) {
                                eventLog = "No event log recorded.";
                            }
                            FlowPanel panel = new FlowPanel();
                            for (String line : eventLog.split("\n")) {
                                panel.add(new Label(line));
                            }
                            panel.setStyleName("eventLog");
                            eventLogPopup.add(panel);
                        }
                        eventLogPopup.center();
                        eventLogPopup.show();
                    }
                });

                table.setWidget(r, c, valueAnchor);
                table.setWidget(r, c + 1, newBar(datapoint.style, measurementSet, value));
                table.setWidget(r, c + 2, newPercentOfReferencePointLabel(rawMedian, value));
            } else {
                table.setWidget(r, c, new Label(""));
                table.setWidget(r, c + 1, new Label(""));
                table.setWidget(r, c + 2, new Label(""));
            }
            c += 3;
        }

        r++;
    }
    resultsDiv.clear();
    resultsDiv.add(table);
    resultsDiv.add(new PlainTextEditor().getWidget());
    HTML dash = new HTML(" - ", false);
    dash.setStyleName("inline");
    resultsDiv.add(dash);
    resultsDiv.add(new SnapshotCreator().getWidget());
}

From source file:com.google.code.gwt.appcache.sample.helloappcache.client.HelloApplicationCache.java

License:Apache License

/**
 * This is the entry point method./*  ww w  . j  a v a2s.co m*/
 */
public void onModuleLoad() {
    Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png");
    Button button = new Button("Click me");

    VerticalPanel vPanel = new VerticalPanel();
    // We can add style names.
    vPanel.addStyleName("widePanel");
    vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    vPanel.add(img);
    vPanel.add(button);

    // Add image and button to the RootPanel
    RootPanel.get().add(vPanel);

    // Create the dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Welcome to GWT ApplicationCache Demo!");
    dialogBox.setAnimationEnabled(true);
    Button closeButton = new Button("close");
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setWidth("100%");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    dialogVPanel.add(closeButton);

    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });

    // Set the contents of the Widget
    dialogBox.setWidget(dialogVPanel);

    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            // Invoke service:
            HelloServiceAsync service = GWT.create(HelloService.class);
            service.sayHello("Bart", new AsyncCallback<String>() {
                public void onFailure(Throwable caught) {
                    dialogBox.setText("Could not invoke 'sayHello' service: " + caught);
                    dialogBox.center();
                    dialogBox.show();
                }

                public void onSuccess(String result) {
                    dialogBox.setText(result + "! Welcome to GWT ApplicationCache Demo!");
                    dialogBox.center();
                    dialogBox.show();
                }
            });
        }
    });
}

From source file:com.google.code.gwt.database.sample.hellodatabase.client.HelloDatabase.java

License:Apache License

/**
 * This is the entry point method./*from  ww  w.  j  ava 2 s  .  c  o  m*/
 */
public void onModuleLoad() {
    if (!Database.isSupported()) {
        Window.alert("HTML 5 Database is NOT supported in this browser!");
        return;
    }

    // Create the dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Welcome to GWT Database Demo!");
    dialogBox.setAnimationEnabled(true);
    Button closeButton = new Button("close", new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setWidth("100%");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    final VerticalPanel clickedData = new VerticalPanel();
    dialogVPanel.add(clickedData);
    dialogVPanel.add(closeButton);

    dialogBox.setWidget(dialogVPanel);

    Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png");
    Button addClickButton = new Button("Add Click", new ClickHandler() {
        public void onClick(ClickEvent event) {
            dbService.insertClick(new Date(), new RowIdListCallback() {
                public void onFailure(DataServiceException error) {
                    Window.alert("Failed to add click! " + error);
                }

                public void onSuccess(final List<Integer> rowIds) {
                    dbService.getClicks(new ListCallback<ClickRow>() {
                        public void onFailure(DataServiceException error) {
                            Window.alert("Failed to query clicks! " + error);
                        }

                        public void onSuccess(List<ClickRow> result) {
                            clickedData.clear();
                            clickedData.add(new Label("Last click insert ID: " + rowIds.get(0)));
                            for (ClickRow row : result) {
                                clickedData.add(new Label("Clicked on " + row.getClicked()));
                            }
                            dialogBox.center();
                            dialogBox.show();
                        }
                    });
                }
            });
        }
    });
    Button getCountButton = new Button("Get Counts", new ClickHandler() {
        public void onClick(ClickEvent event) {
            getCount();
        }
    });

    vPanel = new VerticalPanel();
    // We can add style names.
    vPanel.addStyleName("widePanel");
    vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    vPanel.add(img);
    vPanel.add(addClickButton);
    vPanel.add(getCountButton);

    // Add image and button to the RootPanel
    RootPanel.get().add(vPanel);

    // Create table 'clickcount' if it doesn't exist already:
    dbService.initTable(new VoidCallback() {
        public void onFailure(DataServiceException error) {
            Window.alert("Failed to initialize table! " + error);
        }

        public void onSuccess() {
            Window.alert("Database initialized successfully.");
            getCount();
        }
    });

    getVersion();
}

From source file:com.google.code.gwt.iui.sample.helloiui.client.HelloiUI.java

License:Apache License

/**
 * This is the entry point method./*from www  .  j a v  a2s .com*/
 */
public void onModuleLoad() {
    Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png");
    Button button = new Button("Click me");

    VerticalPanel vPanel = new VerticalPanel();
    // We can add style names.
    vPanel.addStyleName("widePanel");
    vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    vPanel.add(img);
    vPanel.add(button);

    // Add image and button to the RootPanel
    RootPanel.get().add(vPanel);

    // Create the dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Welcome to GWT iUI Demo!");
    dialogBox.setAnimationEnabled(true);
    Button closeButton = new Button("close");
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setWidth("100%");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    dialogVPanel.add(closeButton);

    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });

    // Set the contents of the Widget
    dialogBox.setWidget(dialogVPanel);

    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.center();
            dialogBox.show();
        }
    });
}

From source file:com.google.code.gwt.template.sample.hellotemplate.client.HelloTemplate.java

License:Apache License

/**
 * This is the entry point method.//www.  j av  a 2s  .  co m
 */
public void onModuleLoad() {
    Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png");
    Button button = new Button("Click me");

    VerticalPanel vPanel = new VerticalPanel();
    // We can add style names.
    vPanel.addStyleName("widePanel");
    vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    vPanel.add(img);
    vPanel.add(button);

    // Add image and button to the RootPanel
    RootPanel.get().add(vPanel);

    // Create the dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Welcome to GWT Template Demo!");
    dialogBox.setAnimationEnabled(true);
    Button closeButton = new Button("close");
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setWidth("100%");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    dialogVPanel.add(closeButton);

    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });

    // Set the contents of the Widget
    dialogBox.setWidget(dialogVPanel);

    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.center();
            dialogBox.show();
        }
    });
}