Search in sources :

Example 1 with Container

use of com.vaadin.v7.data.Container in project charts by vaadin.

the class TListUi method addTest.

@SuppressWarnings("unchecked")
private void addTest(Container indexedContainer, String simpleName, Class<?> forName, String subpackage) throws InstantiationException, IllegalAccessException {
    if (AbstractVaadinChartExample.class.isAssignableFrom(forName)) {
        AbstractVaadinChartExample newInstance = (AbstractVaadinChartExample) forName.newInstance();
        Object id = indexedContainer.addItem();
        Item item = indexedContainer.getItem(id);
        item.getItemProperty("name").setValue(simpleName);
        item.getItemProperty("description").setValue(newInstance.getDescription());
        item.getItemProperty("package").setValue(subpackage);
    }
}
Also used : Item(com.vaadin.v7.data.Item) AbstractVaadinChartExample(com.vaadin.addon.charts.examples.AbstractVaadinChartExample)

Example 2 with Container

use of com.vaadin.v7.data.Container in project charts by vaadin.

the class TListUi method loadTestClasses.

private void loadTestClasses(TListUi aThis) {
    if (testClassess != null) {
        return;
    }
    testClassess = new IndexedContainer();
    testClassess.addContainerProperty("name", String.class, "");
    testClassess.addContainerProperty("description", String.class, "");
    testClassess.addContainerProperty("package", String.class, "");
    listTestClasses(testClassess, "area");
    listTestClasses(testClassess, "columnandbar");
    listTestClasses(testClassess, "combinations");
    listTestClasses(testClassess, "container");
    listTestClasses(testClassess, "dynamic");
    listTestClasses(testClassess, "lineandscatter");
    listTestClasses(testClassess, "other");
    listTestClasses(testClassess, "pie");
    listTestClasses(testClassess, "themes");
    listTestClasses(testClassess, "librarydata");
    listTestClasses(testClassess, "timeline");
    listTestClasses(testClassess, "threed");
    listTestClasses(testClassess, "declarative");
    listTestClasses(testClassess, "dataprovider");
    Table table = new Table("Test cases", testClassess);
    table.addGeneratedColumn("name", new Table.ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            String name = (String) source.getItem(itemId).getItemProperty(columnId).getValue();
            String pack = (String) source.getItem(itemId).getItemProperty("package").getValue();
            Link link = new Link();
            link.setResource(new ExternalResource("/" + (pack != null ? pack + "/" : "") + name));
            link.setCaption(name);
            link.setTargetName("_new");
            return link;
        }
    });
    table.addGeneratedColumn("description", new Table.ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            String description = (String) source.getItem(itemId).getItemProperty(columnId).getValue();
            return new Label(description);
        }
    });
    table.setSizeFull();
    table.setColumnExpandRatio("description", 1);
    VerticalLayout verticalLayout = new VerticalLayout();
    TextField filter = new TextField();
    filter.addTextChangeListener(new TextChangeListener() {

        @Override
        public void textChange(TextChangeEvent event) {
            String text = event.getText();
            testClassess.removeAllContainerFilters();
            testClassess.addContainerFilter("name", text, true, false);
        }
    });
    verticalLayout.addComponent(filter);
    filter.focus();
    verticalLayout.addComponent(table);
    setContent(verticalLayout);
}
Also used : Table(com.vaadin.v7.ui.Table) IndexedContainer(com.vaadin.v7.data.util.IndexedContainer) Label(com.vaadin.ui.Label) ExternalResource(com.vaadin.server.ExternalResource) TextChangeEvent(com.vaadin.v7.event.FieldEvents.TextChangeEvent) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.v7.ui.TextField) TextChangeListener(com.vaadin.v7.event.FieldEvents.TextChangeListener) Link(com.vaadin.ui.Link)

Example 3 with Container

use of com.vaadin.v7.data.Container in project charts by vaadin.

the class SparklineExampleWithLargeDataset method getChart.

@Override
protected Component getChart() {
    List<StockData> data = new LinkedList<StockData>();
    for (int i = 0; i < 200; i++) {
        data.addAll(getStockData());
    }
    Container container = new BeanItemContainer<StockData>(StockData.class, data);
    Table table = new Table();
    table.setContainerDataSource(container);
    table.addGeneratedColumn("values", new Table.ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            return new Sparkline(100, 20, (Number[]) source.getItem(itemId).getItemProperty(columnId).getValue());
        }
    });
    table.setVisibleColumns("month", "values", "latest");
    table.setHeightUndefined();
    return table;
}
Also used : BeanItemContainer(com.vaadin.v7.data.util.BeanItemContainer) Container(com.vaadin.v7.data.Container) Table(com.vaadin.v7.ui.Table) BeanItemContainer(com.vaadin.v7.data.util.BeanItemContainer) LinkedList(java.util.LinkedList) Sparkline(com.vaadin.addon.charts.Sparkline)

Example 4 with Container

use of com.vaadin.v7.data.Container in project charts by vaadin.

the class ChartWithExternalContainer method createTable.

private Component createTable(Container container) {
    Table t = new Table();
    t.setCaption("Data from Vaadin Container");
    t.setContainerDataSource(container);
    t.setItemCaptionMode(ItemCaptionMode.ID);
    t.setImmediate(true);
    return t;
}
Also used : Table(com.vaadin.v7.ui.Table)

Example 5 with Container

use of com.vaadin.v7.data.Container in project charts by vaadin.

the class ExampleUtil method addOrderToContainer.

private static void addOrderToContainer(Container container, String description, int quantity, double price) {
    Object itemId = container.addItem();
    Item item = container.getItem(itemId);
    item.getItemProperty(ORDER_DESCRIPTION_PROPERTY_ID).setValue(description);
    item.getItemProperty(ORDER_QUANTITY_PROPERTY_ID).setValue(quantity);
    item.getItemProperty(ORDER_UNITPRICE_PROPERTY_ID).setValue(price);
    item.getItemProperty(ORDER_ITEMPRICE_PROPERTY_ID).setValue((price * quantity));
}
Also used : Item(com.vaadin.v7.data.Item)

Aggregations

ContainerDataSeries (com.vaadin.v7.addon.charts.model.ContainerDataSeries)5 Table (com.vaadin.v7.ui.Table)5 Item (com.vaadin.v7.data.Item)4 HorizontalLayout (com.vaadin.ui.HorizontalLayout)3 Container (com.vaadin.v7.data.Container)3 IndexedContainer (com.vaadin.v7.data.util.IndexedContainer)3 Sparkline (com.vaadin.addon.charts.Sparkline)2 ExternalResource (com.vaadin.server.ExternalResource)2 Component (com.vaadin.ui.Component)2 Label (com.vaadin.ui.Label)2 Link (com.vaadin.ui.Link)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 Property (com.vaadin.v7.data.Property)2 BeanItemContainer (com.vaadin.v7.data.util.BeanItemContainer)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 AbstractVaadinChartExample (com.vaadin.addon.charts.examples.AbstractVaadinChartExample)1 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)1 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)1 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)1