Example usage for com.vaadin.ui Grid removeAllColumns

List of usage examples for com.vaadin.ui Grid removeAllColumns

Introduction

In this page you can find the example usage for com.vaadin.ui Grid removeAllColumns.

Prototype

public void removeAllColumns() 

Source Link

Document

Removes all columns from this Grid.

Usage

From source file:com.cerebro.cable.xforce.view.GestioneRazze.java

public GestioneRazze() {

    setMargin(true);//ww  w.  j  a  v  a2 s  .  co  m

    TableQuery racesTQ = new TableQuery("races", connPool);
    SQLContainer racesContainer = null;
    try {
        racesContainer = new SQLContainer(racesTQ);
    } catch (Exception ex) {
        logger.error("Errore nella tabella delle razze: " + ex.getMessage());
    }
    Grid racesTable = new Grid(racesContainer);
    racesTable.removeAllColumns();
    for (int i = 0; i < racesTabCols.length; i++) {
        racesTable.addColumn(racesTabCols[i][0]);
        Grid.Column col = racesTable.getColumn(racesTabCols[i][0]);
        col.setHeaderCaption(racesTabCols[i][1]);
    }
    racesTable.getColumn("image").setRenderer(new ImageRenderer(), new Converter<Resource, String>() {
        @Override
        public String convertToModel(Resource value, Class<? extends String> targetType, Locale locale)
                throws Converter.ConversionException {
            return "not needed";
        }

        @Override
        public Resource convertToPresentation(String value, Class<? extends Resource> targetType, Locale locale)
                throws Converter.ConversionException {
            return new FileResource(
                    new File(VaadinService.getCurrent().getBaseDirectory().getAbsolutePath() + value));
        }

        @Override
        public Class<String> getModelType() {
            return String.class;
        }

        @Override
        public Class<Resource> getPresentationType() {
            return Resource.class;
        }

    });

    FormLayout raceEditor = new FormLayout();

    addComponents(racesTable);
}