Example usage for com.vaadin.ui GridLayout setSpacing

List of usage examples for com.vaadin.ui GridLayout setSpacing

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout setSpacing.

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:com.klwork.explorer.ui.user.ProfilePanel.java

License:Apache License

protected void initContactSection() {
    Label header = createProfileHeader(i18nManager.getMessage(Messages.PROFILE_CONTACT));
    header.addStyleName(ExplorerLayout.STYLE_H3);
    header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    infoPanelLayout.addComponent(header);

    GridLayout contactLayout = createInfoSectionLayout(2, 4);
    // Email//  w ww  .j a v  a  2 s.  c  o m
    if (!editable && isDefined(user.getEmail())) {
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_EMAIL), user.getEmail());
    } else if (editable) {
        emailField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_EMAIL), emailField,
                user.getEmail());
    }

    // Phone
    if (!editable && isDefined(phone)) {
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_PHONE), phone);
    } else if (editable) {
        phoneField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_PHONE), phoneField, phone);
    }

    // Twitter
    if (!editable && isDefined(twitterName)) {
        Link twitterLink = new Link(twitterName, new ExternalResource("http://www.twitter.com/" + twitterName));
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_TWITTER), twitterLink);
    } else if (editable) {
        twitterField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_TWITTER), twitterField,
                twitterName);
    }

    // Skype
    if (!editable && isDefined(skypeId)) {
        // The skype entry shows the name + skype icon, laid out in a small grid
        GridLayout skypeLayout = new GridLayout(2, 1);
        skypeLayout.setSpacing(true);
        skypeLayout.setSizeUndefined();

        Label skypeIdLabel = new Label(skypeId);
        skypeIdLabel.setSizeUndefined();
        skypeLayout.addComponent(skypeIdLabel);

        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_SKYPE), skypeLayout);
    } else if (editable) {
        skypeField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_SKYPE), skypeField,
                skypeId);
    }
}

From source file:com.klwork.explorer.ui.user.ProfilePanel.java

License:Apache License

protected GridLayout createInfoSectionLayout(int columns, int rows) {
    GridLayout layout = new GridLayout(columns, rows);
    layout.setSpacing(true);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setMargin(new MarginInfo(true, false, true, false));
    infoPanelLayout.addComponent(layout);
    return layout;
}

From source file:com.liferay.mail.vaadin.PreferencesView.java

License:Open Source License

private void updateAccountList() {

    try {/*from   w  ww.  j  a  v a 2  s . c  om*/
        accountPanel.removeAllComponents();

        List<Account> accounts = controller.getAccountManager().getAccounts(controller.getUser());
        if (accounts.size() > 0) {
            GridLayout grid = new GridLayout(3, accounts.size());
            grid.setSpacing(true);
            for (final Account account : accounts) {
                grid.addComponent(new Label(account.getAddress()));

                Button editButton = new Button(Lang.get("edit-account"));
                editButton.setStyleName("small");
                editButton.addListener(new ClickListener() {

                    public void buttonClick(ClickEvent event) {

                        editAccount(account);
                    }
                });
                grid.addComponent(editButton);

                Button deleteButton = new Button(Lang.get("delete-account"));
                deleteButton.setStyleName("small");
                deleteButton.addListener(new ClickListener() {

                    public void buttonClick(ClickEvent event) {

                        deleteAccount(account);
                    }
                });
                grid.addComponent(deleteButton);
            }
            accountPanel.addComponent(grid);
        }
    } catch (SystemException e) {
        // unable to read account information
        controller.showUnexpectedError(e);
    }
}

From source file:com.lizardtech.expresszip.vaadin.FindLayersViewComponent.java

License:Apache License

private void setupAddFilterWindow(Window window) {
    // General variables

    // Layouts/*from  w  ww .j  a  v a  2 s  . c  o m*/
    GridLayout mainLayout = new GridLayout(1, 3);
    HorizontalLayout axisLayout = new HorizontalLayout();
    HorizontalLayout criteriaLayout = new HorizontalLayout();
    HorizontalLayout buttonLayout = new HorizontalLayout();
    hznCriteria = criteriaLayout;

    // Buttons
    ExpressZipButton btnAdd = new ExpressZipButton("Add", Style.ACTION);
    btnAdd.setClickShortcut(KeyCode.ENTER);
    btnAdd.addStyleName("primary");
    ExpressZipButton btnCancel = new ExpressZipButton("Cancel", Style.ACTION);

    // Fields
    ComboBox cmbAxis = new ComboBox();
    cmbAxis.setTextInputAllowed(false);
    cmbAxis.setNullSelectionAllowed(false);

    // Labels
    Label lblAxis = new Label("Axis");

    btnAdd.addListener(filterButtonListener);
    btnCancel.addListener(filterButtonListener);

    for (Filter.AxisFilters f : Filter.axisArray) {
        cmbAxis.addItem(filter.getNameOfFilter(f));
    }
    cmbAxis.setImmediate(true);
    cmbAxis.addListener(axisSelectedListener);
    cmbAxis.setValue(filter.getNameOfFilter(Filter.axisArray[0]));

    mainLayout.addComponent(axisLayout, 0, 0);
    mainLayout.addComponent(criteriaLayout, 0, 1);
    mainLayout.addComponent(buttonLayout, 0, 2);
    mainLayout.setSpacing(true);

    axisLayout.setSpacing(true);

    axisLayout.addComponent(lblAxis);
    axisLayout.addComponent(cmbAxis);
    axisLayout.setExpandRatio(lblAxis, .2f);
    axisLayout.setExpandRatio(cmbAxis, .8f);
    axisLayout.setComponentAlignment(lblAxis, Alignment.MIDDLE_LEFT);
    axisLayout.setComponentAlignment(cmbAxis, Alignment.MIDDLE_LEFT);
    axisLayout.setSizeFull();

    criteriaLayout.setSizeFull();

    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(btnAdd);
    buttonLayout.addComponent(btnCancel);
    buttonLayout.setComponentAlignment(btnAdd, Alignment.BOTTOM_RIGHT);
    buttonLayout.setComponentAlignment(btnCancel, Alignment.BOTTOM_RIGHT);
    buttonLayout.setExpandRatio(btnAdd, 1f);
    buttonLayout.setExpandRatio(btnCancel, 0f);
    buttonLayout.setSizeFull();

    mainLayout.setRowExpandRatio(0, 1f);
    mainLayout.setRowExpandRatio(1, 1f);
    mainLayout.setRowExpandRatio(2, 1f);
    mainLayout.setSizeFull();

    window.addComponent(mainLayout);
    window.getContent().setSizeFull();
}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoDetails.java

License:Open Source License

private Component createProcessInfo(LspsUI ui) {
    ModelInstanceInfo instance = processService.getModelInstanceInfo(todo.getModelInstanceId());

    GridLayout grid = new GridLayout(2, 10);
    grid.setMargin(true);//from   www  .  j  av  a 2 s  .c  om
    grid.setSpacing(true);
    grid.setWidth("100%");
    grid.setColumnExpandRatio(0, 1);
    grid.setColumnExpandRatio(1, 2);

    grid.addComponent(new Label(ui.getMessage("process.id")));
    grid.addComponent(new Label(String.valueOf(instance.getId())));

    grid.addComponent(new Label(ui.getMessage("process.model")));
    grid.addComponent(new Label(instance.getModelName() + " - " + instance.getModelVersion()));

    grid.addComponent(new Label(ui.getMessage("process.started")));
    grid.addComponent(new Label(
            new SimpleDateFormat(ui.getMessage("app.dateTimeFormat")).format(instance.getStartedDate())));

    grid.addComponent(new Label(ui.getMessage("process.finished")));
    grid.addComponent(new Label(instance.getFinishedDate() == null ? ""
            : new SimpleDateFormat(ui.getMessage("app.dateTimeFormat")).format(instance.getFinishedDate())));

    String status = "???";
    switch (instance.getState()) {
    case CREATED:
        status = ui.getMessage("process.statusCreated");
        break;
    case FINISHED:
        status = ui.getMessage("process.statusFinished");
        break;
    case RUNNING:
        status = ui.getMessage("process.statusRunning");
        break;
    case SUSPENDED:
        status = ui.getMessage("process.statusSuspended");
        break;
    case MODEL_UPDATE_PREPROCESSING:
        status = ui.getMessage("process.statusPreprocessing");
        break;
    case MODEL_UPDATE_PREPROCESSED:
        status = ui.getMessage("process.statusPreprocessed");
        break;
    case MODEL_UPDATE_TRANSFORMED:
        status = ui.getMessage("process.statusTransformed");
        break;
    case MODEL_UPDATE_POSTPROCESSING:
        status = ui.getMessage("process.statusPostprocessing");
        break;
    case MODEL_UPDATE_UPDATED:
        status = ui.getMessage("process.statusUpdated");
        break;
    case MODEL_UPDATE_ABORTED:
        status = ui.getMessage("process.statusUpdateAborted");
        break;
    }
    grid.addComponent(new Label(ui.getMessage("process.status")));
    grid.addComponent(new Label(status));

    return grid;
}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoDetails.java

License:Open Source License

private Component createTodoInfo(LspsUI ui) {
    GridLayout grid = new GridLayout(2, 10);
    grid.setMargin(true);/*from   www  . j a v  a  2s  .  c  o m*/
    grid.setSpacing(true);
    grid.setWidth("100%");
    grid.setColumnExpandRatio(0, 1);
    grid.setColumnExpandRatio(1, 2);

    grid.addComponent(new Label(ui.getMessage("todo.id")));
    grid.addComponent(new Label(String.valueOf(todo.getId())));

    //      grid.addComponent(new Label(ui.getMessage("todo.process")));
    //      grid.addComponent(new Label(String.valueOf(todo.getModelInstanceId())));

    //      grid.addComponent(new Label(ui.getMessage("todo.title")));
    //      grid.addComponent(new Label(ui.localizeEngineText(todo.getTitle())));

    grid.addComponent(new Label(ui.getMessage("todo.task")));
    grid.addComponent(new Label(todo.getTaskNamespace()));

    grid.addComponent(new Label(ui.getMessage("todo.issued")));
    grid.addComponent(
            new Label(new SimpleDateFormat(ui.getMessage("app.dateTimeFormat")).format(todo.getIssuedDate())));

    String status = "???";
    switch (todo.getStatus()) {
    case ALIVE:
        status = ui.getMessage("todo.statusAlive");
        break;
    case ACCOMPLISHED:
        status = ui.getMessage("todo.statusAccomplished", todo.getSubmittedDate());
        break;
    case INTERRUPTED:
        status = ui.getMessage("todo.statusInterrupted", todo.getSubmittedDate(), todo.getInterruptionReason());
        break;
    case SUSPENDED:
        status = ui.getMessage("todo.statusSuspended");
        break;
    }
    grid.addComponent(new Label(ui.getMessage("todo.status")));
    grid.addComponent(new Label(status));

    try {
        TodoAuthorization authorization = todoService.getAuthorization(todo.getId(),
                ui.getUser().getPerson().getId());
        String authMsg;
        switch (authorization) {
        case INITIAL_PERFORMER:
            authMsg = ui.getMessage("todo.authorizationPerformer");
            break;
        case DELEGATE:
            authMsg = ui.getMessage("todo.authorizationDelegate");
            break;
        case SUBSTITUTE:
            authMsg = ui.getMessage("todo.authorizationSubstitute");
            break;
        case NOT_PERMITTED:
        default:
            authMsg = ui.getMessage("todo.authorizationUnknown");
            break;
        }
        grid.addComponent(new Label(ui.getMessage("todo.authorization")));
        grid.addComponent(new Label(authMsg));
    } catch (Exception e) {
        Utils.rethrow(e, "could not get authorization for " + todo.getId(), log);
    }

    //currently it's always the current user; no need to show him
    //      grid.addComponent(new Label(ui.getMessage("todo.responsible")));
    //      grid.addComponent(new Label(todo.getAllocatedToFullName()));

    return grid;
}

From source file:com.mycollab.module.crm.ui.components.PeopleInfoComp.java

License:Open Source License

public void displayEntryPeople(ValuedBean bean) {
    this.removeAllComponents();
    this.withMargin(false);

    Label peopleInfoHeader = new Label(
            FontAwesome.USER.getHtml() + " " + UserUIContext.getMessage(CrmCommonI18nEnum.SUB_INFO_PEOPLE),
            ContentMode.HTML);//from   ww  w  . j a v a  2 s. c om
    peopleInfoHeader.setStyleName("info-hdr");
    this.addComponent(peopleInfoHeader);

    GridLayout layout = new GridLayout(2, 2);
    layout.setSpacing(true);
    layout.setWidth("100%");
    layout.setMargin(new MarginInfo(false, false, false, true));
    try {
        Label createdLbl = new Label(UserUIContext.getMessage(CrmCommonI18nEnum.ITEM_CREATED_PEOPLE));
        createdLbl.setSizeUndefined();
        layout.addComponent(createdLbl, 0, 0);

        String createdUserName = (String) PropertyUtils.getProperty(bean, "createduser");
        String createdUserAvatarId = (String) PropertyUtils.getProperty(bean, "createdUserAvatarId");
        String createdUserDisplayName = (String) PropertyUtils.getProperty(bean, "createdUserFullName");

        UserLink createdUserLink = new UserLink(createdUserName, createdUserAvatarId, createdUserDisplayName);
        layout.addComponent(createdUserLink, 1, 0);
        layout.setColumnExpandRatio(1, 1.0f);

        Label assigneeLbl = new Label(UserUIContext.getMessage(CrmCommonI18nEnum.ITEM_ASSIGN_PEOPLE));
        assigneeLbl.setSizeUndefined();
        layout.addComponent(assigneeLbl, 0, 1);
        String assignUserName = (String) PropertyUtils.getProperty(bean, "assignuser");
        String assignUserAvatarId = (String) PropertyUtils.getProperty(bean, "assignUserAvatarId");
        String assignUserDisplayName = (String) PropertyUtils.getProperty(bean, "assignUserFullName");

        UserLink assignUserLink = new UserLink(assignUserName, assignUserAvatarId, assignUserDisplayName);
        layout.addComponent(assignUserLink, 1, 1);
    } catch (Exception e) {
        LOG.error("Can not build user link {} ", BeanUtility.printBeanObj(bean));
    }

    this.addComponent(layout);

}

From source file:com.mycollab.vaadin.web.ui.MailFormWindow.java

License:Open Source License

private void initUI() {
    GridLayout mainLayout = new GridLayout(1, 5);
    mainLayout.setWidth("100%");
    mainLayout.setMargin(true);/*from  w w  w .j ava2s  .  c o m*/
    mainLayout.setSpacing(true);

    CssLayout inputPanel = new CssLayout();
    inputPanel.setWidth("100%");
    inputPanel.setStyleName("mail-panel");

    inputLayout = new GridLayout(3, 4);
    inputLayout.setSpacing(true);
    inputLayout.setWidth("100%");
    inputLayout.setColumnExpandRatio(0, 1.0f);

    inputPanel.addComponent(inputLayout);

    mainLayout.addComponent(inputPanel);

    tokenFieldMailTo = new EmailTokenField();

    inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0);

    if (lstMail != null) {
        for (String mail : lstMail) {
            if (StringUtils.isNotBlank(mail)) {
                if (mail.indexOf("<") > -1) {
                    String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">"));
                    if (strMail != null && !strMail.equalsIgnoreCase("null")) {

                    }
                } else {

                }
            }
        }
    }

    final TextField subject = new TextField();
    subject.setRequired(true);
    subject.setWidth("100%");
    subjectField = createTextFieldMail("Subject:", subject);
    inputLayout.addComponent(subjectField, 0, 1);

    initButtonLinkCcBcc();

    ccField = createTextFieldMail("Cc:", tokenFieldMailCc);
    bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc);

    final RichTextArea noteArea = new RichTextArea();
    noteArea.setWidth("100%");
    noteArea.setHeight("200px");
    mainLayout.addComponent(noteArea, 0, 1);
    mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER);

    final AttachmentPanel attachments = new AttachmentPanel();
    attachments.setWidth("500px");

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);

    MButton sendBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_SEND_EMAIL), clickEvent -> {
        if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) {
            NotificationUtil.showErrorNotification(
                    "To Email field and Subject field must be not empty! Please fulfil them before sending email.");
            return;
        }
        if (UserUIContext.getUser().getEmail() != null && UserUIContext.getUser().getEmail().length() > 0) {
            ExtMailService systemMailService = AppContextUtil.getSpringBean(ExtMailService.class);

            List<File> listFile = attachments.files();
            List<AttachmentSource> attachmentSource = null;
            if (listFile != null && listFile.size() > 0) {
                attachmentSource = new ArrayList<>();
                for (File file : listFile) {
                    attachmentSource.add(new FileAttachmentSource(file));
                }
            }

            systemMailService.sendHTMLMail(UserUIContext.getUser().getEmail(),
                    UserUIContext.getUser().getDisplayName(), tokenFieldMailTo.getListRecipient(),
                    tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(),
                    subject.getValue(), noteArea.getValue(), attachmentSource, true);
            close();
        } else {
            NotificationUtil
                    .showErrorNotification("Your email is empty value, please fulfil it before sending email!");
        }
    }).withIcon(FontAwesome.SEND).withStyleName(WebThemes.BUTTON_ACTION);

    MHorizontalLayout controlsLayout = new MHorizontalLayout(attachments, cancelBtn, sendBtn)
            .expand(attachments).withFullWidth();
    mainLayout.addComponent(controlsLayout, 0, 2);
    this.setContent(mainLayout);
}

From source file:com.openhris.employee.allowance.EmployeeAllowanceInformation.java

ComponentContainer component() {
    GridLayout glayout = new GridLayout(3, 14);
    glayout.setSpacing(true);
    glayout.setWidth("600px");
    glayout.setHeight("100%");

    communication = new TextField("Communication Allowance: ");
    communication.setWidth("170px");
    communication.addStyleName("numerical");
    glayout.addComponent(communication, 0, 0);

    communicationEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    communicationEntry.setWidth("150px");
    glayout.addComponent(communicationEntry, 1, 0);

    Button communicationBtn = new Button("UPDATE COMMUNICATION ALLOWANCE");
    communicationBtn.setWidth("250px");
    communicationBtn.addListener(buttonClickListener);
    glayout.addComponent(communicationBtn, 2, 0);
    glayout.setComponentAlignment(communicationBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        communicationBtn.setEnabled(true);
    } else {// w w w.j  a v a  2 s  .  c  o m
        communicationBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 1, 2, 1);

    perDiem = new TextField("Per Diem: ");
    perDiem.setWidth("170px");
    perDiem.addStyleName("numerical");
    glayout.addComponent(perDiem, 0, 2);

    perDiemEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    perDiemEntry.setWidth("150px");
    glayout.addComponent(perDiemEntry, 1, 2);

    Button perDiemBtn = new Button("UPDATE PER DIEM");
    perDiemBtn.setWidth("250px");
    perDiemBtn.addListener(buttonClickListener);
    glayout.addComponent(perDiemBtn, 2, 2);
    glayout.setComponentAlignment(perDiemBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        perDiemBtn.setEnabled(true);
    } else {
        perDiemBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 3, 2, 3);

    cola = new TextField("Cola: ");
    cola.setWidth("170px");
    cola.addStyleName("numerical");
    glayout.addComponent(cola, 0, 4);

    colaEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    colaEntry.setWidth("150px");
    glayout.addComponent(colaEntry, 1, 4);

    Button colaBtn = new Button("UPDATE COLA");
    colaBtn.setWidth("250px");
    colaBtn.addListener(buttonClickListener);
    glayout.addComponent(colaBtn, 2, 4);
    glayout.setComponentAlignment(colaBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        colaBtn.setEnabled(true);
    } else {
        colaBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 5, 2, 5);

    meal = new TextField("Meal Allowance: ");
    meal.setWidth("170px");
    meal.addStyleName("numerical");
    glayout.addComponent(meal, 0, 6);

    mealEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    mealEntry.setWidth("150px");
    glayout.addComponent(mealEntry, 1, 6);

    Button mealBtn = new Button("UPDATE MEAL ALLOWANCE");
    mealBtn.setWidth("250px");
    mealBtn.addListener(buttonClickListener);
    glayout.addComponent(mealBtn, 2, 6);
    glayout.setComponentAlignment(mealBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        mealBtn.setEnabled(true);
    } else {
        mealBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 7, 2, 7);

    transportation = new TextField("Transportation Allowance: ");
    transportation.setWidth("170px");
    transportation.addStyleName("numerical");
    glayout.addComponent(transportation, 0, 8);

    transportationEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    transportationEntry.setWidth("150px");
    glayout.addComponent(transportationEntry, 1, 8);

    Button transportationBtn = new Button("UPDATE TRANSPORTATION ALLOWANCE");
    transportationBtn.setWidth("250px");
    transportationBtn.addListener(buttonClickListener);
    glayout.addComponent(transportationBtn, 2, 8);
    glayout.setComponentAlignment(transportationBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        transportationBtn.setEnabled(true);
    } else {
        transportationBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 9, 2, 9);

    others = new TextField("Other Allowances: ");
    others.setWidth("170px");
    others.addStyleName("numerical");
    glayout.addComponent(others, 0, 10);

    othersEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    othersEntry.setWidth("150px");
    glayout.addComponent(othersEntry, 1, 10);

    Button othersBtn = new Button("UPDATE OTHER ALLOWANCES");
    othersBtn.setWidth("250px");
    othersBtn.addListener(buttonClickListener);
    glayout.addComponent(othersBtn, 2, 10);
    glayout.setComponentAlignment(othersBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        othersBtn.setEnabled(true);
    } else {
        othersBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 11, 2, 11);

    afl = new TextField("Allowance for Liquidation: ");
    afl.setWidth("170px");
    afl.addStyleName("numerical");
    glayout.addComponent(afl, 0, 12);

    Button aflBtn = new Button("UPDATE AFL");
    aflBtn.setWidth("100%");
    aflBtn.addListener(buttonClickListener);
    glayout.addComponent(aflBtn, 1, 12, 2, 12);
    glayout.setComponentAlignment(aflBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        aflBtn.setEnabled(true);
    } else {
        aflBtn.setEnabled(false);
    }

    if (getEmployeeId() != null) {
        Allowances a = ais.getAllowancesByEmployee(getEmployeeId());

        communication.setValue(a.getCommunication());
        communicationEntry.setValue(
                Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY, a.getComEntryType()));

        perDiem.setValue(a.getPerDiem());
        perDiemEntry.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY,
                a.getPerDiemEntryType()));

        cola.setValue(a.getCola());
        colaEntry.setValue(
                Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY, a.getColaEntryType()));

        meal.setValue(a.getMeal());
        mealEntry.setValue(
                Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY, a.getMealEntryType()));

        transportation.setValue(a.getTransportation());
        transportationEntry.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY,
                a.getTransEntryType()));

        others.setValue(a.getOthers());
        othersEntry.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY,
                a.getOthersEntryType()));

        afl.setValue(a.getAllowanceForLiquidation());
    }

    return glayout;
}

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

public NewEmployeeWindow(String employeeId) {
    this.employeeId = employeeId;

    setCaption("New Employee");
    setWidth("535px");

    errorLabel.setVisible(false);/*from w w w  .ja  v  a2s. co m*/

    GridLayout grid = new GridLayout(3, 9);
    grid.setSpacing(true);
    grid.setSizeFull();

    final TextField firstname = new HRISTextField("Firstname:");
    grid.addComponent(firstname, 0, 0);

    final TextField middlename = new HRISTextField("Middlename:");
    grid.addComponent(middlename, 1, 0);

    final TextField lastname = new HRISTextField("Lastname:");
    grid.addComponent(lastname, 2, 0);

    corporation = dropDown.populateCorporateComboBox(new ComboBox());
    grid.addComponent(corporation, 0, 1, 1, 1);

    final PopupDateField entryDate = new HRISPopupDateField("Entry Date:");
    grid.addComponent(entryDate, 2, 1);

    trade = new ComboBox("Trade: ");
    trade.setWidth("100%");
    corporation.addListener(corporateListener);
    grid.addComponent(trade, 0, 2, 1, 2);

    final ComboBox dependent = dropDown.populateTotalDependent("Employee's Dependent");
    grid.addComponent(dependent, 2, 2);

    branch = new ComboBox("Branch: ");
    branch.setWidth("100%");
    trade.addListener(tradeListener);
    branch.addListener(branchListener);
    grid.addComponent(branch, 0, 3, 1, 3);

    final TextField department = new HRISTextField("Department: ");
    grid.addComponent(department, 2, 3);

    final TextField position = new HRISTextField("Position: ");
    grid.addComponent(position, 0, 4);

    final TextField sssNo = new HRISTextField("SSS #:");
    grid.addComponent(sssNo, 1, 4);

    final TextField hdmfNo = new HRISTextField("HDMF #: ");
    grid.addComponent(hdmfNo, 2, 4);

    final ComboBox employmentStatus = dropDown.populateEmploymentStatus("Employment Status: ");
    grid.addComponent(employmentStatus, 0, 5);

    final TextField tinNo = new HRISTextField("Tin #:");
    grid.addComponent(tinNo, 1, 5);

    final TextField peicNo = new HRISTextField("Philhealth #");
    grid.addComponent(peicNo, 2, 5);

    final TextField employmentWage = new HRISTextField("Employment Wage: ");
    employmentWage.setValue("0.0");
    employmentWage.addListener(checkEntryIfDoubleListener);
    grid.addComponent(employmentWage, 0, 6);

    final ComboBox employmentWageStatus = dropDown.populateEmploymentWageStatus("Employment Wage Status: ");
    grid.addComponent(employmentWageStatus, 1, 6);

    final ComboBox employmentWageEntry = dropDown.populateEmploymentWageEntry("Employment Wage Entry: ");
    grid.addComponent(employmentWageEntry, 2, 6);

    Button saveButton = new Button("SAVE NEW EMPLOYEE");
    saveButton.setWidth("100%");
    saveButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            boolean resultQueryInsert, result1, result2, checkId;
            boolean checkResultForDuplicate;
            result1 = utilities.checkInputIfDouble(employmentWage.getValue().toString().trim());

            if (corporation.getValue() == null) {
                getWindow().showNotification("Select Corporation!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (trade.getValue() == null) {
                getWindow().showNotification("Select Trade!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (branch.getValue() == null) {
                getWindow().showNotification("Select Branch!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (dependent.getValue() == null) {
                getWindow().showNotification("Select # of dependent!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (employmentStatus.getValue() == null) {
                getWindow().showNotification("Select Employment Status!",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (employmentWageStatus.getValue() == null) {
                getWindow().showNotification("Select Employment Wage Status!",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (employmentWageEntry.getValue() == null) {
                getWindow().showNotification("Select Employment Wage Entry!",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (department.getValue() == null) {
                getWindow().showNotification("Select Department!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (result1 == false) {
                getWindow().showNotification("Invalid Input for EmploymentWage/EmploymentAllowanceEntry",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            checkResultForDuplicate = employeeService.checkForDuplicateEmployee(
                    firstname.getValue().toString().trim().toLowerCase(),
                    middlename.getValue().toString().trim().toLowerCase(),
                    lastname.getValue().toString().trim().toLowerCase());

            if (checkResultForDuplicate) {
                try {
                    errorLabel.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace(System.out);
                }

                return;
            }

            int corporate_id = companyService.getCorporateId(corporation.getValue().toString());
            int trade_id = companyService.getTradeId(trade.getValue().toString(), getCorporateId());
            int branch_id = companyService.getBranchId(getTradeId(), branch.getValue().toString());

            PostEmploymentInformationBean pe = new PostEmploymentInformationBean();
            pe.setFirstname(firstname.getValue().toString().trim());
            pe.setMiddlename(middlename.getValue().toString().trim());
            pe.setLastname(lastname.getValue().toString().trim());
            pe.setCompany(corporation.getValue().toString());
            pe.setTrade(trade.getValue().toString());
            pe.setBranch(branch.getValue().toString());
            pe.setBranchId(branch_id);
            pe.setDepartment(department.getValue().toString().trim());
            pe.setTotalDependent(dependent.getItem(dependent.getValue()).toString());
            pe.setPosition(position.getValue().toString().trim());
            pe.setEntryDate(
                    utilities.parsingDate(utilities.convertDateFormat(entryDate.getValue().toString())));
            pe.setSssNo(sssNo.getValue().toString().trim());
            pe.setTinNo(tinNo.getValue().toString().trim());
            pe.setPhicNo(peicNo.getValue().toString().trim());
            pe.setHdmfNo(hdmfNo.getValue().toString().trim());
            pe.setEmploymentStatus(employmentStatus.getItem(employmentStatus.getValue()).toString());
            pe.setEmploymentWageStatus(
                    employmentWageStatus.getItem(employmentWageStatus.getValue()).toString());
            pe.setEmploymentWageEntry(employmentWageEntry.getItem(employmentWageEntry.getValue()).toString());
            pe.setEmploymentWage(utilities.convertStringToDouble(employmentWage.getValue().toString().trim()));

            resultQueryInsert = employeeService.insertNewEmployee(pe);
            if (resultQueryInsert == true) {
                close();
            } else {
                getWindow().showNotification("SQL ERROR!");
            }
        }
    });
    grid.addComponent(saveButton, 1, 7, 2, 7);
    grid.addComponent(errorLabel, 1, 8, 2, 8);

    addComponent(grid);
}