Example usage for com.vaadin.ui Layout addComponent

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

Introduction

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

Prototype

public void addComponent(Component c);

Source Link

Document

Adds the component into this container.

Usage

From source file:com.klwork.explorer.project.MyCalendarView.java

License:Apache License

private void initFormFields(Layout formLayout, Class<? extends CalendarEvent> eventClass) {
    //WW_TODO ??// www.j  a  va2  s . co m
    startDateField = CommonFieldHandler.createDateField("", useSecondResolution);
    endDateField = CommonFieldHandler.createDateField("?", useSecondResolution);

    final CheckBox allDayField = CommonFieldHandler.createCheckBox("");
    allDayField.addValueChangeListener(new Property.ValueChangeListener() {

        private static final long serialVersionUID = -7104996493482558021L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            Object value = event.getProperty().getValue();
            if (value instanceof Boolean && Boolean.TRUE.equals(value)) {
                setFormDateResolution(Resolution.DAY);

            } else {
                setFormDateResolution(Resolution.MINUTE);
            }
        }

    });

    captionField = CommonFieldHandler.createTextField("");
    //final TextField whereField = CommonFieldHandler.createTextField("");
    final TextArea descriptionField = CommonFieldHandler.createTextArea("??");
    descriptionField.setRows(3);
    //
    final ComboBox styleNameField = createStyleNameComboBox();

    formLayout.addComponent(startDateField);
    formLayout.addComponent(endDateField);
    formLayout.addComponent(allDayField);
    formLayout.addComponent(captionField);

    formLayout.addComponent(descriptionField);
    formLayout.addComponent(styleNameField);

    scheduleEventFieldGroup.bind(startDateField, "start");
    scheduleEventFieldGroup.bind(endDateField, "end");
    scheduleEventFieldGroup.bind(captionField, "caption");
    scheduleEventFieldGroup.bind(descriptionField, "description");

    scheduleEventFieldGroup.bind(styleNameField, "styleName");
    scheduleEventFieldGroup.bind(allDayField, "allDay");
}

From source file:com.logicbomb.newschool.MyAppWidgetSet.core.MainMenuWidget.java

public MainMenuWidget() {
    setStyleName("backColorWhite");
    //Accordion accordion = new Accordion();

    // Create the first tab, specify caption when adding
    // Wrap in a layout

    /*   tab1.addComponent(
     new Image(null, // No component caption
     new ThemeResource("img/planets/Mercury.jpg")));
     accordion.addTab(tab1,/* w  ww .  j av a 2s .co  m*/
     "Mercury",
     new ThemeResource("img/planets/Mercury_symbol.png"));*/
    //Button b1= new Button("First");
    //tab1.addComponent(b1);
    Layout tab1 = new VerticalLayout();
    addTab(tab1, "To Do");
    Layout tab2 = new VerticalLayout();
    addTab(tab2, "Timetable");
    Layout tab3 = new VerticalLayout();
    addTab(tab3, "Subjects");
    Layout tab4 = new VerticalLayout();
    addTab(tab4, "Examinations");
    Layout tab5 = new VerticalLayout();
    addTab(tab5, "Attendance");
    Layout tab6 = new VerticalLayout();
    addTab(tab6, "Fees");
    Layout tab7 = new VerticalLayout();
    addTab(tab7, "Reports");
    Layout tab8 = new VerticalLayout();
    addTab(tab8, "Miscellaneous");
    Layout tab9 = new VerticalLayout();
    addTab(tab9, "About");

    // Wrap in a layout
    /*   tab1.addComponent(
     new Image(null, // No component caption
     new ThemeResource("img/planets/Mercury.jpg")));
     accordion.addTab(tab1,
     "Mercury",
     new ThemeResource("img/planets/Mercury_symbol.png"));*/
    for (int i = 0; i < 7; i++) {
        Button b2 = new Button("English");
        tab3.addComponent(b2);
        b2.setSizeFull();
    }
    Button b3 = new Button("Hindi");
    tab3.addComponent(b3);
    b3.setSizeFull();
    //addTab(tab2,"Teacher");

}

From source file:com.mcparland.john.ComponentCollection.java

License:Apache License

/**
 * Create some tabs for each size//from w ww. ja va2 s .  c om
 * 
 * @param sizes
 *            the sizes
 */
private void createTabs() {
    for (String size : sizes) {
        final Layout layout = createLayout();
        layout.setCaption("Icons size " + size + " x " + size);
        addComponent(layout);

        for (String icon : icons) {
            final Image image = createImage(size, icon);
            DragAndDropWrapper imageWrap = new DragAndDropWrapper(image);
            imageWrap.setDragStartMode(DragStartMode.COMPONENT);
            imageWrap.setSizeUndefined();
            layout.addComponent(imageWrap);
        }
    }
}

From source file:com.mycompany.vaadinviews.FieldBinderWithBeanValidation.java

public FieldBinderWithBeanValidation() {
    //addComponent(log);
    //this.// w  w w.  j a  va  2  s.c  o m
    //getContent().
    Layout layout = new VerticalLayout();
    final BeanFieldGroup<PersonWithBeanValidationAnnotations> fieldGroup = new BeanFieldGroup<PersonWithBeanValidationAnnotations>(
            PersonWithBeanValidationAnnotations.class);

    fieldGroup.buildAndBindMemberFields(this);
    //fieldGroup.
    //Layout hlayout = new HorizontalLayout();
    layout.addComponent(firstName);
    //layout.addComponent(hlayout);
    layout.addComponent(lastName);
    layout.addComponent(email);
    layout.addComponent(age);
    layout.addComponent(sex);
    layout.addComponent(deceased);

    Button commitButton = new Button("Commit", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String msg = "Commit succesful";
            try {
                fieldGroup.commit();
            } catch (CommitException e) {
                msg = "Commit failed: " + e.getMessage();
            }
            Notification.show(msg);
            //log.log(msg);
        }
    });

    Button discardButton = new Button("Discard", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            fieldGroup.discard();
            //log.log("Discarded changes");

        }
    });
    Button showBean = new Button("Show bean values", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Notification.show(getPerson(fieldGroup).toString());

        }
    });
    layout.addComponent(commitButton);
    layout.addComponent(discardButton);
    layout.addComponent(showBean);
    sex.setPageLength(0);

    PersonWithBeanValidationAnnotations p = new PersonWithBeanValidationAnnotations("John", "Doe",
            "john@doe.com", 64, Sex.MALE, new Address("John street", 11223, "John's town", Country.USA));
    fieldGroup.setItemDataSource(new BeanItem<PersonWithBeanValidationAnnotations>(p));
    setContent(layout);
}

From source file:com.ocs.dynamo.ui.composite.dialog.EntityPopupDialog.java

License:Apache License

@Override
protected void doBuild(Layout parent) {

    formOptions.setHideCancelButton(false);

    layout = new SimpleEditLayout<ID, T>(entity, service, entityModel, formOptions) {

        private static final long serialVersionUID = -2965981316297118264L;

        @Override//ww  w. j av a2  s .  c o  m
        protected void afterEditDone(boolean cancel, boolean newEntity, T entity) {
            super.afterEditDone(cancel, newEntity, entity);
            EntityPopupDialog.this.close();
            EntityPopupDialog.this.afterEditDone(cancel, newEntity, entity);
        }

        @Override
        protected void afterModeChanged(boolean viewMode, ModelBasedEditForm<ID, T> editForm) {
            super.afterModeChanged(viewMode, editForm);
        }

    };
    parent.addComponent(layout);
}

From source file:com.ocs.dynamo.ui.composite.dialog.ModelBasedSearchDialog.java

License:Apache License

@Override
protected void doBuild(Layout parent) {
    FormOptions formOptions = new FormOptions().setHideAddButton(true).setPopup(true)
            .setSearchImmediately(searchImmediately);

    VerticalLayout wrapper = new DefaultVerticalLayout(false, false);
    wrapper.setStyleName("searchDialogWrapper");
    parent.addComponent(wrapper);

    searchLayout = new SimpleSearchLayout<ID, T>(service, entityModel, QueryType.ID_BASED, formOptions, null,
            filters, sortOrder, joins);/*from  w  ww .  j a v a 2  s .  c  o  m*/
    if (pageLength != null) {
        searchLayout.setPageLength(pageLength);
    }
    searchLayout.setMultiSelect(multiSelect);

    // add double click listener
    searchLayout.getTableWrapper().getTable().addItemClickListener(new ItemClickListener() {

        private static final long serialVersionUID = -6261614659335513455L;

        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                select(event.getItem().getItemProperty(DynamoConstants.ID).getValue());
                getOkButton().click();
            }
        }
    });

    wrapper.addComponent(searchLayout);
}

From source file:com.ocs.dynamo.ui.composite.form.CollectionTable.java

License:Apache License

/**
 * Constructs the button that is used for adding new items
 * /*from  w w  w . ja va 2s . co m*/
 * @param buttonBar
 */
protected void constructAddButton(Layout buttonBar) {
    addButton = new Button(messageService.getMessage("ocs.add"));
    addButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            // add a new item then set the validity to false (since an empty
            // item is never allowed)
            table.addItem();
            if (parentForm != null) {
                parentForm.signalDetailsTableValid(CollectionTable.this, false);
            }
        }
    });
    buttonBar.addComponent(addButton);
}

From source file:com.ocs.dynamo.ui.composite.form.CollectionTable.java

License:Apache License

/**
 * Constructs the button bar/* ww  w. ja  v a 2  s  .co m*/
 * 
 * @param parent
 */
protected void constructButtonBar(Layout parent) {
    Layout buttonBar = new DefaultHorizontalLayout();
    parent.addComponent(buttonBar);

    // button for adding a row
    if (!viewMode && !formOptions.isHideAddButton()) {
        constructAddButton(buttonBar);
    }

    // button for removing a row
    if (!viewMode && formOptions.isShowRemoveButton()) {
        constructRemoveButton(buttonBar);
    }

    postProcessButtonBar(buttonBar);
}

From source file:com.ocs.dynamo.ui.composite.form.CollectionTable.java

License:Apache License

/**
 * Constructs the remove button//from ww  w . j  a v  a 2 s .  co m
 * 
 * @param buttonBar
 */
protected void constructRemoveButton(Layout buttonBar) {
    removeButton = new Button(messageService.getMessage("ocs.remove"));
    removeButton.setEnabled(false);
    removeButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            table.removeItem(getSelectedItem());
            setValue(extractValues());

            setSelectedItem(null);
            onSelect(null);
        }

    });
    removeButton.setDescription(messageService.getMessage("ocs.select.row.to.delete"));
    buttonBar.addComponent(removeButton);
}

From source file:com.ocs.dynamo.ui.composite.form.DetailsEditTable.java

License:Apache License

/**
 * Constructs the button that is used for adding new items
 * //from   w w w  . j a v  a2  s.  c om
 * @param buttonBar
 */
protected void constructAddButton(Layout buttonBar) {
    Button addButton = new Button(messageService.getMessage("ocs.add"));
    addButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            T t = createEntity();
            container.addBean(t);
            parentForm.signalDetailsTableValid(DetailsEditTable.this,
                    VaadinUtils.allFixedTableFieldsValid(table));
        }
    });
    addButton.setVisible(isTableEditEnabled() && !formOptions.isHideAddButton());
    buttonBar.addComponent(addButton);
}