// Two movement objects for storing status and processing touches
private Movement yMov, xMov;
static final double MIN_VEL = 0.6, MAX_VEL = 4, F_VEL = 1500,
- F_ACC = 0.7,
- F_AXIS = 1;
+ F_ACC = 0.7, F_AXIS = 1;
// The object to deal with one direction scrolling
private class Movement {
/*-{
var vScroll = esc.@com.vaadin.v7.client.widgets.Escalator::verticalScrollbar;
var vScrollElem = vScroll.@com.vaadin.v7.client.widget.escalator.ScrollbarBundle::getElement()();
-
+
var hScroll = esc.@com.vaadin.v7.client.widgets.Escalator::horizontalScrollbar;
var hScrollElem = hScroll.@com.vaadin.v7.client.widget.escalator.ScrollbarBundle::getElement()();
-
+
return $entry(function(e) {
var target = e.target;
-
+
// 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.v7.client.widgets.Escalator::body;
deltaY *= brc.@com.vaadin.v7.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.v7.client.widgets.Escalator::logWarning(*)(msg);
}
-
+
// IE8 has only delta y
if (isNaN(deltaY)) {
deltaY = -0.5*e.wheelDelta;
}
-
+
@com.vaadin.v7.client.widgets.Escalator.JsniUtil::moveScrollFromEvent(*)(esc, deltaX, deltaY, e);
});
}-*/;
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));
}
/**
import com.vaadin.v7.client.widgets.Escalator.AbstractRowContainer;
import com.vaadin.v7.client.widgets.Escalator.SubPartArguments;
import com.vaadin.v7.client.widgets.Grid.Editor.State;
-import com.vaadin.v7.client.widgets.Grid.StaticSection.StaticCell;
import com.vaadin.v7.client.widgets.Grid.StaticSection.StaticRow;
import com.vaadin.v7.shared.ui.grid.ColumnResizeMode;
import com.vaadin.v7.shared.ui.grid.GridConstants;
* 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);
}
}
}
public void execute() {
Element focusedElement = WidgetUtil.getFocusedElement();
if (focusedElement == grid.getElement()
- || focusedElement == Document.get().getBody()
- || count > 2) {
+ || focusedElement == Document.get().getBody()
+ || count > 2) {
focusColumn(focusedColumnIndexDOM);
} else {
++count;
// with the grid itself and the position needs to be compensated for
try {
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
if (!columns.contains(column)) {
throw new IllegalArgumentException(
- "Given column is not a column in this grid. "
- + column.toString());
+ "Given column is not a column in this grid. "
+ + column.toString());
}
if (!column.isSortable()) {
final double widthPerRatio;
int leftOver = 0;
if (BrowserInfo.get().isIE8() || BrowserInfo.get().isIE9()
- || BrowserInfo.getBrowserString().contains("PhantomJS")) {
+ || BrowserInfo.getBrowserString().contains("PhantomJS")) {
// These browsers report subpixels as integers. this usually
// results into issues..
widthPerRatio = (int) (pixelsToDistribute / totalRatios);
// Check if the drop marker shouldn't be shown at all
else if (dropMarkerLeft < frozenColumnsWidth
- || dropMarkerLeft > Math.min(rightBoundaryForDrag,
- escalator.getInnerWidth())
+ || dropMarkerLeft > Math.min(rightBoundaryForDrag,
+ escalator.getInnerWidth())
|| dropMarkerLeft < 0) {
dropMarkerLeft = -10000000;
}
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));
public void render(RendererCellReference cell, Object data) {
if (!warned && !(data instanceof String)) {
getLogger().warning(Column.this.toString() + ": "
- + DEFAULT_RENDERER_WARNING);
+ + DEFAULT_RENDERER_WARNING);
warned = true;
}
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.
*/
if (renderer instanceof WidgetRenderer) {
try {
Widget w = WidgetUtil.findWidget(
- cell.getElement().getFirstChildElement());
+ cell.getElement().getFirstChildElement());
if (w != null) {
// Logical detach
// Need to wait for column width recalculation
// scheduled by setWidth() before firing the event
- Scheduler.get().scheduleDeferred(
- new ScheduledCommand() {
- @Override
- public void execute() {
- fireEvent(new ColumnResizeEvent<T>(col));
- }
- });
+ Scheduler.get()
+ .scheduleDeferred(new ScheduledCommand() {
+ @Override
+ public void execute() {
+ fireEvent(new ColumnResizeEvent<T>(
+ col));
+ }
+ });
}
};
addColumnsSkipSelectionColumnCheck(Arrays.asList(columns), count);
}
-
/**
* Checks the given column is valid to add at the given index.
*/
private void checkColumnIsValidToAdd(Column<?, T> column, int index) {
if (column == this.selectionColumn) {
throw new IllegalArgumentException(
- "The selection column may not be added manually");
+ "The selection column may not be added manually");
} else if (this.selectionColumn != null && index == 0) {
throw new IllegalStateException("A column cannot be inserted "
- + "before the selection column");
+ + "before the selection column");
}
}
*/
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) {
}
}
if (visibleNewColumns > 0) {
- final ColumnConfiguration columnConfiguration = this.escalator.getColumnConfiguration();
+ final ColumnConfiguration columnConfiguration = this.escalator
+ .getColumnConfiguration();
columnConfiguration.insertColumns(index, visibleNewColumns);
}
}
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();
}
this.dataSource = dataSource;
- changeHandler = dataSource.addDataChangeHandler(new DataChangeHandler() {
+ changeHandler = dataSource
+ .addDataChangeHandler(new DataChangeHandler() {
@Override
public void dataUpdated(int firstIndex, int numberOfItems) {
- escalator.getBody().refreshRows(firstIndex, numberOfItems);
+ escalator.getBody().refreshRows(firstIndex,
+ numberOfItems);
}
@Override
public void dataRemoved(int firstIndex, int numberOfItems) {
- escalator.getBody().removeRows(firstIndex, numberOfItems);
- Range removed = Range.withLength(firstIndex, numberOfItems);
+ escalator.getBody().removeRows(firstIndex,
+ numberOfItems);
+ Range removed = Range.withLength(firstIndex,
+ numberOfItems);
cellFocusHandler.rowsRemovedFromBody(removed);
}
@Override
public void dataAdded(int firstIndex, int numberOfItems) {
- escalator.getBody().insertRows(firstIndex, numberOfItems);
- Range added = Range.withLength(firstIndex, numberOfItems);
+ escalator.getBody().insertRows(firstIndex,
+ numberOfItems);
+ Range added = Range.withLength(firstIndex,
+ numberOfItems);
cellFocusHandler.rowsAddedToBody(added);
}
@Override
- public void dataAvailable(int firstIndex, int numberOfItems) {
+ public void dataAvailable(int firstIndex,
+ int numberOfItems) {
currentDataAvailable = Range.withLength(firstIndex,
numberOfItems);
fireEvent(new DataAvailableEvent(currentDataAvailable));
int oldSize = body.getRowCount();
// Hide all details.
- Set<Integer> oldDetails = new HashSet<Integer>(visibleDetails);
+ Set<Integer> oldDetails = new HashSet<Integer>(
+ visibleDetails);
for (int i : oldDetails) {
setDetailsVisible(i, false);
}
if (newSize > oldSize) {
body.insertRows(oldSize, newSize - oldSize);
- cellFocusHandler.rowsAddedToBody(
- Range.withLength(oldSize, newSize - oldSize));
+ cellFocusHandler.rowsAddedToBody(Range
+ .withLength(oldSize, newSize - oldSize));
} else if (newSize < oldSize) {
body.removeRows(newSize, oldSize - newSize);
- cellFocusHandler.rowsRemovedFromBody(
- Range.withLength(newSize, oldSize - newSize));
+ cellFocusHandler.rowsRemovedFromBody(Range
+ .withLength(newSize, oldSize - newSize));
}
if (newSize > 0) {
- Range visibleRowRange = escalator.getVisibleRowRange();
- dataSource.ensureAvailability(visibleRowRange.getStart(),
+ Range visibleRowRange = escalator
+ .getVisibleRowRange();
+ dataSource.ensureAvailability(
+ visibleRowRange.getStart(),
visibleRowRange.length());
} else {
- // We won't expect any data more data updates, so just make
- // the bookkeeping happy
+ // We won't expect any data more data updates, so
+ // just make the bookkeeping happy
dataAvailable(0, 0);
}
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
*/
public HandlerRegistration addSpacerVisibilityChangedHandler(
- SpacerVisibilityChangedHandler handler) {
+ SpacerVisibilityChangedHandler handler) {
return escalator.addHandler(handler, SpacerVisibilityChangedEvent.TYPE);
}