Example usage for com.google.gwt.user.client Window alert

List of usage examples for com.google.gwt.user.client Window alert

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window alert.

Prototype

public static void alert(String msg) 

Source Link

Usage

From source file:com.google.api.gwt.oauth2.samples.multi.client.OAuth2SampleEntryPoint.java

License:Apache License

private void addWindowsLiveAuth() {
    // Since the auth flow requires opening a popup window, it must be started
    // as a direct result of a user action, such as clicking a button or link.
    // Otherwise, a browser's popup blocker may block the popup.
    Button button = new Button("Authenticate with Windows Live");
    button.addClickHandler(new ClickHandler() {
        @Override//w  w  w  .  ja va  2  s  . co m
        public void onClick(ClickEvent event) {
            final AuthRequest req = new AuthRequest(WINDOWS_LIVE_AUTH_URL, WINDOWS_LIVE_CLIENT_ID)
                    .withScopes(WINDOWS_LIVE_BASIC_SCOPE);
            AUTH.login(req, new Callback<String, Throwable>() {
                @Override
                public void onSuccess(String token) {
                    Window.alert("Got an OAuth token:\n" + token + "\n" + "Token expires in "
                            + AUTH.expiresIn(req) + " ms\n");
                }

                @Override
                public void onFailure(Throwable caught) {
                    Window.alert("Error:\n" + caught.getMessage());
                }
            });
        }
    });
    RootPanel.get().add(button);
}

From source file:com.google.api.gwt.oauth2.samples.multi.client.OAuth2SampleEntryPoint.java

License:Apache License

private void addClearTokens() {
    Button button = new Button("Clear stored tokens");
    button.addClickHandler(new ClickHandler() {
        @Override/*  w ww.  j  av  a  2s  .  c o m*/
        public void onClick(ClickEvent event) {
            Auth.get().clearAllTokens();
            Window.alert("All tokens cleared");
        }
    });
    RootPanel.get().add(button);
}

From source file:com.google.api.gwt.samples.calendar.client.CalendarEntryPoint.java

License:Apache License

/** Delete an event by its ID. */
private void deleteEvent(String calendarId, String eventId) {
    calendar.events().delete(calendarId, eventId).fire(new Receiver<EmptyResponse>() {
        @Override//from  w  ww.  ja v a 2 s . co  m
        public void onSuccess(EmptyResponse r) {
            // The event has been deleted. And we're done!
            Window.alert("Event deleted! Demo complete!");
        }
    });
}

From source file:com.google.api.gwt.samples.urlshortener.client.UrlshortenerEntryPoint.java

License:Apache License

/** Demonstrates initialization of the RequestTransport. */
private void initialize(String accessToken) {
    new ClientGoogleApiRequestTransport().setApiAccessKey(API_KEY).setApplicationName(APPLICATION_NAME)
            .setAccessToken(accessToken).create(new Receiver<GoogleApiRequestTransport>() {
                @Override/*from   w ww  . j  ava 2s . c  o m*/
                public void onSuccess(GoogleApiRequestTransport transport) {
                    urlShortener.initialize(new SimpleEventBus(), transport);

                    expand();
                }

                @Override
                public void onFailure(ServerFailure error) {
                    Window.alert("Failed to initialize Transport");
                }
            });
}

From source file:com.google.api.gwt.samples.urlshortener.client.UrlshortenerEntryPoint.java

License:Apache License

/** Demonstrates expanding a short URL by requesting its information. */
private void expand() {
    String shortUrl = Window.prompt("Enter a short URL", "http://goo.gl/xwrT5");

    // Get a new RequestContext which we will execute.
    UrlContext urlContext = urlShortener.url();

    // Fire a get() request with the short URL we want to expand.
    urlContext.get(shortUrl).fire(new Receiver<Url>() {
        @Override//w w  w  .  j  av  a2s. com
        public void onSuccess(Url response) {
            Window.alert("Long URL: " + response.getLongUrl() + "\n" //
                    + "Short URL: " + response.getId() + "\n" //
                    + "Status: " + response.getStatus());

            shorten();
        }

        @Override
        public void onFailure(ServerFailure error) {
            Window.alert("Error expanding a URL\n" + error.getMessage());
        }
    });
}

From source file:com.google.api.gwt.samples.urlshortener.client.UrlshortenerEntryPoint.java

License:Apache License

/** Demonstrates shortening a URL by inserting a new {@link Url} object. */
private void shorten() {
    String longUrl = Window.prompt("Enter a long URL",
            "http://gwt-google-apis.googlecode.com/svn/trunk/apis/samples/urlshortener/demo/"
                    + "urlshortener.html");

    // Get a new RequestContext which we will execute.
    UrlContext urlContext = urlShortener.url();

    // Create a new Url instance with the longUrl we want to insert.
    Url url = urlContext.create(Url.class).setLongUrl(longUrl);

    // Fire an insert() request with the Url to insert.
    urlContext.insert(url).fire(new Receiver<Url>() {
        @Override/*w  w w  .  ja v a2  s.  c  o  m*/
        public void onSuccess(Url response) {
            Window.alert("Long URL: " + response.getLongUrl() + "\n" //
                    + "Short URL: " + response.getId() + "\n" //
                    + "Status: " + response.getStatus());
        }

        @Override
        public void onFailure(ServerFailure error) {
            Window.alert("Error shortening a URL\n" + error.getMessage());
        }
    });
}

From source file:com.google.api.services.samples.calendar.appengine.client.CalendarGwtSample.java

License:Apache License

static void handleFailure(Throwable caught) {
    if (caught instanceof AuthenticationException) {
        Window.Location.reload();
    } else {/*from   w  w  w.j a  va  2 s. c  o m*/
        caught.printStackTrace();
        Window.alert("ERROR: " + caught.getMessage());
    }
}

From source file:com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidAssetSelectorPropertyEditor.java

License:Open Source License

@Override
protected boolean okAction() {
    int selected = assetsList.getSelectedIndex();
    if (selected == -1) {
        Window.alert(MESSAGES.noAssetSelected());
        return false;
    }/*from   ww w  .  java2  s.  c o  m*/
    property.setValue(choices.getValueAtIndex(selected));
    return true;
}

From source file:com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidComponentSelectorPropertyEditor.java

License:Open Source License

@Override
protected boolean okAction() {
    int selected = componentsList.getSelectedIndex();
    if (selected == -1) {
        Window.alert(MESSAGES.noComponentSelected());
        return false;
    }//  ww  w.j  a v a  2 s .c o  m
    property.setValue(choices.getValueAtIndex(selected));
    return true;
}

From source file:com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidLengthPropertyEditor.java

License:Open Source License

@Override
protected boolean okAction() {
    if (automaticRadioButton.isChecked()) {
        property.setValue(CONST_AUTOMATIC);
    } else if (fillParentRadioButton.isChecked()) {
        property.setValue(CONST_FILL_PARENT);
    } else if (customLengthRadioButton.isChecked()) {
        // Custom length
        String text = customLengthField.getText();
        // Make sure it's a non-negative number.  It is important
        // that this check stay within the custom length case because
        // CONST_AUTOMATIC and CONST_FILL_PARENT are deliberately negative.
        boolean success = false;
        try {/*from w w w . j  ava 2s . co  m*/
            if (Integer.parseInt(text) >= 0) {
                success = true;
            }
        } catch (NumberFormatException e) {
            // fall through with success == false
        }
        if (!success) {
            Window.alert(MESSAGES.nonnumericInputError());
            return false;
        }
        property.setValue(text);
    } else { // Percent field!
        String text = percentLengthField.getText();
        boolean success = false;
        try {
            int v = Integer.parseInt(text);
            if (v > 0 && v <= 100) {
                success = true;
                property.setValue("" + (-v + MockVisibleComponent.LENGTH_PERCENT_TAG));
            }
        } catch (NumberFormatException e) {
            // fall through with success == false
        }
        if (!success) {
            Window.alert(MESSAGES.nonvalidPercentValue());
            return false;
        }
    }
    return true;
}