use of org.eclipse.nebula.widgets.nattable.print.command.PrintEntireGridCommand in project nebula.widgets.nattable by eclipse.
the class NatExporter method setClientAreaToMaximum.
/**
* Increase the client area so it can include the whole {@link ILayer}.
*
* @param layer
* The {@link ILayer} for which the client area should be
* maximized.
*
* @since 1.5
*/
protected void setClientAreaToMaximum(ILayer layer) {
final Rectangle maxClientArea = new Rectangle(0, 0, layer.getWidth(), layer.getHeight());
layer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return maxClientArea;
}
});
layer.doCommand(new PrintEntireGridCommand());
}
use of org.eclipse.nebula.widgets.nattable.print.command.PrintEntireGridCommand in project nebula.widgets.nattable by eclipse.
the class AutoResizeHelper method init.
/**
* Prepare the layer for complete in-memory rendering.
*/
protected void init() {
this.layer.addLayerListener(this.resizeListener);
this.layer.setClientAreaProvider(this.clientAreaProvider);
this.layer.doCommand(new TurnViewportOffCommand());
this.layer.doCommand(new PrintEntireGridCommand());
}
use of org.eclipse.nebula.widgets.nattable.print.command.PrintEntireGridCommand in project nebula.widgets.nattable by eclipse.
the class ViewportLayer method doCommand.
@Override
public boolean doCommand(ILayerCommand command) {
if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) {
if (this.processingClientAreaResizeCommand) {
return false;
}
this.processingClientAreaResizeCommand = true;
// on client area resize we reset the keep in viewport row position
this.keepInViewportRowPosition = -1;
ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command;
// remember the difference from client area to body region area
// needed because the scrollbar will be removed and therefore the
// client area will become bigger
Scrollable scrollable = clientAreaResizeCommand.getScrollable();
Rectangle clientArea = scrollable.getClientArea();
Rectangle calcArea = clientAreaResizeCommand.getCalcArea();
int widthDiff = clientArea.width - calcArea.width;
int heightDiff = clientArea.height - calcArea.height;
boolean initialClientAreaResize = false;
if (this.hBarListener == null && this.horizontalScrollbarEnabled) {
initialClientAreaResize = true;
ScrollBar hBar = scrollable.getHorizontalBar();
if (hBar != null) {
if (this.horizontalScroller != null) {
hBar.setEnabled(false);
hBar.setVisible(false);
} else {
this.horizontalScroller = new ScrollBarScroller(hBar);
}
this.hBarListener = new HorizontalScrollBarHandler(this, this.horizontalScroller);
if (scrollable instanceof NatTable) {
this.hBarListener.setTable((NatTable) scrollable);
}
}
}
if (this.vBarListener == null && this.verticalScrollbarEnabled) {
initialClientAreaResize = true;
ScrollBar vBar = scrollable.getVerticalBar();
if (vBar != null) {
if (this.verticalScroller != null) {
vBar.setEnabled(false);
vBar.setVisible(false);
} else {
this.verticalScroller = new ScrollBarScroller(vBar);
}
this.vBarListener = new VerticalScrollBarHandler(this, this.verticalScroller);
if (scrollable instanceof NatTable) {
this.vBarListener.setTable((NatTable) scrollable);
}
}
}
if (initialClientAreaResize) {
handleGridResize();
// after handling the scrollbars recalculate the area to use for
// percentage calculation
Rectangle possibleArea = scrollable.getClientArea();
possibleArea.width = possibleArea.width - widthDiff;
possibleArea.height = possibleArea.height - heightDiff;
clientAreaResizeCommand.setCalcArea(possibleArea);
}
// we don't return true here because the ClientAreaResizeCommand
// needs to be handled by the DataLayer in case percentage sizing is
// enabled. if we would return true, the DataLayer wouldn't be able
// to calculate the column/row sizes regarding the client area
boolean result = super.doCommand(command);
if (!initialClientAreaResize) {
handleGridResize();
}
// we need to first give underlying layers the chance to process the
// command and afterwards set the processing flag to false
// this way we avoid processing the resize multiple times because of
// re-calculation in conjunction with scrollbar visibility state
// changes
this.processingClientAreaResizeCommand = false;
return result;
} else if (command instanceof TurnViewportOffCommand) {
this.savedOrigin = this.origin;
this.viewportOff = true;
return true;
} else if (command instanceof TurnViewportOnCommand) {
this.viewportOff = false;
this.origin = this.savedOrigin;
// only necessary in case of split viewports and auto resizing, but
// shouldn't hurt in other cases
recalculateScrollBars();
return true;
} else if (command instanceof PrintEntireGridCommand) {
moveCellPositionIntoViewport(0, 0);
}
return super.doCommand(command);
}
Aggregations