List of usage examples for com.vaadin.ui Notification show
public static Notification show(String caption, String description, Type type)
From source file:com.oodrive.nuage.webui.WebUiUtils.java
License:Apache License
/** * Create a new String text field with a given setter/getter. * //from www . j a v a2 s . c om * @param operation * the operation to get/set the value contains in the text field. * @param fieldName * the name of the field * @param rootLayout * the layout to add the text field * @param model * the model used to get/set the value */ @SuppressWarnings({ "serial" }) public static final void createFieldString(final StringAttributeOperation operation, final String fieldName, final FormLayout rootLayout, final AbstractItemModel model) { String value = operation.getStringValue(); // Display empty string if value is null if (value == null) { value = ""; } final TextField field = new TextField(fieldName, value); field.setWidth("250px"); field.setImmediate(true); rootLayout.addComponent(field); field.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { final String newValue = String.valueOf(event.getProperty().getValue()); final String oldValue = operation.getStringValue(); if (!newValue.equals(oldValue)) { // Set value in background (could be a long operation) WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { operation.setStringValue(newValue); } @Override public void postProcessing() { Notification.show(fieldName + " changed", newValue, Notification.Type.TRAY_NOTIFICATION); } }); } } }); }
From source file:com.oodrive.nuage.webui.WebUiUtils.java
License:Apache License
/** * Create a new long text field with a given setter/getter. * /* ww w.j a v a 2s . c o m*/ * @param operation * the operation to get/set the value contains in the text field. * @param fieldName * the name of the field * @param rootLayout * the layout to add the text field * @param model * the model used to get/set the value */ @SuppressWarnings({ "serial" }) public static final void createFieldLong(final LongAttributeOperation operation, final String fieldName, final FormLayout rootLayout, final AbstractItemModel model) { final TextField field = new TextField(fieldName, Long.toString(operation.getLongValue())); field.setWidth("250px"); field.setImmediate(true); rootLayout.addComponent(field); field.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { final String newValue = String.valueOf(event.getProperty().getValue()); final String oldValue = Long.toString(operation.getLongValue()); if (!oldValue.equals(newValue)) { try { // Cast here to check format final long longNewValue = Long.valueOf(newValue); // Set value in background (could be a long operation) WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { operation.setLongValue(longNewValue); } @Override public void postProcessing() { // Get the new real value set in the model (can be different) final String newValue = Long.toString(operation.getLongValue()); Notification.show(fieldName + " changed", newValue, Notification.Type.TRAY_NOTIFICATION); // Reset the field with the new value field.setValue(newValue); } }); } catch (final NumberFormatException e) { final ErrorWindow err = new ErrorWindow("You must enter a valid number"); err.add(model); // Reset the last value field.setValue(oldValue); } } } }); }
From source file:com.oodrive.nuage.webui.WebUiUtils.java
License:Apache License
/** * Create a new integer text field with a given setter/getter. * //from w ww .j a v a 2 s . com * @param operation * the operation to get/set the value contains in the text field. * @param fieldName * the name of the field * @param rootLayout * the layout to add the text field * @param model * the model used to get/set the value */ @SuppressWarnings({ "serial" }) public static final void createFieldInteger(final IntegerAttributeOperation operation, final String fieldName, final FormLayout rootLayout, final AbstractItemModel model, final boolean emptyAllowed) { final TextField field = new TextField(fieldName, Integer.toString(operation.getIntegerValue())); field.setWidth("250px"); field.setImmediate(true); rootLayout.addComponent(field); field.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { final String newValue = String.valueOf(event.getProperty().getValue()); final String oldValue = Integer.toString(operation.getIntegerValue()); if (!oldValue.equals(newValue)) { try { final int intNewValue; if (emptyAllowed && "".equals(newValue)) { // Empty equals 0 intNewValue = 0; } else { // Cast here to check format intNewValue = Integer.valueOf(newValue); } // Set value in background (could be a long operation) WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { operation.setIntegerValue(intNewValue); } @Override public void postProcessing() { // Get the new real value set in the model (can be different) final String newValue = Integer.toString(operation.getIntegerValue()); Notification.show(fieldName + " changed", newValue, Notification.Type.TRAY_NOTIFICATION); // Reset the field with the new value field.setValue(newValue); } }); } catch (final NumberFormatException e) { final ErrorWindow err = new ErrorWindow("You must enter a valid number"); err.add(model); // Reset the last value field.setValue(oldValue); } } } }); }
From source file:com.philippefichet.vaadincdipush.view.FirstView.java
@PostConstruct public void init() { setHeight("100%"); loginLayout = new HorizontalLayout(); Label loginLabel = new Label("Login"); loginChoose = new TextField(); attach = new Button("Connect"); attach.addClickListener((Button.ClickEvent event) -> { if (chat.loginFree(loginChoose.getValue())) { if (login == null) { login = loginChoose.getValue(); chat.getUsernameConnected().forEach((l) -> { newUser(l);//w w w . ja v a 2 s. c o m }); chat.attach(this); } else { chat.rename(loginChoose.getValue(), this); login = loginChoose.getValue(); } attach.setStyleName(ValoTheme.BUTTON_FRIENDLY); Notification.show("Login \"" + loginChoose.getValue() + "\" valid.", null, Notification.Type.HUMANIZED_MESSAGE); messagePanel.setVisible(true); sendLayout.setVisible(true); } else { Notification.show("Login \"" + loginChoose.getValue() + "\" already exist.", null, Notification.Type.ERROR_MESSAGE); } }); chatMessage.setWidth("100%"); sendLayout.setWidth("100%"); sendMessage.setWidthUndefined(); sendLayout.addComponent(chatMessage); sendLayout.addComponent(sendMessage); sendLayout.setExpandRatio(chatMessage, 100); sendMessage.addClickListener((event) -> { chat.sendMessage(this, chatMessage.getValue()); chatMessage.setValue(""); }); Button next = new Button("next"); next.addClickListener((eventClick) -> { getUI().getNavigator().navigateTo("next"); }); loginLayout.addComponent(loginLabel); loginLayout.addComponent(loginChoose); loginLayout.addComponent(attach); loginLayout.setComponentAlignment(loginLabel, Alignment.MIDDLE_RIGHT); loginLayout.setComponentAlignment(loginChoose, Alignment.MIDDLE_CENTER); loginLayout.setComponentAlignment(attach, Alignment.MIDDLE_LEFT); loginLayout.setWidth("100%"); loginLabel.setWidthUndefined(); loginChoose.setWidth("100%"); attach.setWidthUndefined(); messagePanel.setHeight("100%"); listUserPanel.setStyleName(ValoTheme.PANEL_WELL); listUserPanel.setContent(listUserLayout); listUserPanel.setHeight("100%"); centerLayout.setHeight("100%"); centerLayout.addComponent(listUserPanel); centerLayout.addComponent(messageLayout); centerLayout.setExpandRatio(messageLayout, 100); messagePanel.setContent(centerLayout); addComponent(loginLayout); addComponent(messagePanel); addComponent(sendLayout); messagePanel.setVisible(false); sendLayout.setVisible(false); setExpandRatio(messagePanel, 100); }
From source file:com.pms.component.ganttchart.DemoUI.java
License:Apache License
private void openStepEditor(AbstractStep step) { final Window win = new Window("Step Editor"); win.setResizable(false);// w w w . jav a 2s.c o m win.center(); final Collection<Component> hidden = new ArrayList<Component>(); BeanItem<AbstractStep> item = new BeanItem<AbstractStep>(step); final FieldGroup group = new FieldGroup(item); group.setBuffered(true); TextField captionField = new TextField("Caption"); captionField.setNullRepresentation(""); group.bind(captionField, "caption"); TextField descriptionField = new TextField("Description"); descriptionField.setNullRepresentation(""); group.bind(descriptionField, "description"); descriptionField.setVisible(false); hidden.add(descriptionField); NativeSelect captionMode = new NativeSelect("Caption Mode"); captionMode.addItem(Step.CaptionMode.TEXT); captionMode.addItem(Step.CaptionMode.HTML); group.bind(captionMode, "captionMode"); captionMode.setVisible(false); hidden.add(captionMode); final NativeSelect parentStepSelect = new NativeSelect("Parent Step"); parentStepSelect.setEnabled(false); if (!gantt.getSteps().contains(step)) { // new step parentStepSelect.setEnabled(true); for (Step parentStepCanditate : gantt.getSteps()) { parentStepSelect.addItem(parentStepCanditate); parentStepSelect.setItemCaption(parentStepCanditate, parentStepCanditate.getCaption()); if (step instanceof SubStep) { if (parentStepCanditate.getSubSteps().contains(step)) { parentStepSelect.setValue(parentStepCanditate); parentStepSelect.setEnabled(false); break; } } } } parentStepSelect.setVisible(false); hidden.add(parentStepSelect); TextField bgField = new TextField("Background color"); bgField.setNullRepresentation(""); group.bind(bgField, "backgroundColor"); bgField.setVisible(false); hidden.add(bgField); DateField startDate = new DateField("Start date"); startDate.setLocale(gantt.getLocale()); startDate.setTimeZone(gantt.getTimeZone()); startDate.setResolution(Resolution.SECOND); startDate.setConverter(new DateToLongConverter()); group.bind(startDate, "startDate"); DateField endDate = new DateField("End date"); endDate.setLocale(gantt.getLocale()); endDate.setTimeZone(gantt.getTimeZone()); endDate.setResolution(Resolution.SECOND); endDate.setConverter(new DateToLongConverter()); group.bind(endDate, "endDate"); CheckBox showMore = new CheckBox("Show all settings"); showMore.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { for (Component c : hidden) { c.setVisible((Boolean) event.getProperty().getValue()); } win.center(); } }); VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); win.setContent(content); content.addComponent(captionField); content.addComponent(captionMode); content.addComponent(descriptionField); content.addComponent(parentStepSelect); content.addComponent(bgField); content.addComponent(startDate); content.addComponent(endDate); content.addComponent(showMore); HorizontalLayout buttons = new HorizontalLayout(); content.addComponent(buttons); Button ok = new Button("Ok", new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { group.commit(); AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean(); gantt.markStepDirty(step); if (parentStepSelect.isEnabled() && parentStepSelect.getValue() != null) { SubStep subStep = addSubStep(parentStepSelect, step); step = subStep; } if (step instanceof Step && !gantt.getSteps().contains(step)) { gantt.addStep((Step) step); } if (ganttListener != null && step instanceof Step) { ganttListener.stepModified((Step) step); } win.close(); } catch (CommitException e) { Notification.show("Commit failed", e.getMessage(), Type.ERROR_MESSAGE); e.printStackTrace(); } } private SubStep addSubStep(final NativeSelect parentStepSelect, AbstractStep dataSource) { SubStep subStep = new SubStep(); subStep.setCaption(dataSource.getCaption()); subStep.setCaptionMode(dataSource.getCaptionMode()); subStep.setStartDate(dataSource.getStartDate()); subStep.setEndDate(dataSource.getEndDate()); subStep.setBackgroundColor(dataSource.getBackgroundColor()); subStep.setDescription(dataSource.getDescription()); subStep.setStyleName(dataSource.getStyleName()); ((Step) parentStepSelect.getValue()).addSubStep(subStep); return subStep; } }); Button cancel = new Button("Cancel", new ClickListener() { @Override public void buttonClick(ClickEvent event) { group.discard(); win.close(); } }); Button delete = new Button("Delete", new ClickListener() { @Override public void buttonClick(ClickEvent event) { AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean(); if (step instanceof SubStep) { SubStep substep = (SubStep) step; substep.getOwner().removeSubStep(substep); } else { gantt.removeStep((Step) step); if (ganttListener != null) { ganttListener.stepDeleted((Step) step); } } win.close(); } }); buttons.addComponent(ok); buttons.addComponent(cancel); buttons.addComponent(delete); win.setClosable(true); DashboardUI.getCurrent().getUI().addWindow(win); }
From source file:com.swifta.mats.web.usermanagement.AddUserModule.java
private HashMap<Integer, String> getCountries() { HashMap<Integer, String> c = new HashMap<>(); String qx = "SELECT countryname as cname, countryid as cid FROM " + MatsWebPortalUI.conf.dbin + ".country;"; // String Uname = "psaproduser"; // String Pword = "psaproduser@2015"; String drivers = "com.mysql.jdbc.Driver"; try {/*from w w w . j a va 2 s.c o m*/ Class<?> driver_class = Class.forName(drivers); Driver driver = (Driver) driver_class.newInstance(); DriverManager.registerDriver(driver); Connection conn = DriverManager.getConnection(MatsWebPortalUI.conf.DB, MatsWebPortalUI.conf.UN, MatsWebPortalUI.conf.PW); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(qx); while (rs.next()) { c.put(rs.getInt("cid"), rs.getString("cname")); } } catch (SQLException | ClassNotFoundException | InstantiationException | IllegalAccessException e) { e.printStackTrace(); Notification.show("DB Connection", "Error Establishing DBConnection: " + e.getMessage(), Notification.Type.ERROR_MESSAGE); } return c; }
From source file:com.swifta.mats.web.usermanagement.AddUserModule.java
private HashMap<Integer, String> getStates(int cid) { HashMap<Integer, String> s = new HashMap<>(); String qx = "SELECT state as s, countrystateid as sid FROM " + MatsWebPortalUI.conf.dbin + ".countrystate where countryid = " + cid + ";"; String drivers = "com.mysql.jdbc.Driver"; try {/*from w ww.j av a 2 s . c o m*/ Class<?> driver_class = Class.forName(drivers); Driver driver = (Driver) driver_class.newInstance(); DriverManager.registerDriver(driver); Connection conn = DriverManager.getConnection(MatsWebPortalUI.conf.DB, MatsWebPortalUI.conf.UN, MatsWebPortalUI.conf.PW); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(qx); while (rs.next()) { s.put(rs.getInt("sid"), rs.getString("s")); } } catch (SQLException | ClassNotFoundException | InstantiationException | IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); Notification.show("DB Connection", "Error Establishing DBConnection: " + e.getMessage(), Notification.Type.ERROR_MESSAGE); } return s; }
From source file:com.swifta.mats.web.usermanagement.AddUserModule.java
private HashMap<Integer, String> getLGs(int sid) { HashMap<Integer, String> s = new HashMap<>(); // = 1//from w w w .j a v a 2 s.c om String qx = "SELECT countrystatelgaid as lgid, lganame as lg FROM " + MatsWebPortalUI.conf.dbin + ".countrystatelga where countrystateid = " + sid + ";"; String drivers = "com.mysql.jdbc.Driver"; try { Class<?> driver_class = Class.forName(drivers); Driver driver = (Driver) driver_class.newInstance(); DriverManager.registerDriver(driver); Connection conn = DriverManager.getConnection(MatsWebPortalUI.conf.DB, MatsWebPortalUI.conf.UN, MatsWebPortalUI.conf.PW); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(qx); while (rs.next()) { s.put(rs.getInt("lgid"), rs.getString("lg")); } } catch (SQLException | ClassNotFoundException | InstantiationException | IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); Notification.show("DB Connection", "Error Establishing DBConnection: " + e.getMessage(), Notification.Type.ERROR_MESSAGE); } return s; }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private void validateAndSave() { String strResponse = ""; String idtype = ""; UserManagementService ums = new UserManagementService(); try {/*from w w w .jav a 2s . com*/ try { if (!isValidatorAdded) addValidators(); validate(); } catch (InvalidValueException e) { throw new InvalidValueException(e.getMessage()); } String bacc = (tFBAcc.getValue() == null) ? "" : tFBAcc.getValue().toString(); int bid = (comboBID.getValue() == null) ? 0 : Integer.valueOf(comboBID.getValue().toString()); String bd = (comboBDomain.getValue() == null) ? "" : comboBDomain.getValue().toString(); String clrno = (tFClrNo.getValue() == null) ? "" : tFClrNo.getValue().toString(); String cur = (comboCur.getValue() == null) ? "" : comboCur.getValue().toString(); String accEmail = (tFAccEmail.getValue() == null) ? "" : tFAccEmail.getValue().toString(); String msisdn = (tFMSISDN.getValue() == null) ? "" : tFMSISDN.getValue().toString(); int profid = (comboProfile.getValue() == null) ? 0 : Integer.valueOf(comboProfile.getValue().toString()); String secQn = (comboSecQn.getValue() == null) ? "" : comboSecQn.getValue().toString(); String secAns = (tFSecAns.getValue() == null) ? "" : tFSecAns.getValue().toString(); String tAndC = (chcTAndC.getValue() == null) ? "" : chcTAndC.getValue().toString(); String un = (tFUN.getValue() == null) ? "" : tFUN.getValue().toString(); int country = (comboCountry.getValue() == null) ? 0 : Integer.valueOf(comboCountry.getValue().toString()); Date dob = (dFDoB.getValue() == null) ? new Date() : (Date) dFDoB.getValue(); String employer = (tFEmp.getValue() == null) ? "" : tFEmp.getValue().toString(); String fn = (tFFN.getValue() == null) ? "" : tFFN.getValue().toString(); String gender = (optSex.getValue() == null) ? "" : optSex.getItemCaption(optSex.getValue()).toString(); int lang = (comboLang.getValue() == null) ? 0 : Integer.valueOf(comboLang.getValue().toString()); String ln = (tFLN.getValue() == null) ? "" : tFLN.getValue().toString(); int lgid = (comboLG.getValue() == null) ? 0 : Integer.valueOf(comboLG.getValue().toString()); String mn = (tFMN.getValue() == null) ? "" : tFMN.getValue().toString(); String occ = (tFOcc.getValue() == null) ? "" : tFOcc.getValue().toString(); String pref = (comboPref.getValue() == null) ? "" : comboPref.getValue().toString(); int stateid = (comboState.getValue() == null) ? 0 : Integer.valueOf(comboState.getValue().toString()); String suff = (comboSuff.getValue() == null) ? "" : comboSuff.getValue().toString(); String city = (tFCity.getValue() == null) ? "" : tFCity.getValue().toString(); String pcode = (tFPostalCode.getValue() == null) ? "" : tFPostalCode.getValue().toString(); String str = (tFStreet.getValue() == null) ? "" : tFStreet.getValue().toString(); String prov = (tFProv.getValue() == null) ? "" : tFProv.getValue().toString(); Date doe = (dFDoE.getValue() == null) ? new Date() : (Date) dFDoE.getValue(); String idno = (tFIDNo.getValue() == null) ? "" : tFIDNo.getValue().toString(); Date doi = (dFDoI.getValue() == null) ? new Date() : (Date) dFDoI.getValue(); String issuer = (tFIssuer.getValue() == null) ? "" : tFIssuer.getValue().toString(); String pem = (tFPEmail.getValue() == null) ? "" : tFPEmail.getValue().toString(); String pmno = (tFPMNo.getValue() == null) ? "" : tFPMNo.getValue().toString(); String pamno = (tFPANo.getValue() == null) ? "" : tFPANo.getValue().toString(); String sem = (tFSEmail.getValue() == null) ? "" : tFSEmail.getValue().toString(); String smno = (tFSMNo.getValue() == null) ? "" : tFSMNo.getValue().toString(); String samno = (tFSANo.getValue() == null) ? "" : tFSANo.getValue().toString(); // IdentificationType idtype = // ProvisioningStub.IdentificationType.Factory // .fromValue(comboIDType.getValue().toString()); if (comboIDType.getValue() != null) if (comboIDType.getValue().toString().equals("Passport Number")) { idtype = ProvisioningStub.IdentificationType.PASSP.toString(); System.out.println("idtype>>>>>1 " + idtype); } else if (comboIDType.getValue().toString() .equals("National Registration Identification Number")) { idtype = ProvisioningStub.IdentificationType.NRIN.toString(); System.out.println("idtype>>>>>2 " + idtype); } else if (comboIDType.getValue().toString().equals("Drivers License Number")) { idtype = ProvisioningStub.IdentificationType.DRLCS.toString(); System.out.println("idtype>>>>>3 " + idtype); } else if (comboIDType.getValue().toString().equals("Identification Card")) { idtype = ProvisioningStub.IdentificationType.IDCD.toString(); System.out.println("idtype>>>>>4 " + idtype); } else if (comboIDType.getValue().toString().equals("Employer Identification Number")) { idtype = ProvisioningStub.IdentificationType.EMID.toString(); } else idtype = ""; System.out.println("idtype>>>>> " + idtype); System.out.println("idtype>>>>> " + ProvisioningStub.IdentificationType.PASSP.toString()); strResponse = ums.registerUser(bacc, bid, bd, clrno, cur, accEmail, msisdn, profid, secQn, secAns, tAndC, un, country, dob, employer, fn, gender, lang, ln, lgid, mn, occ, pref, stateid, suff, city, pcode, str, prov, doe, idno, idtype, doi, issuer, pem, pmno, pamno, sem, smno, samno); } catch (Exception e) { e.printStackTrace(); Notification.show("Response: ", e.getMessage(), Notification.Type.ERROR_MESSAGE); return; } if (strResponse.contains("completed") && strResponse.contains("successful")) NotifCustom.show("Message: ", strResponse); else Notification.show("Response: " + strResponse, Notification.Type.ERROR_MESSAGE); }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private void errorHandler(Exception e) { e.printStackTrace();/*from www. ja v a2 s . c o m*/ Notification.show("DB Connection", "Error connecting to the DB: ", Notification.Type.ERROR_MESSAGE); }