Example usage for com.google.gwt.event.logical.shared ValueChangeEvent getValue

List of usage examples for com.google.gwt.event.logical.shared ValueChangeEvent getValue

Introduction

In this page you can find the example usage for com.google.gwt.event.logical.shared ValueChangeEvent getValue.

Prototype

public T getValue() 

Source Link

Document

Gets the value.

Usage

From source file:gov.nist.spectrumbrowser.admin.SystemConfig.java

License:Open Source License

@Override
public void draw() {
    verticalPanel.clear();//from   w w  w .ja v  a 2 s.  c o m
    HTML title = new HTML("<h3>System Configuration</h3>");
    HTML helpText = new HTML("<p>Specifies system wide configuration information. </p>");
    verticalPanel.add(title);
    verticalPanel.add(helpText);
    grid = new Grid(22, 2);
    grid.setCellSpacing(4);
    grid.setBorderWidth(2);
    verticalPanel.add(grid);

    int counter = 0;
    myHostNameTextBox = new TextBox();
    myHostNameTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String hostName = event.getValue();
            jsonObject.put("HOST_NAME", new JSONString(hostName));

        }
    });
    setText(counter++, "HOST_NAME", "Public Host Name ", myHostNameTextBox);

    myPortTextBox = new TextBox();
    myPortTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String publicPort = event.getValue();
            try {
                int publicPortInt = Integer.parseInt(publicPort);
                if (publicPortInt < 0) {
                    Window.alert("Publicly accessible port for server HTTP(s) access");
                    return;
                }
                jsonObject.put("PUBLIC_PORT", new JSONNumber(publicPortInt));
            } catch (NumberFormatException ex) {
                Window.alert("Specify publicly accessible port (int)");
            }

        }
    });
    setInteger(counter++, "PUBLIC_PORT", "Public Web Server Port ", myPortTextBox);

    myProtocolTextBox = new TextBox();
    myProtocolTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String protocol = event.getValue();
            if (!protocol.equals("http") && !protocol.equals("https")) {
                Window.alert("please specify http or https");
                return;
            }
            jsonObject.put("PROTOCOL", new JSONString(protocol));

        }
    });
    setText(counter++, "PROTOCOL", "Server access protocol", myProtocolTextBox);

    myServerIdTextBox = new TextBox();
    myServerIdTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String serverId = event.getValue();
            jsonObject.put("MY_SERVER_ID", new JSONString(serverId));
        }
    });
    myServerIdTextBox.setTitle(
            "Server ID must be unique across federation. Used to identify server to federation peers");
    setText(counter++, "MY_SERVER_ID", "Unique ID for this server", myServerIdTextBox);

    myServerKeyTextBox = new TextBox();
    myServerKeyTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String serverKey = event.getValue();
            jsonObject.put("MY_SERVER_KEY", new JSONString(serverKey));
        }
    });
    myServerKeyTextBox.setTitle("Server key used to authenticate server to federation peers.");
    setText(counter++, "MY_SERVER_KEY", "Server Key", myServerKeyTextBox);

    smtpServerTextBox = new TextBox();
    smtpServerTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String smtpServer = event.getValue();
            jsonObject.put("SMTP_SERVER", new JSONString(smtpServer));
        }
    });

    setText(counter++, "SMTP_SERVER", "Host Name for SMTP server", smtpServerTextBox);
    smtpPortTextBox = new TextBox();
    smtpPortTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            try {
                String portString = event.getValue();
                int port = Integer.parseInt(portString);
                jsonObject.put("SMTP_PORT", new JSONNumber(port));
            } catch (Exception exception) {
                Window.alert("Invalid port");
                draw();
            }
        }
    });
    setInteger(counter++, "SMTP_PORT", "Mail Server Port", smtpPortTextBox);

    smtpEmailAddressTextBox = new TextBox();
    smtpEmailAddressTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String email = event.getValue();
            if (email.matches(
                    "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$")) {
                jsonObject.put("SMTP_EMAIL_ADDRESS", new JSONString(email));
            } else {
                Window.alert("Please enter a valid SMTP email address");
                draw();
            }

        }
    });

    setText(counter++, "SMTP_EMAIL_ADDRESS", "Primary admin email to use for mail FROM this server",
            smtpEmailAddressTextBox);

    adminContactNameTextBox = new TextBox();
    adminContactNameTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String email = event.getValue();
            jsonObject.put("ADMIN_CONTACT_NAME", new JSONString(email));

        }
    });

    setText(counter++, "ADMIN_CONTACT_NAME", "Primary administrator name", adminContactNameTextBox);

    adminContactNumberTextBox = new TextBox();
    adminContactNumberTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String email = event.getValue();
            jsonObject.put("ADMIN_CONTACT_NUMBER", new JSONString(email));

        }
    });

    setText(counter++, "ADMIN_CONTACT_NUMBER", "Primary administrator number", adminContactNumberTextBox);

    isAuthenticationRequiredTextBox = new TextBox();
    isAuthenticationRequiredTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String flagString = event.getValue();
            if (!flagString.equals("true") && !flagString.equals("false")) {
                Window.alert("Invalid entry : enter true or false");
                draw();
            } else {
                try {
                    boolean flag = Boolean.parseBoolean(flagString);
                    jsonObject.put(Defines.IS_AUTHENTICATION_REQUIRED, JSONBoolean.getInstance(flag));
                } catch (Exception ex) {
                    Window.alert("Enter true or false");
                    draw();
                }
            }
        }
    });
    isAuthenticationRequiredTextBox.setTitle("Start page will display a login screen if true");
    setBoolean(counter++, Defines.IS_AUTHENTICATION_REQUIRED, "User Authentication Required (true/false)?",
            isAuthenticationRequiredTextBox);

    apiKeyTextBox = new TextBox();
    apiKeyTextBox.setTitle("Google Timezone API key");
    apiKeyTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String apiKey = event.getValue();
            jsonObject.put("API_KEY", new JSONString(apiKey));
        }
    });
    apiKeyTextBox.setText("Request google for an API key.");
    setText(counter++, "API_KEY", "Google TimeZone API key", apiKeyTextBox);

    this.minStreamingInterArrivalTimeSeconds = new TextBox();
    this.minStreamingInterArrivalTimeSeconds.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            // TODO Auto-generated method stub
            String minStreamingTimeStr = event.getValue();
            try {
                double minStreamingInterArrivalTimeSeconds = Double.parseDouble(minStreamingTimeStr);
                if (minStreamingInterArrivalTimeSeconds < 0) {
                    Window.alert("Please enter value > 0");
                    draw();
                    return;
                }
                jsonObject.put(Defines.MIN_STREAMING_INTER_ARRIVAL_TIME_SECONDS,
                        new JSONNumber(minStreamingInterArrivalTimeSeconds));
            } catch (Exception ex) {
                Window.alert("Please enter an integer > 0");
                draw();
            }
        }
    });
    setFloat(counter++, Defines.MIN_STREAMING_INTER_ARRIVAL_TIME_SECONDS,
            "Min time (s) between successive spectra from streaming sensor",
            minStreamingInterArrivalTimeSeconds);

    myRefreshIntervalTextBox = new TextBox();
    myRefreshIntervalTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String refreshInterval = event.getValue();
            try {
                int refreshIntervalInt = Integer.parseInt(refreshInterval);
                if (refreshIntervalInt < 10) {
                    Window.alert("Specify value above 10");
                    return;
                }
                jsonObject.put("SOFT_STATE_REFRESH_INTERVAL", new JSONNumber(refreshIntervalInt));
            } catch (NumberFormatException ex) {
                Window.alert("Specify soft state refresh interval (seconds) for federation.");
            }

        }
    });
    setInteger(counter++, "SOFT_STATE_REFRESH_INTERVAL", "Peering soft state refresh interval (s) ",
            myRefreshIntervalTextBox);

    useLDAPTextBox = new TextBox();
    useLDAPTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String flagString = event.getValue();
            try {
                if (!flagString.equals("true") && !flagString.equals("false")) {
                    Window.alert("Enter true or false");
                    draw();
                } else {
                    boolean flag = Boolean.parseBoolean(flagString);
                    jsonObject.put("USE_LDAP", JSONBoolean.getInstance(flag));
                    draw();
                }
            } catch (Exception ex) {
                Window.alert("Enter true or false");
                draw();
            }
        }
    });
    setBoolean(counter++, "USE_LDAP", "Use LDAP to store user accounts (true/false)?", useLDAPTextBox);

    accountNumFailedLoginAttemptsTextBox = new TextBox();
    accountNumFailedLoginAttemptsTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String accountNumFailedLoginAttempts = event.getValue();
            try {
                int accountNumFailedLoginAttemptsInt = Integer.parseInt(accountNumFailedLoginAttempts);
                if (accountNumFailedLoginAttemptsInt < 1) {
                    Window.alert("Specify value above 0");
                    return;
                }
                jsonObject.put("ACCOUNT_NUM_FAILED_LOGIN_ATTEMPTS",
                        new JSONNumber(accountNumFailedLoginAttemptsInt));
            } catch (NumberFormatException ex) {
                Window.alert("Specify number of login attempts (e.g. 3) before the user is locked out.");
            }

        }
    });
    setInteger(counter++, "ACCOUNT_NUM_FAILED_LOGIN_ATTEMPTS",
            "Number of failed login attempts before user is locked out ", accountNumFailedLoginAttemptsTextBox);

    changePasswordIntervalDaysTextBox = new TextBox();
    changePasswordIntervalDaysTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String changePasswordIntervalDays = event.getValue();
            try {
                int changePasswordIntervalDaysInt = Integer.parseInt(changePasswordIntervalDays);
                if (changePasswordIntervalDaysInt < 1) {
                    Window.alert("Specify value above 0");
                    return;
                }
                jsonObject.put("CHANGE_PASSWORD_INTERVAL_DAYS", new JSONNumber(changePasswordIntervalDaysInt));
            } catch (NumberFormatException ex) {
                Window.alert("Specify the interval (in days) for how often a user must change their password.");
            }

        }
    });
    setInteger(counter++, "CHANGE_PASSWORD_INTERVAL_DAYS",
            "Interval (in days) between required password changes ", changePasswordIntervalDaysTextBox);

    userAccountAcknowHoursTextBox = new TextBox();
    userAccountAcknowHoursTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String userAccountAcknowHours = event.getValue();
            try {
                int userAccountAcknowHoursInt = Integer.parseInt(userAccountAcknowHours);
                if (userAccountAcknowHoursInt < 1) {
                    Window.alert("Specify value above 0");
                    return;
                }
                jsonObject.put("ACCOUNT_USER_ACKNOW_HOURS", new JSONNumber(userAccountAcknowHoursInt));
            } catch (NumberFormatException ex) {
                Window.alert(
                        "Specify the interval (in hours) for how the user gets to click in an email link for account authorization or password resets. ");
            }

        }
    });
    setInteger(counter++, "ACCOUNT_USER_ACKNOW_HOURS",
            "Interval (in hours) for user to activate account or reset password ",
            userAccountAcknowHoursTextBox);

    accountRequestTimeoutHoursTextBox = new TextBox();
    accountRequestTimeoutHoursTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String accountRequestTimeoutHours = event.getValue();
            try {
                int accountRequestTimeoutHoursInt = Integer.parseInt(accountRequestTimeoutHours);
                if (accountRequestTimeoutHoursInt < 1) {
                    Window.alert("Specify value above 1");
                    return;
                }
                jsonObject.put("ACCOUNT_REQUEST_TIMEOUT_HOURS", new JSONNumber(accountRequestTimeoutHoursInt));
            } catch (NumberFormatException ex) {
                Window.alert(
                        "Specify the interval (in hours) for how the admin gets to click in an email link for account requests.");
            }

        }
    });
    setInteger(counter++, "ACCOUNT_REQUEST_TIMEOUT_HOURS",
            "Interval (in hours) for admin to approve an account ", accountRequestTimeoutHoursTextBox);

    userSessionTimeoutMinutes = new TextBox();
    userSessionTimeoutMinutes.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String accountSessionTimeoutMinutesString = event.getValue();
            try {
                int userSessionTimeoutMinutes = Integer.parseInt(accountSessionTimeoutMinutesString);
                if (userSessionTimeoutMinutes < 1) {
                    Window.alert("Specify a value above 1");
                    return;
                }
                jsonObject.put("USER_SESSION_TIMEOUT_MINUTES", new JSONNumber(userSessionTimeoutMinutes));
            } catch (NumberFormatException nfe) {
                Window.alert("Specify user session timeout in minutes.");
            }
        }
    });
    setInteger(counter++, "USER_SESSION_TIMEOUT_MINUTES", "User session timeout (min)",
            userSessionTimeoutMinutes);

    adminSessionTimeoutMinutes = new TextBox();
    adminSessionTimeoutMinutes.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String accountSessionTimeoutMinutesString = event.getValue();
            try {
                int adminSessionTimeoutMinutes = Integer.parseInt(accountSessionTimeoutMinutesString);
                if (adminSessionTimeoutMinutes < 1) {
                    Window.alert("Specify a value above 1");
                    return;
                }
                jsonObject.put("ADMIN_SESSION_TIMEOUT_MINUTES", new JSONNumber(adminSessionTimeoutMinutes));
            } catch (NumberFormatException nfe) {
                Window.alert("Specify user session timeout in minutes.");
            }
        }
    });
    setInteger(counter++, "ADMIN_SESSION_TIMEOUT_MINUTES", "Admin session timeout (min)",
            adminSessionTimeoutMinutes);

    sslCert = new TextBox();
    sslCert.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String sslCert = event.getValue();
            if (sslCert == null || sslCert.equals("")) {
                Window.alert("Specify path to where certificate file is installed");
            }
            jsonObject.put("CERT", new JSONString(sslCert));
        }
    });
    setText(counter++, "CERT", "path to certificate file", sslCert);

    for (int i = 0; i < grid.getRowCount(); i++) {
        grid.getCellFormatter().setStyleName(i, 0, "textLabelStyle");
    }

    applyButton = new Button("Apply Changes");
    cancelButton = new Button("Cancel Changes");
    logoutButton = new Button("Log Out");

    applyButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            Admin.getAdminService().setSystemConfig(jsonObject.toString(),
                    new SpectrumBrowserCallback<String>() {

                        @Override
                        public void onSuccess(String result) {
                            JSONObject jsonObj = JSONParser.parseLenient(result).isObject();
                            if (jsonObj.get("status").isString().stringValue().equals("OK")) {
                                Window.alert("Configuration successfully updated");
                            } else {
                                String errorMessage = jsonObj.get("ErrorMessage").isString().stringValue();
                                Window.alert("Error in updating config - please re-enter. Error Message : "
                                        + errorMessage);
                            }
                        }

                        @Override
                        public void onFailure(Throwable throwable) {
                            Window.alert("Error communicating with server");
                            admin.logoff();
                        }
                    });
        }
    });

    cancelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            redraw = true;
            Admin.getAdminService().getSystemConfig(SystemConfig.this);
        }
    });

    logoutButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            admin.logoff();
        }
    });

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.add(applyButton);
    buttonPanel.add(cancelButton);
    buttonPanel.add(logoutButton);
    verticalPanel.add(buttonPanel);
}

From source file:gov.nist.spectrumbrowser.client.SensorInfoDisplay.java

License:Open Source License

/**
 * Show the sensor summary information in the side of the map.
 * //from  w ww  . ja v a 2  s .co m
 */

void buildSummary() {
    logger.finer("SensorInfoDisplay: buildSummary " + getId());

    try {

        info = sensorInfo.getSensorDescriptionNoBands();
        sensorDescriptionPanel.add(info);
        for (final String bandName : sensorInfo.getBandNames()) {
            final BandInfo bandInfo = sensorInfo.getBandInfo(bandName);
            if (bandInfo != null) {
                VerticalPanel bandDescriptionPanel = new VerticalPanel();
                HTML bandDescription = sensorInfo.getBandDescription(bandName);

                bandDescriptionPanel.add(bandDescription);

                if (sensorInfo.getMeasurementType().equals(Defines.SWEPT_FREQUENCY)) {
                    HorizontalPanel showAdvancedPanel = new HorizontalPanel();
                    showAdvancedPanel.add(new Label("Advanced     "));
                    CheckBox advancedCheckBox = new CheckBox();

                    advancedCheckBox.setValue(false);
                    showAdvancedPanel.add(advancedCheckBox);
                    bandDescriptionPanel.add(showAdvancedPanel);

                    final VerticalPanel advancedPanel = new VerticalPanel();

                    advancedPanel.add(new Label("Specify Sub-band :"));
                    Grid grid = new Grid(2, 2);

                    grid.setText(0, 0, "Min Freq (MHz):");
                    minFreqBox = new TextBox();
                    minFreqBox.setText(Double.toString(bandInfo.getSelectedMinFreq() / 1E6));
                    minFreqBox.addValueChangeHandler(new ValueChangeHandler<String>() {
                        @Override
                        public void onValueChange(ValueChangeEvent<String> event) {
                            try {
                                double newFreq = Double.parseDouble(event.getValue());
                                if (!bandInfo.setSelectedMinFreq((long) (newFreq * 1E6))) {
                                    Window.alert("Illegal value entered");
                                    minFreqBox.setText(Double.toString(bandInfo.getSelectedMinFreq() / 1E6));
                                }
                            } catch (NumberFormatException ex) {
                                Window.alert("Illegal Entry");
                                minFreqBox.setText(Double.toString(bandInfo.getMinFreq() / 1E6));
                            }

                        }
                    });
                    minFreqBox.setTitle("Enter value >= " + bandInfo.getMinFreq() / 1E6);
                    grid.setWidget(0, 1, minFreqBox);

                    grid.setText(1, 0, "Max Freq (MHz):");
                    maxFreqBox = new TextBox();
                    maxFreqBox.addValueChangeHandler(new ValueChangeHandler<String>() {
                        @Override
                        public void onValueChange(ValueChangeEvent<String> event) {
                            try {
                                double newFreq = Double.parseDouble(event.getValue());

                                if (!bandInfo.setSelectedMaxFreq((long) (newFreq * 1E6))) {

                                    Window.alert("Illegal value entered");
                                    maxFreqBox.setText(Double.toString(bandInfo.getSelectedMaxFreq() / 1E6));
                                }
                            } catch (NumberFormatException ex) {
                                Window.alert("Illegal Entry");
                                maxFreqBox.setText(Double.toString(bandInfo.getSelectedMaxFreq() / 1E6));
                            }

                        }
                    });
                    maxFreqBox.setText(Double.toString(bandInfo.getSelectedMaxFreq() / 1E6));
                    maxFreqBox.setTitle("Enter value <= " + bandInfo.getMaxFreq() / 1E6);
                    grid.setWidget(1, 1, maxFreqBox);
                    advancedPanel.add(grid);
                    advancedPanel.add(new Label("Changing to non-default values increases compute time"));

                    Grid updateGrid = new Grid(1, 2);
                    Button changeButton = new Button("Change");
                    updateGrid.setWidget(0, 0, changeButton);
                    final Label label = new Label();
                    updateGrid.setWidget(0, 1, label);
                    changeButton.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                            double minFreq = Double.parseDouble(minFreqBox.getText());
                            double maxFreq = Double.parseDouble(maxFreqBox.getText());

                            if (!bandInfo.setSelectedMaxFreq((long) (maxFreq * 1E6))
                                    || !bandInfo.setSelectedMinFreq((long) (minFreq * 1E6))) {
                                Window.alert("Illegal value entered");
                                minFreqBox.setText(Double.toString(bandInfo.getMinFreq() / 1E6));
                                maxFreqBox.setText(Double.toString(bandInfo.getSelectedMaxFreq() / 1E6));
                            } else {
                                updateAcquistionCount();
                                label.setText("Changes Updated");
                                Timer timer = new Timer() {
                                    @Override
                                    public void run() {
                                        label.setText(null);
                                    }
                                };
                                timer.schedule(2000);
                            }
                        }
                    });
                    advancedPanel.add(updateGrid);
                    bandDescriptionPanel.add(advancedPanel);
                    advancedPanel.setVisible(false);
                    advancedCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> event) {
                            if (event.getValue()) {
                                advancedPanel.setVisible(true);
                            } else {
                                advancedPanel.setVisible(false);
                            }

                        }
                    });

                }

                final Label bandSelectionButton = new Label(bandInfo.getFreqRange().toString());
                bandSelectionButton.getElement().getStyle().setCursor(Cursor.POINTER);
                if (bandInfo.isActive()) {
                    bandSelectionButton.setStyleName("activeBandSelectionButton");
                    bandSelectionButton.setTitle("Enabled for data collection");
                } else {
                    bandSelectionButton.setTitle("Disabled for data collection");
                    bandSelectionButton.setStyleName("bandSelectionButton");
                }
                sensorDescriptionPanel.add(bandSelectionButton);
                sensorDescriptionPanel.add(bandDescriptionPanel);
                bandDescriptionPanel.setVisible(false);
                selectionButtons.add(bandSelectionButton);
                bandInfo.setSelectionButton(bandSelectionButton);
                bandDescriptionPanels.add(bandDescriptionPanel);
                bandSelectionButton.addClickHandler(
                        new SelectBandClickHandler(bandDescriptionPanel, bandSelectionButton, bandInfo));
            }
        }

    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Error in updating data summary ", ex);
        ex.printStackTrace();
    } finally {
    }

}

From source file:gov.wa.wsdot.search.client.SearchWidget.java

License:Open Source License

/**
 * This method is called whenever the application's history changes.
 * // w  w w. j  ava2 s  .com
 * Calling the History.newItem(historyToken) method causes a new history entry to be
 * added which results in ValueChangeEvent being called as well.
 */
@Override
public void onValueChange(ValueChangeEvent<String> event) {
    String url = JSON_URL;
    String url_flickr = JSON_URL_FLICKR;
    String url_highway_alerts = JSON_URL_HIGHWAY_ALERTS;
    String historyToken = event.getValue();

    // This handles the initial GET call to the page. Rewrites the ?q= to #q=
    String queryParameter = Window.Location.getParameter("q");
    if (queryParameter != null) {
        UrlBuilder urlBuilder = Window.Location.createUrlBuilder().removeParameter("q");
        urlBuilder.setHash(historyToken);
        String location = urlBuilder.buildString();
        Window.Location.replace(location);
    }

    String[] tokens = historyToken.split("&"); // e.g. #q=Ferries&p=2
    Map<String, String> map = new HashMap<String, String>();
    for (String string : tokens) {
        try {
            map.put(string.split("=")[0], string.split("=")[1]);
        } catch (ArrayIndexOutOfBoundsException e) {
            // TODO: Need a better way to handle this.
        }
    }

    String query = map.get("q");
    String page = map.get("p");

    if (page == null) {
        page = "1";
    }

    searchSuggestBox.setText(query);
    String searchString = SafeHtmlUtils
            .htmlEscape(searchSuggestBox.getText().trim().replace("'", "").replace("\"", ""));
    loadingImage.setVisible(true);

    searchSuggestBox.setFocus(true);
    leftNavBoxHTMLPanel.setVisible(false);
    photosDisclosurePanel.setVisible(false);
    boostedResultsHTMLPanel.setVisible(false);
    alertsDisclosurePanel.setVisible(false);

    if (searchString.isEmpty()) {
        clearPage();
        loadingImage.setVisible(false);
        bingLogoHTMLPanel.setVisible(false);
    } else {
        if (ANALYTICS_ENABLED) {
            Analytics.trackEvent(EVENT_TRACKING_CATEGORY, "Keywords", searchString.toLowerCase());
        }
        clearPage();

        // Append the name of the callback function to the JSON URL.
        url += searchString;
        url += "&page=" + page;
        url = URL.encode(url);

        // Append search query to Flickr url.
        url_flickr += searchString;
        url_flickr = URL.encode(url_flickr);

        // Send requests to remote servers with calls to JSNI methods.
        getSearchData(url, searchString, page);
        getPhotoData(url_flickr, searchString);
        getHighwayAlertsData(url_highway_alerts, searchString);
    }
}

From source file:gwt.material.design.demo.client.application.addins.rating.RatingView.java

License:Apache License

@UiHandler("rating")
void onRate(ValueChangeEvent<Integer> event) {
    MaterialToast.fireToast(event.getValue() + " Rate value");
}

From source file:gwt.material.design.demo.client.application.components.forms.FormsView.java

License:Apache License

@UiHandler("cbBox")
void onCheckBox(ValueChangeEvent<Boolean> e) {
    if (e.getValue()) {
        cbBox.setText("CheckBox 1: true");
    } else {//from www.j  a v  a 2 s .  c  o m
        cbBox.setText("CheckBox 1: false");
    }
}

From source file:gwt.material.design.demo.client.application.components.forms.FormsView.java

License:Apache License

@UiHandler("cbBoxAll")
void onCheckAll(ValueChangeEvent<Boolean> e) {
    if (e.getValue()) {
        cbBlue.setValue(true);//from  www  .j av  a  2  s . c  o  m
        cbRed.setValue(true);
        cbCyan.setValue(true);
        cbGreen.setValue(true);
        cbBrown.setValue(true);
    } else {
        cbBlue.setValue(false);
        cbRed.setValue(false);
        cbCyan.setValue(false);
        cbGreen.setValue(false);
        cbBrown.setValue(false);
    }
}

From source file:gwtquery.plugins.draggable.client.GWTIntegrationSample.java

License:Apache License

/**
 * Create a Date picker. The code comes from the GWT show case :
 * http://gwt.google.com/samples/Showcase/Showcase.html#!CwDatePicker@
 *
 * @return/*from   w  w w. j av a 2  s .c  o  m*/
 */
private VerticalPanel createDatePanel() {
    // Create a basic date picker
    DatePicker datePicker = new DatePicker();
    final Label text = new Label();

    // Set the value in the text box when the user selects a date
    datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
        public void onValueChange(ValueChangeEvent<Date> event) {
            Date date = event.getValue();
            String dateString = DateTimeFormat.getMediumDateFormat().format(date);
            text.setText(dateString);
        }
    });

    // Set the default value
    datePicker.setValue(new Date(), true);

    // Combine the widgets into a panel and return them
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(new HTML("Permanent DatePicker:"));
    vPanel.add(text);
    vPanel.add(datePicker);
    return vPanel;

}

From source file:gwtquery.plugins.droppable.client.testoptionssample.DraggableOptionsPanel.java

License:Apache License

@UiHandler(value = "delayBox")
public void onDelayChange(ValueChangeEvent<String> e) {
    getOptions().setDelay(new Integer(e.getValue()));
}

From source file:gwtquery.plugins.droppable.client.testoptionssample.DraggableOptionsPanel.java

License:Apache License

@UiHandler(value = "disabledCheckBox")
public void onDisabledChange(ValueChangeEvent<Boolean> e) {
    getOptions().setDisabled(e.getValue());
}

From source file:gwtquery.plugins.droppable.client.testoptionssample.DraggableOptionsPanel.java

License:Apache License

@UiHandler(value = "distanceBox")
public void onDistanceChange(ValueChangeEvent<String> e) {
    Integer distance;//from   w  w w  .j a  va2s  .co m
    try {
        distance = new Integer(e.getValue());
    } catch (NumberFormatException ex) {
        Window.alert("Please specify a correct number for distance");
        return;
    }
    getOptions().setDistance(distance);
}