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);
}
}
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);
}
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;
}
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;
}
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));
}
Aggregations