Search in sources :

Example 1 with TextChangeListener

use of com.vaadin.v7.event.FieldEvents.TextChangeListener 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)

Aggregations

ExternalResource (com.vaadin.server.ExternalResource)1 Label (com.vaadin.ui.Label)1 Link (com.vaadin.ui.Link)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 IndexedContainer (com.vaadin.v7.data.util.IndexedContainer)1 TextChangeEvent (com.vaadin.v7.event.FieldEvents.TextChangeEvent)1 TextChangeListener (com.vaadin.v7.event.FieldEvents.TextChangeListener)1 Table (com.vaadin.v7.ui.Table)1 TextField (com.vaadin.v7.ui.TextField)1