use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class NatTable method initInternalListener.
protected void initInternalListener() {
this.modeSupport = new ModeSupport(this);
this.modeSupport.registerModeEventHandler(Mode.NORMAL_MODE, new ConfigurableModeEventHandler(this.modeSupport, this));
this.modeSupport.switchMode(Mode.NORMAL_MODE);
addPaintListener(this);
addFocusListener(new FocusListener() {
@Override
public void focusLost(final FocusEvent arg0) {
redraw();
}
@Override
public void focusGained(final FocusEvent arg0) {
redraw();
}
});
addListener(SWT.Resize, new Listener() {
@Override
public void handleEvent(final Event e) {
doCommand(new ClientAreaResizeCommand(NatTable.this));
redraw();
}
});
}
use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class DataLayer method doCommand.
@Override
public boolean doCommand(ILayerCommand command) {
if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) {
ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command;
boolean refresh = false;
if (isColumnPercentageSizing()) {
this.columnWidthConfig.calculatePercentages(this.columnWidthConfig.downScale(clientAreaResizeCommand.getCalcArea().width), getColumnCount());
refresh = true;
}
if (isRowPercentageSizing()) {
this.rowHeightConfig.calculatePercentages(this.rowHeightConfig.downScale(clientAreaResizeCommand.getCalcArea().height), getRowCount());
refresh = true;
}
if (refresh) {
fireLayerEvent(new ResizeStructuralRefreshEvent(this));
}
return refresh;
} else if (command instanceof StructuralRefreshCommand) {
// that the percentage values are re-calculated
if (isColumnPercentageSizing()) {
this.columnWidthConfig.updatePercentageValues(getColumnCount());
}
if (isRowPercentageSizing()) {
this.rowHeightConfig.updatePercentageValues(getRowCount());
}
}
return super.doCommand(command);
}
use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayer method doCommand.
@Override
public boolean doCommand(ILayerCommand command) {
if (command instanceof SelectCellCommand && command.convertToTargetLayer(this)) {
// perform selection of level on level header click
SelectCellCommand selection = (SelectCellCommand) command;
if (isLevelHeaderColumn(selection.getColumnPosition())) {
ILayerCell clickedCell = getCellByPosition(selection.getColumnPosition(), selection.getRowPosition());
// calculate number of header columns to the right
int levelHeaderCount = 0;
for (int i = this.levelHeaderPositions.length - 1; i >= 0; i--) {
if (this.levelHeaderPositions[i] >= selection.getColumnPosition()) {
levelHeaderCount++;
}
}
SelectRegionCommand selectRegion = new SelectRegionCommand(this, clickedCell.getColumnPosition() + 1, clickedCell.getOriginRowPosition(), getColumnCount() - levelHeaderCount - (clickedCell.getColumnPosition()), clickedCell.getRowSpan(), selection.isShiftMask(), selection.isControlMask());
this.underlyingLayer.doCommand(selectRegion);
return true;
}
} else if (command instanceof ConfigureScalingCommand) {
this.dpiConverter = ((ConfigureScalingCommand) command).getHorizontalDpiConverter();
} else if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) {
ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command;
Rectangle possibleArea = clientAreaResizeCommand.getScrollable().getClientArea();
// remove the tree level header width from the client area to
// ensure that the percentage calculation is correct
possibleArea.width = possibleArea.width - (this.levelHeaderPositions.length * getScaledLevelHeaderWidth());
clientAreaResizeCommand.setCalcArea(possibleArea);
} else if (command instanceof ColumnReorderCommand) {
ColumnReorderCommand crCommand = ((ColumnReorderCommand) command);
if (!isValidTargetColumnPosition(crCommand.getFromColumnPosition(), crCommand.getToColumnPosition())) {
// command without doing anything
return true;
}
if (isLevelHeaderColumn(crCommand.getToColumnPosition())) {
// tree level header
return super.doCommand(new ColumnReorderCommand(this, crCommand.getFromColumnPosition(), crCommand.getToColumnPosition() + 1));
}
} else if (command instanceof MultiColumnReorderCommand) {
MultiColumnReorderCommand crCommand = ((MultiColumnReorderCommand) command);
for (int fromColumnPosition : crCommand.getFromColumnPositions()) {
if (!isValidTargetColumnPosition(fromColumnPosition, crCommand.getToColumnPosition())) {
// command would be skipped
return true;
}
}
if (isLevelHeaderColumn(crCommand.getToColumnPosition())) {
// tree level header
return super.doCommand(new MultiColumnReorderCommand(this, crCommand.getFromColumnPositions(), crCommand.getToColumnPosition() + 1));
}
}
return super.doCommand(command);
}
Aggregations