List of usage examples for com.vaadin.ui Notification setStyleName
public void setStyleName(String styleName)
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 . j av a 2 s . c om*/ 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; }