Java Code Examples for com.vaadin.ui.Table#setPageLength()

The following examples show how to use com.vaadin.ui.Table#setPageLength() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StorageAdminPanel.java    From sensorhub with Mozilla Public License 2.0 5 votes vote down vote up
protected Table buildTable(IRecordStorageModule<?> storage, IRecordStoreInfo recordInfo)
{
    Table table = new Table();
    table.setWidth(100, Unit.PERCENTAGE);
    table.setPageLength(10);
    
    // add column names
    List<ScalarIndexer> indexers = new ArrayList<ScalarIndexer>();
    DataComponent recordDef = recordInfo.getRecordDescription();
    addColumns(recordDef, recordDef, table, indexers);
    
    // add data
    Iterator<DataBlock> it = storage.getDataBlockIterator(new DataFilter(recordInfo.getName()));
    int count = 0;
    int pageSize = 10;
    while (it.hasNext() && count < pageSize)
    {
        DataBlock dataBlk = it.next();
        
        Object[] values = new Object[indexers.size()];
        for (int i=0; i<values.length; i++)
            values[i] = indexers.get(i).getStringValue(dataBlk);
        
        table.addItem(values, count);
        count++;
    }
    
    return table;
}
 
Example 2
Source File: ObjectTypeSelectionPopup.java    From sensorhub with Mozilla Public License 2.0 4 votes vote down vote up
public ObjectTypeSelectionPopup(String title, final Map<String, Class<?>> typeList, final ObjectTypeSelectionCallback callback)
{
    super(title);
    VerticalLayout layout = new VerticalLayout();
    
    // generate table with type list
    final Table table = new Table();
    table.setSizeFull();
    table.setSelectable(true);
    table.setColumnReorderingAllowed(true);        
    table.addContainerProperty(UIConstants.PROP_NAME, String.class, null);
    table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
    table.setPageLength(10);
    table.setMultiSelect(false);
    
    final Map<Object, Class<?>> idTypeMap = new HashMap<Object, Class<?>>();
    for (Entry<String, Class<?>> item: typeList.entrySet())
    {
        Object id = table.addItem(new Object[] {item.getKey()}, null);
        idTypeMap.put(id, item.getValue());
    }
    layout.addComponent(table);
    
    // add OK button
    Button okButton = new Button("OK");
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event)
        {
            Object selectedItemId = table.getValue();
            
            if (selectedItemId != null)
            {
                Class<?> clazz = idTypeMap.get(selectedItemId);
                if (clazz != null)
                    callback.typeSelected(clazz);
            }
            
            close();
        }
    });
    layout.addComponent(okButton);
    layout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER);
    
    setContent(layout);
    center();
}