Example usage for com.vaadin.ui Alignment MIDDLE_CENTER

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

Introduction

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

Prototype

Alignment MIDDLE_CENTER

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

Click Source Link

Usage

From source file:com.oodrive.nuage.webui.component.SnapshotItemComponent.java

License:Apache License

/**
 * Create the component for the snapshot attributes
 * /*from   w w w. j  a v  a  2 s  .  c  o  m*/
 * @return the component
 */
private final AbstractComponent createAttributes() {

    final VerticalLayout layout = new VerticalLayout();

    final FormLayout snapshotAttributesLayout = new FormLayout();
    snapshotAttributesLayout.setMargin(true);
    snapshotAttributesLayout.setWidth(null);
    snapshotAttributesLayout.setImmediate(true);
    layout.addComponent(snapshotAttributesLayout);
    layout.setComponentAlignment(snapshotAttributesLayout, Alignment.MIDDLE_CENTER);

    // Enter NAME
    WebUiUtils.createFieldString(new StringAttributeOperation() {
        @Override
        public void setStringValue(final String value) {
            model.setSnapshotName(value);
        }

        @Override
        public String getStringValue() {
            return model.getSnapshotName();
        }
    }, "Name", snapshotAttributesLayout, model);

    // Enter DESCRIPTION
    WebUiUtils.createFieldString(new StringAttributeOperation() {
        @Override
        public void setStringValue(final String value) {
            model.setSnapshotDescription(value);
        }

        @Override
        public String getStringValue() {
            return model.getSnapshotDescription();
        }
    }, "Description", snapshotAttributesLayout, model);

    // Enter UUID (not editable)
    final TextField snapUUID = new TextField("UUID", model.getItemUuid().toString());
    snapUUID.setReadOnly(true);
    snapUUID.setWidth("300px");
    snapshotAttributesLayout.addComponent(snapUUID);

    return layout;
}

From source file:com.oodrive.nuage.webui.component.window.AbstractConfirmationWindow.java

License:Apache License

@SuppressWarnings("serial")
@Override//from  w w w  . j  av  a 2s . co  m
public Window init(final AbstractItemModel model) {

    // Add new window
    final Window vvrConfirmationWindow = new Window("Confirmation");
    vvrConfirmationWindow.center();
    vvrConfirmationWindow.setResizable(false);
    final VerticalLayout vvrConfirmationLayout = new VerticalLayout();
    vvrConfirmationLayout.setMargin(true);
    vvrConfirmationWindow.setContent(vvrConfirmationLayout);

    // Message to display before buttons
    final Label confirmationMessage = new Label(confirmation);
    vvrConfirmationLayout.addComponent(confirmationMessage);
    vvrConfirmationLayout.setComponentAlignment(confirmationMessage, Alignment.MIDDLE_CENTER);
    vvrConfirmationLayout.setSpacing(true);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    vvrConfirmationLayout.addComponent(buttonLayout);
    // Button OK
    final Button okButton = new Button("OK");
    buttonLayout.setSizeFull();
    buttonLayout.addComponent(okButton);
    buttonLayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER);
    okButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                action.execute(model);
                vvrConfirmationWindow.close();
            } catch (final Exception e) {
                vvrConfirmationWindow.close();
            }
        }
    });

    // Button cancel
    final Button cancelButton = new Button("Cancel");
    buttonLayout.addComponent(cancelButton);
    buttonLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);
    cancelButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            // Just close the window
            vvrConfirmationWindow.close();
        }
    });
    return vvrConfirmationWindow;
}

From source file:com.oodrive.nuage.webui.component.window.ErrorWindow.java

License:Apache License

@SuppressWarnings("serial")
@Override//from  w  ww . java 2s . c o  m
public final Window init(final AbstractItemModel model) {
    // Add new window with title "Error"
    final Window vvrErrorWindow = new Window("Error");
    vvrErrorWindow.center();
    vvrErrorWindow.setResizable(false);
    final VerticalLayout vvrErrorLayout = new VerticalLayout();
    vvrErrorLayout.setMargin(true);
    vvrErrorWindow.setContent(vvrErrorLayout);

    // Display message
    final Label errorMessage = new Label(message);
    vvrErrorLayout.addComponent(errorMessage);
    vvrErrorLayout.setComponentAlignment(errorMessage, Alignment.MIDDLE_CENTER);
    vvrErrorLayout.setSpacing(true);

    // Button OK
    final Button okButton = new Button("OK");
    vvrErrorLayout.addComponent(okButton);
    vvrErrorLayout.setComponentAlignment(okButton, Alignment.BOTTOM_CENTER);
    okButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            // Just close the window
            vvrErrorWindow.close();
        }
    });
    return vvrErrorWindow;
}

From source file:com.oodrive.nuage.webui.component.window.VvrAttributesWindow.java

License:Apache License

@SuppressWarnings("serial")
@Override/* w  w w .  ja  v a 2s .  c  o m*/
public final Window init(final AbstractItemModel model) {

    // Cast model in vvrModel
    final VvrModel vvrModel = (VvrModel) model;
    // Add new window
    final Window vvrAttributesWindow = new Window("VVR Attributes");
    vvrAttributesWindow.center();
    vvrAttributesWindow.setWidth("400px");
    vvrAttributesWindow.setResizable(false);

    final VerticalLayout layout = new VerticalLayout();
    vvrAttributesWindow.setContent(layout);
    layout.setMargin(true);

    final FormLayout vvrAttributesLayout = new FormLayout();
    layout.addComponent(vvrAttributesLayout);
    vvrAttributesLayout.setMargin(true);

    // Enter NAME
    String value = vvrModel.getVvrName();
    if (value == null) {
        value = "";
    }
    final TextField name = new TextField("Name", value);
    name.setSizeFull();
    vvrAttributesLayout.addComponent(name);

    // Enter description
    value = vvrModel.getVvrDescription();
    if (value == null) {
        value = "";
    }
    final TextField desc = new TextField("Description", value);
    desc.setSizeFull();
    vvrAttributesLayout.addComponent(desc);

    // Enter name
    final TextField vvrUUID = new TextField("UUID");
    vvrUUID.setValue(vvrUuid.toString());
    vvrUUID.setReadOnly(true);
    vvrUUID.setSizeFull();
    vvrAttributesLayout.addComponent(vvrUUID);

    // OK button
    final HorizontalLayout hzlayout = new HorizontalLayout();
    layout.addComponent(hzlayout);
    hzlayout.setSizeFull();

    final Button okButton = new Button("OK");
    hzlayout.addComponent(okButton);
    hzlayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER);

    okButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            WaitingComponent.executeBackground(vvrModel, new Background() {
                @Override
                public void processing() {
                    vvrModel.setVvrName(name.getValue());
                    vvrModel.setVvrDescription(desc.getValue());
                }

                @Override
                public void postProcessing() {
                }
            });
            vvrAttributesWindow.close();
        }
    });

    // Cancel button
    final Button cancelButton = new Button("Cancel");
    hzlayout.addComponent(cancelButton);
    hzlayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);

    cancelButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            // Just close the window
            vvrAttributesWindow.close();
        }
    });
    return vvrAttributesWindow;
}

From source file:com.oodrive.nuage.webui.VvrManagerUi.java

License:Apache License

/**
 * Add a progress bar for long task./*w w  w .  j a  v  a2s .co m*/
 * 
 * @return the layout
 */
public VerticalLayout addProgressBar() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();

    final ProgressBar bar = new ProgressBar();
    layout.addComponent(new Label("This operation can take some time. Please wait..."));
    bar.setIndeterminate(true);
    bar.setImmediate(true);

    layout.addComponent(bar);
    layout.setComponentAlignment(bar, Alignment.MIDDLE_CENTER);

    rootLayout.addComponent(layout, "top: 50%; left: 39%");
    vvrManagerLayout.setEnabled(false);
    return layout;
}

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

public SchedulerMainUI() {

    setMargin(true);/*www  .  j a va  2 s . 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.EmployeePersonalInformation.java

public ComponentContainer layout() {
    glayout = new GridLayout(4, 19);
    glayout.setSpacing(true);/*from w ww. j  av a 2s . 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.peergreen.example.webconsole.extensions.ConfirmDialogExtension.java

License:Open Source License

public ConfirmDialogExtension() {
    setSizeFull();/*from  w w w.j av a 2  s  .c o  m*/
    setSpacing(true);
    setMargin(true);

    Link showCodeSource = new Link("Show code source",
            new ExternalResource(GitHubClassURL.getURL(ConfirmDialogExtension.class)));
    showCodeSource.setTargetName("_blank");
    addComponent(showCodeSource);
    setComponentAlignment(showCodeSource, Alignment.TOP_RIGHT);

    Label title = new Label("Drag and drop components from a panel to another");
    title.addStyleName("h1");
    addComponent(title);
    setComponentAlignment(title, Alignment.MIDDLE_CENTER);

    HorizontalLayout row = new HorizontalLayout();
    row.setSizeFull();
    row.setSpacing(true);
    row.setMargin(true);

    VerticalLayout leftPanel = new VerticalLayout();
    leftPanel.setSpacing(true);
    leftPanel.addStyleName("dashed-area");
    leftPanel.addComponent(getDraggableComponent(new Label("Label")));
    leftPanel.addComponent(getDraggableComponent(new Button("Button")));
    DragAndDropWrapper leftPanelWrapper = new DragAndDropWrapper(leftPanel);
    row.addComponent(leftPanelWrapper);
    row.setComponentAlignment(leftPanelWrapper, Alignment.TOP_LEFT);

    VerticalLayout rightPanel = new VerticalLayout();
    rightPanel.setSpacing(true);
    rightPanel.addStyleName("dashed-area");
    DragAndDropWrapper rightPanelWrapper = new DragAndDropWrapper(rightPanel);
    row.addComponent(rightPanelWrapper);
    row.setComponentAlignment(rightPanelWrapper, Alignment.TOP_RIGHT);

    leftPanelWrapper.setDropHandler(new ConfirmDialogExtensionDropHandler(rightPanel, leftPanel));
    rightPanelWrapper.setDropHandler(new ConfirmDialogExtensionDropHandler(leftPanel, rightPanel));

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

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

License:Open Source License

/**
 * Build login view//from w  w  w . java2  s .  com
 *
 * @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
 *//*from   w w w .j  a  va2 s.c om*/
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);
}