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.gwt.sample.feedreader.client.GwtFeedReader.java

License:Apache License

public void onModuleLoad() {
    // The first thing that we want to do is to get the Ajax Feed API
    // to download and initialize. All of the other initialization should
    // be deferred until the iframe kicks off
    Loader.init(getApiFeedKey(), new Loader.LoaderCallback() {
        public void onError(Throwable t) {
            Window.alert("Unable to initialize AJAX Feed API.\n" + t.getMessage());
            t.printStackTrace();/*  w w  w .j a v  a 2 s .  com*/
        }

        public void onLoad() {
            onAjaxFeedLoad();
        }
    });

    // Make sure the Loader's modifications to the DOM have taken effect before
    // we do anything else.
    DeferredCommand.addPause();

    DeferredCommand.addCommand(new Command() {
        public void execute() {
            initialize();
        }
    });
}

From source file:com.google.gwt.sample.guestbook.client.TaskEntryForm.java

@UiHandler("button")
void onClick(ClickEvent e) {
    Window.alert("Hello!");
}

From source file:com.google.gwt.sample.healthyeatingapp.client.FoodLog.FoodLog.java

private void addRow(FlexTable flexTable) {
    int numRows = flexTable.getRowCount();

    if ((lbFG.getSelectedIndex() != 0)) {

        if ((lbFN.getSelectedIndex() != 0)) {

            String str2 = lbFG.getValue(lbFG.getSelectedIndex());
            String str3 = lbFN.getValue(lbFN.getSelectedIndex());
            String str4 = flexTable.getText(numRows - 1, 2);

            FoodLogData e = new FoodLogData(userNameTyped, str3, Integer.parseInt(str4), str2, selectedDate);
            foodEntries.add(e);/*from  ww  w  . j a  v a  2s.  c  o  m*/
            //Kevin's code
            flexTable.insertRow(flexTable.getRowCount());
            numRows = flexTable.getRowCount();
            flexTable.setText(numRows - 2, 0, e.getFoodGroup());
            flexTable.setText(numRows - 2, 1, e.getFoodName());
            flexTable.setText(numRows - 2, 2, e.getCalories() + "");
            flexTable.getFlexCellFormatter().setRowSpan(0, 1, numRows + 1);
            //Kevin's code ends
            //Window.alert(""+numRows);

            /*Nadeem's original code
            flexTable.removeAllRows();
            flexTable.insertRow(0);
            numRows = flexTable.getRowCount();
                    
                    
            int i = 0;
            for (FoodLogData j : foodEntries) {               
                       
               flexTable.insertRow(i + 1);
               numRows = flexTable.getRowCount();
                    
               flexTable.setText(numRows - 1, 0, j.getFoodGroup());
               flexTable.setText(numRows - 1, 1, j.getFoodName());
               flexTable.setText(numRows - 1, 2, j.getCalories()+"");
                    
               flexTable.getFlexCellFormatter().setRowSpan(0, 1,
             numRows + 1);
                       
               i++;
                    
            }*/
            //Nadeem's code ends

            numRows = flexTable.getRowCount();
            lbFG.setSelectedIndex(0);
            flexTable.setWidget(numRows, 0, lbFG);
            flexTable.getFlexCellFormatter().setRowSpan(0, 1, numRows + 1);
        } else {
            Window.alert("Food Item Not Selected.");
        }

    } else if (numRows <= 1) {
        lbFG.setSelectedIndex(0);
        flexTable.setWidget(numRows, 0, lbFG);
        flexTable.getFlexCellFormatter().setRowSpan(0, 1, numRows + 1);
    } else {
        Window.alert("Food Item Not Selected.");

    }

}

From source file:com.google.gwt.sample.healthyeatingapp.client.Homepage.java

public Homepage() {
    initWidget(tp);/*w w w .  j  av a 2  s . co  m*/
    // Add a home tab
    tp.add(new FoodLog(tp).onModuleLoad(), "Food Log");
    tp.add(new SocialMedia().SocialMediaWebPageLoad(), "Social Media");
    this.rpc = (DBConnectionServiceAsync) GWT.create(DBConnectionService.class);
    ServiceDefTarget target = (ServiceDefTarget) rpc;
    String moduleRelativeURL = GWT.getModuleBaseURL() + "DBConnectionServiceImpl";
    target.setServiceEntryPoint(moduleRelativeURL);

    Runnable onLoadCallBack = new Runnable() {
        @Override
        public void run() {
            String username = Cookies.getCookie("healthy_app_user");
            rpc.getUserCalories(username, new AsyncCallback<String>() {

                @Override
                public void onFailure(Throwable caught) {
                    // Show the RPC error message to the user
                    Window.alert("No log records for user:" + Cookies.getCookie("healthy_app_user"));
                }

                @Override
                public void onSuccess(String result) {
                    // TODO Auto-generated method stub
                    DataTable data = toDataTable(result);
                    tp.add(new Graph().returnGraph(data), "Graph");
                }
            });
        }
    };

    VisualizationUtils.loadVisualizationApi(onLoadCallBack, CoreChart.PACKAGE);
}

From source file:com.google.gwt.sample.healthyeatingapp.client.SocialMedia.SocialMedia.java

public FlowPanel SocialMediaWebPageLoad() {

    fp = new FlowPanel();
    ft = new FlexTable();
    flexTableInitialize(ft);//from   w ww.  j a  v a  2  s  . c  om

    Btn = new Button();
    Btn.setSize("100px", "30px");
    Btn.setText("Update");
    Btn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            PointsList.clear();
            ft.removeAllRows();
            ft.setText(0, 0, "Updating");
            ft.getFlexCellFormatter().setColSpan(0, 0, 3);
            ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
            if (FBFriends.Friends.size() == 0) {
                System.out.println("Querying Facebook again");
                Window.alert("Please authenticate with Facebook to use this feature");
                FacebookGraph.getStaticObject().RequestAuthorizationAndQueryGraph("me/friends",
                        new Callback<JSONObject, Throwable>() {

                            @Override
                            public void onFailure(Throwable reason) {
                                // TODO Auto-generated method stub
                                System.out.println(reason.getMessage());
                            }

                            @Override
                            public void onSuccess(JSONObject result) {
                                // TODO Auto-generated method stub
                                JSONArray datas = (JSONArray) result.get("data");
                                for (int i = 0; i < datas.size(); i++) {
                                    JSONObject friend = (JSONObject) datas.get(i);
                                    FBFriends.FriendsNames.add(friend.get("name").toString());
                                }
                                FBFriends.FriendsNameSort(FBFriends.FriendsNames);
                                VerifyFriendAsUser();
                            }

                        });
            }
            VerifyFriendAsUser();
        }
    });
    fp.add(ft);
    fp.add(Btn);
    if (FBFriends.Friends.size() != 0) {
        VerifyFriendAsUser();
    }
    //flexTablePaint();*/
    return fp;
}

From source file:com.google.gwt.sample.hello.client.Hello.java

License:Apache License

public void onModuleLoad() {
    Button b = new Button("Click me", new ClickListener() {
        public void onClick(Widget sender) {
            Window.alert("Hello, AJAX");
        }//from w w  w .  j a  va2 s  .co  m
    });

    RootPanel.get().add(b);
}

From source file:com.google.gwt.sample.hellomaps.client.Map.java

License:Apache License

public void setLocation(String address) {
    // Notice that the callbacks work correctly with anonymous classes
    geocoder.lookup(address, new GeocoderCallback() {
        // This will move the map to the location returned by the service
        @Override//w ww.java  2  s .co m
        public void onGeocode(GLatLng position) {
            if (position == null) {
                Window.alert("The name you entered couldn't be found.");
            } else {
                map.panTo(position);
            }
        }
    });
}

From source file:com.google.gwt.sample.homeworkfive.client.HomeworkFive.java

/**
* Return to work on this to make sure that exclusings work
* 
*///  w w  w  . j a v  a2  s  . co  m
private void addContact() {

    final String name = newNameTextBox.getText().toUpperCase().trim();
    newNameTextBox.setFocus(true);

    final String phone = newPhoneTextBox.getText().toUpperCase().trim();
    newPhoneTextBox.setFocus(true);

    final String email = newEmailTextBox.getText().toUpperCase().trim();
    newEmailTextBox.setFocus(true);

    // E-mail address must contain numbers, letters, dots, and @.
    if (!name.matches("^[A-Z\\.]{1,50}$")) {
        Window.alert("Enter your name again");
        newNameTextBox.selectAll();
        return;

    } else if (!phone.matches("^[0-9\\.]{1,10}$")) {
        Window.alert("Enter a proper phone number");
        newPhoneTextBox.selectAll();
        return;

    } else if (!email.matches("^[0-9A-Z.@\\.]{12,50}$")) {
        Window.alert("Enter a proper email address");
        newEmailTextBox.selectAll();

        return;
    }

    newEmailTextBox.setText("");
    newPhoneTextBox.setText("");
    newNameTextBox.setText("");

    // Don't add the contact if it's already in the table with the same exact information.
    if (contacts.contains(name) && (contacts.contains(phone) && contacts.contains(email)))
        return;

    if (!name.matches("^[A-Z\\.]{1,50}$"))
        return;

    if (!phone.matches("^[0-9\\.]{1,10}$"))
        return;

    if (!email.matches("^[0-9A-Z@\\.]{12,50}$"))
        return;

    // Add the contact to the table.
    int row = contactsFlexTable.getRowCount();
    contacts.add(name);
    contacts.add(phone);
    contacts.add(email);
    contactsFlexTable.setText(row, 0, name);
    contactsFlexTable.setText(row, 1, phone);
    contactsFlexTable.setText(row, 2, email);

    // Add a button to remove this contact from the table.
    Button removeContactButton = new Button("x");
    removeContactButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            int removedIndex = contacts.indexOf(name);
            contacts.remove(removedIndex);
            contactsFlexTable.removeRow(removedIndex + 1);
        }
    });
    contactsFlexTable.setWidget(row, 3, removeContactButton);

}

From source file:com.google.gwt.sample.json.client.JSON.java

License:Apache License

/**
 * Initialize the main form's layout and content.
 *//*  w  w w .j a v  a2 s.c om*/
private void initializeMainForm() {
    searchButton.setStyleName("JSON-SearchButton");
    searchButton.setText(SEARCH_BUTTON_DEFAULT_TEXT);
    searchButton.addClickHandler(new SearchButtonHandler());

    // Avoids showing an "empty" cell
    jsonTree.setVisible(false);

    // Find out where the host page wants the button.
    //
    RootPanel searchButtonSlot = RootPanel.get("search");
    if (searchButtonSlot == null) {
        Window.alert("Please define a container element whose id is 'search'");
        return;
    }

    // Find out where the host page wants the tree view.
    //
    RootPanel treeViewSlot = RootPanel.get("tree");
    if (treeViewSlot == null) {
        Window.alert("Please define a container element whose id is 'tree'");
        return;
    }

    // Add both widgets.
    //
    searchButtonSlot.add(searchButton);
    treeViewSlot.add(jsonTree);
}

From source file:com.google.gwt.sample.kitchensink.client.Menus.java

License:Apache License

public void execute() {
    Window.alert("Thank you for selecting a menu item.");
}