Dynamic preferred min column width in composite layer [message #1766518] |
Thu, 22 June 2017 14:19 |
Odgerel Boldbaatar Messages: 1 Registered: June 2017 |
Junior Member |
|
|
Hello,
How can i get the preferred min width of each column in composite layer? I want the column resize event to fire only if the new column width is more than the preferred width.
I have seen the class MaxCellBoundsHelper, but it is only used in AutoResizeColumnCommandHandler, which requires gridlayer.
By now i have written a custom ColumnResizeCommandHandler and set the min possible width to 75. But this solution i dun find satisfactory.
My table looks as following.
ColumnLabelAccumulator labels = new ColumnLabelAccumulator();
final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
bodyDataLayer.setConfigLabelAccumulator(labels);
bodyDataLayer.registerCommandHandler(new CustomColumnResizeCommandHandler(bodyDataLayer));
SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer, false);
ViewportLayer viewportLayer = new ViewportLayer(bodyDataLayer);
ConfigRegistry configRegistry = new ConfigRegistry();
// build the column header layer stack
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyTranslationMap);
DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
// create the composite layer composed of only column and viewportlayer
CompositeLayer compositeLayer = new CompositeLayer(1, 2);
compositeLayer.setChildLayer(GridRegion.ROW_HEADER, columnHeaderLayer, 0, 0);
compositeLayer.setChildLayer(GridRegion.BODY, viewportLayer, 0, 1);
compositeLayer.addConfiguration(new AbstractUiBindingConfiguration() {
@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
uiBindingRegistry.registerFirstMouseMoveBinding(
new ColumnResizeEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, 0),
new ColumnResizeCursorAction());
uiBindingRegistry.registerFirstMouseDragMode(
new ColumnResizeEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, 1),
new ColumnResizeDragMode());
}
});
// create and configure nattable
parent.setLayout(new GridLayout(1, true));
final NatTable natTable = new NatTable(parent, compositeLayer, false);
natTable.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
natTable.addOverlayPainter(new NatTableBorderOverlayPainter());
natTable.addConfiguration(new ModernNatTableThemeConfiguration());
natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
{
this.cellPainter = new LineBorderDecorator(new TextPainter(false, false, 5, false, true));
}
});
natTable.configure();
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05101 seconds