Search in sources :

Example 1 with AbstractVaadinChartExample

use of com.vaadin.addon.charts.examples.AbstractVaadinChartExample 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 AbstractVaadinChartExample

use of com.vaadin.addon.charts.examples.AbstractVaadinChartExample in project charts by vaadin.

the class ChartsDemoUI method updateTabSheet.

/**
 * Updates main tabSheet
 * <p>
 * Adds one tab with one example instance, one with the java source and
 * another one with html source in case of declarative example
 *
 * @param chartExample
 */
private void updateTabSheet(Class chartExample) {
    try {
        tabSheet.removeAllComponents();
        AbstractVaadinChartExample newInstance = (AbstractVaadinChartExample) chartExample.newInstance();
        tabSheet.addTab(newInstance, "Example");
        addResourceTab(chartExample, chartExample.getSimpleName() + ".java", "Java Source");
        if (chartExample.isAnnotationPresent(DesignRoot.class)) {
            String designRoot = ((DesignRoot) chartExample.getAnnotation(DesignRoot.class)).value();
            addResourceTab(chartExample, designRoot, "HTML Source");
        }
        Page.getCurrent().setUriFragment(chartExample.getSimpleName(), false);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : AbstractVaadinChartExample(com.vaadin.addon.charts.examples.AbstractVaadinChartExample) IOException(java.io.IOException) DesignRoot(com.vaadin.annotations.DesignRoot)

Example 3 with AbstractVaadinChartExample

use of com.vaadin.addon.charts.examples.AbstractVaadinChartExample in project charts by vaadin.

the class ChartsDemoUI method getContainer.

private HierarchicalContainer getContainer() {
    HierarchicalContainer hierarchicalContainer = new HierarchicalContainer();
    hierarchicalContainer.addContainerProperty("displayName", String.class, "");
    hierarchicalContainer.addContainerProperty("searchName", String.class, "");
    for (int i = 0; i < GROUP_CAPTIONS.length; i++) {
        String group = GROUP_ORDER[i];
        String groupName = GROUP_CAPTIONS[i];
        Item groupItem = hierarchicalContainer.addItem(group);
        groupItem.getItemProperty("displayName").setValue(groupName);
        groupItem.getItemProperty("searchName").setValue(groupName);
        List<Class<? extends AbstractVaadinChartExample>> list = tests.get(group);
        for (Class<? extends AbstractVaadinChartExample> class1 : list) {
            Item testItem = hierarchicalContainer.addItem(class1);
            String itemName = splitCamelCase(class1.getSimpleName());
            testItem.getItemProperty("displayName").setValue(itemName);
            testItem.getItemProperty("searchName").setValue(groupName + " " + itemName);
            hierarchicalContainer.setParent(class1, group);
            hierarchicalContainer.setChildrenAllowed(class1, false);
        }
    }
    return hierarchicalContainer;
}
Also used : Item(com.vaadin.v7.data.Item) HierarchicalContainer(com.vaadin.v7.data.util.HierarchicalContainer) AbstractVaadinChartExample(com.vaadin.addon.charts.examples.AbstractVaadinChartExample)

Example 4 with AbstractVaadinChartExample

use of com.vaadin.addon.charts.examples.AbstractVaadinChartExample in project charts by vaadin.

the class TListUi method listTestClasses.

private void listTestClasses(Container indexedContainer, String subpackage) {
    String packageName = "com.vaadin.addon.charts.examples";
    if (subpackage != null) {
        packageName += "." + subpackage;
    }
    Reflections reflections = new Reflections(packageName);
    Set<Class<? extends AbstractVaadinChartExample>> subTypes = reflections.getSubTypesOf(AbstractVaadinChartExample.class);
    for (Class<? extends AbstractVaadinChartExample> subType : subTypes) {
        try {
            addTest(indexedContainer, subType.getSimpleName(), subType, subpackage);
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
Also used : AbstractVaadinChartExample(com.vaadin.addon.charts.examples.AbstractVaadinChartExample) Reflections(org.reflections.Reflections)

Aggregations

AbstractVaadinChartExample (com.vaadin.addon.charts.examples.AbstractVaadinChartExample)4 Item (com.vaadin.v7.data.Item)2 DesignRoot (com.vaadin.annotations.DesignRoot)1 HierarchicalContainer (com.vaadin.v7.data.util.HierarchicalContainer)1 IOException (java.io.IOException)1 Reflections (org.reflections.Reflections)1