blob: 649a073730bf7eb3f0dfb4f4d4183db7594c7ad1 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2012, 2020 Original authors and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Original authors and others - initial API and implementation
******************************************************************************/
package org.eclipse.nebula.widgets.nattable.examples.fixtures;
import java.util.Map;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.data.IColumnPropertyAccessor;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel;
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider;
import org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer;
import org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer;
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform;
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
import org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider;
import ca.odell.glazedlists.SortedList;
/**
* Column header layer stack, with a {@link SortHeaderLayer}. Utilizes
* {@link GlazedListsSortModel} for sorting
*/
public class GlazedListsColumnHeaderLayerStack<T> extends
AbstractLayerTransform {
private IDataProvider dataProvider;
private DefaultColumnHeaderDataLayer dataLayer;
private ColumnHeaderLayer columnHeaderLayer;
public GlazedListsColumnHeaderLayerStack(String[] propertyNames,
Map<String, String> propertyToLabelMap, SortedList<T> sortedList,
IColumnPropertyAccessor<T> columnPropertyAccessor,
IConfigRegistry configRegistry, DefaultBodyLayerStack bodyLayerStack) {
this(new DefaultColumnHeaderDataProvider(propertyNames,
propertyToLabelMap), sortedList, columnPropertyAccessor,
configRegistry, bodyLayerStack);
}
public GlazedListsColumnHeaderLayerStack(IDataProvider dataProvider,
SortedList<T> sortedList,
IColumnPropertyAccessor<T> columnPropertyAccessor,
IConfigRegistry configRegistry, DefaultBodyLayerStack bodyLayerStack) {
this.dataProvider = dataProvider;
this.dataLayer = new DefaultColumnHeaderDataLayer(dataProvider);
this.columnHeaderLayer = new ColumnHeaderLayer(this.dataLayer, bodyLayerStack,
bodyLayerStack.getSelectionLayer());
SortHeaderLayer<T> sortHeaderLayer = new SortHeaderLayer<>(
this.columnHeaderLayer, new GlazedListsSortModel<>(sortedList,
columnPropertyAccessor, configRegistry, this.dataLayer),
false);
setUnderlyingLayer(sortHeaderLayer);
}
@Override
public void setClientAreaProvider(IClientAreaProvider clientAreaProvider) {
super.setClientAreaProvider(clientAreaProvider);
}
public DataLayer getDataLayer() {
return this.dataLayer;
}
public IDataProvider getDataProvider() {
return this.dataProvider;
}
public ColumnHeaderLayer getColumnHeaderLayer() {
return this.columnHeaderLayer;
}
}