Each RowContainer can be thought to have three levels of
indices for any given displayed row (but the distinction
- matters primarily for the BodyRowContainerImpl, because of
+ matters primarily for the BodyRowContainerImpl, because of
the way it scrolls through data):
- Logical index
(because of 0-based indices). In Header and
FooterRowContainers, you are safe to assume that the logical
index is the same as the physical index. But because the
- BodyRowContainerImpl never displays large data sources
- entirely in the DOM, a physical index usually has no
+ BodyRowContainerImpl never displays large data sources
+ entirely in the DOM, a physical index usually has no
apparent direct relationship with its logical index.
VISUAL INDEX is the index relating to the order that you
/*-{
var vScroll = esc.@com.vaadin.client.widgets.Escalator::verticalScrollbar;
var vScrollElem = vScroll.@com.vaadin.client.widget.escalator.ScrollbarBundle::getElement()();
-
+
var hScroll = esc.@com.vaadin.client.widgets.Escalator::horizontalScrollbar;
var hScrollElem = hScroll.@com.vaadin.client.widget.escalator.ScrollbarBundle::getElement()();
-
+
return $entry(function(e) {
var target = e.target || e.srcElement; // IE8 uses e.scrElement
-
+
// in case the scroll event was native (i.e. scrollbars were dragged, or
// the scrollTop/Left was manually modified), the bundles have old cache
// values. We need to make sure that the caches are kept up to date.
return $entry(function(e) {
var deltaX = e.deltaX ? e.deltaX : -0.5*e.wheelDeltaX;
var deltaY = e.deltaY ? e.deltaY : -0.5*e.wheelDeltaY;
-
+
// Delta mode 0 is in pixels; we don't need to do anything...
-
+
// A delta mode of 1 means we're scrolling by lines instead of pixels
// We need to scale the number of lines by the default line height
if(e.deltaMode === 1) {
var brc = esc.@com.vaadin.client.widgets.Escalator::body;
deltaY *= brc.@com.vaadin.client.widgets.Escalator.AbstractRowContainer::getDefaultRowHeight()();
}
-
+
// Other delta modes aren't supported
if((e.deltaMode !== undefined) && (e.deltaMode >= 2 || e.deltaMode < 0)) {
var msg = "Unsupported wheel delta mode \"" + e.deltaMode + "\"";
-
+
// Print warning message
esc.@com.vaadin.client.widgets.Escalator::logWarning(*)(msg);
}
-
+
// IE8 has only delta y
if (isNaN(deltaY)) {
deltaY = -0.5*e.wheelDelta;
}
-
+
@com.vaadin.client.widgets.Escalator.JsniUtil::moveScrollFromEvent(*)(esc, deltaX, deltaY, e);
});
}-*/;
/**
* The table section element ({@code <thead>}, {@code <tbody>} or
- * {@code <tfoot>}) the rows (i.e. {@code
- *
+ * {@code <tfoot>}) the rows (i.e. {@code
+ *
<tr>
* } tags) are contained in.
*/
* Applies the total length of the columns to each row element.
* <p>
* <em>Note:</em> In contrast to {@link #reapplyColumnWidths()}, this
- * method only modifies the width of the {@code
- *
+ * method only modifies the width of the {@code
+ *
<tr>
* } element, not the cells within.
*/
/**
* Gets the logical row index for the given table row element.
- *
+ *
* @param tr
* the table row element inside this container.
* @return the logical index of the given element
* |3| ==> |*| ==> |5| <- newly rendered
* |4| |*|
* 5 5
- *
+ *
* 1 1 |1| <- newly rendered
* |2| |*| |4|
* |3| ==> |*| ==> |5| <- newly rendered
* 1 |1| <-- newly rendered (by scrolling)
* |4| |4|
* |*| ==> |*|
- * |*|
+ * |*|
* 5 5
*/
final double newScrollTop = contentBottom
* |1| |1|
* |4| ==> |4|
* |*| |5| <-- newly rendered
- *
+ *
* 5
*/
* : : |4| <- newly rendered
* |5| |5| |5|
* |6| ==> |*| ==> |7|
- * |7| |7|
+ * |7| |7|
*/
final int logicalTargetIndex = getLogicalRowIndex(
}
if (index < 0 || index + numberOfColumns > getColumnCount()) {
- throw new IndexOutOfBoundsException(
- "The given " + "column range (" + index + ".."
- + (index + numberOfColumns)
- + ") was outside of the current number of columns ("
- + getColumnCount() + ")");
+ throw new IndexOutOfBoundsException("The given "
+ + "column range (" + index + ".."
+ + (index + numberOfColumns)
+ + ") was outside of the current number of columns ("
+ + getColumnCount() + ")");
}
header.refreshColumns(index, numberOfColumns);
public void show() {
getRootElement().getStyle().clearDisplay();
getDecoElement().getStyle().clearDisplay();
- Escalator.this.fireEvent(
- new SpacerVisibilityChangedEvent(getRow(), true));
+ fireEvent(new SpacerVisibilityChangedEvent(getRow(), true));
}
public void hide() {
getRootElement().getStyle().setDisplay(Display.NONE);
getDecoElement().getStyle().setDisplay(Display.NONE);
- Escalator.this.fireEvent(
- new SpacerVisibilityChangedEvent(getRow(), false));
+ fireEvent(new SpacerVisibilityChangedEvent(getRow(), false));
}
/**
double footerHeight = footer.getHeightOfSection();
double bodyHeight = body.getDefaultRowHeight() * heightByRows;
double scrollbar = horizontalScrollbar.showsScrollHandle()
- ? horizontalScrollbar.getScrollbarThickness() : 0;
+ ? horizontalScrollbar.getScrollbarThickness()
+ : 0;
double spacerHeight = 0; // ignored if HeightMode.ROW
if (heightMode == HeightMode.UNDEFINED) {
spacerHeight = body.spacerContainer.getSpacerHeightsSum();
/**
* Internal method for checking whether the browser is IE11 or Edge
- *
+ *
* @return true only if the current browser is IE11, or Edge
*/
private static boolean isCurrentBrowserIE11OrEdge() {
import com.vaadin.client.widgets.Escalator.AbstractRowContainer;
import com.vaadin.client.widgets.Escalator.SubPartArguments;
import com.vaadin.client.widgets.Grid.Editor.State;
-import com.vaadin.client.widgets.Grid.StaticSection.StaticCell;
import com.vaadin.client.widgets.Grid.StaticSection.StaticRow;
import com.vaadin.shared.data.sort.SortDirection;
import com.vaadin.shared.ui.grid.ColumnResizeMode;
* a plain text caption
*/
public void setText(String text) {
- this.content = text;
- this.type = GridStaticCellType.TEXT;
+ content = text;
+ type = GridStaticCellType.TEXT;
section.requestSectionRefresh();
}
* The html content of the cell
*/
public void setHtml(String html) {
- this.content = html;
- this.type = GridStaticCellType.HTML;
+ content = html;
+ type = GridStaticCellType.HTML;
section.requestSectionRefresh();
}
* null).
*/
public void setWidget(Widget widget) {
- if (this.content == widget) {
+ if (content == widget) {
return;
}
- if (this.content instanceof Widget) {
+ if (content instanceof Widget) {
// Old widget in the cell, detach it first
- section.getGrid().detachWidget((Widget) this.content);
+ section.getGrid().detachWidget((Widget) content);
}
- this.content = widget;
- this.type = GridStaticCellType.WIDGET;
+ content = widget;
+ type = GridStaticCellType.WIDGET;
section.requestSectionRefresh();
}
* @since 7.6.3
*/
void detach() {
- if (this.content instanceof Widget) {
+ if (content instanceof Widget) {
// Widget in the cell, detach it
- section.getGrid().detachWidget((Widget) this.content);
+ section.getGrid().detachWidget((Widget) content);
}
}
}
}
}
});
- grid.scrollToRow(rowIndex, isBuffered()
- ? ScrollDestination.MIDDLE : ScrollDestination.ANY);
+ grid.scrollToRow(rowIndex,
+ isBuffered() ? ScrollDestination.MIDDLE
+ : ScrollDestination.ANY);
}
}
cellWrapper.getStyle().setLeft(newLeft, Unit.PX);
try {
- // sometimes focus handling twists the editor row out of alignment
- // with the grid itself and the position needs to be compensated for
+ // sometimes focus handling twists the editor row out of
+ // alignment with the grid itself and the position needs to be
+ // compensated for
TableRowElement rowElement = grid.getEscalator().getBody()
- .getRowElement(grid.getEditor().getRow());
+ .getRowElement(grid.getEditor().getRow());
int rowLeft = rowElement.getAbsoluteLeft();
int editorLeft = cellWrapper.getAbsoluteLeft();
if (editorLeft != rowLeft + frozenWidth) {
- cellWrapper.getStyle().setLeft(newLeft + rowLeft - editorLeft,
- Unit.PX);
+ cellWrapper.getStyle()
+ .setLeft(newLeft + rowLeft - editorLeft, Unit.PX);
}
} catch (IllegalStateException e) {
// IllegalStateException may occur if user has scrolled Grid so
});
selectAllCheckBox.setValue(selected);
- headerClickHandler = addHeaderClickHandler(new HeaderClickHandler() {
- @Override
- public void onClick(GridClickEvent event) {
- if (!userSelectionAllowed) {
- return;
- }
-
- CellReference<?> targetCell = event.getTargetCell();
- int defaultRowIndex = getHeader().getRows()
- .indexOf(getDefaultHeaderRow());
+ headerClickHandler = addHeaderClickHandler(
+ new HeaderClickHandler() {
+ @Override
+ public void onClick(GridClickEvent event) {
+ if (!userSelectionAllowed) {
+ return;
+ }
- if (targetCell.getColumnIndex() == 0 && targetCell
- .getRowIndex() == defaultRowIndex) {
- selectAllCheckBox.setValue(
- !selectAllCheckBox.getValue(), true);
- }
- }
- });
+ CellReference<?> targetCell = event
+ .getTargetCell();
+ int defaultRowIndex = getHeader().getRows()
+ .indexOf(getDefaultHeaderRow());
+
+ if (targetCell.getColumnIndex() == 0
+ && targetCell
+ .getRowIndex() == defaultRowIndex) {
+ selectAllCheckBox.setValue(
+ !selectAllCheckBox.getValue(),
+ true);
+ }
+ }
+ });
// Select all with space when "select all" cell is active
addHeaderKeyUpHandler(new HeaderKeyUpHandler() {
if (focusedColumnIndex == draggedColumnIndex) {
// move with the dragged column
int adjustedDropIndex = latestColumnDropIndex > draggedColumnIndex
- ? latestColumnDropIndex - 1 : latestColumnDropIndex;
+ ? latestColumnDropIndex - 1
+ : latestColumnDropIndex;
// remove hidden columns from indexing
adjustedDropIndex = getVisibleColumns()
.indexOf(getColumn(adjustedDropIndex));
private Grid<T> grid;
/**
- * Width of column in pixels as {@link #setWidth(double)} has been called.
+ * Width of column in pixels as {@link #setWidth(double)} has been
+ * called.
*/
protected double widthUser = GridConstants.DEFAULT_COLUMN_WIDTH_PX;
*/
protected int expandRatio = GridConstants.DEFAULT_EXPAND_RATIO;
-
/**
* Constructs a new column with a simple TextRenderer.
*/
// Need to wait for column width recalculation
// scheduled by setWidth() before firing the event
- Scheduler.get().scheduleDeferred(
- new ScheduledCommand() {
+ Scheduler.get()
+ .scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
- fireEvent(new ColumnResizeEvent<T>(col));
+ fireEvent(new ColumnResizeEvent<T>(
+ col));
}
});
}
addColumnsSkipSelectionColumnCheck(Arrays.asList(columns), count);
}
-
/**
* Checks the given column is valid to add at the given index.
*/
*/
public <C extends Column<?, T>> C addColumn(C column, int index) {
checkColumnIsValidToAdd(column, index);
- addColumnsSkipSelectionColumnCheck(Collections.singleton(column), index);
+ addColumnsSkipSelectionColumnCheck(Collections.singleton(column),
+ index);
return column;
}
-
- private <C extends Column<?, T>> void addColumnsSkipSelectionColumnCheck(Collection<C> columnCollection, int index) {
+ private <C extends Column<?, T>> void addColumnsSkipSelectionColumnCheck(
+ Collection<C> columnCollection, int index) {
int visibleNewColumns = 0;
int currentIndex = index;
- //prevent updates of hiding toggles.
- //it will be updated finally all at once.
+ // prevent updates of hiding toggles.
+ // it will be updated finally all at once.
this.columnHider.hidingColumn = true;
for (final Column<?, T> column : columnCollection) {
escalatorIndex--;
}
}
- final ColumnConfiguration columnConfiguration = this.escalator.getColumnConfiguration();
- columnConfiguration.insertColumns(escalatorIndex, visibleNewColumns);
+ final ColumnConfiguration columnConfiguration = this.escalator
+ .getColumnConfiguration();
+ columnConfiguration.insertColumns(escalatorIndex,
+ visibleNewColumns);
}
for (final Column<?, T> column : columnCollection) {
}
sinkEvents(events);
}
- //now we do the update of the hiding toggles.
+ // now we do the update of the hiding toggles.
this.columnHider.hidingColumn = false;
this.columnHider.updateTogglesOrder();
refreshHeader();
cellFocusHandler.offsetRangeBy(1);
selectionColumn = new SelectionColumn(selectColumnRenderer);
- addColumnsSkipSelectionColumnCheck(Collections.singleton(selectionColumn), 0);
+ addColumnsSkipSelectionColumnCheck(
+ Collections.singleton(selectionColumn), 0);
selectionColumn.setEnabled(isEnabled());
selectionColumn.initDone();
* Adds a spacer visibility changed handler to the underlying escalator.
*
* @param handler
- * the handler to be called when a spacer's visibility changes
+ * the handler to be called when a spacer's visibility changes
* @return the registration object with which the handler can be removed
* @since 7.7.13
*/