summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorMarkus Koivisto <markus@vaadin.com>2014-08-04 14:25:16 +0300
committerVaadin Code Review <review@vaadin.com>2014-08-05 08:31:02 +0000
commitae37910f4cb307c929df32e6499b9e1872192377 (patch)
tree5690abd4b9716b38d3e74f3442993e463b334b09 /client
parentf5bb5f33883e31d128fe784b4a0d874b970fb3f4 (diff)
downloadvaadin-framework-ae37910f4cb307c929df32e6499b9e1872192377.tar.gz
vaadin-framework-ae37910f4cb307c929df32e6499b9e1872192377.zip
Reverting multiple commits that caused 100+ regression tests to fail.
Commits reverted: * 392e8a0 - Minor refactor to #14147 patch * 8d470c9 - Context menu is not shown in Table body on mobi... (#13694) * f7dc719 - Fix Table stuck scroll position after setting ... (#14147) Change-Id: I3f5ed7fa15a9cfebce7a57662d229bf46118c5d6
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/VScrollTable.java526
-rw-r--r--client/src/com/vaadin/client/ui/table/TableConnector.java17
2 files changed, 218 insertions, 325 deletions
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java
index 9c271858e0..5e6207f53f 100644
--- a/client/src/com/vaadin/client/ui/VScrollTable.java
+++ b/client/src/com/vaadin/client/ui/VScrollTable.java
@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -47,6 +47,8 @@ import com.google.gwt.dom.client.TableSectionElement;
import com.google.gwt.dom.client.Touch;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
+import com.google.gwt.event.dom.client.ContextMenuEvent;
+import com.google.gwt.event.dom.client.ContextMenuHandler;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.dom.client.KeyCodes;
@@ -101,160 +103,31 @@ import com.vaadin.shared.ui.table.TableConstants;
/**
* VScrollTable
- *
+ *
* VScrollTable is a FlowPanel having two widgets in it: * TableHead component *
* ScrollPanel
- *
+ *
* TableHead contains table's header and widgets + logic for resizing,
* reordering and hiding columns.
- *
+ *
* ScrollPanel contains VScrollTableBody object which handles content. To save
* some bandwidth and to improve clients responsiveness with loads of data, in
* VScrollTableBody all rows are not necessary rendered. There are "spacers" in
* VScrollTableBody to use the exact same space as non-rendered rows would use.
* This way we can use seamlessly traditional scrollbars and scrolling to fetch
* more rows instead of "paging".
- *
+ *
* In VScrollTable we listen to scroll events. On horizontal scrolling we also
* update TableHeads scroll position which has its scrollbars hidden. On
* vertical scroll events we will check if we are reaching the end of area where
* we have rows rendered and
- *
+ *
* TODO implement unregistering for child components in Cells
*/
public class VScrollTable extends FlowPanel implements HasWidgets,
ScrollHandler, VHasDropHandler, FocusHandler, BlurHandler, Focusable,
ActionOwner, SubPartAware {
- /**
- * Simple interface for parts of the table capable of owning a context menu.
- *
- * @author Vaadin Ltd
- */
- private interface ContextMenuOwner {
- public void showContextMenu(Event event);
- }
-
- /**
- * Handles showing context menu on "long press" from a touch screen.
- *
- * @author Vaadin Ltd
- */
- private class TouchContextProvider {
- private static final int TOUCH_CONTEXT_MENU_TIMEOUT = 500;
- private Timer contextTouchTimeout;
-
- private Event touchStart;
- private int touchStartY;
- private int touchStartX;
-
- private ContextMenuOwner target;
-
- /**
- * Initializes a handler for a certain context menu owner.
- *
- * @param target
- * the owner of the context menu
- */
- public TouchContextProvider(ContextMenuOwner target) {
- this.target = target;
- }
-
- /**
- * Cancels the current context touch timeout.
- */
- public void cancel() {
- if (contextTouchTimeout != null) {
- contextTouchTimeout.cancel();
- contextTouchTimeout = null;
- }
- touchStart = null;
- }
-
- /**
- * A function to handle touch context events in a table.
- *
- * @param event
- * browser event to handle
- */
- public void handleTouchEvent(final Event event) {
- int type = event.getTypeInt();
-
- switch (type) {
- case Event.ONCONTEXTMENU:
- target.showContextMenu(event);
- break;
- case Event.ONTOUCHSTART:
- // save position to fields, touches in events are same
- // instance during the operation.
- touchStart = event;
-
- Touch touch = event.getChangedTouches().get(0);
- touchStartX = touch.getClientX();
- touchStartY = touch.getClientY();
-
- if (contextTouchTimeout == null) {
- contextTouchTimeout = new Timer() {
-
- @Override
- public void run() {
- if (touchStart != null) {
- // Open the context menu if finger
- // is held in place long enough.
- target.showContextMenu(touchStart);
- event.preventDefault();
- touchStart = null;
- }
- }
- };
- }
- contextTouchTimeout.schedule(TOUCH_CONTEXT_MENU_TIMEOUT);
- break;
- case Event.ONTOUCHCANCEL:
- case Event.ONTOUCHEND:
- cancel();
- break;
- case Event.ONTOUCHMOVE:
- if (isSignificantMove(event)) {
- // Moved finger before the context menu timer
- // expired, so let the browser handle the event.
- cancel();
- }
- }
- }
-
- /**
- * Calculates how many pixels away the user's finger has traveled. This
- * reduces the chance of small non-intentional movements from canceling
- * the long press detection.
- *
- * @param event
- * the Event for which to check the move distance
- * @return true if this is considered an intentional move by the user
- */
- protected boolean isSignificantMove(Event event) {
- if (touchStart == null) {
- // no touch start
- return false;
- }
-
- // Calculate the distance between touch start and the current touch
- // position
- Touch touch = event.getChangedTouches().get(0);
- int deltaX = touch.getClientX() - touchStartX;
- int deltaY = touch.getClientY() - touchStartY;
- int delta = deltaX * deltaX + deltaY * deltaY;
-
- // Compare to the square of the significant move threshold to remove
- // the need for a square root
- if (delta > TouchScrollDelegate.SIGNIFICANT_MOVE_THRESHOLD
- * TouchScrollDelegate.SIGNIFICANT_MOVE_THRESHOLD) {
- return true;
- }
- return false;
- }
- }
-
public static final String STYLENAME = "v-table";
public enum SelectMode {
@@ -391,7 +264,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* The last known row height used to preserve the height of a table with
* custom row heights and a fixed page length after removing the last row
* from the table.
- *
+ *
* A new VScrollTableBody instance is created every time the number of rows
* changes causing {@link VScrollTableBody#rowHeight} to be discarded and
* the height recalculated by {@link VScrollTableBody#getRowHeight(boolean)}
@@ -435,7 +308,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#toString()
*/
@@ -496,34 +369,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/** For internal use only. May be removed or replaced in the future. */
public final TableFooter tFoot = new TableFooter();
- /** Handles context menu for table body */
- private ContextMenuOwner contextMenuOwner = new ContextMenuOwner() {
-
- @Override
- public void showContextMenu(Event event) {
- int left = Util.getTouchOrMouseClientX(event);
- int top = Util.getTouchOrMouseClientY(event);
- boolean menuShown = handleBodyContextMenu(left, top);
- if (menuShown) {
- event.stopPropagation();
- event.preventDefault();
- }
- }
- };
-
- /** Handles touch events to display a context menu for table body */
- private TouchContextProvider touchContextProvider = new TouchContextProvider(
- contextMenuOwner);
-
/** For internal use only. May be removed or replaced in the future. */
public final FocusableScrollPanel scrollBodyPanel = new FocusableScrollPanel(
- true) {
- @Override
- public void onBrowserEvent(Event event) {
- super.onBrowserEvent(event);
- touchContextProvider.handleTouchEvent(event);
- };
- };
+ true);
private KeyPressHandler navKeyPressHandler = new KeyPressHandler() {
@@ -685,14 +533,14 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Values (serverCacheFirst+serverCacheLast) sent by server that tells which
* rows (indexes) are in the server side cache (page buffer). -1 means
* unknown. The server side cache row MUST MATCH the client side cache rows.
- *
+ *
* If the client side cache contains additional rows with e.g. buttons, it
* will cause out of sync when such a button is pressed.
- *
+ *
* If the server side cache contains additional rows with e.g. buttons,
* scrolling in the client will cause empty buttons to be rendered
* (cached=true request for non-existing components)
- *
+ *
* For internal use only. May be removed or replaced in the future.
*/
public int serverCacheFirst = -1;
@@ -762,7 +610,16 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
}
scrollBodyPanel.addKeyUpHandler(navKeyUpHandler);
- scrollBodyPanel.sinkEvents(Event.TOUCHEVENTS | Event.ONCONTEXTMENU);
+ scrollBodyPanel.sinkEvents(Event.TOUCHEVENTS);
+
+ scrollBodyPanel.sinkEvents(Event.ONCONTEXTMENU);
+ scrollBodyPanel.addDomHandler(new ContextMenuHandler() {
+
+ @Override
+ public void onContextMenu(ContextMenuEvent event) {
+ handleBodyContextMenu(event);
+ }
+ }, ContextMenuEvent.getType());
setStyleName(STYLENAME);
@@ -824,29 +681,25 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
});
}
- /**
- * Handles a context menu event on table body.
- *
- * @param left
- * left position of the context menu
- * @param top
- * top position of the context menu
- * @return true if a context menu was shown, otherwise false
- */
- private boolean handleBodyContextMenu(int left, int top) {
+ private void handleBodyContextMenu(ContextMenuEvent event) {
if (enabled && bodyActionKeys != null) {
+ int left = Util.getTouchOrMouseClientX(event.getNativeEvent());
+ int top = Util.getTouchOrMouseClientY(event.getNativeEvent());
top += Window.getScrollTop();
left += Window.getScrollLeft();
client.getContextMenu().showAt(this, left, top);
- return true;
+
+ // Only prevent browser context menu if there are action handlers
+ // registered
+ event.stopPropagation();
+ event.preventDefault();
}
- return false;
}
/**
* Fires a column resize event which sends the resize information to the
* server.
- *
+ *
* @param columnId
* The columnId of the column which was resized
* @param originalWidth
@@ -868,7 +721,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Non-immediate variable update of column widths for a collection of
* columns.
- *
+ *
* @param columns
* the columns to trigger the events for.
*/
@@ -884,7 +737,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Moves the focus one step down
- *
+ *
* @return Returns true if succeeded
*/
private boolean moveFocusDown() {
@@ -893,7 +746,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Moves the focus down by 1+offset rows
- *
+ *
* @return Returns true if succeeded, else false if the selection could not
* be move downwards
*/
@@ -917,7 +770,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Moves the selection one step up
- *
+ *
* @return Returns true if succeeded
*/
private boolean moveFocusUp() {
@@ -926,10 +779,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Moves the focus row upwards
- *
+ *
* @return Returns true if succeeded, else false if the selection could not
* be move upwards
- *
+ *
*/
private boolean moveFocusUp(int offset) {
if (isSelectable()) {
@@ -953,7 +806,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Selects a row where the current selection head is
- *
+ *
* @param ctrlSelect
* Is the selection a ctrl+selection
* @param shiftSelect
@@ -988,7 +841,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Sends the selection to the server if it has been changed since the last
* update/visit.
- *
+ *
* @param immediately
* set to true to immediately send the rows
*/
@@ -1045,7 +898,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Get the key that moves the selection head upwards. By default it is the
* up arrow key but by overriding this you can change the key to whatever
* you want.
- *
+ *
* @return The keycode of the key
*/
protected int getNavigationUpKey() {
@@ -1056,7 +909,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Get the key that moves the selection head downwards. By default it is the
* down arrow key but by overriding this you can change the key to whatever
* you want.
- *
+ *
* @return The keycode of the key
*/
protected int getNavigationDownKey() {
@@ -1067,7 +920,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Get the key that scrolls to the left in the table. By default it is the
* left arrow key but by overriding this you can change the key to whatever
* you want.
- *
+ *
* @return The keycode of the key
*/
protected int getNavigationLeftKey() {
@@ -1078,7 +931,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Get the key that scroll to the right on the table. By default it is the
* right arrow key but by overriding this you can change the key to whatever
* you want.
- *
+ *
* @return The keycode of the key
*/
protected int getNavigationRightKey() {
@@ -1089,7 +942,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Get the key that selects an item in the table. By default it is the space
* bar key but by overriding this you can change the key to whatever you
* want.
- *
+ *
* @return
*/
protected int getNavigationSelectKey() {
@@ -1100,7 +953,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Get the key the moves the selection one page up in the table. By default
* this is the Page Up key but by overriding this you can change the key to
* whatever you want.
- *
+ *
* @return
*/
protected int getNavigationPageUpKey() {
@@ -1111,7 +964,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Get the key the moves the selection one page down in the table. By
* default this is the Page Down key but by overriding this you can change
* the key to whatever you want.
- *
+ *
* @return
*/
protected int getNavigationPageDownKey() {
@@ -1122,7 +975,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Get the key the moves the selection to the beginning of the table. By
* default this is the Home key but by overriding this you can change the
* key to whatever you want.
- *
+ *
* @return
*/
protected int getNavigationStartKey() {
@@ -1133,7 +986,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Get the key the moves the selection to the end of the table. By default
* this is the End key but by overriding this you can change the key to
* whatever you want.
- *
+ *
* @return
*/
protected int getNavigationEndKey() {
@@ -1240,9 +1093,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/*
* The focus is no longer on a selected row. Move
* focus to the selected row. (#10522)
- *
+ *
* Don't do this for multiselect (#13341).
- *
+ *
* Checking the selection mode here instead of in
* setRowFocus allows keyboard shift+downarrow
* selection to work as expected.
@@ -1332,7 +1185,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
@Override
public void execute() {
- if (firstvisible >= 0) {
+ if (firstvisible > 0) {
firstRowInViewPort = firstvisible;
if (firstvisibleOnLastPage > -1) {
scrollBodyPanel
@@ -1449,7 +1302,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Returns the extra space that is given to the header column when column
* width is determined by header text.
- *
+ *
* @return extra space in pixels
*/
private int getHeaderPadding() {
@@ -1460,7 +1313,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* This method exists for the needs of {@link VTreeTable} only. Not part of
* the official API, <b>extend at your own risk</b>. May be removed or
* replaced in the future.
- *
+ *
* @return index of TreeTable's hierarchy column, or -1 if not applicable
*/
protected int getHierarchyColumnIndex() {
@@ -1506,7 +1359,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Selects the last row visible in the table
* <p>
* For internal use only. May be removed or replaced in the future.
- *
+ *
* @param focusOnly
* Should the focus only be moved to the last row
*/
@@ -1533,7 +1386,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Selects the first row visible in the table
* <p>
* For internal use only. May be removed or replaced in the future.
- *
+ *
* @param focusOnly
* Should the focus only be moved to the first row
*/
@@ -1632,7 +1485,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* <p>
* Update headers whould be called before this method is called!
* </p>
- *
+ *
* @param strings
*/
private void updateFooter(String[] strings) {
@@ -1661,7 +1514,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* For internal use only. May be removed or replaced in the future.
- *
+ *
* @param uidl
* which contains row data
* @param firstRow
@@ -1790,7 +1643,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* on the commands in the UIDL.
* <p>
* For internal use only. May be removed or replaced in the future.
- *
+ *
* @param partialRowAdditions
* the UIDL containing row updates.
*/
@@ -1820,7 +1673,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Gives correct column index for given column key ("cid" in UIDL).
- *
+ *
* @param colKey
* @return column index of visible columns, -1 if column not visible
*/
@@ -1888,9 +1741,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Note: not part of the official API, extend at your own risk. May be
* removed or replaced in the future.
- *
+ *
* Sets the indicated column's width for headers and scrollBody alike.
- *
+ *
* @param colIndex
* index of the modified column
* @param w
@@ -1938,7 +1791,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Get a rendered row by its key
- *
+ *
* @param key
* The key to search with
* @return
@@ -1959,10 +1812,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Returns the next row to the given row
- *
+ *
* @param row
* The row to calculate from
- *
+ *
* @return The next row or null if no row exists
*/
private VScrollTableRow getNextRow(VScrollTableRow row, int offset) {
@@ -1985,7 +1838,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Returns the previous row from the given row
- *
+ *
* @param row
* The row to calculate from
* @return The previous row or null if no row exists
@@ -2097,13 +1950,13 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Run only once when component is attached and received its initial
* content. This function:
- *
+ *
* * Syncs headers and bodys "natural widths and saves the values.
- *
+ *
* * Sets proper width and height
- *
+ *
* * Makes deferred request to get some cache rows
- *
+ *
* For internal use only. May be removed or replaced in the future.
*/
public void sizeInit() {
@@ -2115,7 +1968,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* We will use browsers table rendering algorithm to find proper column
* widths. If content and header take less space than available, we will
* divide extra space relatively to each column which has not width set.
- *
+ *
* Overflow pixels are added to last column.
*/
@@ -2414,7 +2267,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Note: this method is not part of official API although declared as
* protected. Extend at your own risk.
- *
+ *
* @return true if content area will have scrollbars visible.
*/
protected boolean willHaveScrollbars() {
@@ -2804,7 +2657,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Sets width to the header cell. This width should not include any
* possible indent modifications that are present in
* {@link VScrollTableBody#getMaxIndent()}.
- *
+ *
* @param w
* required width of the cell sans indentations
* @param ensureDefinedWidth
@@ -2867,7 +2720,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Detects if width is fixed by developer on server side or resized to
* current width by user.
- *
+ *
* @return true if defined, false if "natural" width
*/
public boolean isDefinedWidth() {
@@ -2876,10 +2729,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* This method exists for the needs of {@link VTreeTable} only.
- *
+ *
* Returns the pixels width of the header cell. This includes the
* indent, if applicable.
- *
+ *
* @return The width in pixels
*/
protected int getWidthWithIndent() {
@@ -2894,7 +2747,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Returns the pixels width of the header cell.
- *
+ *
* @return The width in pixels
*/
public int getWidth() {
@@ -2903,7 +2756,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* This method exists for the needs of {@link VTreeTable} only.
- *
+ *
* @return <code>true</code> if this is hierarcyColumn's header cell,
* <code>false</code> otherwise
*/
@@ -3017,7 +2870,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Fires a header click event after the user has clicked a column header
* cell
- *
+ *
* @param event
* The click event
*/
@@ -3229,7 +3082,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Returns the smallest possible cell width in pixels.
- *
+ *
* @param includeIndent
* - width should include hierarchy column indent if
* applicable (VTreeTable only)
@@ -3281,10 +3134,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Detects the natural minimum width for the column of this header cell.
* If column is resized by user or the width is defined by server the
* actual width is returned. Else the natural min width is returned.
- *
+ *
* @param columnIndex
* column index hint, if -1 (unknown) it will be detected
- *
+ *
* @return
*/
public int getNaturalColumnWidth(int columnIndex) {
@@ -3345,7 +3198,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* HeaderCell that is header cell for row headers.
- *
+ *
* Reordering disabled and clicking on it resets sorting.
*/
public class RowHeadersHeaderCell extends HeaderCell {
@@ -3674,9 +3527,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Get's HeaderCell by it's column Key.
- *
+ *
* Note that this returns HeaderCell even if it is currently collapsed.
- *
+ *
* @param cid
* Column key of accessed HeaderCell
* @return HeaderCell
@@ -3969,7 +3822,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Sets the text of the footer
- *
+ *
* @param footerText
* The text in the footer
*/
@@ -3983,7 +3836,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Set alignment of the text in the cell
- *
+ *
* @param c
* The alignment which can be ALIGN_CENTER, ALIGN_LEFT,
* ALIGN_RIGHT
@@ -4007,7 +3860,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Get the alignment of the text int the cell
- *
+ *
* @return Returns either ALIGN_CENTER, ALIGN_LEFT or ALIGN_RIGHT
*/
public char getAlign() {
@@ -4018,7 +3871,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Sets the width of the cell. This width should not include any
* possible indent modifications that are present in
* {@link VScrollTableBody#getMaxIndent()}.
- *
+ *
* @param w
* The width of the cell
* @param ensureDefinedWidth
@@ -4100,7 +3953,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Detects if width is fixed by developer on server side or resized to
* current width by user.
- *
+ *
* @return true if defined, false if "natural" width
*/
public boolean isDefinedWidth() {
@@ -4109,7 +3962,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Returns the pixels width of the footer cell.
- *
+ *
* @return The width in pixels
*/
public int getWidth() {
@@ -4118,7 +3971,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Sets the expand ratio of the cell
- *
+ *
* @param floatAttribute
* The expand ratio
*/
@@ -4128,7 +3981,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Returns the expand ration of the cell
- *
+ *
* @return The expand ratio
*/
public float getExpandRatio() {
@@ -4137,7 +3990,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Is the cell enabled?
- *
+ *
* @return True if enabled else False
*/
public boolean isEnabled() {
@@ -4173,7 +4026,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Handles a event on the captions
- *
+ *
* @param event
* The event to handle
*/
@@ -4187,7 +4040,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Fires a footer click event after the user has clicked a column footer
* cell
- *
+ *
* @param event
* The click event
*/
@@ -4204,7 +4057,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Returns the column key of the column
- *
+ *
* @return The column key
*/
public String getColKey() {
@@ -4215,10 +4068,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Detects the natural minimum width for the column of this header cell.
* If column is resized by user or the width is defined by server the
* actual width is returned. Else the natural min width is returned.
- *
+ *
* @param columnIndex
* column index hint, if -1 (unknown) it will be detected
- *
+ *
* @return
*/
public int getNaturalColumnWidth(int columnIndex) {
@@ -4264,7 +4117,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* HeaderCell that is header cell for row headers.
- *
+ *
* Reordering disabled and clicking on it resets sorting.
*/
public class RowHeadersFooterCell extends FooterCell {
@@ -4334,7 +4187,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/*
* (non-Javadoc)
- *
+ *
* @see
* com.google.gwt.user.client.ui.Panel#remove(com.google.gwt.user.client
* .ui.Widget)
@@ -4353,7 +4206,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/*
* (non-Javadoc)
- *
+ *
* @see com.google.gwt.user.client.ui.HasWidgets#iterator()
*/
@@ -4364,10 +4217,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Gets a footer cell which represents the given columnId
- *
+ *
* @param cid
* The columnId
- *
+ *
* @return The cell
*/
public FooterCell getFooterCell(String cid) {
@@ -4376,7 +4229,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Gets a footer cell by using a column index
- *
+ *
* @param index
* The index of the column
* @return The Cell
@@ -4391,7 +4244,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Updates the cells contents when updateUIDL request is received
- *
+ *
* @param uidl
* The UIDL
*/
@@ -4462,7 +4315,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Set a footer cell for a specified column index
- *
+ *
* @param index
* The index
* @param cell
@@ -4493,7 +4346,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Remove a cell by using the columnId
- *
+ *
* @param colKey
* The columnId to remove
*/
@@ -4504,7 +4357,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Enable a column (Sets the footer cell)
- *
+ *
* @param cid
* The columnId
* @param index
@@ -4537,7 +4390,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Set the horizontal position in the cell in the footer. This is done
* when a horizontal scrollbar is present.
- *
+ *
* @param scrollLeft
* The value of the leftScroll
*/
@@ -4547,7 +4400,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Swap cells when the column are dragged
- *
+ *
* @param oldIndex
* The old index of the cell
* @param newIndex
@@ -4569,7 +4422,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* This Panel can only contain VScrollTableRow type of widgets. This
* "simulates" very large table, keeping spacers which take room of
* unrendered rows.
- *
+ *
*/
public class VScrollTableBody extends Panel {
@@ -4762,7 +4615,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/*
* #8040 - scroll position is completely changed since the
* latest request, so request a new set of rows.
- *
+ *
* TODO: We should probably check whether the fetched rows match
* the current scroll position right when they arrive, so as to
* not waste time rendering a set of rows that will never be
@@ -4777,7 +4630,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
} else if (firstRendered > reactFirstRow) {
/*
* Branch for fetching cache above visible area.
- *
+ *
* If cache needed for both before and after visible area, this
* will be rendered after-cache is received and rendered. So in
* some rare situations the table may make two cache visits to
@@ -4790,7 +4643,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Inserts rows as provided in the rowData starting at firstIndex.
- *
+ *
* @param rowData
* @param firstIndex
* @param rows
@@ -4872,9 +4725,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* This method is used to instantiate new rows for this table. It
* automatically sets correct widths to rows cells and assigns correct
* client reference for child widgets.
- *
+ *
* This method can be called only after table has been initialized
- *
+ *
* @param uidl
*/
private VScrollTableRow prepareRow(UIDL uidl) {
@@ -5115,7 +4968,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Returns the width available for column content.
- *
+ *
* @param columnIndex
* @return
*/
@@ -5141,14 +4994,14 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Sets the content width of a column.
- *
+ *
* Due IE limitation, we must set the width to a wrapper elements inside
* table cells (with overflow hidden, which does not work on td
* elements).
- *
+ *
* To get this work properly crossplatform, we will also set the width
* of td.
- *
+ *
* @param colIndex
* @param w
*/
@@ -5174,9 +5027,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* This method exists for the needs of {@link VTreeTable} only. May be
* removed or replaced in the future.</br> </br> Returns the maximum
* indent of the hierarcyColumn, if applicable.
- *
+ *
* @see {@link VScrollTable#getHierarchyColumnIndex()}
- *
+ *
* @return maximum indent in pixels
*/
protected int getMaxIndent() {
@@ -5267,8 +5120,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
return -1;
}
- public class VScrollTableRow extends Panel implements ActionOwner,
- ContextMenuOwner {
+ public class VScrollTableRow extends Panel implements ActionOwner {
private static final int TOUCHSCROLL_TIMEOUT = 100;
private static final int DRAGMODE_MULTIROW = 2;
@@ -5279,15 +5131,13 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
private String[] actionKeys = null;
private final TableRowElement rowElement;
private int index;
-
private Event touchStart;
+
+ private static final int TOUCH_CONTEXT_MENU_TIMEOUT = 500;
+ private Timer contextTouchTimeout;
private Timer dragTouchTimeout;
private int touchStartY;
private int touchStartX;
-
- private TouchContextProvider touchContextProvider = new TouchContextProvider(
- this);
-
private TooltipInfo tooltipInfo = null;
private Map<TableCellElement, TooltipInfo> cellToolTips = new HashMap<TableCellElement, TooltipInfo>();
private boolean isDragging = false;
@@ -5445,7 +5295,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Overriding this and returning true causes all text cells to be
* rendered as HTML.
- *
+ *
* @return always returns false in the default implementation
*/
protected boolean isRenderHtmlInCells() {
@@ -5454,7 +5304,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Detects whether row is visible in tables viewport.
- *
+ *
* @return
*/
public boolean isInViewPort() {
@@ -5470,7 +5320,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Makes a check based on indexes whether the row is before the
* compared row.
- *
+ *
* @param row1
* @return true if this rows index is smaller than in the row1
*/
@@ -5481,7 +5331,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Sets the index of the row in the whole table. Currently used just
* to set even/odd classname
- *
+ *
* @param indexInWholeTable
*/
private void setIndex(int indexInWholeTable) {
@@ -5660,7 +5510,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* If there are registered click listeners, sends a click event and
* returns true. Otherwise, does nothing and returns false.
- *
+ *
* @param event
* @param targetTdOrTr
* @param immediate
@@ -5735,7 +5585,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Special handler for touch devices that support native scrolling
- *
+ *
* @return Whether the event was handled by this method.
*/
private boolean handleTouchEvent(final Event event) {
@@ -5743,8 +5593,6 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
boolean touchEventHandled = false;
if (enabled && hasNativeTouchScrolling) {
- touchContextProvider.handleTouchEvent(event);
-
final Element targetTdOrTr = getEventTargetTdOrTr(event);
final int type = event.getTypeInt();
@@ -5775,10 +5623,37 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
}
dragTouchTimeout.schedule(TOUCHSCROLL_TIMEOUT);
}
+
+ if (actionKeys != null) {
+ if (contextTouchTimeout == null) {
+ contextTouchTimeout = new Timer() {
+
+ @Override
+ public void run() {
+ if (touchStart != null) {
+ // Open the context menu if finger
+ // is held in place long enough.
+ showContextMenu(touchStart);
+ event.preventDefault();
+ touchStart = null;
+ }
+ }
+ };
+ }
+ contextTouchTimeout
+ .schedule(TOUCH_CONTEXT_MENU_TIMEOUT);
+ }
break;
case Event.ONTOUCHMOVE:
touchEventHandled = true;
if (isSignificantMove(event)) {
+ if (contextTouchTimeout != null) {
+ // Moved finger before the context menu timer
+ // expired, so let the browser handle this as a
+ // scroll.
+ contextTouchTimeout.cancel();
+ contextTouchTimeout = null;
+ }
if (!isDragging && dragTouchTimeout != null) {
// Moved finger before the drag timer expired,
// so let the browser handle this as a scroll.
@@ -5798,6 +5673,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
case Event.ONTOUCHEND:
case Event.ONTOUCHCANCEL:
touchEventHandled = true;
+ if (contextTouchTimeout != null) {
+ contextTouchTimeout.cancel();
+ }
if (dragTouchTimeout != null) {
dragTouchTimeout.cancel();
}
@@ -5975,7 +5853,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
Util.simulateClickFromTouchEvent(touchStart, this);
touchStart = null;
}
- touchContextProvider.cancel();
+ if (contextTouchTimeout != null) {
+ contextTouchTimeout.cancel();
+ }
break;
case Event.ONTOUCHMOVE:
if (isSignificantMove(event)) {
@@ -5990,7 +5870,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
.getActiveScrollDelegate() == null)) {
startRowDrag(touchStart, type, targetTdOrTr);
}
- touchContextProvider.cancel();
+ if (contextTouchTimeout != null) {
+ contextTouchTimeout.cancel();
+ }
/*
* Avoid clicks and drags by clearing touch start
* flag.
@@ -6047,6 +5929,25 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
}
}
}.schedule(TOUCHSCROLL_TIMEOUT);
+
+ if (contextTouchTimeout == null
+ && actionKeys != null) {
+ contextTouchTimeout = new Timer() {
+
+ @Override
+ public void run() {
+ if (touchStart != null) {
+ showContextMenu(touchStart);
+ touchStart = null;
+ }
+ }
+ };
+ }
+ if (contextTouchTimeout != null) {
+ contextTouchTimeout.cancel();
+ contextTouchTimeout
+ .schedule(TOUCH_CONTEXT_MENU_TIMEOUT);
+ }
}
break;
case Event.ONMOUSEDOWN:
@@ -6107,7 +6008,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Checks if the row represented by the row key has been selected
- *
+ *
* @param key
* The generated row key
*/
@@ -6177,7 +6078,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* target of the event should not be handled. If the event target is
* the row directly this method returns the TR element instead of
* the TD.
- *
+ *
* @param event
* @return TD or TR element that the event targets (the actual event
* target is this element or a child of it)
@@ -6207,7 +6108,6 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
return getTdOrTr(eventTarget);
}
- @Override
public void showContextMenu(Event event) {
if (enabled && actionKeys != null) {
// Show context menu if there are registered action handlers
@@ -6227,7 +6127,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Has the row been selected?
- *
+ *
* @return Returns true if selected, else false
*/
public boolean isSelected() {
@@ -6252,7 +6152,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Is called when a user clicks an item when holding SHIFT key down.
* This will select a new range from the last focused row
- *
+ *
* @param deselectPrevious
* Should the previous selected range be deselected
*/
@@ -6321,7 +6221,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/*
* (non-Javadoc)
- *
+ *
* @see com.vaadin.client.ui.IActionOwner#getActions ()
*/
@@ -6499,7 +6399,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Ensure the component has a focus.
- *
+ *
* TODO the current implementation simply always calls focus for the
* component. In case the Table at some point implements focus/blur
* listeners, this method needs to be evolved to conditionally call
@@ -6693,7 +6593,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
if (getTotalRows() == 0) {
/*
* Too wide header combined with no rows in the table.
- *
+ *
* No horizontal scrollbars would be displayed because
* there's no rows that grows too wide causing the
* scrollBody container div to overflow. Must explicitely
@@ -6844,7 +6744,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* helper to set pixel size of head and body part
- *
+ *
* @param pixels
*/
private void setContentWidth(int pixels) {
@@ -7000,7 +6900,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Helper function to build html snippet for column or row headers
- *
+ *
* @param uidl
* possibly with values caption and icon
* @return html snippet containing possibly an icon + caption text
@@ -7033,7 +6933,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
scrollTop = scrollBodyPanel.getScrollPosition();
/*
* #6970 - IE sometimes fires scroll events for a detached table.
- *
+ *
* FIXME initializedAndAttached should probably be renamed - its name
* doesn't seem to reflect its semantics. onDetach() doesn't set it to
* false, and changing that might break something else, so we need to
@@ -7325,7 +7225,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Moves the selection head to a specific row
- *
+ *
* @param row
* The row to where the selection head should move
* @return Returns true if focus was moved successfully, else false
@@ -7366,7 +7266,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Ensures that the row is visible
- *
+ *
* @param row
* The row to ensure is visible
*/
@@ -7381,7 +7281,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Handles the keyboard events handled by the table
- *
+ *
* @param event
* The keyboard event received
* @return true iff the navigation event was handled
@@ -7638,7 +7538,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/*
* (non-Javadoc)
- *
+ *
* @see
* com.google.gwt.event.dom.client.FocusHandler#onFocus(com.google.gwt.event
* .dom.client.FocusEvent)
@@ -7660,7 +7560,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/*
* (non-Javadoc)
- *
+ *
* @see
* com.google.gwt.event.dom.client.BlurHandler#onBlur(com.google.gwt.event
* .dom.client.BlurEvent)
@@ -7698,7 +7598,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Removes a key from a range if the key is found in a selected range
- *
+ *
* @param key
* The key to remove
*/
@@ -7724,7 +7624,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/**
* Can the Table be focused?
- *
+ *
* @return True if the table can be focused, else false
*/
public boolean isFocusable() {
@@ -7744,7 +7644,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
/*
* (non-Javadoc)
- *
+ *
* @see com.vaadin.client.Focusable#focus()
*/
@@ -7813,7 +7713,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
}
/**
- *
+ *
* @param keyCode
* @return true if the given keyCode is used by the table for navigation
*/
@@ -7874,7 +7774,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* Add this to the element mouse down event by using element.setPropertyJSO
* ("onselectstart",applyDisableTextSelectionIEHack()); Remove it then again
* when the mouse is depressed in the mouse up event.
- *
+ *
* @return Returns the JSO preventing text selection
*/
private static native JavaScriptObject getPreventTextSelectionIEHack()
@@ -8025,8 +7925,4 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
addCloseHandler.removeHandler();
}
}
-
- public void totalRowsHaveChanged() {
- firstvisibleOnLastPage = -1;
- }
}
diff --git a/client/src/com/vaadin/client/ui/table/TableConnector.java b/client/src/com/vaadin/client/ui/table/TableConnector.java
index d3535e96c9..d37fd36522 100644
--- a/client/src/com/vaadin/client/ui/table/TableConnector.java
+++ b/client/src/com/vaadin/client/ui/table/TableConnector.java
@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -64,7 +64,7 @@ public class TableConnector extends AbstractHasComponentsConnector implements
/*
* (non-Javadoc)
- *
+ *
* @see com.vaadin.client.Paintable#updateFromUIDL(com.vaadin.client.UIDL,
* com.vaadin.client.ApplicationConnection)
*/
@@ -121,7 +121,7 @@ public class TableConnector extends AbstractHasComponentsConnector implements
int previousTotalRows = getWidget().totalRows;
getWidget().updateTotalRows(uidl);
- boolean totalRowsHaveChanged = (getWidget().totalRows != previousTotalRows);
+ boolean totalRowsChanged = (getWidget().totalRows != previousTotalRows);
getWidget().updateDragMode(uidl);
@@ -146,9 +146,6 @@ public class TableConnector extends AbstractHasComponentsConnector implements
getWidget().updatePageLength(uidl);
getWidget().updateFirstVisibleAndScrollIfNeeded(uidl);
- if (totalRowsHaveChanged) {
- getWidget().totalRowsHaveChanged();
- }
getWidget().showRowHeaders = uidl.getBooleanAttribute("rowheaders");
getWidget().showColHeaders = uidl.getBooleanAttribute("colheaders");
@@ -202,7 +199,7 @@ public class TableConnector extends AbstractHasComponentsConnector implements
if (getWidget().headerChangedDuringUpdate) {
getWidget().triggerLazyColumnAdjustment(true);
} else if (!getWidget().isScrollPositionVisible()
- || totalRowsHaveChanged
+ || totalRowsChanged
|| getWidget().lastRenderedHeight != getWidget().scrollBody
.getOffsetHeight()) {
// webkits may still bug with their disturbing scrollbar
@@ -387,7 +384,7 @@ public class TableConnector extends AbstractHasComponentsConnector implements
/**
* Shows a saved row context menu if the row for the context menu is still
* visible. Does nothing if a context menu has not been saved.
- *
+ *
* @param savedContextMenu
*/
public void showSavedContextMenu(ContextMenuDetails savedContextMenu) {