Search in sources :

Example 1 with DefaultSortConfiguration

use of org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration in project nebula.widgets.nattable by eclipse.

the class SortIntegrationTest method setup.

@Before
public void setup() {
    EventList<RowDataFixture> eventList = GlazedLists.eventList(RowDataListFixture.getList().subList(0, 4));
    ConfigRegistry configRegistry = new ConfigRegistry();
    this.gridLayerStack = new GlazedListsGridLayer<RowDataFixture>(GlazedLists.threadSafeList(eventList), RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap(), configRegistry);
    this.nattable = new NatTableFixture(this.gridLayerStack, false);
    this.nattable.setConfigRegistry(configRegistry);
    this.nattable.addConfiguration(new DefaultNatTableStyleConfiguration());
    this.nattable.addConfiguration(new DefaultSortConfiguration());
    this.nattable.configure();
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) DefaultSortConfiguration(org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration) NatTableFixture(org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) Before(org.junit.Before)

Example 2 with DefaultSortConfiguration

use of org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration in project tdq-studio-se by Talend.

the class DataSampleTable method sortByColumn.

// sort by the current selected column
public void sortByColumn(List<ModelElement> columns) {
    if (columns == null || columns.size() < 1) {
        return;
    }
    // if the next sort direction is back to original
    SortDirectionEnum nextSortDirection = sortState.getNextSortDirection();
    List<Object[]> sortedData = bodyDataProvider.getList();
    if (SortDirectionEnum.NONE.equals(nextSortDirection) && isContainGID) {
        // if the data has GID, back to order by GID
        sortedData = MatchRuleAnlaysisUtils.sortResultByGID(propertyNames, sortedData);
    } else {
        sortedData = MatchRuleAnlaysisUtils.sortDataByColumn(sortState, sortedData, columns);
    }
    // refresh the table by the sorted data
    Composite parent = this.natTable.getParent();
    createTableControl(parent, sortedData);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
    // add sort data function
    natTable.addConfiguration(new DefaultSortConfiguration());
    natTable.configure();
    this.natTable.redraw();
    parent.getParent().layout();
    parent.layout();
}
Also used : DefaultSortConfiguration(org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration) Composite(org.eclipse.swt.widgets.Composite) SortDirectionEnum(org.eclipse.nebula.widgets.nattable.sort.SortDirectionEnum)

Example 3 with DefaultSortConfiguration

use of org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration in project nebula.widgets.nattable by eclipse.

the class RowSelectionIntegrationTest method setup.

@Before
public void setup() {
    IConfigRegistry configRegistry = new ConfigRegistry();
    // 10 rows in fixture
    this.eventListFixture = GlazedLists.eventList(RowDataListFixture.getList(10));
    GlazedListsGridLayer<RowDataFixture> gridLayer = new GlazedListsGridLayer<>(this.eventListFixture, RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap(), configRegistry);
    this.nattable = new NatTableFixture(gridLayer, false);
    this.nattable.setConfigRegistry(configRegistry);
    this.selectionLayer = gridLayer.getBodyLayerStack().getSelectionLayer();
    this.bodyDataProvider = gridLayer.getBodyDataProvider();
    this.selectionProvider = new RowSelectionProvider<>(this.selectionLayer, this.bodyDataProvider);
    this.nattable.addConfiguration(new DefaultSortConfiguration());
    // Enable preserve selection on data update
    this.selectionLayer.setSelectionModel(new RowSelectionModel<>(this.selectionLayer, this.bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {

        @Override
        public Serializable getRowId(RowDataFixture rowObject) {
            return rowObject.getSecurity_id();
        }
    }));
    // Enable test mode - events can be fired outside the Display thread
    gridLayer.getGlazedListsEventLayer().setTestMode(true);
    this.nattable.configure();
}
Also used : IRowIdAccessor(org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DefaultSortConfiguration(org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration) NatTableFixture(org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) Before(org.junit.Before)

Aggregations

DefaultSortConfiguration (org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration)3 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)2 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)2 NatTableFixture (org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture)2 Before (org.junit.Before)2 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)1 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)1 IRowIdAccessor (org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor)1 SortDirectionEnum (org.eclipse.nebula.widgets.nattable.sort.SortDirectionEnum)1 Composite (org.eclipse.swt.widgets.Composite)1