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:org.jpos.qi.QIEntityView.java

License:Open Source License

protected void addFields(Layout l) {
    Object o = bean;/*from   w w  w  . j  av  a2s  .c  o m*/
    for (String id : getVisibleFields()) {
        //Check if there's a custom builder
        Component field = buildAndBindCustomComponent(id);
        if (field == null) {
            //if it wasn't built yet, build it now.
            try {
                Class dataType = getDataType(id);
                if (dataType.equals(Date.class)) {
                    l.addComponent(buildAndBindTimestampField(id));
                } else if (dataType.equals(BigDecimal.class)) {
                    l.addComponent(buildAndBindBigDecimalField(id));
                } else if (dataType.equals(Long.class) || dataType.equals(long.class)) {
                    l.addComponent(buildAndBindLongField(id));
                } else if (dataType.equals(Integer.class) || dataType.equals(int.class)) {
                    l.addComponent(buildAndBindIntField(id));
                } else if (dataType.equals(Short.class) || dataType.equals(short.class)) {
                    l.addComponent(buildAndBindShortField(id));
                } else if (dataType.equals(Boolean.class) || dataType.equals(boolean.class)) {
                    l.addComponent(buildAndBindBooleanField(id));
                } else if (dataType.equals(String.class)) {
                    l.addComponent(buildAndBindTextField(id));
                } else {
                    l.addComponent(new TextField("unconfigured data type " + dataType));
                }
            } catch (NoSuchFieldException e) {
                getApp().getLog().error(e);
            }
        } else {
            l.addComponent(field);
        }
    }
}

From source file:org.jpos.qi.QIEntityView.java

License:Open Source License

private void loadRevisionHistory(Layout formLayout, String ref) {
    DB db = new DB();
    db.open();/*from w  ww .j av a 2  s .  c  o  m*/
    revisionsPanel = new RevisionsPanel(ref, db);
    formLayout.addComponent(revisionsPanel);
    db.close();
}

From source file:org.jpos.qi.RevisionsPanel.java

License:Open Source License

private void addRevision(Revision r) {
    Label author = new Label("<strong>" + r.getAuthor().getName() + "</strong>", ContentMode.HTML);
    Label date = new Label(r.getDate().toString());
    Label info = new Label(r.getInfo(), ContentMode.HTML);
    author.setWidth("60%");

    HorizontalLayout hl = new HorizontalLayout();
    hl.setHeight("30px");
    hl.setWidth("100%");
    hl.addComponent(author);//from w w w .ja v a2  s . c  o m
    hl.addComponent(date);

    Layout content = (Layout) getContent();
    content.addComponent(hl);
    content.addComponent(info);
    content.addComponent(new Label("<hr/>", ContentMode.HTML));
}

From source file:org.lucidj.browser.BrowserView.java

License:Apache License

private Button createButton(Layout parent, String id, Resource icon, String caption, int kc, int mk) {
    final Button new_button = new Button();

    if (caption != null) {
        new_button.setCaption(caption);
    }//w  w  w  . j a v a  2 s  .co m
    new_button.setIcon(icon);
    new_button.addStyleName("tiny");
    new_button.addStyleName("toolbar");
    new_button.setId(id);

    new_button.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            handle_button_click(new_button);
        }
    });

    parent.addComponent(new_button);

    if (kc != 0) {
        new_button.addShortcutListener(new AbstractField.FocusShortcut(new_button, kc, mk) {
            @Override
            public void handleAction(Object sender, Object target) {
                handle_button_click(new_button);
            }
        });
    }

    return (new_button);
}

From source file:org.nooon.kutya.ui.pages.vehicle.VehicleEditPopup.java

@Override
protected void createBinding(Layout formLayout) {
    binder = new BeanFieldGroup<Vehicle>(Vehicle.class);
    binder.setBuffered(true);/* w  w  w .ja  v  a 2s . c  o  m*/
    binder.setItemDataSource(String.class.equals(itemID.getClass())
            ? new BeanItem<Vehicle>(sourceContainer.getItem(itemID).getEntity())
            : ((BeanItem<Vehicle>) itemID));

    TextField typeField = new TextField(getText("vehicle.type"));
    typeField.setNullRepresentation("");
    formLayout.addComponent(typeField);
    binder.bind(typeField, Vehicle_.type.getName());

    TextField licenseNumberField = new TextField(getText("vehicle.licenseNumber"));
    licenseNumberField.setNullRepresentation("");
    formLayout.addComponent(licenseNumberField);
    binder.bind(licenseNumberField, Vehicle_.licenseNumber.getName());

    TextField vinField = new TextField(getText("vehicle.vin"));
    vinField.setNullRepresentation("");
    formLayout.addComponent(vinField);
    binder.bind(vinField, Vehicle_.vin.getName());

    TextField engineNumberField = new TextField(getText("vehicle.engineNumber"));
    engineNumberField.setNullRepresentation("");
    formLayout.addComponent(engineNumberField);
    binder.bind(engineNumberField, Vehicle_.engineNumber.getName());

}

From source file:org.opennms.features.jmxconfiggenerator.webui.ui.HeaderPanel.java

License:Open Source License

public HeaderPanel() {
    Layout layout = new VerticalLayout();
    label = new Label();
    label.setContentMode(ContentMode.HTML);
    layout.addComponent(label);
    setContent(layout);/*  w  w w .j a v a2  s  .  c  o  m*/
}

From source file:org.opennms.features.jmxconfiggenerator.webui.ui.IntroductionView.java

License:Open Source License

public IntroductionView(JmxConfigGeneratorApplication app) {
    this.app = app;
    Button next = UIHelper.createButton("next", IconProvider.BUTTON_NEXT, this);

    setSizeFull();/*from   w  w  w.j a  va 2s. c  o  m*/
    setContent(new VerticalLayout());
    getContent().setSizeFull();

    Layout layout = new VerticalLayout();
    layout.addComponent(new Label(
            UIHelper.loadContentFromFile(getClass(), "/descriptions/IntroductionView.html"), ContentMode.HTML));
    layout.addComponent(next);
    setContent(layout);
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.MultitabPanel.java

License:Mozilla Public License

private void createMultitabPanel() {
    addStyleName(Runo.PANEL_LIGHT);//from w w  w.jav  a2 s  . co  m
    getLayout().setMargin(true);

    // Search results tab content
    searchResultPanel = new Panel();
    final VerticalLayout searchLayer = new VerticalLayout();
    searchLayer.setHeight(SEARCH_RESULTS_PANEL_HEIGHT);
    searchResultPanel.addStyleName(Runo.PANEL_LIGHT);
    searchLayer.addComponent(searchResultPanel);

    // Details form tab content
    final VerticalLayout detailsFormLayout = new VerticalLayout();
    detailsFormLayout.setMargin(true);
    detailsForm = new Form() {
        @SuppressWarnings("unchecked")
        @Override
        public void setReadOnly(final boolean readOnly) {
            super.setReadOnly(readOnly);
            final BeanItem<DetailsData> dataSrc = (BeanItem<DetailsData>) detailsForm.getItemDataSource();
            final Set detailsInstance = dataSrc.getBean().getInstance();
            if (!InstanceGetter.hasModifiableName(detailsInstance)) {
                for (final String id : DetailsData.getNameFieldIds()) {
                    final Field f = detailsForm.getField(id);
                    f.setReadOnly(true);
                }
            }
        }
    };
    detailsForm.setCaption("Instance Details");
    detailsForm.setImmediate(true);
    detailsForm.setWriteThrough(false);

    final DetailsData detailsData = new DetailsData(Root.root);
    final BeanItem<DetailsData> detailsItem = new BeanItem<DetailsData>(detailsData);

    final FormFieldFactory formFieldFactory = new PanelFormFieldFactory();
    detailsForm.setFormFieldFactory(formFieldFactory);
    //addImageUploadControls(detailsData);
    detailsForm.setItemDataSource(detailsItem);
    detailsForm.setVisibleItemProperties(DetailsData.getDisplayOrder());
    detailsForm.setFooter(new VerticalLayout());

    final HorizontalLayout formButtonBar = new HorizontalLayout();
    formButtonBar.setSpacing(true);
    formButtonBar.setHeight(BUTTON_BAR_HEIGHT);

    final Layout footer = detailsForm.getFooter();

    footer.addComponent(formButtonBar);

    editBtn = new Button(EDIT_BUTTON_LABEL, this, FORM_EVENT_HANDLER);

    saveBtn = new Button(SAVE_BUTTON_LABEL, this, FORM_EVENT_HANDLER);
    saveBtn.setVisible(false);

    cancelBtn = new Button(CANCEL_BUTTON_LABEL, this, FORM_EVENT_HANDLER);
    cancelBtn.setVisible(false);

    formButtonBar.addComponent(editBtn);
    formButtonBar.setComponentAlignment(editBtn, Alignment.TOP_RIGHT);
    formButtonBar.addComponent(saveBtn);
    formButtonBar.addComponent(cancelBtn);

    detailsFormLayout.addComponent(detailsForm);

    tabSheet = new TabSheet();
    tabSheet.setWidth(TAB_SHEET_WIDTH_RATIO);
    tabSheet.setHeight("90%");

    tabSheet.addTab(searchLayer, SEARCH_TAB_LABEL, EditorIcon.SEARCH.getIconImage());
    tabSheet.addTab(detailsFormLayout, DETAILS_TAB_LABEL, EditorIcon.DETAILS.getIconImage());
    tabSheet.addTab(new AdminFormLayout(this), ADMIN_TAB_LABEL, EditorIcon.ADMIN.getIconImage());
    //tabSheet.addTab(new GraphVisualizationLayout(this), VISUALIZATION_TAB, EditorIcon.ADMIN.getIconImage());
    addComponent(tabSheet);
}

From source file:org.tylproject.vaadin.addon.datanav.CrudButtonBar.java

License:Apache License

public CrudButtonBar(final DataNavigation nav) {
    super(nav);//from   w w  w.  ja  v  a 2  s. c om
    Layout buttonLayout = getLayout();

    buttonLayout.addComponent(createButton);
    buttonLayout.addComponent(editButton);
    buttonLayout.addComponent(removeButton);
    buttonLayout.addComponent(commitButton);
    buttonLayout.addComponent(discardButton);

    createButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            getNavigation().create();
        }
    });

    editButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            getNavigation().edit();
        }
    });

    removeButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            getNavigation().remove();
        }
    });

    commitButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            getNavigation().commit();
        }
    });

    discardButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            getNavigation().discard();
        }
    });

    setNavigation(nav);

}

From source file:org.tylproject.vaadin.addon.datanav.NavButtonBar.java

License:Apache License

public NavButtonBar(final DataNavigation nav) {
    super(nav);/*  w  ww  .j  a v  a2  s  .  co m*/
    Layout buttonLayout = getLayout();

    buttonLayout.addComponent(firstButton);
    buttonLayout.addComponent(prevButton);
    buttonLayout.addComponent(nextButton);
    buttonLayout.addComponent(lastButton);

    firstButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            getNavigation().first();
        }
    });

    nextButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            getNavigation().next();
        }
    });

    prevButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            getNavigation().prev();
        }
    });

    lastButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            getNavigation().last();
        }
    });

    setNavigation(nav);
}