Example usage for com.vaadin.ui FormLayout FormLayout

List of usage examples for com.vaadin.ui FormLayout FormLayout

Introduction

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

Prototype

public FormLayout() 

Source Link

Usage

From source file:org.milleni.dunning.ui.dpdetail.DunningProcessDetailSearchPanel.java

License:Apache License

protected void initInputField() {
    /*//from   w  w w.j av a2 s .  c  o  m
            
    BeanFieldGroup<Customer>personBinder = new BeanFieldGroup<Customer>(PersonVo.class);
    personBinder.setItemDataSource(person);
    myFormLayout.addComponent(personBinder.buildAndBind("Firstname", "firstName"));
    myFormLayout.addComponent(personBinder.buildAndBind("Country", "country.name"));
            
    */

    formLayout = new FormLayout();

    //txtCustomerId = new TextField(i18nManager.getMessage(Constants.CUSTOMER_ID));
    //formLayout.addComponent(txtCustomerId);

    txtCustomerName = new TextField(i18nManager.getMessage(Constants.CUSTOMER_NAME));
    //formLayout.addComponent(txtCustomerName);

    formLayout.setWidth(100, UNITS_PERCENTAGE); // 99, otherwise the Panel will
    // display scrollbars
    //formLayout.setSpacing(true);
    //formLayout.setMargin(false, false, true, true);

    dpMaster = new DunningProcessMaster();
    dpDetail = new DunningProcessDetail();
    Form dpSearchForm = new Form();
    Form dpDetailSearchForm = new Form();

    dpSearchForm.setFormFieldFactory(new FormFieldFactory() {
        @SuppressWarnings("serial")
        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            Field field = DefaultFieldFactory.get().createField(item, propertyId, uiContext);
            if (field instanceof TextField) {
                ((TextField) field).setNullRepresentation("");
            }

            if ("dunningPolicyId".equals(propertyId)) {
                List<DunningPolicy> dunningPolicyList = new ArrayList<DunningPolicy>();
                Iterable<DunningPolicy> dunningPolicies = DaoHelper.getInstance().getDunningPolicyRepository()
                        .findAll();
                for (DunningPolicy dunningPolicy : dunningPolicies) {
                    dunningPolicyList.add(dunningPolicy);
                }
                BeanItemContainer<DunningPolicy> objects = new BeanItemContainer(DunningPolicy.class,
                        dunningPolicyList);

                policyCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_TYPE), objects);
                policyCombo.addListener(new ValueChangeListener() {

                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        DunningPolicy selectedDunningPolicy = (DunningPolicy) event.getProperty().getValue();
                        List<ProcessSteps> processSteps = DaoHelper.getInstance().getDunningPolicyRepository()
                                .retrieveDunningProcessSteps(selectedDunningPolicy.getPolicyId());
                        BeanItemContainer<ProcessSteps> objects = new BeanItemContainer(ProcessSteps.class,
                                processSteps);
                        stepCombo.setContainerDataSource(objects);
                    }

                });
                policyCombo.setItemCaptionPropertyId("policyName");
                return policyCombo;
            } else if ("processLastStepId".equals(propertyId)) {
                stepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_STEP));
                stepCombo.setItemCaptionPropertyId("stepText");
                return stepCombo;
            } else if ("status".equals(propertyId)) {
                statusCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_PROCESS_STATUS));
                statusCombo.setItemCaptionPropertyId("statusText");
                List<DunningProcessMasterStatus> statusList = DaoHelper.getInstance()
                        .getDunningPolicyRepository().retrieveAllDunningProcessMasterStatus();
                BeanItemContainer<DunningProcessMasterStatus> objects = new BeanItemContainer(
                        DunningProcessMasterStatus.class, statusList);
                statusCombo.setContainerDataSource(objects);
                /*
                statusCombo.addItem(Constants.SUCCESS);
                statusCombo.setItemCaption(Constants.SUCCESS, "Baarl");
                statusCombo.addItem(Constants.WARNING);
                statusCombo.setItemCaption(Constants.WARNING, "Uyar");
                statusCombo.addItem(Constants.ERROR);
                statusCombo.setItemCaption(Constants.ERROR, "Hatal");
                statusCombo.addItem(Constants.INITIAL);
                statusCombo.setItemCaption(Constants.INITIAL, "Balang");
                */
                return statusCombo;
            } else if ("createDate".equals(propertyId)) {
                processStartDate = new DateField("Process Balama Zaman");
                return processStartDate;
            } else if ("customerId".equals(propertyId)) {
                txtCustomerId = (TextField) field;
                txtCustomerId.setCaption(i18nManager.getMessage(Constants.CUSTOMER_ID));
                txtCustomerId.setPropertyDataSource(new PropertyFormatter() {

                    @Override
                    public Object parse(String formattedValue) throws Exception {
                        if (StringUtils.hasText(formattedValue))
                            try {
                                return new Customer(Long.parseLong(formattedValue));
                            } catch (Exception e) {
                                return null;
                            }

                        else
                            return null;
                    }

                    @Override
                    public String format(Object value) {
                        if (value instanceof Customer)
                            return String.valueOf(((Customer) value).getCustomerId());
                        return String.valueOf(value);
                    }
                });
                return txtCustomerId;
            }

            return field;
        }

    });

    dpDetailSearchForm.setFormFieldFactory(new FormFieldFactory() {
        @SuppressWarnings("serial")
        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            Field field = DefaultFieldFactory.get().createField(item, propertyId, uiContext);
            if (field instanceof TextField) {
                ((TextField) field).setNullRepresentation("");
            }

            if ("processStepId".equals(propertyId)) {
                stepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_LAST_STEP));
                stepCombo.setItemCaptionPropertyId("stepText");
                return stepCombo;
            } else if ("status".equals(propertyId)) {
                statusCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_STATUS));
                statusCombo.setItemCaptionPropertyId("statusText");
                List<DunningProcessDetailStatus> statusList = DaoHelper.getInstance()
                        .getDunningPolicyRepository().retrieveAllDunningProcessDetailStatus();
                BeanItemContainer<DunningProcessDetailStatus> objects = new BeanItemContainer(
                        DunningProcessDetailStatus.class, statusList);
                statusCombo.setContainerDataSource(objects);
                return statusCombo;
            } else if ("createDate".equals(propertyId)) {
                stepCreateDate = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_START));
                return stepCreateDate;
            } else if ("statusDate".equals(propertyId)) {
                statusChangeDate = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_STOP));
                return statusChangeDate;
            }

            return field;
        }

    });

    BeanItem<DunningProcessMaster> item = new BeanItem<DunningProcessMaster>(dpMaster,
            new String[] { "dunningPolicyId", "processLastStepId", "createDate", "status" });
    BeanItem<DunningProcessDetail> items = new BeanItem<DunningProcessDetail>(dpDetail,
            new String[] { "status" });

    dpSearchForm.setItemDataSource(item);
    dpDetailSearchForm.setItemDataSource(items);

    stepCreateDateEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_START_END));
    stepCreateDate = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_START));

    statusChangeDate = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_STOP));
    statusChangeDateEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_STOP_END));

    formLayout.addComponent(dpSearchForm);
    formLayout.addComponent(dpDetailSearchForm);

    FormLayout layout = (FormLayout) dpSearchForm.getLayout();
    layout.addComponent(stepCreateDate);
    layout.addComponent(stepCreateDateEnd);
    layout.addComponent(statusChangeDate);
    layout.addComponent(statusChangeDateEnd);

    setContent(formLayout);

}

From source file:org.milleni.dunning.ui.dpmaster.DunningProcessSearchPanel.java

License:Apache License

protected void initInputField() {
    /*// ww w  .j a  v  a 2  s  .  c o  m
            
    BeanFieldGroup<Customer>personBinder = new BeanFieldGroup<Customer>(PersonVo.class);
    personBinder.setItemDataSource(person);
    myFormLayout.addComponent(personBinder.buildAndBind("Firstname", "firstName"));
    myFormLayout.addComponent(personBinder.buildAndBind("Country", "country.name"));
            
    */

    formLayout = new FormLayout();

    //txtCustomerId = new TextField(i18nManager.getMessage(Constants.CUSTOMER_ID));
    //formLayout.addComponent(txtCustomerId);

    txtCustomerName = new TextField(i18nManager.getMessage(Constants.CUSTOMER_NAME));
    //formLayout.addComponent(txtCustomerName);

    formLayout.setWidth(100, UNITS_PERCENTAGE); // 99, otherwise the Panel will
    // display scrollbars
    //formLayout.setSpacing(true);
    //formLayout.setMargin(false, false, true, true);

    dpMaster = new DunningProcessMaster();

    Form dpSearchForm = new Form();

    dpSearchForm.setFormFieldFactory(new FormFieldFactory() {
        @SuppressWarnings("serial")
        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            Field field = DefaultFieldFactory.get().createField(item, propertyId, uiContext);
            if (field instanceof TextField) {
                ((TextField) field).setNullRepresentation("");
            }

            if ("dunningPolicyId".equals(propertyId)) {
                List<DunningPolicy> dunningPolicyList = new ArrayList<DunningPolicy>();
                Iterable<DunningPolicy> dunningPolicies = DaoHelper.getInstance().getDunningPolicyRepository()
                        .findAll();
                for (DunningPolicy dunningPolicy : dunningPolicies) {
                    dunningPolicyList.add(dunningPolicy);
                }
                BeanItemContainer<DunningPolicy> objects = new BeanItemContainer(DunningPolicy.class,
                        dunningPolicyList);

                policyCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_TYPE), objects);
                policyCombo.addListener(new ValueChangeListener() {

                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        DunningPolicy selectedDunningPolicy = (DunningPolicy) event.getProperty().getValue();
                        List<ProcessSteps> processSteps = DaoHelper.getInstance().getDunningPolicyRepository()
                                .retrieveDunningProcessSteps(selectedDunningPolicy.getPolicyId());
                        BeanItemContainer<ProcessSteps> objects = new BeanItemContainer(ProcessSteps.class,
                                processSteps);
                        stepCombo.setContainerDataSource(objects);
                        nextStepCombo.setContainerDataSource(objects);
                        currentStepCombo.setContainerDataSource(objects);
                    }

                });
                policyCombo.setItemCaptionPropertyId("policyName");
                return policyCombo;
            } else if ("currentStepId".equals(propertyId)) {
                currentStepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_CURRENT_STEP));
                currentStepCombo.setItemCaptionPropertyId("stepText");
                return currentStepCombo;
            } else if ("processLastStepId".equals(propertyId)) {
                stepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_LAST_STEP));
                stepCombo.setItemCaptionPropertyId("stepText");
                return stepCombo;
            } else if ("nextStepId".equals(propertyId)) {
                nextStepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_NEXT_STEP));
                nextStepCombo.setItemCaptionPropertyId("stepText");
                return nextStepCombo;
            } else if ("status".equals(propertyId)) {
                statusCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_PROCESS_STATUS));
                statusCombo.setItemCaptionPropertyId("statusText");
                List<DunningProcessMasterStatus> statusList = DaoHelper.getInstance()
                        .getDunningPolicyRepository().retrieveAllDunningProcessMasterStatus();
                BeanItemContainer<DunningProcessMasterStatus> objects = new BeanItemContainer(
                        DunningProcessMasterStatus.class, statusList);
                statusCombo.setContainerDataSource(objects);
                return statusCombo;
            } else if ("customerId".equals(propertyId)) {
                txtCustomerId = (TextField) field;
                txtCustomerId.setCaption(i18nManager.getMessage(Constants.CUSTOMER_ID));
                txtCustomerId.setPropertyDataSource(new PropertyFormatter() {

                    @Override
                    public Object parse(String formattedValue) throws Exception {
                        if (StringUtils.hasText(formattedValue))
                            try {
                                return new Customer(Long.parseLong(formattedValue));
                            } catch (Exception e) {
                                return null;
                            }

                        else
                            return null;
                    }

                    @Override
                    public String format(Object value) {
                        if (value instanceof Customer)
                            return String.valueOf(((Customer) value).getCustomerId());
                        return String.valueOf(value);
                    }
                });
                return txtCustomerId;
            }

            return field;
        }

    });

    BeanItem<DunningProcessMaster> item = new BeanItem<DunningProcessMaster>(dpMaster, new String[] {
            "dunningPolicyId", "currentStepId", "processLastStepId", "nextStepId", "customerId", "status" });
    dpSearchForm.setItemDataSource(item);

    nextStepDateStart = new DateField(i18nManager.getMessage(Constants.DUNNING_NEXT_STEP_DATE_START));
    nextStepDateStart.setDateFormat("dd.MM.yyyy");

    nextStepDateEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_NEXT_STEP_DATE_END));
    nextStepDateEnd.setDateFormat("dd.MM.yyyy");

    processStartDate = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_DATE_START));
    processStartDate.setDateFormat("dd.MM.yyyy");

    processStartEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_DATE_END));
    processStartEnd.setDateFormat("dd.MM.yyyy");

    processStatusDateStart = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STATUS_DATE_START));
    processStatusDateStart.setDateFormat("dd.MM.yyyy");

    processStatusDateEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STATUS_DATE_END));
    processStatusDateEnd.setDateFormat("dd.MM.yyyy");

    invoiceDateStart = new DateField(i18nManager.getMessage(Constants.DUNNING_INVOICE_DATE_START));
    invoiceDateStart.setDateFormat("dd.MM.yyyy");

    invoiceDateEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_INVOICE_DATE_END));
    invoiceDateEnd.setDateFormat("dd.MM.yyyy");

    //dpSearchForm.addField(processStartFinishDate, processStartFinishDate);

    FormLayout layout = (FormLayout) dpSearchForm.getLayout();
    layout.addComponent(nextStepDateStart);
    layout.addComponent(nextStepDateEnd);
    layout.addComponent(processStartDate);
    layout.addComponent(processStartEnd);
    layout.addComponent(processStatusDateStart);
    layout.addComponent(processStatusDateEnd);
    layout.addComponent(invoiceDateStart);
    layout.addComponent(invoiceDateEnd);

    formLayout.addComponent(dpSearchForm);
    setContent(formLayout);
}

From source file:org.opencms.ui.dialogs.CmsCopyMoveDialog.java

License:Open Source License

/**
 * Initializes the form fields.<p>
 *
 * @return the form component//from  ww  w.  j  a  v  a  2  s .c  o m
 */
private FormLayout initForm() {

    FormLayout form = new FormLayout();
    form.setWidth("100%");
    m_targetPath = new CmsPathSelectField();
    m_targetPath.setCaption(
            CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_TARGET_0));
    m_targetPath.setFileSelectCaption(
            CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_SELECT_TARGET_CAPTION_0));
    m_targetPath.setResourceFilter(CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireFolder());
    m_targetPath.setWidth("100%");
    form.addComponent(m_targetPath);

    if (m_dialogMode != DialogMode.move) {
        m_actionCombo = new ComboBox();
        m_actionCombo
                .setCaption(CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_COPYPAGE_COPY_MODE_0));
        m_actionCombo.setNullSelectionAllowed(false);
        m_actionCombo.setNewItemsAllowed(false);
        m_actionCombo.setWidth("100%");
        //            m_actionCombo.addItem(Action.automatic);
        //            m_actionCombo.setItemCaption(
        //                Action.automatic,
        //                CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_AUTOMATIC_0));
        //            m_actionCombo.setValue(Action.automatic);
        if (m_context.getResources().size() == 1) {
            if (m_context.getResources().get(0).isFile()) {
                m_actionCombo.addItem(Action.copy_all);
                m_actionCombo.setItemCaption(Action.copy_all, CmsVaadinUtils
                        .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_AS_NEW_0));
                m_actionCombo.addItem(Action.copy_sibling_all);
                m_actionCombo.setItemCaption(Action.copy_sibling_all, CmsVaadinUtils
                        .getMessageText(org.opencms.workplace.commons.Messages.GUI_CREATE_SIBLING_0));
                if (m_dialogMode == DialogMode.copy_and_move) {
                    m_actionCombo.addItem(Action.move);
                    m_actionCombo.setItemCaption(Action.move, CmsVaadinUtils
                            .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_MOVE_FILE_0));
                }
            } else {
                CmsResource folder = m_context.getResources().get(0);
                m_hasContainerPageDefaultFile = hasContainerPageDefaultFile(folder);
                if (m_hasContainerPageDefaultFile) {
                    m_actionCombo.addItem(Action.container_page_automatic);
                    m_actionCombo.setItemCaption(Action.container_page_automatic,
                            CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_AUTOMATIC_0));
                    m_actionCombo.addItem(Action.container_page_copy);
                    m_actionCombo.setItemCaption(Action.container_page_copy,
                            CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_CONTAINERPAGE_COPY_0));
                    m_actionCombo.addItem(Action.container_page_reuse);
                    m_actionCombo.setItemCaption(Action.container_page_reuse,
                            CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_CONTAINERPAGE_REUSE_0));
                }
                if (CmsResourceTypeFolderSubSitemap.isSubSitemap(folder)) {
                    m_actionCombo.addItem(Action.sub_sitemap);
                    m_actionCombo.setItemCaption(Action.sub_sitemap,
                            CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_SUBSITEMAP_0));
                }
                m_actionCombo.addItem(Action.copy_sibling_mixed);
                m_actionCombo.setItemCaption(Action.copy_sibling_mixed, CmsVaadinUtils
                        .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_ALL_NO_SIBLINGS_0));
                m_actionCombo.addItem(Action.copy_all);
                m_actionCombo.setItemCaption(Action.copy_all,
                        CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_ALL_0));
                m_actionCombo.addItem(Action.copy_sibling_all);
                m_actionCombo.setItemCaption(Action.copy_sibling_all, CmsVaadinUtils.getMessageText(
                        org.opencms.workplace.commons.Messages.GUI_COPY_MULTI_CREATE_SIBLINGS_0));
                if (m_dialogMode == DialogMode.copy_and_move) {
                    m_actionCombo.addItem(Action.move);
                    m_actionCombo.setItemCaption(Action.move, CmsVaadinUtils.getMessageText(
                            org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_MOVE_FOLDER_0));
                }
            }
        } else {
            m_actionCombo.addItem(Action.copy_sibling_mixed);
            m_actionCombo.setItemCaption(Action.copy_sibling_mixed, CmsVaadinUtils
                    .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_ALL_NO_SIBLINGS_0));
            m_actionCombo.addItem(Action.copy_all);
            m_actionCombo.setItemCaption(Action.copy_all,
                    CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_ALL_0));
            m_actionCombo.addItem(Action.copy_sibling_all);
            m_actionCombo.setItemCaption(Action.copy_sibling_all, CmsVaadinUtils
                    .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MULTI_CREATE_SIBLINGS_0));
            if (m_dialogMode == DialogMode.copy_and_move) {
                m_actionCombo.addItem(Action.move);
                m_actionCombo.setItemCaption(Action.move, CmsVaadinUtils
                        .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_MOVE_RESOURCES_0));
            }
        }
        m_actionCombo.setItemStyleGenerator(new ItemStyleGenerator() {

            private static final long serialVersionUID = 1L;

            public String getStyle(ComboBox source, Object itemId) {

                String style = null;
                if (m_defaultActions.contains(itemId)) {
                    style = "bold";
                }
                return style;
            }
        });
        form.addComponent(m_actionCombo);
    }
    if (m_context.getResources().size() > 1) {
        m_overwriteExisting = new CheckBox(CmsVaadinUtils
                .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MULTI_OVERWRITE_0));
        m_overwriteExisting.setValue(Boolean.FALSE);
        form.addComponent(m_overwriteExisting);
    }

    return form;
}

From source file:org.opencms.ui.dialogs.CmsProjectSelectDialog.java

License:Open Source License

/**
 * Initializes the form component.<p>
 *
 * @return the form component/*from   w  w w .jav a 2s .  c  o m*/
 */
private FormLayout initForm() {

    FormLayout form = new FormLayout();
    form.setWidth("100%");

    IndexedContainer sites = CmsVaadinUtils.getAvailableSitesContainer(m_context.getCms(), CAPTION_PROPERTY);
    m_siteComboBox = prepareComboBox(sites, org.opencms.workplace.Messages.GUI_LABEL_SITE_0);
    m_siteComboBox.select(m_context.getCms().getRequestContext().getSiteRoot());
    form.addComponent(m_siteComboBox);
    ValueChangeListener changeListener = new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {

            submit();
        }
    };
    m_siteComboBox.addValueChangeListener(changeListener);
    IndexedContainer projects = CmsVaadinUtils.getProjectsContainer(m_context.getCms(), CAPTION_PROPERTY);
    m_projectComboBox = prepareComboBox(projects, org.opencms.workplace.Messages.GUI_LABEL_PROJECT_0);
    CmsUUID currentProjectId = m_context.getCms().getRequestContext().getCurrentProject().getUuid();
    if (projects.containsId(currentProjectId)) {
        m_projectComboBox.select(currentProjectId);
    } else {
        try {
            CmsUUID ouProject = OpenCms.getOrgUnitManager().readOrganizationalUnit(m_context.getCms(),
                    m_context.getCms().getRequestContext().getOuFqn()).getProjectId();
            if (projects.containsId(ouProject)) {
                m_projectComboBox.select(ouProject);
            }
        } catch (CmsException e) {
            LOG.error("Error while reading current OU.", e);
        }
    }

    form.addComponent(m_projectComboBox);
    m_projectComboBox.addValueChangeListener(changeListener);
    return form;
}

From source file:org.opencms.ui.dialogs.CmsPublishScheduledDialog.java

License:Open Source License

/**
 * Initializes the form fields.<p>
 *
 * @return the form component/*from ww w. j  a  va 2s .c o m*/
 */
private FormLayout initForm() {

    FormLayout form = new FormLayout();
    form.setWidth("100%");
    m_dateField = new CmsDateField();
    m_dateField.setCaption(CmsVaadinUtils
            .getMessageText(org.opencms.workplace.commons.Messages.GUI_LABEL_DATE_PUBLISH_SCHEDULED_0));
    form.addComponent(m_dateField);
    m_includeSubResources = new CheckBox(CmsVaadinUtils
            .getMessageText(org.opencms.workplace.commons.Messages.GUI_PUBLISH_MULTI_SUBRESOURCES_0));
    if (hasFolders()) {
        form.addComponent(m_includeSubResources);
    }

    return form;
}

From source file:org.opencms.ui.dialogs.CmsSiteSelectDialog.java

License:Open Source License

/**
 * Initializes the form component.<p>
 *
 * @return the form component//w  w w  . j  a  va2s .c o m
 */
private FormLayout initForm() {

    FormLayout form = new FormLayout();
    form.setWidth("100%");

    IndexedContainer sites = CmsVaadinUtils.getAvailableSitesContainer(m_context.getCms(), CAPTION_PROPERTY);
    m_siteComboBox = prepareComboBox(sites, org.opencms.workplace.Messages.GUI_LABEL_SITE_0);
    m_siteComboBox.select(m_context.getCms().getRequestContext().getSiteRoot());
    form.addComponent(m_siteComboBox);
    ValueChangeListener changeListener = new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {

            submit();
        }
    };
    m_siteComboBox.addValueChangeListener(changeListener);
    return form;
}

From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorOptions.java

License:Open Source License

/**
 * Creates the upper right component of the options grid.
 * Creation includes the initialization of {@link #m_filePathField}.
 *
 * @return the upper right component in the options grid.
 *///from   ww w.j  ava  2s  .c o  m
private Component createUpperRightComponent() {

    HorizontalLayout upperRight = new HorizontalLayout();
    upperRight.setSizeFull();

    FormLayout fileNameDisplay = new FormLayout();
    fileNameDisplay.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    fileNameDisplay.setSizeFull();

    m_filePathField = new TextField();
    m_filePathField.setWidth("100%");
    m_filePathField.setEnabled(true);
    m_filePathField.setReadOnly(true);

    fileNameDisplay.addComponent(m_filePathField);
    fileNameDisplay.setSpacing(true);

    FormLayout filePathDisplay = new FormLayout();
    filePathDisplay.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    filePathDisplay.setSizeFull();
    filePathDisplay.addComponent(m_filePathField);
    filePathDisplay.setSpacing(true);

    upperRight.addComponent(filePathDisplay);
    upperRight.setExpandRatio(filePathDisplay, 2f);

    HorizontalLayout placeHolder = new HorizontalLayout();
    placeHolder.setWidth(CmsMessageBundleEditorTypes.OPTION_COLUMN_WIDTH_PX);
    upperRight.addComponent(placeHolder);

    return upperRight;
}

From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorOptions.java

License:Open Source License

/**
 * Initializes the language switcher UI Component {@link #m_languageSwitch}, including {@link #m_languageSelect}.
 * @param locales the locales that can be selected.
 * @param current the currently selected locale.
 *//*w ww .j  av  a  2 s  .  c o m*/
private void initLanguageSwitch(Collection<Locale> locales, Locale current) {

    FormLayout languages = new FormLayout();
    languages.setHeight("100%");
    languages.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    ComboBox languageSelect = new ComboBox();
    languageSelect.setCaption(m_messages.key(Messages.GUI_LANGUAGE_SWITCHER_LABEL_0));
    languageSelect.setNullSelectionAllowed(false);

    // set Locales
    for (Locale locale : locales) {
        languageSelect.addItem(locale);
        String caption = locale.getDisplayName(UI.getCurrent().getLocale());
        if (CmsLocaleManager.getDefaultLocale().equals(locale)) {
            caption += " ("
                    + Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_DEFAULT_LOCALE_0)
                    + ")";
        }
        languageSelect.setItemCaption(locale, caption);
    }
    languageSelect.setValue(current);
    languageSelect.setNewItemsAllowed(false);
    languageSelect.setTextInputAllowed(false);
    languageSelect.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {

            m_listener.handleLanguageChange((Locale) event.getProperty().getValue());

        }
    });

    if (locales.size() == 1) {
        languageSelect.setEnabled(false);
    }
    languages.addComponent(languageSelect);
    m_languageSwitch = languages;
}

From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorOptions.java

License:Open Source License

/**
 * Initializes the mode switcher.//from w w w  .jav  a2s  .com
 * @param current the current edit mode
 */
private void initModeSwitch(final EditMode current) {

    FormLayout modes = new FormLayout();
    modes.setHeight("100%");
    modes.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    m_modeSelect = new ComboBox();
    m_modeSelect.setCaption(m_messages.key(Messages.GUI_VIEW_SWITCHER_LABEL_0));

    // add Modes
    m_modeSelect.addItem(CmsMessageBundleEditorTypes.EditMode.DEFAULT);
    m_modeSelect.setItemCaption(CmsMessageBundleEditorTypes.EditMode.DEFAULT,
            m_messages.key(Messages.GUI_VIEW_SWITCHER_EDITMODE_DEFAULT_0));
    m_modeSelect.addItem(CmsMessageBundleEditorTypes.EditMode.MASTER);
    m_modeSelect.setItemCaption(CmsMessageBundleEditorTypes.EditMode.MASTER,
            m_messages.key(Messages.GUI_VIEW_SWITCHER_EDITMODE_MASTER_0));

    // set current mode as selected
    m_modeSelect.setValue(current);

    m_modeSelect.setNewItemsAllowed(false);
    m_modeSelect.setTextInputAllowed(false);
    m_modeSelect.setNullSelectionAllowed(false);

    m_modeSelect.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {

            m_listener.handleModeChange((EditMode) event.getProperty().getValue());

        }
    });

    modes.addComponent(m_modeSelect);
    m_modeSwitch = modes;
}

From source file:org.opencms.ui.sitemap.CmsCopyPageDialog.java

License:Open Source License

/**
 * Initializes the content panel.<p>
 *
 * @return the content panel// w  w w  .  j  a v a 2 s  .  co m
 */
private FormLayout initContent() {

    FormLayout form = new FormLayout();
    CmsPathSelectField field = new CmsPathSelectField();
    field.setValue(getInitialTarget(m_context.getCms(), m_context.getResources().get(0)));
    field.setStartWithSitempaView(true);
    field.setResourceFilter(CmsResourceFilter.IGNORE_EXPIRATION.addRequireFolder());
    field.setCaption(
            CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_TARGET_0));
    form.addComponent(field);
    m_targetSelect = field;
    m_copyMode.addItem(CmsContainerPageCopier.CopyMode.automatic);
    m_copyMode.setItemCaption(CmsContainerPageCopier.CopyMode.automatic,
            CmsVaadinUtils.getMessageText(Messages.GUI_COPYPAGE_MODE_AUTO_0));

    m_copyMode.addItem(CmsContainerPageCopier.CopyMode.smartCopyAndChangeLocale);
    m_copyMode.setItemCaption(CmsContainerPageCopier.CopyMode.smartCopyAndChangeLocale,
            CmsVaadinUtils.getMessageText(Messages.GUI_COPYPAGE_MODE_SMART_0));
    m_copyMode.addItem(CmsContainerPageCopier.CopyMode.reuse);
    m_copyMode.setItemCaption(CmsContainerPageCopier.CopyMode.reuse,
            CmsVaadinUtils.getMessageText(Messages.GUI_COPYPAGE_MODE_REUSE_0));
    m_copyMode.setValue(CmsContainerPageCopier.CopyMode.automatic);
    form.addComponent(m_copyMode);
    m_copyMode.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_COPYPAGE_COPY_MODE_0));
    return form;
}