class DataSetDefPreviewTable implements IsWidget {

    public void show(final DataSetDef dataSetDef, final Collection<DataColumnDef> columns,
                     final DisplayerListener displayerListener) {
        clear();
        
        if (dataSetDef != null) {
            
            // Build the table displayer settings.
            final TableDisplayerSettingsBuilder settingsBuilder = DisplayerSettingsFactory.newTableSettings()
                    .dataset(dataSetDef.getUUID())
                    .renderer(DefaultRenderer.UUID)
                    .titleVisible(false)
                    .tablePageSize(6)
                    .tableOrderEnabled(true)
                    .filterOn(true, false, false);

            // Make only the specified columns visible (if null then show all)
            if (columns != null && !columns.isEmpty()) {
                for (final DataColumnDef column : columns) {
                    settingsBuilder.column(column.getId());
                }
            }

            // Disable backend cache for preview.
            DataSetDef editCloneWithoutCacheSettings = dataSetDef.clone();
            editCloneWithoutCacheSettings.setCacheEnabled(false);

            // Close the current displayer (if any)
            if (tableDisplayer != null) {
                tableDisplayer.close();
            }

            // Configure the table displayer and the data set handler for edition.
            DisplayerSettings settings = settingsBuilder.buildSettings();
            tableDisplayer = displayerLocator.lookupDisplayer(settings);
            tableDisplayer.setDataSetHandler(new DataSetEditHandler(clientServices, settings.getDataSetLookup(), editCloneWithoutCacheSettings));

            // For CSV datasets, make sure dates & numbers are displayed as defined in the CSV configuration
            if (dataSetDef instanceof CSVDataSetDef) {
                CSVDataSetDef csvDataSetDef = (CSVDataSetDef) dataSetDef;
                tableDisplayer.addListener(new AbstractDisplayerListener() {

                    // The column settings are set right after the data set load, once the dataset columns are known
                    @Override
                    public void onDataLoaded(Displayer displayer) {
                        configureColumnSettings(displayer, csvDataSetDef);
                    }
                });
            }

            // Draw the table
            draw(displayerListener);
        }
    }

    @Inject public  DataSetDefPreviewTable(final DisplayerLocator displayerLocator,
                                  final DataSetClientServices clientServices,
                                  final View view);

}