Example usage for com.vaadin.ui FormLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

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  v a 2 s . co 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.
 */// w ww.java  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.
 *///from w w  w  .j  av a2 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 www.ja  v a 2 s.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//from  w  w  w.j  a v a  2 s  . c  om
 */
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;
}

From source file:org.opennms.features.topology.app.internal.ui.info.DefaultEdgeInfoPanelItem.java

License:Open Source License

@Override
protected Component getComponent(EdgeRef ref, GraphContainer container) {
    FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);/* www  .  j a v a2 s . c om*/
    formLayout.setMargin(false);

    if (ref instanceof AbstractEdge) {
        AbstractEdge edge = (AbstractEdge) ref;

        formLayout.addComponent(createLabel("Source", edge.getSource().getVertex().getLabel()));
        formLayout.addComponent(createLabel("Target", edge.getTarget().getVertex().getLabel()));
    }

    return formLayout;
}

From source file:org.opennms.features.topology.app.internal.ui.info.DefaultEdgeInfoPanelItemProvider.java

License:Open Source License

private Component createComponent(EdgeRef ref) {
    FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);/*  w  ww . j  a  v a 2  s.  c  om*/
    formLayout.setMargin(false);

    if (ref instanceof AbstractEdge) {
        AbstractEdge edge = (AbstractEdge) ref;

        formLayout.addComponent(createLabel("Source", edge.getSource().getVertex().getLabel()));
        formLayout.addComponent(createLabel("Target", edge.getTarget().getVertex().getLabel()));
    }

    return formLayout;
}

From source file:org.opennms.features.topology.app.internal.ui.info.DefaultVertexInfoPanelItem.java

License:Open Source License

@Override
protected Component getComponent(VertexRef ref, GraphContainer container) {
    FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);//from  w w  w .jav a 2  s  . co m
    formLayout.setMargin(false);

    formLayout.addComponent(createLabel("Name", ref.getLabel()));
    formLayout.addComponent(createLabel("ID", String.format("%s:%s", ref.getNamespace(), ref.getId())));

    if (ref instanceof AbstractVertex) {
        AbstractVertex vertex = (AbstractVertex) ref;

        formLayout.addComponent(createLabel("Icon Key", vertex.getIconKey()));

        if (vertex.getIpAddress() != null) {
            formLayout.addComponent(createLabel("IP Address", vertex.getIpAddress()));
        }
    }

    return formLayout;
}

From source file:org.opennms.features.topology.app.internal.ui.info.DefaultVertexInfoPanelItemProvider.java

License:Open Source License

private Component createComponent(VertexRef ref) {
    FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);/*from  w  w  w  .j  a  v a2 s .c  o m*/
    formLayout.setMargin(false);

    formLayout.addComponent(createLabel("Name", ref.getLabel()));
    formLayout.addComponent(createLabel("ID", String.format("%s:%s", ref.getNamespace(), ref.getId())));

    if (ref instanceof AbstractVertex) {
        AbstractVertex vertex = (AbstractVertex) ref;

        formLayout.addComponent(createLabel("Icon Key", vertex.getIconKey()));

        if (vertex.getIpAddress() != null) {
            formLayout.addComponent(createLabel("IP Address", vertex.getIpAddress()));
        }
    }

    return formLayout;
}

From source file:org.opennms.features.topology.app.internal.ui.info.NodeInfoPanelItem.java

License:Open Source License

@Override
protected Component getComponent(VertexRef ref, GraphContainer container) {
    if (ref instanceof AbstractVertex && ((AbstractVertex) ref).getNodeID() != null) {
        AbstractVertex vertex = ((AbstractVertex) ref);
        OnmsNode node = nodeDao.get(vertex.getNodeID());

        if (node != null) {
            FormLayout formLayout = new FormLayout();
            formLayout.setSpacing(false);
            formLayout.setMargin(false);

            formLayout.addComponent(createLabel("Node ID", "" + node.getId()));

            final HorizontalLayout nodeButtonLayout = new HorizontalLayout();
            Button nodeButton = createButton(node.getLabel(), null, null,
                    event -> new NodeInfoWindow(vertex.getNodeID()).open());
            nodeButton.setStyleName(BaseTheme.BUTTON_LINK);
            nodeButtonLayout.addComponent(nodeButton);
            nodeButtonLayout.setCaption("Node Label");
            formLayout.addComponent(nodeButtonLayout);

            if (!Strings.isNullOrEmpty(node.getSysObjectId())) {
                formLayout.addComponent(createLabel("Enterprise OID", node.getSysObjectId()));
            }/*from   w  ww.j  ava2  s.c o m*/

            return formLayout;
        }
    }

    return null;
}