Example usage for com.vaadin.ui FormLayout setDefaultComponentAlignment

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

Introduction

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

Prototype

@Override
    public void setDefaultComponentAlignment(Alignment defaultAlignment) 

Source Link

Usage

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.
 *///ww w . ja  v a2  s  .co  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 w  w.  jav  a 2s  . com*/
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.// w  ww .  ja  v a 2  s  . c  o m
 * @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:uk.co.intec.keyDatesApp.components.MainViewFilter.java

License:Apache License

/**
 * Main method to load the filtering fields and valueChangeListeners for
 * those fields./*from ww w. ja v a2s .  c  o m*/
 */
public void loadContent() {
    final FormLayout cust = new FormLayout();
    cust.setMargin(false);
    setCustField(new ComboBox("Customer:", KeyDateDatabaseUtils.getCustContainer()));
    getCustField().setInputPrompt("No Customer Selected");
    getCustField().setFilteringMode(FilteringMode.STARTSWITH);
    getCustField().setImmediate(true);
    getCustField().setInvalidAllowed(false);
    getCustField().setNullSelectionAllowed(true);
    getCustField().setPageLength(5);
    getCustField().setWidth("95%");
    getCustField().setResponsive(true);
    getCustField().addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        /*
         * (non-Javadoc)
         *
         * @see
         * com.vaadin.data.Property.ValueChangeListener#valueChange(com.
         * vaadin.data.Property.ValueChangeEvent)
         */
        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            final KeyDateViewWrapper viewWrapper = getParentView().getViewWrapper();
            getParentView().loadRowData(viewWrapper.getEntriesAsMap((String) event.getProperty().getValue(),
                    viewWrapper.getStartDate(), viewWrapper.isSingleCat(), viewWrapper.getCount()));
            getParentView().getPager().loadPagerPagesButtons();
        }
    });
    cust.addComponent(getCustField());

    final FormLayout date = new FormLayout();
    date.setMargin(false);
    setDateField(new PopupDateField("Start Date:"));
    getDateField().setValue(new Date());
    getDateField().setResolution(Resolution.DAY);
    getDateField().setLocale(Locale.getDefault());
    getDateField().setResponsive(true);
    getDateField().setTextFieldEnabled(false);
    getDateField().setWidth("95%");
    getDateField().setRequired(true);
    getDateField().setRequiredError("A date is required!");

    getDateField().addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        /*
         * (non-Javadoc)
         *
         * @see
         * com.vaadin.data.Property.ValueChangeListener#valueChange(com.
         * vaadin.data.Property.ValueChangeEvent)
         */
        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            final KeyDateViewWrapper viewWrapper = getParentView().getViewWrapper();
            getParentView().loadRowData(viewWrapper.getEntriesAsMap(viewWrapper.getCustomerName(),
                    (Date) event.getProperty().getValue(), viewWrapper.isSingleCat(), viewWrapper.getCount()));
            getParentView().getPager().loadPagerPagesButtons();
        }
    });

    date.addComponent(getDateField());

    final FormLayout singleCatLayout = new FormLayout();
    singleCatLayout.setMargin(false);
    singleCatLayout.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);
    setSingleCatButton(new CheckBox());
    getSingleCatButton().setStyleName(ValoTheme.CHECKBOX_SMALL);
    getSingleCatButton().setResponsive(true);
    getSingleCatButton().setCaption("Restrict to Date");
    getSingleCatButton().setWidth("95%");
    getSingleCatButton().addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        /*
         * (non-Javadoc)
         *
         * @see
         * com.vaadin.data.Property.ValueChangeListener#valueChange(com.
         * vaadin.data.Property.ValueChangeEvent)
         */
        @Override
        public void valueChange(ValueChangeEvent event) {
            final KeyDateViewWrapper viewWrapper = getParentView().getViewWrapper();
            final Boolean val = (Boolean) event.getProperty().getValue();
            getParentView().loadRowData(viewWrapper.getEntriesAsMap(viewWrapper.getCustomerName(),
                    viewWrapper.getStartDate(), val.booleanValue(), viewWrapper.getCount()));
            getParentView().getPager().loadPagerPagesButtons();
        }
    });
    singleCatLayout.addComponent(getSingleCatButton());

    addComponents(cust, date, singleCatLayout);
    setExpandRatio(cust, 2);
    setExpandRatio(date, 1);
    setExpandRatio(singleCatLayout, 1);
    setComponentAlignment(singleCatLayout, Alignment.MIDDLE_RIGHT);

}