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

The following examples show how to use com.vaadin.ui.Table#addItem() . 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: Application.java    From boot-examples with Apache License 2.0 6 votes vote down vote up
@Override
protected void init(VaadinRequest vaadinRequest) {
    getPage().setTitle("Root UI");

    Table table = new Table("Customer Table");

    table.addContainerProperty("firstName", String.class, null);
    table.addContainerProperty("lastName", String.class, null);
    table.addContainerProperty("id", Long.class, null);

    for (Customer c : this.customerRepository.findAll())
        table.addItem(new Object[]{c.getFirstName(), c.getLastName(), c.getId()}, c.getId());

    table.setSizeFull();
    table.setColumnHeader("firstName", "First Name");
    table.setColumnHeader("lastName", "First Name");
    setContent(table);
}
 
Example 2
Source File: ModuleLayout.java    From usergrid with Apache License 2.0 6 votes vote down vote up
public void loadData( Table userTable ){
    ModuleDao moduleDao = InjectorFactory.getInstance( ModuleDao.class );
    List<Module> modules = moduleDao.getAll();
    for( final Module module : modules ) {
        Label groupLabel = new Label( module.getGroupId( ) );
        Label artifactLabel = new Label( module.getArtifactId( ) );
        Label versionLabel = new Label( module.getVersion( ) );

        Button detailsField = new Button( "show details" );
        detailsField.addStyleName( "link" );
        detailsField.addClickListener( new Button.ClickListener( ) {
            @Override
            public void buttonClick( Button.ClickEvent event ) {
                onItemClick( module.getId() );
            }
        } );
        userTable.addItem( new Object[]{ groupLabel, artifactLabel, versionLabel, detailsField }, module.getId( ) );
    }
}
 
Example 3
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 4
Source File: StatView.java    From chipster with MIT License 5 votes vote down vote up
private void mapListToTable(List<Map<Object, Object>> list, Table table) {				

		table.setSizeFull();
		table.removeAllItems();
		
		if (list.size() > 0) {

			List<Object> keyList = new LinkedList<Object>(list.get(0).keySet());


			//Column headers
			for (Object columnHeader : keyList) {
				table.addContainerProperty(columnHeader, String.class, null);
			}
			
			
			//Content rows
			int i = 0;
			for (Map<Object, Object> map : list) {
			
				//We assume that the order of returned values is identical in all these maps 
				//otherwise values are put to wrong columns
				List<String> stringValues = new LinkedList<String>();
				
				for (Object objValue : map.values()) {
					if (objValue != null) {
						stringValues.add(objValue.toString());
					} else {
						stringValues.add("");
					}					
				}
				
				table.addItem(stringValues.toArray(), i++);
			}
		}
	}
 
Example 5
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();
}
 
Example 6
Source File: RunnersLayout.java    From usergrid with Apache License 2.0 3 votes vote down vote up
private void addRunnerToTable( Table table, Runner runner ) {

        State state = runnerService.getState(runner);
        StatsSnapshot stats = state == State.RUNNING ? runnerService.getStats(runner) : null;

        String percentageComplete = stats != null ? stats.getPercentageComplete() + "%" : "";
        String startTime = stats != null ? DATE_FORMAT.format( new Date( stats.getStartTime() ) ) : "";

        Object[] cells = new Object[] { runner.getUrl(), state.toString(), percentageComplete, startTime };

        table.addItem( cells, runner.getUrl() );
    }