Example usage for com.vaadin.ui Alignment MIDDLE_LEFT

List of usage examples for com.vaadin.ui Alignment MIDDLE_LEFT

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment MIDDLE_LEFT.

Prototype

Alignment MIDDLE_LEFT

To view the source code for com.vaadin.ui Alignment MIDDLE_LEFT.

Click Source Link

Usage

From source file:com.openhris.calendar.SchedulerMainUI.java

public SchedulerMainUI() {

    setMargin(true);//  w ww.  jav a  2s .c o  m
    cal = new Calendar();

    calendarEvents();
    cal.setWidth("100%");
    cal.setHeight("100%");
    cal.setImmediate(true);

    Date today = new Date();
    calendar = new GregorianCalendar();
    calendar.setTime(today);

    updateCaptionLabel();
    initNavigationButtons();

    if (!showWeeklyView) {
        int rollAmount = calendar.get(GregorianCalendar.DAY_OF_MONTH) - 1;
        calendar.add(GregorianCalendar.DAY_OF_MONTH, -rollAmount);
        currentMonthsFirstDate = calendar.getTime();
        cal.setStartDate(currentMonthsFirstDate);
        calendar.add(GregorianCalendar.MONTH, 1);
        calendar.add(GregorianCalendar.DATE, -1);
        cal.setEndDate(calendar.getTime());
    }

    cal.setHandler(new BasicDateClickHandler() {
        @Override
        public void dateClick(CalendarComponentEvents.DateClickEvent event) {
            Calendar cal = event.getComponent();
            long currentCalDateRange = cal.getEndDate().getTime() - cal.getStartDate().getTime();

            if (currentCalDateRange < VCalendar.DAYINMILLIS) {
                // Change the date range to the current week
                cal.setStartDate(cal.getFirstDateForWeek(event.getDate()));
                cal.setEndDate(cal.getLastDateForWeek(event.getDate()));

            } else {
                // Default behaviour, change date range to one day
                super.dateClick(event);
            }
        }
    });

    addCalendarEventListeners();

    GridLayout grid = new GridLayout(5, 1);
    grid.setSizeFull();

    monthButton.setVisible(false);
    weekButton.setVisible(false);

    grid.addComponent(monthButton, 1, 0);
    grid.setComponentAlignment(monthButton, Alignment.MIDDLE_CENTER);

    monthLabel = new Label();
    monthLabel.setValue(OpenHrisUtilities.convertDateFormatForCalendar(currentMonthsFirstDate.toString()));
    monthLabel.setContentMode(Label.CONTENT_XHTML);
    monthLabel.addStyleName("month");
    grid.addComponent(monthLabel, 2, 0);
    grid.setComponentAlignment(monthLabel, Alignment.MIDDLE_CENTER);

    grid.addComponent(weekButton, 3, 0);
    grid.setComponentAlignment(weekButton, Alignment.MIDDLE_CENTER);

    grid.addComponent(nextButton, 4, 0);
    grid.setComponentAlignment(nextButton, Alignment.MIDDLE_RIGHT);

    grid.addComponent(prevButton, 0, 0);
    grid.setComponentAlignment(prevButton, Alignment.MIDDLE_LEFT);

    addComponent(grid);
    addComponent(cal);
    setExpandRatio(cal, 1);
}

From source file:com.openhris.employee.EmployeeInformationUI.java

public ComponentContainer employeeInformationWindow() {
    TabSheet ts = new TabSheet();
    ts.setSizeFull();//w w w. j av a2 s  .c om
    ts.addStyleName("bar");

    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setCaption("Personal Information");
    vlayout.addComponent(employeePersonalInformation);
    vlayout.setComponentAlignment(employeePersonalInformation, Alignment.MIDDLE_LEFT);
    ts.addComponent(vlayout);

    vlayout = new VerticalLayout();
    vlayout.setCaption("Address");
    vlayout.addComponent(employeeAddress);
    ts.addComponent(vlayout);

    vlayout = new VerticalLayout();
    vlayout.setCaption("Character Reference");
    vlayout.addComponent(characterReference);
    ts.addComponent(vlayout);

    vlayout = new VerticalLayout();
    vlayout.setCaption("Dependent(s)");
    //   vlayout.addComponent(employeePersonalInformation);
    ts.addComponent(vlayout);

    vlayout = new VerticalLayout();
    vlayout.setCaption("Educational Background");
    //   vlayout.addComponent(employeePersonalInformation);
    ts.addComponent(vlayout);

    vlayout = new VerticalLayout();
    vlayout.setCaption("Post Employment Info");
    vlayout.addComponent(postEmploymentInfomation);
    ts.addComponent(vlayout);

    vlayout = new VerticalLayout();
    vlayout.setCaption("Work History");
    //   vlayout.addComponent(employeePersonalInformation);
    ts.addComponent(vlayout);

    vlayout = new VerticalLayout();
    vlayout.setCaption("Salary Information");
    vlayout.addComponent(employeeSalaryInformation);
    ts.addComponent(vlayout);

    vlayout = new VerticalLayout();
    vlayout.setCaption("Allowance Information");
    vlayout.addComponent(employeeAllowanceInformation);
    ts.addComponent(vlayout);

    vlayout = new VerticalLayout();
    vlayout.setCaption("Other Information");
    vlayout.addComponent(otherInformation);
    ts.addComponent(vlayout);

    return ts;
}

From source file:com.openhris.employee.EmployeePersonalInformation.java

public ComponentContainer layout() {
    glayout = new GridLayout(4, 19);
    glayout.setSpacing(true);/*  ww  w  .ja  v  a 2  s  . c o  m*/
    glayout.setWidth("600px");
    glayout.setHeight("100%");

    final Panel imagePanel = new Panel();
    imagePanel.setStyleName("light");
    AbstractLayout panelLayout = (AbstractLayout) imagePanel.getContent();
    panelLayout.setMargin(false);
    imagePanel.setWidth("100px");

    avatar = new Embedded(null, new ThemeResource("../myTheme/img/fnc.jpg"));
    avatar.setImmediate(true);
    avatar.setWidth(90, Sizeable.UNITS_PIXELS);
    avatar.setHeight(90, Sizeable.UNITS_PIXELS);
    avatar.addStyleName("logo-img");
    imagePanel.addComponent(avatar);
    glayout.addComponent(avatar, 0, 0, 0, 1);
    glayout.setComponentAlignment(imagePanel, Alignment.MIDDLE_CENTER);

    Button uploadPhotoBtn = new Button("Upload..");
    uploadPhotoBtn.setWidth("100%");
    uploadPhotoBtn.setStyleName(Reindeer.BUTTON_SMALL);
    uploadPhotoBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (getEmployeeId() == null) {
                getWindow().showNotification("You did not select and Employee!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            Window uploadImage = new UploadImage(imagePanel, avatar, getEmployeeId());
            uploadImage.setWidth("450px");
            if (uploadImage.getParent() == null) {
                getWindow().addWindow(uploadImage);
            }
            uploadImage.setModal(true);
            uploadImage.center();
        }
    });
    glayout.addComponent(uploadPhotoBtn, 0, 2);
    glayout.setComponentAlignment(uploadPhotoBtn, Alignment.MIDDLE_CENTER);

    fnField = createTextField("Firstname: ");
    glayout.addComponent(fnField, 1, 0);
    glayout.setComponentAlignment(fnField, Alignment.MIDDLE_LEFT);

    mnField = createTextField("Middlename: ");
    glayout.addComponent(mnField, 2, 0);
    glayout.setComponentAlignment(mnField, Alignment.MIDDLE_LEFT);

    lnField = createTextField("Lastname: ");
    glayout.addComponent(lnField, 3, 0);
    glayout.setComponentAlignment(lnField, Alignment.MIDDLE_LEFT);

    companyIdField = createTextField("Employee ID: ");
    companyIdField.setEnabled(false);
    glayout.addComponent(companyIdField, 1, 1, 2, 1);
    glayout.setComponentAlignment(companyIdField, Alignment.MIDDLE_LEFT);

    dobField = new PopupDateField("Date of Birth: ");
    dobField.addStyleName("mydate");
    dobField.setDateFormat("MM/dd/yyyy");
    dobField.setWidth("100%");
    dobField.setResolution(DateField.RESOLUTION_DAY);
    glayout.addComponent(dobField, 1, 2);
    glayout.setComponentAlignment(dobField, Alignment.MIDDLE_LEFT);

    pobField = createTextField("Birth Place: ");
    pobField.setValue("N/A");
    glayout.addComponent(pobField, 2, 2, 3, 2);
    glayout.setComponentAlignment(pobField, Alignment.MIDDLE_LEFT);

    genderBox = dropDownComponent.populateGenderList(new ComboBox());
    genderBox.setWidth("100%");
    glayout.addComponent(genderBox, 1, 3);
    glayout.setComponentAlignment(genderBox, Alignment.MIDDLE_LEFT);

    civilStatusBox = dropDownComponent.populateCivilStatusList(new ComboBox());
    civilStatusBox.setWidth("100%");
    glayout.addComponent(civilStatusBox, 2, 3);
    glayout.setComponentAlignment(civilStatusBox, Alignment.MIDDLE_LEFT);

    citizenshipField = createTextField("Citizenship: ");
    citizenshipField.setValue("N/A");
    glayout.addComponent(citizenshipField, 3, 3);
    glayout.setComponentAlignment(citizenshipField, Alignment.MIDDLE_LEFT);

    heightField = createTextField("Height(cm):");
    heightField.setValue(0.0);
    glayout.addComponent(heightField, 1, 4);
    glayout.setComponentAlignment(heightField, Alignment.MIDDLE_LEFT);

    weightField = createTextField("Weight(kg): ");
    weightField.setValue(0.0);
    glayout.addComponent(weightField, 2, 4);
    glayout.setComponentAlignment(weightField, Alignment.MIDDLE_LEFT);

    religionField = createTextField("Religion: ");
    religionField.setValue("N/A");
    glayout.addComponent(religionField, 3, 4);
    glayout.setComponentAlignment(religionField, Alignment.MIDDLE_LEFT);

    spouseNameField = createTextField("Spouse Name: ");
    spouseNameField.setValue("N/A");
    glayout.addComponent(spouseNameField, 1, 5, 2, 5);
    glayout.setComponentAlignment(spouseNameField, Alignment.MIDDLE_LEFT);

    spouseOccupationField = createTextField("Spouse Occupation: ");
    spouseOccupationField.setValue("N/A");
    glayout.addComponent(spouseOccupationField, 3, 5);
    glayout.setComponentAlignment(spouseOccupationField, Alignment.MIDDLE_LEFT);

    spouseOfficeAddressField = createTextField("Spouse Office Address: ");
    spouseOfficeAddressField.setValue("N/A");
    glayout.addComponent(spouseOfficeAddressField, 1, 6, 3, 6);
    glayout.setComponentAlignment(spouseOfficeAddressField, Alignment.MIDDLE_LEFT);

    fathersNameField = createTextField("Father's Name: ");
    fathersNameField.setValue("N/A");
    glayout.addComponent(fathersNameField, 1, 7, 2, 7);
    glayout.setComponentAlignment(fathersNameField, Alignment.MIDDLE_LEFT);

    fathersOccupationField = createTextField("Father's Occupation: ");
    fathersOccupationField.setValue("N/A");
    glayout.addComponent(fathersOccupationField, 3, 7);
    glayout.setComponentAlignment(fathersOccupationField, Alignment.MIDDLE_LEFT);

    mothersNameField = createTextField("Mother's Maiden Name: ");
    mothersNameField.setValue("N/A");
    glayout.addComponent(mothersNameField, 1, 8, 2, 8);
    glayout.setComponentAlignment(mothersNameField, Alignment.MIDDLE_LEFT);

    mothersOccupationField = createTextField("Mother's Occupation: ");
    mothersOccupationField.setValue("N/A");
    glayout.addComponent(mothersOccupationField, 3, 8);
    glayout.setComponentAlignment(mothersOccupationField, Alignment.MIDDLE_LEFT);

    parentsAddressField = createTextField("Parents Address");
    parentsAddressField.setValue("N/A");
    glayout.addComponent(parentsAddressField, 1, 9, 3, 9);
    glayout.setComponentAlignment(parentsAddressField, Alignment.MIDDLE_LEFT);

    dialectSpeakWriteField = createTextField("Language or Dialect you can speak or write: ");
    dialectSpeakWriteField.setValue("N/A");
    glayout.addComponent(dialectSpeakWriteField, 1, 10, 3, 10);
    glayout.setComponentAlignment(dialectSpeakWriteField, Alignment.MIDDLE_LEFT);

    contactPersonNameField = createTextField("Contact Person: ");
    contactPersonNameField.setValue("N/A");
    glayout.addComponent(contactPersonNameField, 1, 11);
    glayout.setComponentAlignment(contactPersonNameField, Alignment.MIDDLE_LEFT);

    contactPersonAddressField = createTextField("Contact Person's Address: ");
    contactPersonAddressField.setValue("N/A");
    glayout.addComponent(contactPersonAddressField, 2, 11, 3, 11);
    glayout.setComponentAlignment(contactPersonAddressField, Alignment.MIDDLE_LEFT);

    contactPersonNoField = createTextField("Contact Person's Tel No: ");
    contactPersonNoField.setValue("N/A");
    glayout.addComponent(contactPersonNoField, 1, 12);
    glayout.setComponentAlignment(contactPersonNoField, Alignment.MIDDLE_LEFT);

    skillsField = createTextField("Skills: ");
    skillsField.setValue("N/A");
    glayout.addComponent(skillsField, 2, 12);
    glayout.setComponentAlignment(skillsField, Alignment.MIDDLE_LEFT);

    hobbyField = createTextField("Hobbies");
    hobbyField.setValue("N/A");
    glayout.addComponent(hobbyField, 3, 12);
    glayout.setComponentAlignment(hobbyField, Alignment.MIDDLE_LEFT);

    if (employeeId != null) {
        personalInformation = piService.getPersonalInformationData(employeeId);
        final byte[] image = personalInformation.getImage();
        if (image != null) {
            StreamResource.StreamSource imageSource = new StreamResource.StreamSource() {

                @Override
                public InputStream getStream() {
                    return new ByteArrayInputStream(image);
                }

            };

            StreamResource imageResource = new StreamResource(imageSource,
                    personalInformation.getFirstname() + ".jpg", getThisApplication());
            imageResource.setCacheTime(0);
            avatar.setSource(imageResource);
        }
        fnField.setValue(personalInformation.getFirstname().toUpperCase());
        mnField.setValue(personalInformation.getMiddlename().toUpperCase());
        lnField.setValue(personalInformation.getLastname().toUpperCase());
        companyIdField.setValue(employeeId);
        dobField.setValue(personalInformation.getDob());
        pobField.setValue(personalInformation.getPob());

        if (personalInformation.getCivilStatus() != null) {
            Object civilStatusId = civilStatusBox.addItem();
            civilStatusBox.setItemCaption(civilStatusId, personalInformation.getCivilStatus());
            civilStatusBox.setValue(civilStatusId);
        }

        if (personalInformation.getGender() != null) {
            Object genderId = genderBox.addItem();
            genderBox.setItemCaption(genderId, personalInformation.getGender());
            genderBox.setValue(genderId);
        }

        citizenshipField.setValue(personalInformation.getCitizenship());
        heightField.setValue(personalInformation.getHeight());
        weightField.setValue(personalInformation.getWeight());
        religionField.setValue(personalInformation.getReligion());
        spouseNameField.setValue(personalInformation.getSpouseName());
        spouseOccupationField.setValue(personalInformation.getSpouseOccupation());
        spouseOfficeAddressField.setValue(personalInformation.getSpouseOfficeAddress());
        fathersNameField.setValue(personalInformation.getFathersName());
        fathersOccupationField.setValue(personalInformation.getFathersOccupation());
        mothersNameField.setValue(personalInformation.getMothersName());
        mothersOccupationField.setValue(personalInformation.getMothersOccupation());
        parentsAddressField.setValue(personalInformation.getParentsAddress());
        dialectSpeakWriteField.setValue(personalInformation.getDialectSpeakWrite());
        contactPersonNameField.setValue(personalInformation.getContactPersonName());
        contactPersonAddressField.setValue(personalInformation.getContactPersonAddress());
        contactPersonNoField.setValue(personalInformation.getContactPersonNo());
        skillsField.setValue(personalInformation.getSkills());
        hobbyField.setValue(personalInformation.getHobby());
    }

    Button removeBtn = new Button("REMOVE EMPLOYEE");
    removeBtn.setWidth("100%");
    boolean visible = false;
    if (GlobalVariables.getUserRole() == null) {
        visible = false;
    } else if (GlobalVariables.getUserRole().equals("hr")
            || GlobalVariables.getUserRole().equals("administrator")) {
        visible = true;
    }
    removeBtn.setVisible(visible);
    removeBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (!GlobalVariables.getUserRole().equals("administrator")) {
                getWindow().showNotification("You need to an ADMINISTRATOR to perform this ACTION.",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            Window window = getRemoveWindow(getEmployeeId());
            window.setModal(true);
            if (window.getParent() == null) {
                getWindow().addWindow(window);
            }
            window.center();
        }
    });
    glayout.addComponent(removeBtn, 1, 13);

    Button saveButton = new Button("UPDATE EMPLOYEE's INFORMATION");
    saveButton.setWidth("100%");
    saveButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (dobField.getValue() == null || dobField.getValue().toString().isEmpty()) {
                getWindow().showNotification("Date of Birth Required!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (heightField.getValue() == null || heightField.getValue().toString().isEmpty()) {
                getWindow().showNotification("Null/Empty Value for Height is not ALLOWED!",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            } else {
                if (!convertionUtilities.checkInputIfDouble(heightField.getValue().toString())) {
                    getWindow().showNotification("Enter a numeric format for Height!",
                            Window.Notification.TYPE_ERROR_MESSAGE);
                    return;
                }
            }

            if (weightField.getValue() == null || weightField.getValue().toString().isEmpty()) {
                getWindow().showNotification("Null/Empty Value for Weight is not ALLOWED!",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            } else {
                if (!convertionUtilities.checkInputIfDouble(weightField.getValue().toString())) {
                    getWindow().showNotification("Enter a numeric format for Weight!",
                            Window.Notification.TYPE_ERROR_MESSAGE);
                    return;
                }
            }

            if (genderBox.getValue() == null || genderBox.getValue().toString().isEmpty()) {
                getWindow().showNotification("Select a Gender!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (civilStatusBox.getValue() == null || civilStatusBox.getValue().toString().isEmpty()) {
                getWindow().showNotification("Select Civil Status!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            PersonalInformation pi = new PersonalInformation();
            pi.setFirstname(fnField.getValue().toString().toLowerCase().trim());
            pi.setMiddlename(mnField.getValue().toString().toLowerCase().trim());
            pi.setLastname(lnField.getValue().toString().toLowerCase().trim());
            pi.setEmployeeId(employeeId);
            pi.setDob((Date) dobField.getValue());
            pi.setPob((pobField.getValue() == null) ? "N/A"
                    : pobField.getValue().toString().toLowerCase().trim());
            pi.setHeight(convertionUtilities.convertStringToDouble(heightField.getValue().toString()));
            pi.setWeight(convertionUtilities.convertStringToDouble(weightField.getValue().toString()));

            if (convertionUtilities.checkInputIfInteger(genderBox.getValue().toString())) {
                pi.setGender(genderBox.getItemCaption(genderBox.getValue()));
            } else {
                pi.setGender(genderBox.getValue().toString());
            }

            if (convertionUtilities.checkInputIfInteger(civilStatusBox.getValue().toString())) {
                pi.setCivilStatus(civilStatusBox.getItemCaption(civilStatusBox.getValue()));
            } else {
                pi.setCivilStatus(civilStatusBox.getValue().toString());
            }

            pi.setCitizenship(
                    (citizenshipField.getValue() == null) ? "N/A" : citizenshipField.getValue().toString());
            pi.setReligion((religionField.getValue() == null) ? "N/A" : religionField.getValue().toString());
            pi.setSpouseName(
                    (spouseNameField.getValue() == null) ? "N/A" : spouseNameField.getValue().toString());
            pi.setSpouseOccupation((spouseOccupationField.getValue() == null) ? "N/A"
                    : spouseOccupationField.getValue().toString());
            pi.setSpouseOfficeAddress((spouseOfficeAddressField.getValue() == null) ? "N/A"
                    : spouseOfficeAddressField.getValue().toString());
            pi.setFathersName(
                    (fathersNameField.getValue() == null) ? "N/A" : fathersNameField.getValue().toString());
            pi.setFathersOccupation((fathersOccupationField.getValue() == null) ? "N/A"
                    : fathersOccupationField.getValue().toString());
            pi.setMothersName(
                    (mothersNameField.getValue() == null) ? "N/A" : mothersNameField.getValue().toString());
            pi.setMothersOccupation((mothersOccupationField.getValue() == null) ? "N/A"
                    : mothersOccupationField.getValue().toString());
            pi.setParentsAddress((parentsAddressField.getValue() == null) ? "N/A"
                    : parentsAddressField.getValue().toString());
            pi.setDialectSpeakWrite((dialectSpeakWriteField.getValue() == null) ? "N/A"
                    : dialectSpeakWriteField.getValue().toString());
            pi.setContactPersonName((contactPersonNameField.getValue() == null) ? "N/A"
                    : contactPersonNameField.getValue().toString());
            pi.setContactPersonAddress((contactPersonAddressField.getValue() == null) ? "N/A"
                    : contactPersonAddressField.getValue().toString());
            pi.setContactPersonNo((contactPersonNoField.getValue() == null) ? "N/A"
                    : contactPersonNoField.getValue().toString());
            pi.setSkills((skillsField.getValue() == null) ? "N/A" : skillsField.getValue().toString());
            pi.setHobby((hobbyField.getValue() == null) ? "N/A" : hobbyField.getValue().toString());
            pi.setEmployeeId(getEmployeeId());

            //                boolean result = piService.updatePersonalInformation(pi, "UPDATE PERSONAL INFORMATION");
            Window window = updatePersonalInformationConfirmation(pi);
            window.setModal(true);
            if (window.getParent() == null) {
                getWindow().addWindow(window);
            }
            window.center();

            //      if(result){
            //          getWindow().showNotification("Information Updated", Window.Notification.TYPE_TRAY_NOTIFICATION);
            //      } else {
            //          getWindow().showNotification("SQL Error", Window.Notification.TYPE_ERROR_MESSAGE);
            //      }
        }
    });
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        saveButton.setEnabled(true);
    } else {
        saveButton.setEnabled(false);
    }
    glayout.addComponent(saveButton, 2, 13, 3, 13);

    glayout.setColumnExpandRatio(1, .10f);
    glayout.setColumnExpandRatio(2, .10f);
    glayout.setColumnExpandRatio(3, .10f);

    return glayout;
}

From source file:com.openhris.timekeeping.EditAttendanceTableContainerWindow.java

public EditAttendanceTableContainerWindow(String name, List dateList, String employeeId, String payrollPeriod,
        String payrollDate, String attendancePeriodFrom, String attendancePeriodTo, String employmentWageEntry,
        double employmentWage, int branchId, int payrollId) {

    this.name = name;
    this.dateList = dateList;
    this.employeeId = employeeId;
    this.payrollPeriod = payrollPeriod;
    this.payrollDate = payrollDate;
    this.attendancePeriodFrom = attendancePeriodFrom;
    this.attendancePeriodTo = attendancePeriodTo;
    this.employmentWageEntry = employmentWageEntry;
    this.employmentWage = employmentWage;
    this.branchId = branchId;
    this.payrollId = payrollId;

    setCaption("ATTENDANCE TABLE for " + getEmployeesName());
    setSizeFull();/*ww w  . j  a  va2  s .  c  om*/
    setModal(true);
    center();

    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();
    vlayout.setSpacing(true);

    GridLayout glayout = new GridLayout(2, 2);
    glayout.setSpacing(true);

    Label payrollPeriodLabel = new Label("Payroll Period: ");
    glayout.addComponent(payrollPeriodLabel, 0, 0);
    glayout.setComponentAlignment(payrollPeriodLabel, Alignment.MIDDLE_RIGHT);

    Label periodLabel = new Label(getPayrollPeriod());
    glayout.addComponent(periodLabel, 1, 0);
    glayout.setComponentAlignment(periodLabel, Alignment.MIDDLE_LEFT);

    Label payrollDateLabel = new Label("Payroll Date: ");
    glayout.addComponent(payrollDateLabel, 0, 1);
    glayout.setComponentAlignment(payrollDateLabel, Alignment.MIDDLE_RIGHT);

    Label dateLabel = new Label(getPayrollDate());
    glayout.addComponent(dateLabel, 1, 1);
    glayout.setComponentAlignment(dateLabel, Alignment.MIDDLE_LEFT);

    vlayout.addComponent(glayout);
    vlayout.addComponent(generateAttendanceTable());
    addComponent(vlayout);
}

From source file:com.openhris.timekeeping.EditAttendanceTableContainerWindow.java

VerticalLayout generateAttendanceTable() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();/*w ww .  j  a  va 2  s .c  o  m*/
    vlayout.setSpacing(true);

    if (getEmploymentWageEntry().equals("monthly")) {
        employmentWage = utilities.roundOffToTwoDecimalPlaces((employmentWage * 12) / 314);
    }

    final Table table = new Table();
    table.removeAllItems();
    table.setEnabled(true);
    table.setWidth("100%");
    table.setImmediate(true);
    table.setColumnCollapsingAllowed(true);

    table.addContainerProperty("edit", CheckBox.class, null);
    table.addContainerProperty("date", String.class, null);
    table.addContainerProperty("policy", String.class, null);
    table.addContainerProperty("holidays", String.class, null);
    table.addContainerProperty("premium", CheckBox.class, null);
    table.addContainerProperty("lates", TextField.class, null);
    table.addContainerProperty("undertime", TextField.class, null);
    table.addContainerProperty("overtime", TextField.class, null);
    table.addContainerProperty("night differential", TextField.class, null);
    table.addContainerProperty("l/min", Double.class, null);
    table.addContainerProperty("u/min", Double.class, null);
    table.addContainerProperty("o/min", Double.class, null);
    table.addContainerProperty("nd/min", Double.class, null);
    table.addContainerProperty("lholiday", Double.class, null);
    table.addContainerProperty("sholiday", Double.class, null);
    table.addContainerProperty("wdo", Double.class, null);
    table.addContainerProperty("psday", Double.class, null); //paid non-working holiday
    table.addContainerProperty("latesLH", Double.class, null);
    table.addContainerProperty("latesSH", Double.class, null);
    table.addContainerProperty("latesWO", Double.class, null);
    table.addContainerProperty("undertimeLH", Double.class, null);
    table.addContainerProperty("undertimeSH", Double.class, null);
    table.addContainerProperty("undertimeWO", Double.class, null);

    table.setColumnAlignment("edit", Table.ALIGN_CENTER);
    table.setColumnAlignment("date", Table.ALIGN_CENTER);
    table.setColumnAlignment("policy", Table.ALIGN_CENTER);
    table.setColumnAlignment("premium", Table.ALIGN_CENTER);
    table.setColumnAlignment("lates", Table.ALIGN_CENTER);
    table.setColumnAlignment("undertime", Table.ALIGN_CENTER);
    table.setColumnAlignment("overtime", Table.ALIGN_CENTER);
    table.setColumnAlignment("night differential", Table.ALIGN_CENTER);
    table.setColumnAlignment("l/min", Table.ALIGN_RIGHT);
    table.setColumnAlignment("u/min", Table.ALIGN_RIGHT);
    table.setColumnAlignment("o/min", Table.ALIGN_RIGHT);
    table.setColumnAlignment("nd/min", Table.ALIGN_RIGHT);
    table.setColumnAlignment("lholiday", Table.ALIGN_RIGHT);
    table.setColumnAlignment("sholiday", Table.ALIGN_RIGHT);
    table.setColumnAlignment("wdo", Table.ALIGN_RIGHT);
    table.setColumnAlignment("psday", Table.ALIGN_RIGHT);
    table.setColumnAlignment("latesLH", Table.ALIGN_RIGHT);
    table.setColumnAlignment("latesSH", Table.ALIGN_RIGHT);
    table.setColumnAlignment("latesWO", Table.ALIGN_RIGHT);
    table.setColumnAlignment("undertimeLH", Table.ALIGN_RIGHT);
    table.setColumnAlignment("undertimeSH", Table.ALIGN_RIGHT);
    table.setColumnAlignment("undertimeWO", Table.ALIGN_RIGHT);

    table.setColumnCollapsed("latesLH", true);
    table.setColumnCollapsed("latesSH", true);
    table.setColumnCollapsed("latesWO", true);
    table.setColumnCollapsed("undertimeLH", true);
    table.setColumnCollapsed("undertimeSH", true);
    table.setColumnCollapsed("undertimeWO", true);

    final String[] holidayList = { "legal-holiday", "special-holiday" };
    for (int i = 0; i < getDateList().size(); i++) {
        Object itemId = new Integer(i);

        final CheckBox edit = new CheckBox();
        edit.setData(i);
        edit.setEnabled(UserAccessControl.isEditAttendance());
        edit.setImmediate(true);

        final CheckBox premium = new CheckBox();
        premium.setData(itemId);
        premium.setEnabled(false);
        premium.setImmediate(true);

        final TextField lates = new TextField();
        lates.setWidth("50px");
        lates.setValue("0");
        lates.setEnabled(true);
        lates.setData(itemId);
        lates.setEnabled(false);
        lates.setImmediate(true);

        final TextField undertime = new TextField();
        undertime.setWidth("50px");
        undertime.setValue("0");
        undertime.setEnabled(true);
        undertime.setData(itemId);
        undertime.setEnabled(false);
        undertime.setImmediate(true);

        final TextField overtime = new TextField();
        overtime.setWidth("50px");
        overtime.setValue("0");
        overtime.setEnabled(true);
        overtime.setData(itemId);
        overtime.setEnabled(false);
        overtime.setImmediate(true);

        final TextField nightDifferential = new TextField();
        nightDifferential.setWidth("50px");
        nightDifferential.setValue("0");
        nightDifferential.setEnabled(true);
        nightDifferential.setData(itemId);
        nightDifferential.setEnabled(false);
        nightDifferential.setImmediate(true);

        edit.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                premium.setEnabled(event.getButton().booleanValue());
                lates.setEnabled(event.getButton().booleanValue());
                undertime.setEnabled(event.getButton().booleanValue());
                overtime.setEnabled(event.getButton().booleanValue());
                nightDifferential.setEnabled(event.getButton().booleanValue());
            }
        });

        premium.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);

                lates.setValue("0");
                undertime.setValue("0");
                overtime.setValue("0");
                nightDifferential.setValue("0");

                item.getItemProperty("l/min").setValue(0.0);
                item.getItemProperty("u/min").setValue(0.0);
                item.getItemProperty("o/min").setValue(0.0);
                item.getItemProperty("nd/min").setValue(0.0);

                if (event.getButton().booleanValue() == true) {
                    premiumRate = 0.1;
                } else {
                    premiumRate = 0.0;
                }

                item.getItemProperty("wdo")
                        .setValue(utilities.roundOffToTwoDecimalPlaces(
                                Double.parseDouble(item.getItemProperty("wdo").getValue().toString())
                                        + (Double.parseDouble(item.getItemProperty("wdo").getValue().toString())
                                                * premiumRate)));

                item.getItemProperty("lholiday")
                        .setValue(utilities.roundOffToTwoDecimalPlaces(Double
                                .parseDouble(item.getItemProperty("lholiday").getValue().toString())
                                + (Double.parseDouble(item.getItemProperty("lholiday").getValue().toString())
                                        * premiumRate)));

                item.getItemProperty("sholiday")
                        .setValue(utilities.roundOffToTwoDecimalPlaces(Double
                                .parseDouble(item.getItemProperty("sholiday").getValue().toString())
                                + (Double.parseDouble(item.getItemProperty("sholiday").getValue().toString())
                                        * premiumRate)));
            }
        });

        lates.addListener(new FieldEvents.TextChangeListener() {

            @Override
            public void textChange(FieldEvents.TextChangeEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);
                String policyStr = item.getItemProperty("policy").toString();
                String holidayStr = item.getItemProperty("holidays").toString();
                double lateDeduction;

                boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim());
                if (!checkIfInputIsInteger) {
                    getWindow().showNotification("Enter numeric format for lates!",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }

                if (!event.getText().isEmpty()) {
                    if (utilities.convertStringToInteger(event.getText().trim()) > 5) {
                        lateDeduction = computation.processEmployeesLates(policyStr, holidayStr,
                                utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage());
                        if (policyStr == null || policyStr.isEmpty()) {
                            item.getItemProperty("l/min")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                        } else if (policyStr.equals("working-holiday") && holidayStr.equals("legal-holiday")) {
                            item.getItemProperty("latesLH")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                            item.getItemProperty("latesSH").setValue(0.0);
                            item.getItemProperty("latesWO").setValue(0.0);
                            item.getItemProperty("l/min").setValue(0.0);
                        } else if (policyStr.equals("working-holiday")
                                && holidayStr.equals("special-holiday")) {
                            item.getItemProperty("latesLH").setValue(0.0);
                            item.getItemProperty("latesSH")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                            item.getItemProperty("latesWO").setValue(0.0);
                            item.getItemProperty("l/min").setValue(0.0);
                        } else if (policyStr.equals("working-day-off")) {
                            item.getItemProperty("latesLH").setValue(0.0);
                            item.getItemProperty("latesSH").setValue(0.0);
                            item.getItemProperty("latesWO")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                            item.getItemProperty("l/min").setValue(0.0);
                        }
                    } else {
                        item.getItemProperty("l/min").setValue(0.0);
                    }
                } else {
                    item.getItemProperty("l/min").setValue(0.0);
                }

            }
        });

        undertime.addListener(new FieldEvents.TextChangeListener() {

            @Override
            public void textChange(FieldEvents.TextChangeEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);
                String policyStr = item.getItemProperty("policy").toString();
                String holidayStr = item.getItemProperty("holidays").toString();
                double undertimeDeduction;

                boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim());
                if (!checkIfInputIsInteger) {
                    getWindow().showNotification("Enter numeric format for undertime!",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }

                if (!event.getText().isEmpty()) {
                    undertimeDeduction = computation.processEmployeesUndertime(policyStr, holidayStr,
                            utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage());
                    if (policyStr == null || policyStr.isEmpty()) {
                        item.getItemProperty("u/min")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                    } else if (policyStr.equals("working-holiday") && holidayStr.equals("legal-holiday")) {
                        item.getItemProperty("undertimeLH")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                        item.getItemProperty("undertimeSH").setValue(0.0);
                        item.getItemProperty("undertimeWO").setValue(0.0);
                        item.getItemProperty("u/min").setValue(0.0);
                    } else if (policyStr.equals("working-holiday") && holidayStr.equals("special-holiday")) {
                        item.getItemProperty("undertimeLH").setValue(0.0);
                        item.getItemProperty("undertimeSH")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                        item.getItemProperty("undertimeWO").setValue(0.0);
                        item.getItemProperty("u/min").setValue(0.0);
                    } else if (policyStr.equals("working-day-off")) {
                        item.getItemProperty("undertimeLH").setValue(0.0);
                        item.getItemProperty("undertimeSH").setValue(0.0);
                        item.getItemProperty("undertimeWO")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                        item.getItemProperty("u/min").setValue(0.0);
                    }
                } else {
                    item.getItemProperty("u/min").setValue(0.0);
                }
            }
        });

        overtime.addListener(new FieldEvents.TextChangeListener() {

            @Override
            public void textChange(FieldEvents.TextChangeEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);
                String policyStr = item.getItemProperty("policy").toString();
                String holidayStr = item.getItemProperty("holidays").toString();
                double overtimeAddition;

                boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim());
                if (!checkIfInputIsInteger) {
                    getWindow().showNotification("Enter numeric format for undertime!",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }

                if (!event.getText().isEmpty()) {
                    overtimeAddition = computation.processEmployeesOvertime(policyStr, holidayStr,
                            Integer.parseInt(event.getText().trim()), getEmploymentWage());
                    item.getItemProperty("o/min").setValue(utilities
                            .roundOffToTwoDecimalPlaces(overtimeAddition + (overtimeAddition * premiumRate)));
                } else {
                    item.getItemProperty("o/min").setValue(0.0);
                }
            }
        });

        nightDifferential.addListener(new FieldEvents.TextChangeListener() {

            @Override
            public void textChange(FieldEvents.TextChangeEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);
                String policyStr = item.getItemProperty("policy").toString();
                String holidayStr = item.getItemProperty("holidays").toString();
                double nightDifferentialAddition;

                boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim());
                if (!checkIfInputIsInteger) {
                    getWindow().showNotification("Enter numeric format for undertime!",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }

                if (!event.getText().isEmpty()) {
                    nightDifferentialAddition = computation.processEmployeesNightDifferential(policyStr,
                            holidayStr, Integer.parseInt(event.getText().trim()), getEmploymentWage());
                    item.getItemProperty("nd/min").setValue(utilities.roundOffToTwoDecimalPlaces(
                            nightDifferentialAddition + (nightDifferentialAddition * premiumRate)));
                } else {
                    item.getItemProperty("nd/min").setValue(0.0);
                }
            }
        });

        List<Timekeeping> timekeepingListByRowData = timekeepingService.getTimekeepingRowData(
                utilities.convertDateFormat(getDateList().get(i).toString()), getPayrollId());

        for (Timekeeping t : timekeepingListByRowData) {
            String policy;
            String holiday;
            if (!t.getPolicy().equals("null")) {
                policy = t.getPolicy();
            } else {
                policy = "";
            }

            if (!t.getHoliday().equals("null")) {
                holiday = t.getHoliday();
            } else {
                holiday = "";
            }

            premium.setValue(t.isPremium());

            lates.setValue(t.getLates());
            undertime.setValue(t.getUndertime());
            overtime.setValue(t.getOvertime());
            nightDifferential.setValue(t.getNightDifferential());
            table.addItem(
                    new Object[] { edit, utilities.convertDateFormat(getDateList().get(i).toString()), policy,
                            holiday, premium, lates, undertime, overtime, nightDifferential,
                            t.getLateDeduction(), t.getUndertimeDeduction(), t.getOvertimePaid(),
                            t.getNightDifferentialPaid(), t.getLegalHolidayPaid(), t.getSpecialHolidayPaid(),
                            t.getWorkingDayOffPaid(), t.getNonWorkingHolidayPaid(),
                            t.getLatesLegalHolidayDeduction(), t.getLatesSpecialHolidayDeduction(),
                            t.getLatesWorkingDayOffDeduction(), t.getUndertimeLegalHolidayDeduction(),
                            t.getUndertimeSpecialHolidayDeduction(), t.getUndertimeWorkingDayOffDeduction() },
                    new Integer(i));
        }
    }
    table.setPageLength(table.size());

    for (Object listener : table.getListeners(ItemClickEvent.class)) {
        table.removeListener(ItemClickEvent.class, listener);
    }

    table.addListener(new ItemClickEvent.ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            final Object itemId = event.getItemId();
            final Item item = table.getItem(itemId);

            Boolean editRow = Boolean.valueOf(item.getItemProperty("edit").getValue().toString());

            if (event.getPropertyId().equals("policy")) {
                if (editRow) {
                    Window sub = new AttendancePolicyWindow(holidayList, item, getEmploymentWageEntry(),
                            getEmploymentWage());
                    if (sub.getParent() == null) {
                        getApplication().getMainWindow().addWindow(sub);
                    }
                } else {
                    getWindow().showNotification("Click Edit!", Window.Notification.TYPE_WARNING_MESSAGE);
                }
            }
        }
    });

    vlayout.addComponent(table);

    final Button saveButton = new Button();
    saveButton.setWidth("200px");
    saveButton.setCaption("UPDATE ATTENDANCE DATA");
    saveButton.setEnabled(UserAccessControl.isEditAttendance());

    for (Object listener : saveButton.getListeners(Button.ClickListener.class)) {
        saveButton.removeListener(Button.ClickListener.class, listener);
    }

    GridLayout glayout = new GridLayout(2, 1);
    glayout.setSizeFull();
    glayout.setSpacing(true);

    saveButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                Collection attendanceTableCollection = table.getContainerDataSource().getItemIds();
                List<Timekeeping> attendanceList = new ArrayList<>();
                Iterator iterator = attendanceTableCollection.iterator();
                while (iterator.hasNext()) {
                    String str = table.getItem(iterator.next()).toString();
                    String[] attStr = str.split(" ");
                    List<String> tkeepList = new ArrayList<>(Arrays.asList(attStr));

                    Timekeeping t = new Timekeeping();
                    t.setAttendanceDate(utilities.parsingDate(tkeepList.get(1)));
                    t.setPolicy(tkeepList.get(2));
                    t.setHoliday(tkeepList.get(3));
                    t.setPremium(utilities.convertStringToBoolean(tkeepList.get(4)));
                    t.setLates(utilities.convertStringToDouble(tkeepList.get(5)));
                    t.setUndertime(utilities.convertStringToDouble(tkeepList.get(6)));
                    t.setOvertime(utilities.convertStringToDouble(tkeepList.get(7)));
                    t.setNightDifferential(utilities.convertStringToDouble(tkeepList.get(8)));
                    t.setLateDeduction(utilities.convertStringToDouble(tkeepList.get(9)));
                    t.setUndertimeDeduction(utilities.convertStringToDouble(tkeepList.get(10)));
                    t.setOvertimePaid(utilities.convertStringToDouble(tkeepList.get(11)));
                    t.setNightDifferentialPaid(utilities.convertStringToDouble(tkeepList.get(12)));
                    t.setLegalHolidayPaid(utilities.convertStringToDouble(tkeepList.get(13)));
                    t.setSpecialHolidayPaid(utilities.convertStringToDouble(tkeepList.get(14)));
                    t.setWorkingDayOffPaid(utilities.convertStringToDouble(tkeepList.get(15)));
                    t.setNonWorkingHolidayPaid(utilities.convertStringToDouble(tkeepList.get(16)));
                    t.setLatesLegalHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(17)));
                    t.setLatesSpecialHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(18)));
                    t.setLatesWorkingDayOffDeduction(utilities.convertStringToDouble(tkeepList.get(19)));
                    t.setUndertimeLegalHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(20)));
                    t.setUndertimeSpecialHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(21)));
                    t.setUndertimeWorkingDayOffDeduction(utilities.convertStringToDouble(tkeepList.get(22)));
                    attendanceList.add(t);
                }

                ProcessPayrollComputation processPayroll = new ProcessPayrollComputation(getEmployeeId(),
                        getBranchId());
                processPayroll.initVariables();
                processPayroll.initVariablesForComputation(attendanceList);
                boolean result = processPayroll.processPayrollComputation(payrollDate, payrollPeriod,
                        attendancePeriodFrom, attendancePeriodTo, getPayrollId());
                if (result) {
                    close();
                } else {
                    getWindow().showNotification("SQL ERROR");
                }
            } catch (Exception e) {
                e.getMessage();
            }
        }

    });
    glayout.addComponent(saveButton, 0, 0);
    glayout.setComponentAlignment(saveButton, Alignment.MIDDLE_LEFT);
    //        vlayout.addComponent(saveButton);

    Button printButton = new Button("PRINT ATTENDANCE");
    printButton.setWidth("200px");
    printButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            OpenHrisReports reports = new OpenHrisReports(0, null);
            String fileName = "IndividualAttendanceReport_";
            reports.deleteFile(fileName);
            Window reportWindow = new IndividualAttendanceReport(getPayrollId(), getApplication());
        }
    });
    glayout.addComponent(printButton, 1, 0);
    glayout.setComponentAlignment(printButton, Alignment.MIDDLE_RIGHT);

    vlayout.addComponent(glayout);

    return vlayout;
}

From source file:com.peergreen.webconsole.core.exception.ExceptionView.java

License:Open Source License

public ExceptionView(Exception ex) {

    setSizeFull();/* www.j a va  2s.c o m*/
    addStyleName("dashboard-view");

    HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setSpacing(true);
    top.addStyleName("toolbar");
    addComponent(top);
    final Label title = new Label("Oops ! A problem occurred when drawing this view");
    title.setSizeUndefined();
    title.addStyleName("h1");
    top.addComponent(title);
    top.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
    top.setExpandRatio(title, 1);

    HorizontalLayout row = new HorizontalLayout();
    row.setSizeFull();
    row.setMargin(new MarginInfo(true, true, false, true));
    row.setSpacing(true);
    addComponent(row);
    setExpandRatio(row, 1.5f);

    Table t = new Table();
    t.setCaption("Stack trace");
    t.addContainerProperty("<p style=\"display:none\">Stack</p>", String.class, null);
    t.setWidth("100%");
    t.setImmediate(true);
    t.addStyleName("plain");
    t.addStyleName("borderless");
    t.setSortEnabled(false);
    t.setImmediate(true);
    t.setSizeFull();

    int i = 1;
    t.addItem(new Object[] { ex.toString() }, i++);
    for (StackTraceElement element : ex.getStackTrace()) {
        t.addItem(new Object[] { element.toString() }, i++);
    }
    CssLayout panel = new CssLayout();
    panel.addStyleName("layout-panel");
    panel.setSizeFull();

    panel.addComponent(t);

    row.addComponent(panel);
}

From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java

License:Open Source License

/**
 * Build login view//w  ww . j a  v  a2  s . co m
 *
 * @param exit
 */
private void buildLoginView(final boolean exit) {
    if (exit) {
        root.removeAllComponents();
    }
    notifierService.closeAll();

    addStyleName("login");

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setId("webconsole_loginlayout_id");
    loginLayout.setSizeFull();
    loginLayout.addStyleName("login-layout");
    root.addComponent(loginLayout);

    final CssLayout loginPanel = new CssLayout();
    loginPanel.addStyleName("login-panel");

    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth(MAX_WIDTH);
    labels.setMargin(true);
    loginPanel.addComponent(labels);

    Label welcome = new Label("Welcome");
    welcome.addStyleName("h4");
    labels.addComponent(welcome);
    labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT);

    Label title = new Label(consoleName);
    //title.setSizeUndefined();
    title.addStyleName("h2");
    title.addStyleName("light");
    labels.addComponent(title);
    labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);

    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.setMargin(true);
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.focus();
    username.setId("webconsole_login_username");
    fields.addComponent(username);

    final PasswordField password = new PasswordField("Password");
    password.setId("webconsole_login_password");
    fields.addComponent(password);

    final Button signin = new Button("Sign In");
    signin.setId("webconsole_login_signin");
    signin.addStyleName("default");
    fields.addComponent(signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    final ShortcutListener enter = new ShortcutListener("Sign In", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            signin.click();
        }
    };

    signin.addShortcutListener(enter);
    loginPanel.addComponent(fields);

    HorizontalLayout bottomRow = new HorizontalLayout();
    bottomRow.setWidth(MAX_WIDTH);
    bottomRow.setMargin(new MarginInfo(false, true, false, true));
    final CheckBox keepLoggedIn = new CheckBox("Keep me logged in");
    bottomRow.addComponent(keepLoggedIn);
    bottomRow.setComponentAlignment(keepLoggedIn, Alignment.MIDDLE_LEFT);
    // Add new error message
    final Label error = new Label("Wrong username or password.", ContentMode.HTML);
    error.setId("webconsole_login_error");
    error.addStyleName("error");
    error.setSizeUndefined();
    error.addStyleName("light");
    // Add animation
    error.addStyleName("v-animate-reveal");
    error.setVisible(false);
    bottomRow.addComponent(error);
    bottomRow.setComponentAlignment(error, Alignment.MIDDLE_RIGHT);
    loginPanel.addComponent(bottomRow);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (authenticate(username.getValue(), password.getValue())) {
                //                    if (keepLoggedIn.getValue()) {
                //                        //Cookie userCookie = getCookieByName(PEERGREEN_USER_COOKIE_NAME);
                //                       if (getCookieByName(PEERGREEN_USER_COOKIE_NAME) == null) {
                //                            // Get a token for this user and create a cooki
                //                            Page.getCurrent().getJavaScript().execute( String.format("document.cookie = '%s=%s; path=%s'",
                //                                    PEERGREEN_USER_COOKIE_NAME, token, VaadinService.getCurrentRequest().getContextPath()));
                //                        } else {
                //                            // update token
                //                            userCookie.setValue(token);
                //                            userCookie.setPath(VaadinService.getCurrentRequest().getContextPath());
                //                        }
                //                    }

                buildMainView();
            } else {
                error.setVisible(true);
            }
        }
    });

    loginLayout.addComponent(loginPanel);
    loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}

From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java

License:Open Source License

/**
 * Build Welcome progress indicator view
 *//*ww w  . ja  v  a2  s.co m*/
private void buildProgressIndicatorView() {

    final CssLayout progressPanel = new CssLayout();
    progressPanel.addStyleName("login-panel");

    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth(MAX_WIDTH);
    labels.setMargin(true);
    progressPanel.addComponent(labels);

    Label welcome = new Label("Welcome " + ((securityManager == null) ? "" : securityManager.getUserName()));
    welcome.addStyleName("h4");
    labels.addComponent(welcome);
    labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT);

    Label title = new Label(consoleName);
    title.addStyleName("h2");
    title.addStyleName("light");
    labels.addComponent(title);
    labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);

    Float scopesViewsBound = (float) scopes.size();
    final Float stopValue = new Float(1.0);

    if (scopesFactories.isEmpty()) {
        progressIndicator.setValue(stopValue);
    } else {
        progressIndicator.setValue(scopesViewsBound / nbScopesToBind);
    }

    if (stopValue.equals(progressIndicator.getValue())) {
        showMainContent();
    } else {
        // We are still waiting for scopes we have requested their creation, wait a while.
        TimeOutThread timeOutThread = new TimeOutThread();
        timeOutThread.start();
        progressIndicator.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                if (stopValue.equals(event.getProperty().getValue())) {
                    showMainContent();
                }
            }
        });
    }

    HorizontalLayout progressBarPanel = new HorizontalLayout();
    progressBarPanel.setWidth(MAX_WIDTH);
    progressBarPanel.setMargin(true);
    progressBarPanel.addComponent(progressIndicator);
    progressBarPanel.setComponentAlignment(progressIndicator, Alignment.MIDDLE_CENTER);
    progressPanel.addComponent(progressBarPanel);

    progressIndicatorLayout.addComponent(progressPanel);
    progressIndicatorLayout.setComponentAlignment(progressPanel, Alignment.MIDDLE_CENTER);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.directory.DirectoryView.java

License:Open Source License

@PostConstruct
public void init() {
    File deploy = new File(System.getProperty("user.dir") + File.separator + "deploy");
    repositoryManager.addRepository(formatUrl(deploy), "Deploy", RepositoryType.DIRECTORY);

    File m2 = new File(
            System.getProperty("user.home") + File.separator + ".m2" + File.separator + "repository");
    if (m2.exists()) {
        repositoryManager.addRepository(formatUrl(m2), "Local M2 repository", RepositoryType.DIRECTORY);
    }//from   w w  w. j  a v  a2s .  co  m

    File tmp = new File(Constants.STORAGE_DIRECTORY);
    if (!tmp.exists()) {
        tmp.mkdirs();
    }
    repositoryManager.addRepository(formatUrl(tmp), "Temporary directory", RepositoryType.DIRECTORY);

    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setSpacing(true);
    header.setMargin(true);

    final TextField filter = new TextField();
    filter.setInputPrompt("Filter deployable files");
    filter.setWidth("100%");
    filter.addTextChangeListener(new FilterFiles(DEPLOYABLE_NAME, getContainer()));
    header.addComponent(filter);
    header.setComponentAlignment(filter, Alignment.TOP_LEFT);
    header.setExpandRatio(filter, 3);

    HorizontalLayout actionArea = new HorizontalLayout();
    final NativeSelect actionSelection = new NativeSelect();
    actionSelection.addItem(DeploymentActions.DEPLOY);
    actionSelection.addItem(DeploymentActions.DELETE);
    actionSelection.addItem(DeploymentActions.DEPLOYMENT_PLAN);
    actionSelection.setWidth("100px");
    actionSelection.setNullSelectionAllowed(false);

    Button doButton = new Button("Do");
    doButton.addStyleName("default");
    doButton.addClickListener(
            new DoClickListener(artifactBuilder, getTree(), actionSelection, deploymentViewManager));

    actionArea.addComponent(actionSelection);
    actionArea.addComponent(doButton);
    header.addComponent(actionArea);
    header.setExpandRatio(actionArea, 2);
    header.setComponentAlignment(actionArea, Alignment.TOP_RIGHT);
    addComponent(header);

    HorizontalLayout repositoryInfo = new HorizontalLayout();
    repositoryInfo.setWidth("100%");
    repositoryInfo.addComponent(getFetching());
    repositoryInfo.setComponentAlignment(getFetching(), Alignment.MIDDLE_LEFT);
    addComponent(repositoryInfo);

    getTree().addShortcutListener(new DeleteFileShortcutListener(deploymentViewManager, getTree(), "Delete",
            ShortcutAction.KeyCode.DELETE, null));
    getTree().addExpandListener(new TreeItemExpandListener(this, getRepositoryService(), repositoryManager));

    addComponent(getTree());
    setExpandRatio(getTree(), 1.5f);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.maven.MavenView.java

License:Open Source License

@PostConstruct
public void init() throws URISyntaxException {
    repositoryManager.loadRepositoriesInCache();
    addRootItemToContainer("Peergreen Releases",
            new URI("https://forge.peergreen.com/repository/content/repositories/releases/"));
    addRootItemToContainer("Maven Central", new URI("http://repo1.maven.org/maven2/"));

    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setSpacing(true);// www .  j  a va 2 s.  co  m
    header.setMargin(true);

    final TextField filterG = new TextField();
    filterG.setInputPrompt("Filter by group id");
    filterG.addTextChangeListener(new FilterFiles(MVN_GROUP_ID, getContainer()));
    header.addComponent(filterG);
    header.setComponentAlignment(filterG, Alignment.TOP_LEFT);

    final TextField filterA = new TextField();
    filterA.setInputPrompt("Filter by artifact id");
    filterA.addTextChangeListener(new FilterFiles(MVN_ARTIFACT_ID, getContainer()));
    header.addComponent(filterA);
    header.setComponentAlignment(filterA, Alignment.TOP_LEFT);

    //        final TextField filterV = new TextField();
    //        filterV.setInputPrompt("Filter by version");
    //        filterV.addTextChangeListener(new FilterFiles(MVN_VERSION, getContainer()));
    //        header.addComponent(filterV);
    //        header.setComponentAlignment(filterV, Alignment.TOP_LEFT);

    HorizontalLayout actionArea = new HorizontalLayout();
    final NativeSelect actionSelection = new NativeSelect();
    actionSelection.addItem(DeploymentActions.DEPLOY);
    actionSelection.addItem(DeploymentActions.DEPLOYMENT_PLAN);
    actionSelection.addItem(CLEAR_FILTER);
    actionSelection.setWidth("100px");
    actionSelection.setNullSelectionAllowed(false);

    Button doButton = new Button("Do");
    doButton.addStyleName("default");
    doButton.addClickListener(
            new DoClickListener(artifactBuilder, getTree(), actionSelection, deploymentViewManager));
    doButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (CLEAR_FILTER.equals(actionSelection.getValue())) {
                getContainer().removeAllContainerFilters();
            }
        }
    });

    actionArea.addComponent(actionSelection);
    actionArea.addComponent(doButton);
    header.addComponent(actionArea);
    header.setExpandRatio(actionArea, 2);
    header.setComponentAlignment(actionArea, Alignment.TOP_RIGHT);
    addComponent(header);

    HorizontalLayout repositoryInfo = new HorizontalLayout();
    repositoryInfo.setWidth("100%");
    repositoryInfo.addComponent(getFetching());
    repositoryInfo.setComponentAlignment(getFetching(), Alignment.MIDDLE_LEFT);
    addComponent(repositoryInfo);

    getTree().addExpandListener(new TreeItemExpandListener(this, getRepositoryService(), repositoryManager));
    addComponent(getTree());
    setExpandRatio(getTree(), 1.5f);

    updateTree();
}