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.github.tdesjardins.ol3.demo.client.example.SelectFeaturesExample.java

License:Apache License

@Override
public void show(String exampleId) {

    Coordinate centerCoordinate = OLFactory.createCoordinate(13.37, 52.52);
    Coordinate transformedMidPoint = Projection.transform(centerCoordinate, DemoConstants.EPSG_4326,
            DemoConstants.EPSG_3857);//from  w w  w.j  av a  2  s. com

    // create a polygon
    Polygon polygon = DemoUtils.createTestPolygon();

    // create a feature
    FeatureOptions featureOptions = OLFactory.createOptions();
    // TODO Setter for ID seems to doesn't have an effect in feature options.
    // featureOptions.setId("g1");
    featureOptions.setGeometry(polygon);

    Feature feature = new Feature(featureOptions);
    feature.setId("g1");
    feature.set("name", "triangle");

    // create another feature via cloning
    Feature feature2 = feature.clone();
    feature2.setId("g2");
    feature2.getGeometry().rotate(180, transformedMidPoint);

    Collection<Feature> lstFeatures = new Collection<Feature>();
    lstFeatures.push(feature);
    lstFeatures.push(feature2);

    VectorOptions vectorSourceOptions = OLFactory.createOptions();
    vectorSourceOptions.setFeatures(lstFeatures);
    Vector vectorSource = new Vector(vectorSourceOptions);

    VectorLayerOptions vectorLayerOptions = OLFactory.createOptions();
    vectorLayerOptions.setSource(vectorSource);
    ol.layer.Vector vectorLayer = new ol.layer.Vector(vectorLayerOptions);

    // create an OSM-layer
    XyzOptions osmSourceOptions = OLFactory.createOptions();
    Osm osmSource = new Osm(osmSourceOptions);
    LayerOptions osmLayerOptions = OLFactory.createOptions();
    osmLayerOptions.setSource(osmSource);
    Tile osmLayer = new Tile(osmLayerOptions);

    // create a view
    View view = new View();

    view.setCenter(transformedMidPoint);
    view.setZoom(14);

    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Collection<Base> lstLayer = new Collection<Base>();
    lstLayer.push(osmLayer);
    lstLayer.push(vectorLayer);
    mapOptions.setLayers(lstLayer);
    Map map = new Map(mapOptions);

    // add some controls
    map.addControl(OLFactory.createScaleLine());

    MousePositionOptions mousePositionOptions = OLFactory.createOptions();
    ProjectionOptions projectionOptions = OLFactory.createOptions();
    projectionOptions.setCode(DemoConstants.EPSG_4326);
    mousePositionOptions.setProjection(OLFactory.createProjection(projectionOptions));

    MousePosition mousePosition = new MousePosition(mousePositionOptions);
    mousePosition.setCoordinateFormat(Coordinate.createStringXY(5));
    map.addControl(mousePosition);

    SelectOptions selectOptions = new SelectOptions();
    selectOptions.setCondition(Condition.getClick());

    // create a select interaction
    final Select selectFeature = new Select(selectOptions);
    map.addInteraction(selectFeature);

    EventListener<Select.Event> selectListener = new EventListener<Select.Event>() {

        @Override
        public void onEvent(Select.Event event) {

            Collection<Feature> selectedFeatures = selectFeature.getFeatures();

            if (selectedFeatures.getLength() > 0) {
                Feature feature = selectedFeatures.item(0);
                String output = "You selected feature with id '" + feature.getId() + "'" + " and name '"
                        + feature.get("name") + "'" + " and geometry name '" + feature.getGeometryName() + "'"
                        + ".";
                Window.alert(output);
            }

        }

    };

    selectFeature.on("select", selectListener);

}

From source file:com.github.tdesjardins.ol3.demo.client.example.TileExample.java

License:Apache License

@Override
public void show(String exampleId) {

    LayerOptions stamenLayerOptions = OLFactory.createOptions();

    // create a Stamen-layer
    StamenOptions stamenOptions = OLFactory.createOptions();
    stamenOptions.setLayer("watercolor");

    Stamen stamenSource = new Stamen(stamenOptions);
    stamenLayerOptions.setSource(stamenSource);
    Tile stamenLayer = new Tile(stamenLayerOptions);

    // create a view
    View view = new View();

    Coordinate centerCoordinate = OLFactory.createCoordinate(1490463, 6894388);

    view.setCenter(centerCoordinate);//w w w . j  a  v  a  2 s  .  c om
    view.setZoom(10);

    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);

    Map map = new Map(mapOptions);

    stamenLayer.setOpacity(0.5f);

    // add some controls
    map.addControl(new ScaleLine());
    DemoUtils.addDefaultControls(map.getControls());

    Attribution attribution = new Attribution();
    attribution.setCollapsed(true);

    map.addControl(attribution);

    // add some interactions
    map.addInteraction(new KeyboardPan());
    map.addInteraction(new KeyboardZoom());

    DragAndDrop dragAndDrop = new DragAndDrop();
    map.addInteraction(dragAndDrop);

    EventListener<DragAndDrop.Event> eventListener = new EventListener<DragAndDrop.Event>() {

        @Override
        public void onEvent(DragAndDrop.Event event) {
            Window.alert(String.valueOf(event.getFeatures().length));
            Window.alert(event.getProjection().getUnits());
            Window.alert(String.valueOf(event.getProjection().getMetersPerUnit()));

        }
    };

    dragAndDrop.on("addfeatures", eventListener);

    map.addControl(new Rotate());

    map.getLayers().push(stamenLayer);

}

From source file:com.github.tdesjardins.ol3.demo.client.example.WfsExample.java

License:Apache License

@Override
public void show(String exampleId) {

    // create a vector layer
    Vector vectorSource = new Vector();
    VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
    vectorLayerOptions.setSource(vectorSource);
    ol.layer.Vector wfsLayer = new ol.layer.Vector(vectorLayerOptions);

    // create a view
    View view = new View();

    Coordinate centerCoordinate = new Coordinate(-8908887.277395891, 5381918.072437216);
    view.setCenter(centerCoordinate);/*www. ja v a  2s  .  c om*/
    view.setZoom(12);
    view.setMaxZoom(19);

    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);

    Map map = new Map(mapOptions);

    map.addLayer(DemoUtils.createOsmLayer());
    map.addLayer(wfsLayer);

    Wfs wfs = new Wfs();
    WfsWriteFeatureOptions wfsWriteFeatureOptions = new WfsWriteFeatureOptions();

    String[] featureTypes = { "water_areas" };
    wfsWriteFeatureOptions.setSrsName(DemoConstants.EPSG_3857);
    wfsWriteFeatureOptions.setFeaturePrefix("osm");
    wfsWriteFeatureOptions.setFeatureNS("http://openstreemap.org");
    wfsWriteFeatureOptions.setFeatureTypes(featureTypes);

    // set a filter
    wfsWriteFeatureOptions.setFilter(new IsLike("name", "Mississippi*"));
    wfsWriteFeatureOptions.setOutputFormat("application/json");

    // create WFS-XML node
    Node wfsNode = wfs.writeGetFeature(wfsWriteFeatureOptions);

    RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST,
            "https://ahocevar.com/geoserver/wfs");
    requestBuilder.setRequestData(new XMLSerializer().serializeToString(wfsNode));
    requestBuilder.setCallback(new RequestCallback() {

        @Override
        public void onResponseReceived(com.google.gwt.http.client.Request request, Response response) {

            GeoJson geoJson = new GeoJson();
            Feature[] features = geoJson.readFeatures(response.getText());

            vectorSource.addFeatures(features);
            map.getView().fit(vectorSource.getExtent());
        }

        @Override
        public void onError(com.google.gwt.http.client.Request request, Throwable exception) {
            Window.alert(exception.getMessage());
        }

    });

    try {
        requestBuilder.send();
    } catch (RequestException e) {
        Window.alert(e.getMessage());
    }

}

From source file:com.goodow.wave.client.wavepanel.blip.SetColor.java

License:Apache License

@Override
public void onBrowserEvent(final Event event) {
    if (DOM.eventGetType(event) == Event.ONCLICK) {
        if (changeElm == null) {
            Window.alert("changeElm is null!");
            return;
        }//w ww  .  j a  v  a  2 s  . c o  m

        NodeList<Element> aTags = changeElm.getElementsByTagName("span");
        Element aTag = aTags.getItem(1);
        Element elm = Element.as(event.getEventTarget());
        Style elmStyle = elm.getStyle();
        Style aTagStyle = aTag.getStyle();

        if (elm.getTitle().equals("White") || elm.getTitle().equals("20% Black")) {
            aTagStyle.setBackgroundColor(elmStyle.getBackgroundColor());
            aTagStyle.setColor("black");
            aTagStyle.setBorderStyle(BorderStyle.SOLID);
            aTagStyle.setBorderWidth(1, Unit.PX);
            aTagStyle.setBorderColor("black");
            aTagStyle.setTextDecoration(TextDecoration.NONE);
        } else {
            if (!aTagStyle.getBorderWidth().equals("")) {
                aTagStyle.clearBorderColor();
                aTagStyle.clearBorderStyle();
                aTagStyle.clearBorderWidth();
            }
            aTagStyle.setTextDecoration(TextDecoration.NONE);
            aTagStyle.setBackgroundColor(elmStyle.getBackgroundColor());
            aTagStyle.setColor("white");
        }
        // Window.alert("title:" + elm.getTitle() + ";color:" + elm.getStyle().getBackgroundColor());
    }
}

From source file:com.google.api.explorer.client.embedded.EmbeddedParameterFormPresenter.java

License:Apache License

public void submit() {
    Preconditions.checkState(method != null);
    final RestApiRequest req = new RestApiRequest(service, method);

    // If the user has declared a body, set it on the request.
    String body = display.getBodyText();
    if (!body.isEmpty()) {
        req.body = body;/*from   w w w  . j a va2 s . c o  m*/
        req.addHeader("Content-Type", "application/json");
    }

    Multimap<String, String> paramValues = display.getParameterValues();
    for (Map.Entry<String, String> entry : paramValues.entries()) {
        if (entry.getValue().isEmpty()) {
            continue;
        }
        req.getParamValues().put(entry.getKey(), entry.getValue());
    }

    // Do not send the API key if the service is a public-only API.
    req.setUseApiKey(!ExplorerConfig.PUBLIC_ONLY_APIS.contains(service.getName()));

    // Set the auth header if we have a token.
    AuthToken oauth2Token = authManager.getToken(service);
    if (oauth2Token != null) {
        req.addHeader("Authorization", "Bearer " + oauth2Token.getAuthToken());
    }

    display.setExecuting(true);

    final long start = System.currentTimeMillis();
    req.send(new AsyncCallback<ApiResponse>() {
        @Override
        public void onSuccess(ApiResponse response) {
            display.setExecuting(false);
            callback.finished(req, response, start, System.currentTimeMillis());
        }

        @Override
        public void onFailure(Throwable caught) {
            display.setExecuting(false);
            // TODO(jasonhall): Better error handling when request fails (i.e.,
            // cannot communicate at all).
            Window.alert("An error occured: " + caught.getMessage());
        }
    });

    // This has to be after the actual send so that the API key gets initialized properly.
    callback.starting(req);
}

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

License:Apache License

private void addGoogleAuth() {
    // 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 Google");
    button.addClickHandler(new ClickHandler() {
        @Override//from  www .  ja  v a 2  s . c o  m
        public void onClick(ClickEvent event) {
            final AuthRequest req = new AuthRequest(GOOGLE_AUTH_URL, GOOGLE_CLIENT_ID)
                    .withScopes(PLUS_ME_SCOPE);

            // Calling login() will display a popup to the user the first time it is
            // called. Once the user has granted access to the application,
            // subsequent calls to login() will not display the popup, and will
            // immediately result in the callback being given the token to use.
            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 addInstagramAuth() {
    // 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 Instagram");
    button.addClickHandler(new ClickHandler() {
        @Override//from  w  ww. jav a 2s. co  m
        public void onClick(ClickEvent event) {
            final AuthRequest req = new AuthRequest(INSTAGRAM_AUTH_URL, INSTAGRAM_CLIENT_ID)
                    .withScopes(INSTAGRAM_COMMENTS_SCOPE, INSTAGRAM_LIKES_SCOPE)
                    // Instagram expects a plus-delimited list of scopes
                    .withScopeDelimiter("+");
            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 addFoursquareAuth() {
    // 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 Foursquare");
    button.addClickHandler(new ClickHandler() {
        @Override//  www .ja  v a  2 s  .c o m
        public void onClick(ClickEvent event) {
            final AuthRequest req = new AuthRequest(FOURSQUARE_AUTH_URL, FOURSQUARE_CLIENT_ID);
            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 addFacebookAuth() {
    // 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 Facebook");
    button.addClickHandler(new ClickHandler() {
        @Override//from w  w w .j  a  v  a  2 s .c  o  m
        public void onClick(ClickEvent event) {
            final AuthRequest req = new AuthRequest(FACEBOOK_AUTH_URL, FACEBOOK_CLIENT_ID)
                    .withScopes(FACEBOOK_EMAIL_SCOPE, FACEBOOK_BIRTHDAY_SCOPE)
                    // Facebook expects a comma-delimited list of scopes
                    .withScopeDelimiter(",");
            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 addDailymotionAuth() {
    // 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 Dailymotion");
    button.addClickHandler(new ClickHandler() {
        @Override/*  ww  w  . ja  va 2 s.  c o m*/
        public void onClick(ClickEvent event) {
            final AuthRequest req = new AuthRequest(DAILYMOTION_AUTH_URL, DAILYMOTION_CLIENT_ID);
            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);
}