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.stockwatcher.client.StockWatcher2.java

/**
* Add stock to FlexTable. Executed when the user clicks the addStockButton or
* presses enter in the newSymbolTextBox.
*/// w ww.ja  v a2 s.c om
private void addStock() {
    // TODO Auto-generated method stub
    final String symbol = newSymbolTextBox.getText().toUpperCase().trim();
    newSymbolTextBox.setFocus(true);

    // Stock code must be between 1 and 10 chars that are numbers, letters, or dots.
    if (!symbol.matches("^[0-9A-Z\\.]{1,10}$")) {
        Window.alert("'" + symbol + "' is not a valid symbol.");
        newSymbolTextBox.selectAll();
        return;

    }

    newSymbolTextBox.setText("");

    // Don't add the stock if it's already in the table.
    if (stocks.contains(symbol))
        return;

    // Add the stock to the table.
    int row = stocksFlexTable.getRowCount();
    stocks.add(symbol);
    stocksFlexTable.setText(row, 0, symbol);
    //
    stocksFlexTable.setWidget(row, 2, new Label());
    stocksFlexTable.getCellFormatter().addStyleName(row, 1, "watchListNumericColumn");
    stocksFlexTable.getCellFormatter().addStyleName(row, 2, "watchListNumericColumn");
    stocksFlexTable.getCellFormatter().addStyleName(row, 3, "watchListRemoveColumn");

    // TODO Add a button to remove this stock from the table.
    // Add a button to remove this stock from the table.
    Button removeStockButton = new Button("x");
    removeStockButton.addStyleDependentName("remove");
    removeStockButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            int removedIndex = stocks.indexOf(symbol);
            stocks.remove(removedIndex);
            stocksFlexTable.removeRow(removedIndex + 1);
        }
    });
    stocksFlexTable.setWidget(row, 3, removeStockButton);
    // Ly gi c phiu.
    refreshWatchList();

    // TODO Get the stock price.

}

From source file:com.google.gwt.sample.stockwatcher.client.StockWatcherActivity.java

private void addStock() {

    final String symbol = display.getInput().getValue().toUpperCase().trim();
    // newSymbolTextBox.setFocus(true);

    // Stock code must be between 1 and 10 chars that are numbers, letters,
    // or dots.//from w w w  .  jav  a2 s  . co  m
    if (!symbol.matches("^[0-9A-Z\\.]{1,10}$")) {
        Window.alert("'" + symbol + "' is not a valid symbol.");
        display.selectAllInput();
        return;
    }

    display.getInput().setValue("");

    if (stocks.contains(symbol)) {
        return;
    }
    stocks.add(symbol);
    display.addRow(symbol, new RemoveStockEvent(symbol));

    eventBus.fireEvent(new AddStockEvent());
}

From source file:com.google.gwt.sample.stockwatcher.client.StockWatcherT.java

/**
 * Add stock to FlexTable. Executed when the user clicks the addStockButton or
 * presses enter in the newSymbolTextBox.
*//*from ww  w .j a  v a  2s  . c o  m*/
private void addStock() {
    final String symbol = newSymbolTextBox.getText().toUpperCase().trim();
    newSymbolTextBox.setFocus(true);

    // Stock code must be between 1 and 10 chars that are numbers, letters, or dots.
    if (!symbol.matches("^[0-9A-Z\\.]{1,10}$")) {
        Window.alert("'" + symbol + "' is not a valid symbol.");
        newSymbolTextBox.selectAll();
        return;
    }

    newSymbolTextBox.setText("");

    // Don't add the stock if it's already in the table.
    if (stocks.contains(symbol))
        return;
    // Add the stock to the table.
    int row = stocksFlexTable.getRowCount();
    stocks.add(symbol);
    stocksFlexTable.setText(row, 0, symbol);
    stocksFlexTable.setWidget(row, 2, new Label());
    stocksFlexTable.getCellFormatter().addStyleName(row, 1, "watchListNumericColumn");
    stocksFlexTable.getCellFormatter().addStyleName(row, 2, "watchListNumericColumn");
    stocksFlexTable.getCellFormatter().addStyleName(row, 3, "watchListRemoveColumn");

    // Add a button to remove this stock from the table.
    Button removeStockButton = new Button("x");
    removeStockButton.addStyleDependentName("remove");
    removeStockButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            int removedIndex = stocks.indexOf(symbol);
            stocks.remove(removedIndex);
            stocksFlexTable.removeRow(removedIndex + 1);
        }
    });
    stocksFlexTable.setWidget(row, 3, removeStockButton);
    // Get the stock price.
    refreshWatchList();

}

From source file:com.google.gwt.sample.stockwatcher.client.TemperatureWatcher.java

/**
 * Add stock to FlexTable. Executed when the user clicks the addStockButton or
 * presses enter in the newSymbolTextBox.
 *//*  www .  j a va  2s.  c om*/
private void addCity() {
    final String country = newSymbolTextBox.getText().toUpperCase().trim();
    final String city = newCityTextBox.getText().toUpperCase().trim();
    final String area = newAreaTextBox.getText().toUpperCase().trim();
    newSymbolTextBox.setFocus(true);

    // Stock code must be between 1 and 10 chars that are numbers, letters, or dots.
    if (!country.matches("^[0-9A-Z\\.]{1,10}$") || !city.matches("^[0-9A-Z\\.]{1,10}$")
            || !area.matches("^[0-9A-Z\\.]{1,10}$")) {
        Window.alert("Some input is not correct");
        newSymbolTextBox.selectAll();
        return;
    }

    newSymbolTextBox.setText("");
    newAreaTextBox.setText("");
    newCityTextBox.setText("");

    // Don't add the stock if it's already in the table.

    for (int i = 0; i < listOfTemperatures.size(); i++) {
        if (listOfTemperatures.get(i).getCity().equals(city.toUpperCase()))
            return; //can be improved, only compares the city, i.e two cities with the same name in defferent countries/region can't be added
    }

    // Add the stock to the table.
    int row = temperatureFlextable.getRowCount();
    Temperature tempTemp = new Temperature();
    tempTemp.setArea(area);
    tempTemp.setCity(city);
    tempTemp.setCountry(country);
    listOfTemperatures.add(tempTemp);
    temperatureFlextable.setText(row, 0, country);
    temperatureFlextable.setText(row, 1, area);
    temperatureFlextable.setText(row, 2, city);
    temperatureFlextable.setWidget(row, 4, new Label());
    temperatureFlextable.getCellFormatter().addStyleName(row, 3, "watchListNumericColumn");
    temperatureFlextable.getCellFormatter().addStyleName(row, 4, "watchListNumericColumn");
    temperatureFlextable.getCellFormatter().addStyleName(row, 5, "watchListRemoveColumn");
    Widget countryWidget = temperatureFlextable.getWidget(row, 0);
    Widget areaWidget = temperatureFlextable.getWidget(row, 1);
    Widget cityWidget = temperatureFlextable.getWidget(row, 2);
    // Add a button to remove this stock from the table.

    Button removeStockButton = new Button("x");
    removeStockButton.addStyleDependentName("remove");
    removeStockButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) { //TODO: FIX
            Boolean boo = false;
            int removedIndex = 0;
            for (removedIndex = 0; removedIndex < listOfTemperatures.size() && !boo; removedIndex++) {
                if (listOfTemperatures.get(removedIndex).getCity().toUpperCase().equals(city.toUpperCase()))
                    boo = true; //can be improved, only compares the city, i.e two cities with the same name in defferent countries/region can't be added
            }
            removedIndex--;
            listOfTemperatures.remove(removedIndex);
            temperatureFlextable.removeRow(removedIndex + 1);
        }
    });
    temperatureFlextable.setWidget(row, 5, removeStockButton);

    //gets the stock price

    refreshWatchList();

}

From source file:com.google.gwt.sample.stockwatcher.client.ui.StockWatcherViewImpl.java

public StockWatcherViewImpl() {
    initFlexTable();//from w  w w . j  a  v  a 2s .  c  om

    // Setup timer to refresh list automatically.
    Timer refreshTimer = new Timer() {
        @Override
        public void run() {
            refreshWatchList();
        }
    };
    refreshTimer.scheduleRepeating(REFRESH_INTERVAL);
    initWidget(uiBinder.createAndBindUi(this));

    aboutMenuItem.setCommand(new Command() {

        @Override
        public void execute() {
            Window.alert("fuck...");
        }
    });
}

From source file:com.google.gwt.sample.stockwatcher.client.ui.StockWatcherViewImpl.java

/**
 * Add stock to FlexTable. Executed when the user clicks the addStockButton
 * or presses enter in the newSymbolTextBox.
 *//* www .  j ava 2 s  .c  o m*/
public void addStock() {
    final String symbol = newSymbolTextBox.getText().toUpperCase().trim();
    newSymbolTextBox.setFocus(true);

    // Stock code must be between 1 and 10 chars that are numbers, letters,
    // or dots.
    if (!symbol.matches("^[0-9A-Z\\.]{1,10}$")) {
        Window.alert("'" + symbol + "' is not a valid symbol.");
        newSymbolTextBox.selectAll();
        return;
    }

    newSymbolTextBox.setText("");

    // Don't add the stock if it's already in the table.
    if (stocks.contains(symbol))
        return;

    // Add the stock to the table.
    int row = stocksFlexTable.getRowCount();
    stocks.add(symbol);
    stocksFlexTable.setText(row, 0, symbol);
    stocksFlexTable.setWidget(row, 2, new Label());
    stocksFlexTable.getCellFormatter().addStyleName(row, 1, "watchListNumericColumn");
    stocksFlexTable.getCellFormatter().addStyleName(row, 2, "watchListNumericColumn");
    stocksFlexTable.getCellFormatter().addStyleName(row, 3, "watchListRemoveColumn");

    // Add a button to remove this stock from the table.
    Button removeStockButton = new Button("x");
    removeStockButton.addStyleDependentName("remove");
    removeStockButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            presenter.onDeleteStockButtonClicked(new DeleteStockEvent(symbol));
        }
    });
    stocksFlexTable.setWidget(row, 3, removeStockButton);

    // Get the stock price.
    refreshWatchList();
}

From source file:com.google.gwt.sample.stockwatcher.client.UserNotificationPage.java

private void subscribeController(final String user, final String controller) {
    Utility.newRequestObj().userSubscribeControllerNotification(user, controller, new AsyncCallback<String>() {
        public void onFailure(Throwable caught) {
            //            Window.alert("Unable to subscribe to "+controller);
        }/*  w  w w. j a  v a  2s .c o m*/

        public void onSuccess(String reply) {
            Window.alert("Controller Subscription: " + reply);
            if (success(reply)) {
                //               cTable.setText(cTable.getRowCount(), 0, controller); //Local Update
                getSubscribedController(user);
                removeItemFromListBox(controllerLB, controller);
                subscribeSelectionPopup.setVisible(false);
                updateControllerLastReadTime(user, controller);
            }
        }
    });
}

From source file:com.google.gwt.sample.stockwatcher.client.UserNotificationPage.java

private void subscribeSensor(final String user, final String sensor) {
    Utility.newRequestObj().userSubscribeSensorNotification(user, sensor, new AsyncCallback<String>() {
        public void onFailure(Throwable caught) {
            //            Window.alert("Unable to subscribe to "+sensor);
        }//from  ww  w .  ja va 2 s.co  m

        public void onSuccess(String reply) {
            Window.alert("Sensor Subscription: " + reply);
            if (success(reply)) {
                //               sTable.setText(sTable.getRowCount(), 0, sensor);
                getSubscribedSensor(user);
                removeItemFromListBox(sensorLB, sensor);
                subscribeSelectionPopup.setVisible(false);
                updateSensorLastReadTime(user, sensor);
            }
        }
    });
}

From source file:com.google.gwt.sample.stockwatcher.client.UserNotificationPage.java

private void subscribeActuator(final String user, final String actuator) {
    Utility.newRequestObj().userSubscribeActuatorNotification(user, actuator, new AsyncCallback<String>() {
        public void onFailure(Throwable caught) {
            //            Window.alert("Unable to subscribe to "+actuator);
        }// w w  w .ja v  a 2 s . com

        public void onSuccess(String reply) {
            Window.alert("Actuator Subscription: " + reply);
            if (success(reply)) {
                //               aTable.setText(aTable.getRowCount(), 0, actuator);
                getSubscribedActuator(user);
                removeItemFromListBox(actuatorLB, actuator);
                subscribeSelectionPopup.setVisible(false);
                updateActuatorLastReadTime(user, actuator);
            }
        }
    });
}