use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class DisplayColumnStyleEditorCommandHandlerTest method setup.
@Before
public void setup() {
this.labelAccumulatorFixture = new ColumnOverrideLabelAccumulator(new DataLayerFixture());
this.natTableFixture = new NatTableFixture();
this.configRegistryFixture = this.natTableFixture.getConfigRegistry();
this.commandFixture = new DisplayColumnStyleEditorCommand(this.natTableFixture, this.natTableFixture.getConfigRegistry(), 1, 1);
final SelectionLayer selectionLayer = ((DummyGridLayerStack) this.natTableFixture.getLayer()).getBodyLayer().getSelectionLayer();
this.handlerUnderTest = new DisplayColumnStyleEditorCommandHandler(selectionLayer, this.labelAccumulatorFixture, this.configRegistryFixture);
}
use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class RowHeaderLayer method getConfigLabelsByPosition.
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
LabelStack labelStack = super.getConfigLabelsByPosition(columnPosition, rowPosition);
if (this.selectionLayer.length > 0) {
final int selectionLayerRowPosition = LayerUtil.convertRowPosition(this, rowPosition, this.selectionLayer[0]);
boolean fullySelected = true;
for (SelectionLayer sl : this.selectionLayer) {
if (!sl.isRowPositionFullySelected(selectionLayerRowPosition)) {
fullySelected = false;
break;
}
}
if (fullySelected) {
labelStack.addLabel(SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE);
}
}
return labelStack;
}
use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class ColumnHeaderLayer method getConfigLabelsByPosition.
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
LabelStack labelStack = super.getConfigLabelsByPosition(columnPosition, rowPosition);
if (this.selectionLayer.length > 0) {
final int selectionLayerColumnPosition = LayerUtil.convertColumnPosition(this, columnPosition, this.selectionLayer[0]);
boolean fullySelected = true;
for (SelectionLayer sl : this.selectionLayer) {
if (!sl.isColumnPositionFullySelected(selectionLayerColumnPosition)) {
fullySelected = false;
break;
}
}
if (fullySelected) {
labelStack.addLabel(SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE);
}
}
return labelStack;
}
use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class SelectionListenerExample method postConstruct.
@PostConstruct
public void postConstruct(Composite parent) {
// property names of the Person class
String[] propertyNames = { "firstName", "lastName", "gender", "married", "birthday" };
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<>();
propertyToLabelMap.put("firstName", "Firstname");
propertyToLabelMap.put("lastName", "Lastname");
propertyToLabelMap.put("gender", "Gender");
propertyToLabelMap.put("married", "Married");
propertyToLabelMap.put("birthday", "Birthday");
IColumnPropertyAccessor<Person> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
final List<Person> data = PersonService.getPersons(10);
// create the body layer stack
final IRowDataProvider<Person> bodyDataProvider = new ListDataProvider<>(data, columnPropertyAccessor);
final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
final SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
// create a E4SelectionListener and configure it for providing selection
// on cell selection
E4SelectionListener<Person> esl = new E4SelectionListener<>(service, selectionLayer, bodyDataProvider);
esl.setFullySelectedRowsOnly(false);
esl.setHandleSameRowSelection(false);
selectionLayer.addLayerListener(esl);
// create the column header layer stack
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
ILayer columnHeaderLayer = new ColumnHeaderLayer(new DataLayer(columnHeaderDataProvider), viewportLayer, selectionLayer);
// create the row header layer stack
IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
ILayer rowHeaderLayer = new RowHeaderLayer(new DefaultRowHeaderDataLayer(new DefaultRowHeaderDataProvider(bodyDataProvider)), viewportLayer, selectionLayer);
// create the corner layer stack
ILayer cornerLayer = new CornerLayer(new DataLayer(new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider)), rowHeaderLayer, columnHeaderLayer);
// create the grid layer composed with the prior created layer stacks
GridLayer gridLayer = new GridLayer(viewportLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer);
final NatTable natTable = new NatTable(parent, gridLayer);
natTable.setData("org.eclipse.e4.ui.css.CssClassName", "modern");
parent.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
outputArea = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
outputArea.setEditable(false);
GridDataFactory.fillDefaults().grab(true, false).hint(0, 100).align(SWT.FILL, SWT.BEGINNING).applyTo(outputArea);
showSourceLinks(parent, getClass().getName());
}
use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class _5014_SpanningDataLayerExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
// To make the default edit and selection configurations work correctly,
// the region label
// GridRegion.BODY is necessary, which is directly set to the
// ViewportLayer instance here.
ViewportLayer layer = new ViewportLayer(new SelectionLayer(new SpanningDataLayer(new DummySpanningBodyDataProvider(100, 100))));
layer.setRegionName(GridRegion.BODY);
NatTable natTable = new NatTable(parent, layer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
// add configurations to enable editing
// this is to verify that spanned cells are also editable and update the
// data model correctly
// @see Bug 414754
layer.addConfiguration(new DefaultEditBindings());
layer.addConfiguration(new DefaultEditConfiguration());
layer.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE);
}
});
natTable.configure();
return natTable;
}
Aggregations