Example usage for com.vaadin.ui Notification show

List of usage examples for com.vaadin.ui Notification show

Introduction

In this page you can find the example usage for com.vaadin.ui Notification show.

Prototype

public static Notification show(String caption, Type type) 

Source Link

Document

Shows a notification message the current page.

Usage

From source file:com.save.area.CreateNewAreaWindow.java

VerticalLayout getVlayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();//from   w  w w.  jav a2 s.  c  o  m
    vlayout.setMargin(true);
    vlayout.setSpacing(true);

    final TextField areaField = new TextField("Create Area: ");
    areaField.setWidth("100%");
    areaField.setRequired(true);
    areaField.setRequiredError("*Required Field");
    vlayout.addComponent(areaField);

    Button createBtn = new Button("CREATE NEW AREA");
    createBtn.setWidth("100%");
    createBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (as.isAreaExist(areaField.getValue().trim().toLowerCase())) {
                Notification.show("Area already Exist!", Notification.Type.WARNING_MESSAGE);
                return;
            }

            if (areaField.getValue() == null || areaField.getValue().trim().isEmpty()) {
                Notification.show("Area Field cannot be empty!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            boolean result = as.createNewArea(areaField.getValue().trim().toLowerCase());
            if (result) {
                Notification.show("Done!");
                close();
            }
        }
    });
    createBtn.setImmediate(true);

    vlayout.addComponent(createBtn);

    return vlayout;
}

From source file:com.save.area.DeleteAreaWindow.java

@Override
public void buttonClick(Button.ClickEvent event) {
    if (area.getValue() == null) {
        Notification.show("Select Area to Delete", Notification.Type.WARNING_MESSAGE);
        return;/*  www  .  ja  v a2 s. co  m*/
    }

    boolean result = as.deleteArea((int) area.getValue(), area.getItemCaption(area.getValue()));
    if (result) {
        close();
    }
}

From source file:com.save.area.serviceprovider.AreaServiceImpl.java

@Override
public boolean updateArea(String newAreaCode, String previousAreaCode) {
    Connection conn = DBConnection.connect();
    PreparedStatement pstmt = null;
    boolean result = false;

    try {//  w  ww .  j  av  a 2  s . c  o m
        conn.setAutoCommit(false);
        pstmt = conn.prepareStatement("UPDATE area SET AreaCode = ? " + "WHERE AreaCode = ? ");
        pstmt.setString(1, newAreaCode);
        pstmt.setString(2, previousAreaCode);
        pstmt.executeUpdate();

        pstmt = conn.prepareStatement("UPDATE city SET AreaCode = ? " + "WHERE AreaCode = ? ");
        pstmt.setString(1, newAreaCode);
        pstmt.setString(2, previousAreaCode);
        pstmt.executeUpdate();

        conn.commit();
        Notification.show("Commit Update", Notification.Type.TRAY_NOTIFICATION);
        result = true;
    } catch (SQLException ex) {
        try {
            conn.rollback();
            Notification.show("Commit Rollback", Notification.Type.ERROR_MESSAGE);
        } catch (SQLException ex1) {
            ErrorLoggedNotification.showErrorLoggedOnWindow(ex1.toString(), this.getClass().getName());
            Logger.getLogger(AreaServiceImpl.class.getName()).log(Level.SEVERE, null, ex1);
        }
        ErrorLoggedNotification.showErrorLoggedOnWindow(ex.toString(), this.getClass().getName());
        Logger.getLogger(AreaServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            if (conn != null || !conn.isClosed()) {
                pstmt.close();
                conn.close();
            }
        } catch (SQLException ex) {
            ErrorLoggedNotification.showErrorLoggedOnWindow(ex.toString(), this.getClass().getName());
            Logger.getLogger(AreaServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    return result;
}

From source file:com.save.area.serviceprovider.AreaServiceImpl.java

@Override
public boolean deleteArea(int areaId, String areaCode) {
    Connection conn = DBConnection.connect();
    PreparedStatement pstmt = null;
    boolean result = false;

    try {//from  www .  j  a v  a  2s.co m
        conn.setAutoCommit(false);

        pstmt = conn.prepareStatement("DELETE FROM area WHERE AreaID = " + areaId + " ");
        pstmt.executeUpdate();

        pstmt = conn.prepareStatement(
                "UPDATE city " + "SET AreaCode = null " + "WHERE AreaCode = '" + areaCode + "' ");
        pstmt.executeUpdate();

        conn.commit();
        result = true;
        Notification.show("Delete Area " + areaCode, Notification.Type.TRAY_NOTIFICATION);
    } catch (SQLException ex) {
        try {
            conn.rollback();
            Notification.show("Delete Failed!", Notification.Type.ERROR_MESSAGE);
        } catch (SQLException ex1) {
            ErrorLoggedNotification.showErrorLoggedOnWindow(ex1.toString(), this.getClass().getName());
            Logger.getLogger(AreaServiceImpl.class.getName()).log(Level.SEVERE, null, ex1);
        }
        ErrorLoggedNotification.showErrorLoggedOnWindow(ex.toString(), this.getClass().getName());
        Logger.getLogger(AreaServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            if (conn != null || !conn.isClosed()) {
                pstmt.close();
                conn.close();
            }
        } catch (SQLException ex) {
            ErrorLoggedNotification.showErrorLoggedOnWindow(ex.toString(), this.getClass().getName());
            Logger.getLogger(AreaServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    return result;
}

From source file:com.save.client.ClientInformationForm.java

void editClient() {
    if (getClientId() == 0) {
        Notification.show("Select a Client from Table", Notification.Type.WARNING_MESSAGE);
        return;//ww  w .j  av  a 2  s.  co  m
    }

    if (client.getValue() == null || client.getValue().trim().isEmpty()) {
        getNotification();
        return;
    }
    if (province.getValue() == null) {
        getNotification();
        return;
    }
    if (city.getValue() == null) {
        getNotification();
        return;
    }
    if (address.getValue() == null || address.getValue().trim().isEmpty()) {
        getNotification();
        return;
    }
    if (landline.getValue() == null || landline.getValue().trim().isEmpty()) {
        getNotification();
        return;
    }
    if (mobile.getValue() == null || mobile.getValue().trim().isEmpty()) {
        getNotification();
        return;
    }

    Client c = new Client();
    c.setClientName(client.getValue().trim().toLowerCase());
    c.setCityId((int) city.getValue());
    c.setStreet(address.getValue().trim().toLowerCase());
    c.setLandline(landline.getValue().trim());
    c.setMobile(mobile.getValue().trim().toLowerCase());
    c.setAsDistributor(asDistributor);
    if (asDistributor == 1) {
        c.setClientType("distributor");
    } else {
        c.setClientType(clientType.getItemCaption(clientType.getValue()));
    }
    c.setClientId(getClientId());

    boolean result = clientService.editClient(c);
    if (result) {
        getHsplit().setFirstComponent(new ClientsDataGridProperties(getHsplit(), "client"));
    }
}

From source file:com.save.client.ClientInformationForm.java

void getNotification() {
    Notification.show("Complete Fields!", Notification.Type.ERROR_MESSAGE);
}

From source file:com.save.client.RemoveAccountWindow.java

VerticalLayout getVLayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);//w ww  .j a  va  2  s .c om
    vlayout.setMargin(true);
    vlayout.setSizeFull();

    final TextArea remarks = new TextArea("Remarks: ");
    remarks.setRows(2);
    remarks.setWidth("100%");
    vlayout.addComponent(remarks);

    Button removeBtn = new Button("REMOVE ACCOUNT?");
    removeBtn.setWidth("100%");
    removeBtn.addClickListener((Button.ClickEvent event) -> {
        if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
            Notification.show("Add Remarks!", Notification.Type.ERROR_MESSAGE);
            return;
        }

        boolean result = clientService.removeAccount(getClientId(), remarks.getValue().trim().toLowerCase());
        if (result) {
            close();
        }
    });
    vlayout.addComponent(removeBtn);

    return vlayout;
}

From source file:com.save.clients.AcknowledgementPromoForm.java

void getNotification() {
    Notification.show("Fill-up all Fields!", Notification.Type.ERROR_MESSAGE);
}

From source file:com.save.clients.AcknowledgementPromoForm.java

@Override
public void buttonClick(Button.ClickEvent event) {
    if (getClientId() == 0) {
        Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
        return;/*from  w w w  .j  a  va2s  .c  o  m*/
    }
    if (entryDate.getValue() == null) {
        getNotification();
        return;
    }
    if (promoItem.getValue() == null || promoItem.getValue().trim().isEmpty()) {
        getNotification();
        return;
    }
    if (promoAmount.getValue() == null || promoAmount.getValue().trim().isEmpty()) {
        getNotification();
        return;
    } else {
        if (!CommonUtilities.checkInputIfDouble(promoAmount.getValue().trim())) {
            Notification.show("Enter a numerical format for Amount!", Notification.Type.ERROR_MESSAGE);
            return;
        }
    }
    if (quantity.getValue() == null || quantity.getValue().trim().isEmpty()) {
        getNotification();
        return;
    } else {
        if (!CommonUtilities.checkInputIfDouble(quantity.getValue().trim())) {
            Notification.show("Enter a numerical format for Quantity!", Notification.Type.ERROR_MESSAGE);
            return;
        }
    }
    if (productItems.getValue() == null) {
        getNotification();
        return;
    }
    if (startDate.getValue() == null) {
        getNotification();
        return;
    }
    if (endDate.getValue() == null) {
        getNotification();
        return;
    }
    //        if(areaSales.getValue() == null){ getNotification(); return; }
    if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
        getNotification();
        return;
    }

    PromoDeals pd = new PromoDeals();
    pd.setClientId(getClientId());
    pd.setPromoItem(promoItem.getValue().trim().toLowerCase());
    pd.setPromoAmount(CommonUtilities.convertStringToDouble(promoAmount.getValue().trim()));
    pd.setQuantity(CommonUtilities.convertStringToDouble(quantity.getValue().trim()));
    pd.setProductId((int) productItems.getValue());
    pd.setEntryDate(entryDate.getValue());
    pd.setStartDate(startDate.getValue());
    pd.setEndDate(endDate.getValue());
    pd.setRemarks(remarks.getValue().trim().toLowerCase());
    pd.setSalesRepId((int) ((salesRep.getValue() == null) ? 0 : salesRep.getValue()));
    pd.setAreaSalesId((int) ((areaSales.getValue() == null) ? 0 : areaSales.getValue()));

    PDDataGridProperties dataGrid = new PDDataGridProperties(getClientId());

    if (event.getButton().getCaption().equals("SAVE")) {
        boolean result = pds.create(pd);
        if (result) {
            this.close();
        }
    } else {
        pd.setPromoId(getPromoId());
        boolean result = pds.update(pd);
        if (result) {
            this.close();
        }
    }

}

From source file:com.save.employee.CreateNewAccountWindow.java

FormLayout getLayout() {
    FormLayout f = new FormLayout();
    f.setReadOnly(false);//w  w w .  j  a  v  a 2  s.  co  m
    f.setSpacing(true);
    f.setMargin(true);

    final TextField employeeNo = new TextField("Employee No: ");
    employeeNo.setWidth("100%");
    employeeNo.setRequired(true);
    employeeNo.setNullSettingAllowed(false);
    f.addComponent(employeeNo);

    final TextField firstname = new TextField("Firstname: ");
    firstname.setWidth("100%");
    firstname.setRequired(true);
    firstname.setNullSettingAllowed(false);
    f.addComponent(firstname);

    final TextField middlename = new TextField("Middlename: ");
    middlename.setWidth("100%");
    middlename.setRequired(true);
    middlename.setNullSettingAllowed(false);
    f.addComponent(middlename);

    final TextField lastname = new TextField("Lastname: ");
    lastname.setWidth("100%");
    lastname.setRequired(true);
    lastname.setNullSettingAllowed(false);
    f.addComponent(lastname);

    final OptionGroup gender = new OptionGroup("Gender: ");
    gender.addItem("Female");
    gender.addItem("Male");
    gender.addStyleName("horizontal");
    gender.setValue("Female");
    f.addComponent(gender);

    final ComboBox status = new ComboBox("Status: ");
    status.setWidth("100%");
    status.setNullSelectionAllowed(false);
    status.addItem("Single");
    status.addItem("Married");
    status.addItem("Widow");
    status.addItem("Separated");
    f.addComponent(status);

    Button saveBtn = new Button("SAVE");
    saveBtn.setWidth("100%");
    saveBtn.addClickListener((Button.ClickEvent event) -> {
        //TODO
        if (employeeNo.getValue().isEmpty() || employeeNo.getValue() == null) {
            Notification.show("Requried Emloyee ID", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (firstname.getValue().isEmpty() || firstname.getValue() == null) {
            Notification.show("Requried Firstname", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (middlename.getValue().isEmpty() || middlename.getValue() == null) {
            Notification.show("Requried Middlename", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (lastname.getValue().isEmpty() || lastname.getValue() == null) {
            Notification.show("Requried Lastname", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (status.getValue() == null) {
            Notification.show("Requried Status", Notification.Type.WARNING_MESSAGE);
        }

        if (employeeService.checkIfEmployeeNoExist(employeeNo.getValue().trim().toLowerCase())) {
            Notification.show("EmployeeId already Exist!", Notification.Type.ERROR_MESSAGE);
            return;
        }

        Employee e = new Employee();
        e.setEmployeeNo(employeeNo.getValue().trim().toLowerCase());
        e.setFirstname(firstname.getValue().trim().toLowerCase());
        e.setMiddlename(middlename.getValue().trim().toLowerCase());
        e.setLastname(lastname.getValue().trim().toLowerCase());
        e.setGender(gender.getValue().toString().trim().toLowerCase());
        e.setPersonalStatus(status.getValue().toString());

        boolean result = employeeService.createNewAccount(e);
        if (result) {
            close();
            getHsplit().setFirstComponent(new EmployeesDataGridProperties(getHsplit(), "personal"));
        }
    });
    f.addComponent(saveBtn);

    return f;
}