Example usage for com.vaadin.ui.themes ValoTheme NOTIFICATION_CLOSABLE

List of usage examples for com.vaadin.ui.themes ValoTheme NOTIFICATION_CLOSABLE

Introduction

In this page you can find the example usage for com.vaadin.ui.themes ValoTheme NOTIFICATION_CLOSABLE.

Prototype

String NOTIFICATION_CLOSABLE

To view the source code for com.vaadin.ui.themes ValoTheme NOTIFICATION_CLOSABLE.

Click Source Link

Document

Adds a close button to the notification to imply that the user must click on the notification to dismiss it.

Usage

From source file:uicomponents.LigandExtractPanel.java

License:Open Source License

public boolean isValid() {
    boolean res = true;
    String error = "";
    for (Iterator i = extractionExperiments.getItemIds().iterator(); i.hasNext();) {
        // Get the current item identifier, which is an integer.
        int iid = (Integer) i.next();

        // Now get the actual item from the table.
        Item item = extractionExperiments.getItem(iid);

        TextField mass = (TextField) item.getItemProperty("Mass [mg]").getValue();
        try {//  w  w  w  .ja  va2s . c o  m
            Integer.parseInt(mass.getValue());
        } catch (NumberFormatException e) {
            res = false;
            error = "Sample mass has to be a number!";
        }
        DateField d = (DateField) item.getItemProperty("Date").getValue();

        if (d.getValue() == null) {
            error = "Please select preparation dates for all samples!";
        }
        ComboBox ab1 = (ComboBox) item.getItemProperty("Antibody 1").getValue();
        TextField mass1 = (TextField) item.getItemProperty("Mass 1 [mg]").getValue();
        ComboBox ab2 = (ComboBox) item.getItemProperty("Antibody 2").getValue();
        TextField mass2 = (TextField) item.getItemProperty("Mass 2 [mg]").getValue();
        ComboBox ab3 = (ComboBox) item.getItemProperty("Antibody 3").getValue();
        TextField mass3 = (TextField) item.getItemProperty("Mass 3 [mg]").getValue();

        String antibodyError = "Please choose at least one antibody and fill in the mass.";

        if (ab1.getValue() != null && !mass1.getValue().isEmpty()) {
            try {
                Integer.parseInt(mass.getValue());
            } catch (NumberFormatException e) {
                res = false;
                error = "Antibody 1 mass has to be a number!";
            }
        } else {
            res = false;
            error = antibodyError;
        }
        if (ab2.getValue() != null && !mass2.getValue().isEmpty()) {
            try {
                Integer.parseInt(mass.getValue());
            } catch (NumberFormatException e) {
                res = false;
                error = "Antibody 2 mass has to be a number!";
            }
        }
        if (ab3.getValue() != null && !mass3.getValue().isEmpty()) {
            try {
                Integer.parseInt(mass.getValue());
            } catch (NumberFormatException e) {
                res = false;
                error = "Antibody 3 mass has to be a number!";
            }
        }
    }

    if (!res) {
        Notification n = new Notification(error);
        n.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE);
        n.setDelayMsec(-1);
        n.show(UI.getCurrent().getPage());
        return false;
    } else
        return true;
}