Example usage for com.vaadin.ui HorizontalLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.promote.ArticlePromotionViewImpl.java

License:Open Source License

private void createAlert() {
    VerticalLayout alertTextLayout = new VerticalLayout();
    alertTextLayout.setSpacing(true);//from   w w w.  j a v a 2 s.  c  o  m
    alertTextLayout.setCaption("Alert Text");

    MagnoliaRichTextField textField = (MagnoliaRichTextField) listener.createRichTextField();
    textField.setSizeFull();

    HorizontalLayout periodLayout = new HorizontalLayout();
    periodLayout.setSpacing(true);
    // periodLayout.setWidth("100%");
    DateField startDate = new DateField();
    // startDate.setWidth("100%");
    DateField endDate = new DateField();
    // endDate.setWidth("100%");

    periodLayout.addComponent(new Label("START"));
    periodLayout.addComponent(startDate);
    periodLayout.addComponent(new Label("END"));
    periodLayout.addComponent(endDate);

    alertTextLayout.addComponent(textField);
    alertTextLayout.addComponent(periodLayout);

    HorizontalLayout alertLayout = new HorizontalLayout();
    alertLayout.setSpacing(true);
    alertLayout.setWidth("100%");
    alertLayout.addComponent(alertTextLayout);

    final Label alertPreview = new Label("", ContentMode.HTML);
    alertPreview.setCaption("Alert Preview");
    alertPreview.addStyleName("preview-label");
    textField.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            alertPreview.setValue(String.valueOf(event.getProperty().getValue()));
        }
    });
    alertPreview.setSizeUndefined();
    alertLayout.addComponent(alertPreview);
    alert.setContent(alertLayout);

    textField.setValue(
            "<b>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,</b>");
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.tagging.components.SearchEngineMetaDescription.java

License:Open Source License

private Component createSEOProgressBar() {
    ProgressBar seoProgressBar = new ProgressBar();
    seoProgressBar.setWidth("250px");
    seoProgressBar.setValue(0.5f);/*from   w  w w  .  j a  v a  2s .co m*/

    HorizontalLayout layout = new HorizontalLayout();
    layout.addComponent(new Label("SEO Rating:"));
    layout.addComponent(seoProgressBar);
    layout.setSpacing(true);
    layout.setMargin(new MarginInfo(false, false, true, false));

    NativeButton addUpdateButton = new NativeButton("", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            // do nothing
        }
    });
    addUpdateButton.addStyleName("update-button");
    addUpdateButton.setHeight("28px");
    addUpdateButton.setCaption("Update");
    addUpdateButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            updateMetaDescriptionPreview(textArea.getValue());
        }
    });
    layout.addComponent(addUpdateButton);

    return layout;
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.tagging.TaggingViewImpl.java

License:Open Source License

private void buildCustomTagsLayout() {

    final VerticalLayout customTags = new VerticalLayout();
    customTags.setCaption("Custom Tags");

    final HorizontalLayout newTagLayout = new HorizontalLayout();
    newTagLayout.setSizeUndefined();//from  w  w w.  jav a 2  s  .  c o  m

    final TextField newTagTextField = new TextField();
    newTagTextField.addStyleName("new-tag-textfield");
    newTagTextField.setHeight("52px");
    newTagTextField.setWidth("320px");
    newTagTextField.setNullRepresentation("");
    newTagTextField.setInputPrompt("Add new tag");
    NativeButton addTagButton = new NativeButton("", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addCustomTag(newTagTextField);
        }
    });
    addTagButton.addStyleName("add-tag-button");

    newTagLayout.addComponent(newTagTextField);
    newTagLayout.addComponent(addTagButton);
    newTagLayout.setExpandRatio(newTagTextField, 1f);

    /*
    NativeButton addGenerateTagsButton = new NativeButton("", new Button.ClickListener() {
    @Override
    public void buttonClick(Button.ClickEvent event) {
        // Generate Tags
    }
    });
    addGenerateTagsButton.addStyleName("generate-tags-button");
    addGenerateTagsButton.setCaption("Generate Tags");
    newTagLayout.addComponent(addGenerateTagsButton);
    */

    customTags.addComponent(newTagLayout);
    customTags.addComponent(customTagLayout);

    this.tagLayout.addComponent(customTags);
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.umbrellacontent.UmbrellaContentPreview.java

License:Open Source License

public UmbrellaContentPreview() {
    titleLabel.setCaption("TITLE");
    authorLabel.setCaption("AUTHOR");
    seriesLabel.setCaption("SERIES");

    setSizeFull();/*from   w w w .  jav  a2  s  . c o  m*/
    addComponent(titleLabel);

    HorizontalLayout authorAndSeries = new HorizontalLayout();
    authorAndSeries.setWidth("100%");
    authorAndSeries.addComponent(authorLabel);
    authorAndSeries.addComponent(seriesLabel);

    addComponent(authorAndSeries);

    setMargin(true);
    setSpacing(true);
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.umbrellacontent.UmbrellaContentViewImpl.java

License:Open Source License

private Component createSEOProgressBar() {
    ProgressBar seoProgressBar = new ProgressBar();
    seoProgressBar.setWidth("300px");
    seoProgressBar.setValue(0.5f);//from  www  .ja  va  2 s .  c om

    HorizontalLayout layout = new HorizontalLayout();
    layout.addComponent(new Label("SEO Rating:"));
    layout.addComponent(seoProgressBar);
    layout.setSpacing(true);
    layout.setMargin(new MarginInfo(false, false, true, false));
    return layout;
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.umbrellacontent.UmbrellaContentViewImpl.java

License:Open Source License

private HorizontalLayout createSeriesLayout() {
    HorizontalLayout seriesLayout = new HorizontalLayout();
    seriesLayout.setSpacing(true);/* w  w  w  . j av a  2 s .  com*/
    seriesLayout.setCaption("Series");
    seriesSelect.addItem("Test");
    Button addSeries = new Button("new series");
    addSeries.addStyleName("link");

    seriesLayout.addComponent(seriesSelect);
    seriesLayout.addComponent(addSeries);
    return seriesLayout;
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.umbrellacontent.UmbrellaContentViewImpl.java

License:Open Source License

private HorizontalLayout createAuthorsLayout() {
    HorizontalLayout authorsLayout = new HorizontalLayout();
    authorsLayout.setSpacing(true);// w ww.j  a  va 2  s. c  o m
    authorsLayout.setCaption("Author");
    authorSelect.addItem("Test");
    Button addAuthor = new Button("new author");
    addAuthor.addStyleName("link");
    /*
    addAuthor.addClickListener(new Button.ClickListener() {
    @Override
    public void buttonClick(Button.ClickEvent event) {
        try {
            String path = Path.getAbsolutePath(parentItem.applyChanges().getPath(), NEW_NODE_NAME);
            DetailLocation location = new DetailLocation(getDefinition().getAppName(), getDefinition().getSubAppId(), DetailView.ViewType.EDIT, path, "");
            locationController.goTo(location);
        } catch (RepositoryException e) {
            throw new ActionExecutionException(e);
        }
    }
    });
    */

    authorsLayout.addComponent(authorSelect);
    authorsLayout.addComponent(addAuthor);
    return authorsLayout;
}

From source file:com.ocs.dynamo.ui.component.EntityLookupField.java

License:Apache License

@Override
protected Component initContent() {
    HorizontalLayout bar = new DefaultHorizontalLayout(false, true, true);

    if (this.getAttributeModel() != null) {
        this.setCaption(getAttributeModel().getDisplayName());
    }//from  w  w  w  . j a va  2 s  .  com

    label = new Label();
    updateLabel(getValue());
    bar.addComponent(label);

    // button for selecting an entity - brings up the search dialog
    selectButton = new Button(getMessageService().getMessage("ocs.select"));
    selectButton.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 8377632639548698729L;

        @Override
        public void buttonClick(ClickEvent event) {
            ModelBasedSearchDialog<ID, T> dialog = new ModelBasedSearchDialog<ID, T>(getService(),
                    getEntityModel(), filters, sortOrder, multiSelect, true, joins) {

                private static final long serialVersionUID = -3432107069929941520L;

                @Override
                @SuppressWarnings("unchecked")
                protected boolean doClose() {
                    if (multiSelect) {
                        if (getValue() == null) {
                            setValue(getSelectedItems());
                        } else {
                            // get current value
                            Collection<T> current = (Collection<T>) EntityLookupField.this.getValue();
                            // add new values
                            for (T t : getSelectedItems()) {
                                if (!current.contains(t)) {
                                    current.add(t);
                                }
                            }
                            EntityLookupField.this.setValue(current);
                        }
                    } else {
                        setValue(getSelectedItem());
                    }
                    return true;
                }
            };
            dialog.setPageLength(pageLength);
            dialog.build();

            UI.getCurrent().addWindow(dialog);
        }
    });
    bar.addComponent(selectButton);

    // button for clearing the current selection
    clearButton = new Button(getMessageService().getMessage("ocs.clear"));
    clearButton.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 8377632639548698729L;

        @Override
        public void buttonClick(ClickEvent event) {
            setValue(null);
        }
    });
    bar.addComponent(clearButton);

    // quick add button
    if (addAllowed) {
        Button addButton = constructAddButton();
        bar.addComponent(addButton);
    }

    return bar;
}

From source file:com.ocs.dynamo.ui.component.FancyListSelect.java

License:Apache License

@Override
protected Component initContent() {
    VerticalLayout layout = new DefaultVerticalLayout(false, false);

    HorizontalLayout firstBar = new DefaultHorizontalLayout(false, false, true);
    firstBar.setSizeFull();/*  w w w  .ja v  a2  s.com*/

    comboBox.setCaption(null);
    comboBox.setSizeFull();

    firstBar.addComponent(comboBox);

    layout.addComponent(firstBar);

    HorizontalLayout secondBar = new DefaultHorizontalLayout(false, true, true);
    firstBar.addComponent(secondBar);

    // button for selecting an item
    selectButton = new Button(getMessageService().getMessage("ocs.select"));
    selectButton.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 2333147549550914035L;

        @Override
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            if (comboBox.getValue() != null) {
                if (!container.containsId(comboBox.getValue())) {
                    container.addBean((T) comboBox.getValue());
                    copyValueFromContainer();
                }
            }
            comboBox.setValue(null);
        }

    });
    secondBar.addComponent(selectButton);

    // adds a button for removing the selected items from the list select
    removeButton = new Button(getMessageService().getMessage("ocs.remove"));
    removeButton.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -1761776309410298236L;

        @Override
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            Object value = listSelect.getValue();
            if (value instanceof Collection) {
                Collection<T> col = (Collection<T>) value;
                for (T t : col) {
                    container.removeItem(t);
                    copyValueFromContainer();
                }
            }
        }
    });
    secondBar.addComponent(removeButton);

    // add a button for removing all items at once
    clearButton = new Button(getMessageService().getMessage("ocs.clear"));
    clearButton.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -1761776309410298236L;

        @Override
        public void buttonClick(ClickEvent event) {
            // clear the container
            setValue(new HashSet<>());
            copyValueFromContainer();
        }
    });
    secondBar.addComponent(clearButton);

    if (addAllowed) {
        Button addButton = constructAddButton();
        secondBar.addComponent(addButton);
    }

    listSelect.setSizeFull();
    listSelect.setNullSelectionAllowed(false);
    listSelect.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    listSelect.setItemCaptionPropertyId(getEntityModel().getDisplayProperty());
    listSelect.setMultiSelect(true);
    layout.addComponent(listSelect);

    return layout;
}

From source file:com.ocs.dynamo.ui.component.QuickAddEntityComboBox.java

License:Apache License

@Override
protected Component initContent() {
    HorizontalLayout bar = new DefaultHorizontalLayout(false, true, true);
    bar.setSizeFull();/*from  w  w w. j a  v  a 2s. c o  m*/

    if (this.getAttributeModel() != null) {
        this.setCaption(getAttributeModel().getDisplayName());
    }

    // no caption needed (the wrapping component has the caption)
    comboBox.setCaption(null);
    comboBox.setSizeFull();

    comboBox.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 5114731461745867455L;

        @Override
        @SuppressWarnings("unchecked")
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            setValue((T) event.getProperty().getValue());
        }
    });

    bar.addComponent(comboBox);

    Button addButton = constructAddButton();
    bar.addComponent(addButton);

    return bar;
}