From: Henrik Paul Date: Wed, 27 Aug 2014 12:18:30 +0000 (+0300) Subject: ScrollbarBundle, Escalator and Grid fire Scroll events (#13334) X-Git-Tag: 7.4.0.beta1~9^2~189^2~42 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1de6a75497bae315dfcb70c272225a6d3ea0af19;p=vaadin-framework.git ScrollbarBundle, Escalator and Grid fire Scroll events (#13334) Change-Id: I362f1f8d2107d762b43ab52c1f22dfd218f67ba4 --- diff --git a/client/src/com/vaadin/client/ui/grid/Escalator.java b/client/src/com/vaadin/client/ui/grid/Escalator.java index dd220b2964..ceff55e303 100644 --- a/client/src/com/vaadin/client/ui/grid/Escalator.java +++ b/client/src/com/vaadin/client/ui/grid/Escalator.java @@ -57,6 +57,8 @@ import com.vaadin.client.ui.grid.PositionFunction.TranslatePosition; import com.vaadin.client.ui.grid.PositionFunction.WebkitTranslate3DPosition; import com.vaadin.client.ui.grid.ScrollbarBundle.HorizontalScrollbarBundle; import com.vaadin.client.ui.grid.ScrollbarBundle.VerticalScrollbarBundle; +import com.vaadin.client.ui.grid.events.ScrollEvent; +import com.vaadin.client.ui.grid.events.ScrollHandler; import com.vaadin.shared.ui.grid.GridState; import com.vaadin.shared.ui.grid.HeightMode; import com.vaadin.shared.ui.grid.Range; @@ -3950,11 +3952,20 @@ public class Escalator extends Widget { final Element root = DOM.createDiv(); setElement(root); + ScrollHandler scrollHandler = new ScrollHandler() { + @Override + public void onScroll(ScrollEvent event) { + fireEvent(new ScrollEvent()); + } + }; + root.appendChild(verticalScrollbar.getElement()); + verticalScrollbar.addScrollHandler(scrollHandler); verticalScrollbar.getElement().setTabIndex(-1); verticalScrollbar.setScrollbarThickness(Util.getNativeScrollbarSize()); root.appendChild(horizontalScrollbar.getElement()); + horizontalScrollbar.addScrollHandler(scrollHandler); horizontalScrollbar.getElement().setTabIndex(-1); horizontalScrollbar .setScrollbarThickness(Util.getNativeScrollbarSize()); @@ -4668,4 +4679,15 @@ public class Escalator extends Widget { + direction); } } + + /** + * Adds a scroll handler to this escalator + * + * @param handler + * the scroll handler to add + * @return a handler registration for the registered scroll handler + */ + public HandlerRegistration addScrollHandler(ScrollHandler handler) { + return addHandler(handler, ScrollEvent.TYPE); + } } diff --git a/client/src/com/vaadin/client/ui/grid/Grid.java b/client/src/com/vaadin/client/ui/grid/Grid.java index 4d8aa25c3b..9c12b37bb5 100644 --- a/client/src/com/vaadin/client/ui/grid/Grid.java +++ b/client/src/com/vaadin/client/ui/grid/Grid.java @@ -52,22 +52,24 @@ import com.vaadin.client.ui.SubPartAware; import com.vaadin.client.ui.grid.GridFooter.FooterRow; import com.vaadin.client.ui.grid.GridHeader.HeaderRow; import com.vaadin.client.ui.grid.GridStaticSection.StaticCell; -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler; -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyDownHandler; -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyPressHandler; -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyUpHandler; -import com.vaadin.client.ui.grid.keyevents.BodyKeyDownHandler; -import com.vaadin.client.ui.grid.keyevents.BodyKeyPressHandler; -import com.vaadin.client.ui.grid.keyevents.BodyKeyUpHandler; -import com.vaadin.client.ui.grid.keyevents.FooterKeyDownHandler; -import com.vaadin.client.ui.grid.keyevents.FooterKeyPressHandler; -import com.vaadin.client.ui.grid.keyevents.FooterKeyUpHandler; -import com.vaadin.client.ui.grid.keyevents.GridKeyDownEvent; -import com.vaadin.client.ui.grid.keyevents.GridKeyPressEvent; -import com.vaadin.client.ui.grid.keyevents.GridKeyUpEvent; -import com.vaadin.client.ui.grid.keyevents.HeaderKeyDownHandler; -import com.vaadin.client.ui.grid.keyevents.HeaderKeyPressHandler; -import com.vaadin.client.ui.grid.keyevents.HeaderKeyUpHandler; +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler; +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyDownHandler; +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyPressHandler; +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyUpHandler; +import com.vaadin.client.ui.grid.events.BodyKeyDownHandler; +import com.vaadin.client.ui.grid.events.BodyKeyPressHandler; +import com.vaadin.client.ui.grid.events.BodyKeyUpHandler; +import com.vaadin.client.ui.grid.events.FooterKeyDownHandler; +import com.vaadin.client.ui.grid.events.FooterKeyPressHandler; +import com.vaadin.client.ui.grid.events.FooterKeyUpHandler; +import com.vaadin.client.ui.grid.events.GridKeyDownEvent; +import com.vaadin.client.ui.grid.events.GridKeyPressEvent; +import com.vaadin.client.ui.grid.events.GridKeyUpEvent; +import com.vaadin.client.ui.grid.events.HeaderKeyDownHandler; +import com.vaadin.client.ui.grid.events.HeaderKeyPressHandler; +import com.vaadin.client.ui.grid.events.HeaderKeyUpHandler; +import com.vaadin.client.ui.grid.events.ScrollEvent; +import com.vaadin.client.ui.grid.events.ScrollHandler; import com.vaadin.client.ui.grid.renderers.ComplexRenderer; import com.vaadin.client.ui.grid.renderers.WidgetRenderer; import com.vaadin.client.ui.grid.selection.HasSelectionChangeHandlers; @@ -1225,6 +1227,13 @@ public class Grid extends Composite implements setSelectionMode(SelectionMode.SINGLE); + escalator.addScrollHandler(new ScrollHandler() { + @Override + public void onScroll(ScrollEvent event) { + fireEvent(new ScrollEvent()); + } + }); + escalator .addRowVisibilityChangeHandler(new RowVisibilityChangeHandler() { @Override @@ -1814,6 +1823,15 @@ public class Grid extends Composite implements return escalator.getScrollTop(); } + /** + * Gets the horizontal scroll offset + * + * @return the number of pixels this grid is scrolled to the right + */ + public double getScrollLeft() { + return escalator.getScrollLeft(); + } + private static final Logger getLogger() { return Logger.getLogger(Grid.class.getName()); } @@ -2560,4 +2578,15 @@ public class Grid extends Composite implements return firstRowIndex; } + + /** + * Adds a scroll handler to this grid + * + * @param handler + * the scroll handler to add + * @return a handler registration for the registered scroll handler + */ + public HandlerRegistration addScrollHandler(ScrollHandler handler) { + return addHandler(handler, ScrollEvent.TYPE); + } } diff --git a/client/src/com/vaadin/client/ui/grid/ScrollbarBundle.java b/client/src/com/vaadin/client/ui/grid/ScrollbarBundle.java index a45affb0be..ceaa4b9fec 100644 --- a/client/src/com/vaadin/client/ui/grid/ScrollbarBundle.java +++ b/client/src/com/vaadin/client/ui/grid/ScrollbarBundle.java @@ -16,6 +16,8 @@ package com.vaadin.client.ui.grid; +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Style.Overflow; import com.google.gwt.dom.client.Style.Unit; @@ -27,6 +29,8 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; import com.google.gwt.user.client.Timer; +import com.vaadin.client.ui.grid.events.ScrollEvent; +import com.vaadin.client.ui.grid.events.ScrollHandler; /** * An element-like bundle representing a configurable and visual scrollbar in @@ -39,6 +43,41 @@ import com.google.gwt.user.client.Timer; */ abstract class ScrollbarBundle { + private class ScrollEventFirer { + private final ScheduledCommand fireEventCommand = new ScheduledCommand() { + @Override + public void execute() { + if (!pixelValuesEqual(startScrollPos, getScrollPos())) { + getHandlerManager().fireEvent(new ScrollEvent()); + } + reset(); + } + }; + + private boolean isBeingFired; + private double startScrollPos; + + public ScrollEventFirer() { + reset(); + } + + public void scheduleEvent() { + if (!isBeingFired) { + /* + * We'll gather all the scroll events, and only fire once, once + * everything has calmed down. + */ + Scheduler.get().scheduleDeferred(fireEventCommand); + isBeingFired = true; + } + } + + private void reset() { + isBeingFired = false; + startScrollPos = getScrollPos(); + } + } + /** * The orientation of the scrollbar. */ @@ -288,6 +327,8 @@ abstract class ScrollbarBundle { private TemporaryResizer invisibleScrollbarTemporaryResizer = new TemporaryResizer(); + private final ScrollEventFirer scrollEventFirer = new ScrollEventFirer(); + private ScrollbarBundle() { root.appendChild(scrollSizeElement); } @@ -409,6 +450,8 @@ abstract class ScrollbarBundle { * only facilitating future virtual scrollbars. */ internalSetScrollPos(toInt32(scrollPos)); + + scrollEventFirer.scheduleEvent(); } } @@ -603,6 +646,7 @@ abstract class ScrollbarBundle { int newScrollPos = internalGetScrollPos(); if (!isLocked()) { scrollPos = newScrollPos; + scrollEventFirer.scheduleEvent(); } else if (scrollPos != newScrollPos) { // we need to actually undo the setting of the scroll. internalSetScrollPos(toInt32(scrollPos)); @@ -694,4 +738,15 @@ abstract class ScrollbarBundle { * @return the scroll direction of this scrollbar bundle */ public abstract Direction getDirection(); + + /** + * Adds a scroll handler to the scrollbar bundle. + * + * @param handler + * the handler to add + * @return the registration object for the handler registration + */ + public HandlerRegistration addScrollHandler(final ScrollHandler handler) { + return getHandlerManager().addHandler(ScrollEvent.TYPE, handler); + } } diff --git a/client/src/com/vaadin/client/ui/grid/events/AbstractGridKeyEventHandler.java b/client/src/com/vaadin/client/ui/grid/events/AbstractGridKeyEventHandler.java new file mode 100644 index 0000000000..8dcd24305b --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/AbstractGridKeyEventHandler.java @@ -0,0 +1,44 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.google.gwt.event.shared.EventHandler; +import com.vaadin.client.ui.grid.Grid.AbstractGridKeyEvent; + +/** + * Base interface of all handlers for {@link AbstractGridKeyEvent}s. + * + * @since + * @author Vaadin Ltd + */ +public abstract interface AbstractGridKeyEventHandler extends EventHandler { + + public abstract interface GridKeyDownHandler extends + AbstractGridKeyEventHandler { + public void onKeyDown(GridKeyDownEvent event); + } + + public abstract interface GridKeyUpHandler extends + AbstractGridKeyEventHandler { + public void onKeyUp(GridKeyUpEvent event); + } + + public abstract interface GridKeyPressHandler extends + AbstractGridKeyEventHandler { + public void onKeyPress(GridKeyPressEvent event); + } + +} diff --git a/client/src/com/vaadin/client/ui/grid/events/BodyKeyDownHandler.java b/client/src/com/vaadin/client/ui/grid/events/BodyKeyDownHandler.java new file mode 100644 index 0000000000..2ec81174b9 --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/BodyKeyDownHandler.java @@ -0,0 +1,28 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyDownHandler; + +/** + * Handler for {@link GridKeyDownEvent}s that happen when active cell is in the + * body of the Grid. + * + * @since + * @author Vaadin Ltd + */ +public interface BodyKeyDownHandler extends GridKeyDownHandler { +} diff --git a/client/src/com/vaadin/client/ui/grid/events/BodyKeyPressHandler.java b/client/src/com/vaadin/client/ui/grid/events/BodyKeyPressHandler.java new file mode 100644 index 0000000000..f328a11ab8 --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/BodyKeyPressHandler.java @@ -0,0 +1,28 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyPressHandler; + +/** + * Handler for {@link GridKeyPressEvent}s that happen when active cell is in the + * body of the Grid. + * + * @since + * @author Vaadin Ltd + */ +public interface BodyKeyPressHandler extends GridKeyPressHandler { +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/events/BodyKeyUpHandler.java b/client/src/com/vaadin/client/ui/grid/events/BodyKeyUpHandler.java new file mode 100644 index 0000000000..f5cab67946 --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/BodyKeyUpHandler.java @@ -0,0 +1,28 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyUpHandler; + +/** + * Handler for {@link GridKeyUpEvent}s that happen when active cell is in the + * body of the Grid. + * + * @since + * @author Vaadin Ltd + */ +public interface BodyKeyUpHandler extends GridKeyUpHandler { +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/events/FooterKeyDownHandler.java b/client/src/com/vaadin/client/ui/grid/events/FooterKeyDownHandler.java new file mode 100644 index 0000000000..e84da350dd --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/FooterKeyDownHandler.java @@ -0,0 +1,28 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyDownHandler; + +/** + * Handler for {@link GridKeyDownEvent}s that happen when active cell is in the + * footer of the Grid. + * + * @since + * @author Vaadin Ltd + */ +public interface FooterKeyDownHandler extends GridKeyDownHandler { +} diff --git a/client/src/com/vaadin/client/ui/grid/events/FooterKeyPressHandler.java b/client/src/com/vaadin/client/ui/grid/events/FooterKeyPressHandler.java new file mode 100644 index 0000000000..617e25f190 --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/FooterKeyPressHandler.java @@ -0,0 +1,28 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyPressHandler; + +/** + * Handler for {@link GridKeyPressEvent}s that happen when active cell is in the + * footer of the Grid. + * + * @since + * @author Vaadin Ltd + */ +public interface FooterKeyPressHandler extends GridKeyPressHandler { +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/events/FooterKeyUpHandler.java b/client/src/com/vaadin/client/ui/grid/events/FooterKeyUpHandler.java new file mode 100644 index 0000000000..4dd3dc7f01 --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/FooterKeyUpHandler.java @@ -0,0 +1,28 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyUpHandler; + +/** + * Handler for {@link GridKeyUpEvent}s that happen when active cell is in the + * footer of the Grid. + * + * @since + * @author Vaadin Ltd + */ +public interface FooterKeyUpHandler extends GridKeyUpHandler { +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/events/GridKeyDownEvent.java b/client/src/com/vaadin/client/ui/grid/events/GridKeyDownEvent.java new file mode 100644 index 0000000000..2fab683bb0 --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/GridKeyDownEvent.java @@ -0,0 +1,50 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.google.gwt.dom.client.BrowserEvents; +import com.vaadin.client.ui.grid.Grid; +import com.vaadin.client.ui.grid.Grid.AbstractGridKeyEvent; +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyDownHandler; + +/** + * Represents native key down event in Grid. + * + * @since + * @author Vaadin Ltd + */ +public class GridKeyDownEvent extends AbstractGridKeyEvent { + + public GridKeyDownEvent(Grid grid) { + super(grid); + } + + @Override + protected void dispatch(GridKeyDownHandler handler) { + super.dispatch(handler); + if ((activeSection == GridSection.BODY && handler instanceof BodyKeyDownHandler) + || (activeSection == GridSection.HEADER && handler instanceof HeaderKeyDownHandler) + || (activeSection == GridSection.FOOTER && handler instanceof FooterKeyDownHandler)) { + handler.onKeyDown(this); + } + } + + @Override + protected String getBrowserEventType() { + return BrowserEvents.KEYDOWN; + } + +} diff --git a/client/src/com/vaadin/client/ui/grid/events/GridKeyPressEvent.java b/client/src/com/vaadin/client/ui/grid/events/GridKeyPressEvent.java new file mode 100644 index 0000000000..112200b03a --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/GridKeyPressEvent.java @@ -0,0 +1,51 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.google.gwt.dom.client.BrowserEvents; +import com.vaadin.client.ui.grid.Grid; +import com.vaadin.client.ui.grid.Grid.AbstractGridKeyEvent; +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyPressHandler; + +/** + * Represents native key press event in Grid. + * + * @since + * @author Vaadin Ltd + */ +public class GridKeyPressEvent extends + AbstractGridKeyEvent { + + public GridKeyPressEvent(Grid grid) { + super(grid); + } + + @Override + protected void dispatch(GridKeyPressHandler handler) { + super.dispatch(handler); + if ((activeSection == GridSection.BODY && handler instanceof BodyKeyPressHandler) + || (activeSection == GridSection.HEADER && handler instanceof HeaderKeyPressHandler) + || (activeSection == GridSection.FOOTER && handler instanceof FooterKeyPressHandler)) { + handler.onKeyPress(this); + } + } + + @Override + protected String getBrowserEventType() { + return BrowserEvents.KEYPRESS; + } + +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/events/GridKeyUpEvent.java b/client/src/com/vaadin/client/ui/grid/events/GridKeyUpEvent.java new file mode 100644 index 0000000000..9aa8ce7084 --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/GridKeyUpEvent.java @@ -0,0 +1,50 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.google.gwt.dom.client.BrowserEvents; +import com.vaadin.client.ui.grid.Grid; +import com.vaadin.client.ui.grid.Grid.AbstractGridKeyEvent; +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyUpHandler; + +/** + * Represents native key up event in Grid. + * + * @since + * @author Vaadin Ltd + */ +public class GridKeyUpEvent extends AbstractGridKeyEvent { + + public GridKeyUpEvent(Grid grid) { + super(grid); + } + + @Override + protected void dispatch(GridKeyUpHandler handler) { + super.dispatch(handler); + if ((activeSection == GridSection.BODY && handler instanceof BodyKeyUpHandler) + || (activeSection == GridSection.HEADER && handler instanceof HeaderKeyUpHandler) + || (activeSection == GridSection.FOOTER && handler instanceof FooterKeyUpHandler)) { + handler.onKeyUp(this); + } + } + + @Override + protected String getBrowserEventType() { + return BrowserEvents.KEYUP; + } + +} diff --git a/client/src/com/vaadin/client/ui/grid/events/HeaderKeyDownHandler.java b/client/src/com/vaadin/client/ui/grid/events/HeaderKeyDownHandler.java new file mode 100644 index 0000000000..a19bfad6bf --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/HeaderKeyDownHandler.java @@ -0,0 +1,28 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyDownHandler; + +/** + * Handler for {@link GridKeyDownEvent}s that happen when active cell is in the + * header of the Grid. + * + * @since + * @author Vaadin Ltd + */ +public interface HeaderKeyDownHandler extends GridKeyDownHandler { +} diff --git a/client/src/com/vaadin/client/ui/grid/events/HeaderKeyPressHandler.java b/client/src/com/vaadin/client/ui/grid/events/HeaderKeyPressHandler.java new file mode 100644 index 0000000000..1188dc9b3e --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/HeaderKeyPressHandler.java @@ -0,0 +1,28 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyPressHandler; + +/** + * Handler for {@link GridKeyPressEvent}s that happen when active cell is in the + * header of the Grid. + * + * @since + * @author Vaadin Ltd + */ +public interface HeaderKeyPressHandler extends GridKeyPressHandler { +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/events/HeaderKeyUpHandler.java b/client/src/com/vaadin/client/ui/grid/events/HeaderKeyUpHandler.java new file mode 100644 index 0000000000..3a8bc3e78a --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/HeaderKeyUpHandler.java @@ -0,0 +1,28 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.vaadin.client.ui.grid.events.AbstractGridKeyEventHandler.GridKeyUpHandler; + +/** + * Handler for {@link GridKeyUpEvent}s that happen when active cell is in the + * header of the Grid. + * + * @since + * @author Vaadin Ltd + */ +public interface HeaderKeyUpHandler extends GridKeyUpHandler { +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/events/ScrollEvent.java b/client/src/com/vaadin/client/ui/grid/events/ScrollEvent.java new file mode 100644 index 0000000000..751823f9a5 --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/ScrollEvent.java @@ -0,0 +1,39 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * An event that signifies that a scrollbar bundle has been scrolled + * + * @author Vaadin Ltd + */ +public class ScrollEvent extends GwtEvent { + + /** The type of this event */ + public static final Type TYPE = new Type(); + + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(final ScrollHandler handler) { + handler.onScroll(this); + } +} diff --git a/client/src/com/vaadin/client/ui/grid/events/ScrollHandler.java b/client/src/com/vaadin/client/ui/grid/events/ScrollHandler.java new file mode 100644 index 0000000000..473b18071a --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/events/ScrollHandler.java @@ -0,0 +1,34 @@ +/* + * 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 + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui.grid.events; + +import com.google.gwt.event.shared.EventHandler; + +/** + * A handler that gets called whenever a scrollbar bundle is scrolled + * + * @author Vaadin Ltd + */ +public interface ScrollHandler extends EventHandler { + /** + * A callback method that is called once a scrollbar bundle has been + * scrolled. + * + * @param event + * the scroll event + */ + public void onScroll(ScrollEvent event); +} diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/AbstractGridKeyEventHandler.java b/client/src/com/vaadin/client/ui/grid/keyevents/AbstractGridKeyEventHandler.java deleted file mode 100644 index 57708e8bc9..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/AbstractGridKeyEventHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.google.gwt.event.shared.EventHandler; -import com.vaadin.client.ui.grid.Grid.AbstractGridKeyEvent; - -/** - * Base interface of all handlers for {@link AbstractGridKeyEvent}s. - * - * @since - * @author Vaadin Ltd - */ -public abstract interface AbstractGridKeyEventHandler extends EventHandler { - - public abstract interface GridKeyDownHandler extends - AbstractGridKeyEventHandler { - public void onKeyDown(GridKeyDownEvent event); - } - - public abstract interface GridKeyUpHandler extends - AbstractGridKeyEventHandler { - public void onKeyUp(GridKeyUpEvent event); - } - - public abstract interface GridKeyPressHandler extends - AbstractGridKeyEventHandler { - public void onKeyPress(GridKeyPressEvent event); - } - -} diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/BodyKeyDownHandler.java b/client/src/com/vaadin/client/ui/grid/keyevents/BodyKeyDownHandler.java deleted file mode 100644 index 9e61624a28..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/BodyKeyDownHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyDownHandler; - -/** - * Handler for {@link GridKeyDownEvent}s that happen when active cell is in the - * body of the Grid. - * - * @since - * @author Vaadin Ltd - */ -public interface BodyKeyDownHandler extends GridKeyDownHandler { -} diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/BodyKeyPressHandler.java b/client/src/com/vaadin/client/ui/grid/keyevents/BodyKeyPressHandler.java deleted file mode 100644 index f44c1d172e..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/BodyKeyPressHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyPressHandler; - -/** - * Handler for {@link GridKeyPressEvent}s that happen when active cell is in the - * body of the Grid. - * - * @since - * @author Vaadin Ltd - */ -public interface BodyKeyPressHandler extends GridKeyPressHandler { -} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/BodyKeyUpHandler.java b/client/src/com/vaadin/client/ui/grid/keyevents/BodyKeyUpHandler.java deleted file mode 100644 index a6b3929d80..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/BodyKeyUpHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyUpHandler; - -/** - * Handler for {@link GridKeyUpEvent}s that happen when active cell is in the - * body of the Grid. - * - * @since - * @author Vaadin Ltd - */ -public interface BodyKeyUpHandler extends GridKeyUpHandler { -} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/FooterKeyDownHandler.java b/client/src/com/vaadin/client/ui/grid/keyevents/FooterKeyDownHandler.java deleted file mode 100644 index 5e9fffdcda..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/FooterKeyDownHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyDownHandler; - -/** - * Handler for {@link GridKeyDownEvent}s that happen when active cell is in the - * footer of the Grid. - * - * @since - * @author Vaadin Ltd - */ -public interface FooterKeyDownHandler extends GridKeyDownHandler { -} diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/FooterKeyPressHandler.java b/client/src/com/vaadin/client/ui/grid/keyevents/FooterKeyPressHandler.java deleted file mode 100644 index d5713d9135..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/FooterKeyPressHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyPressHandler; - -/** - * Handler for {@link GridKeyPressEvent}s that happen when active cell is in the - * footer of the Grid. - * - * @since - * @author Vaadin Ltd - */ -public interface FooterKeyPressHandler extends GridKeyPressHandler { -} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/FooterKeyUpHandler.java b/client/src/com/vaadin/client/ui/grid/keyevents/FooterKeyUpHandler.java deleted file mode 100644 index 87978e1cd2..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/FooterKeyUpHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyUpHandler; - -/** - * Handler for {@link GridKeyUpEvent}s that happen when active cell is in the - * footer of the Grid. - * - * @since - * @author Vaadin Ltd - */ -public interface FooterKeyUpHandler extends GridKeyUpHandler { -} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/GridKeyDownEvent.java b/client/src/com/vaadin/client/ui/grid/keyevents/GridKeyDownEvent.java deleted file mode 100644 index 65c8327eb6..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/GridKeyDownEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.google.gwt.dom.client.BrowserEvents; -import com.vaadin.client.ui.grid.Grid; -import com.vaadin.client.ui.grid.Grid.AbstractGridKeyEvent; -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyDownHandler; - -/** - * Represents native key down event in Grid. - * - * @since - * @author Vaadin Ltd - */ -public class GridKeyDownEvent extends AbstractGridKeyEvent { - - public GridKeyDownEvent(Grid grid) { - super(grid); - } - - @Override - protected void dispatch(GridKeyDownHandler handler) { - super.dispatch(handler); - if ((activeSection == GridSection.BODY && handler instanceof BodyKeyDownHandler) - || (activeSection == GridSection.HEADER && handler instanceof HeaderKeyDownHandler) - || (activeSection == GridSection.FOOTER && handler instanceof FooterKeyDownHandler)) { - handler.onKeyDown(this); - } - } - - @Override - protected String getBrowserEventType() { - return BrowserEvents.KEYDOWN; - } - -} diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/GridKeyPressEvent.java b/client/src/com/vaadin/client/ui/grid/keyevents/GridKeyPressEvent.java deleted file mode 100644 index 388467990b..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/GridKeyPressEvent.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.google.gwt.dom.client.BrowserEvents; -import com.vaadin.client.ui.grid.Grid; -import com.vaadin.client.ui.grid.Grid.AbstractGridKeyEvent; -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyPressHandler; - -/** - * Represents native key press event in Grid. - * - * @since - * @author Vaadin Ltd - */ -public class GridKeyPressEvent extends - AbstractGridKeyEvent { - - public GridKeyPressEvent(Grid grid) { - super(grid); - } - - @Override - protected void dispatch(GridKeyPressHandler handler) { - super.dispatch(handler); - if ((activeSection == GridSection.BODY && handler instanceof BodyKeyPressHandler) - || (activeSection == GridSection.HEADER && handler instanceof HeaderKeyPressHandler) - || (activeSection == GridSection.FOOTER && handler instanceof FooterKeyPressHandler)) { - handler.onKeyPress(this); - } - } - - @Override - protected String getBrowserEventType() { - return BrowserEvents.KEYPRESS; - } - -} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/GridKeyUpEvent.java b/client/src/com/vaadin/client/ui/grid/keyevents/GridKeyUpEvent.java deleted file mode 100644 index dd1fb33e3f..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/GridKeyUpEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.google.gwt.dom.client.BrowserEvents; -import com.vaadin.client.ui.grid.Grid; -import com.vaadin.client.ui.grid.Grid.AbstractGridKeyEvent; -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyUpHandler; - -/** - * Represents native key up event in Grid. - * - * @since - * @author Vaadin Ltd - */ -public class GridKeyUpEvent extends AbstractGridKeyEvent { - - public GridKeyUpEvent(Grid grid) { - super(grid); - } - - @Override - protected void dispatch(GridKeyUpHandler handler) { - super.dispatch(handler); - if ((activeSection == GridSection.BODY && handler instanceof BodyKeyUpHandler) - || (activeSection == GridSection.HEADER && handler instanceof HeaderKeyUpHandler) - || (activeSection == GridSection.FOOTER && handler instanceof FooterKeyUpHandler)) { - handler.onKeyUp(this); - } - } - - @Override - protected String getBrowserEventType() { - return BrowserEvents.KEYUP; - } - -} diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/HeaderKeyDownHandler.java b/client/src/com/vaadin/client/ui/grid/keyevents/HeaderKeyDownHandler.java deleted file mode 100644 index d8a1132a84..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/HeaderKeyDownHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyDownHandler; - -/** - * Handler for {@link GridKeyDownEvent}s that happen when active cell is in the - * header of the Grid. - * - * @since - * @author Vaadin Ltd - */ -public interface HeaderKeyDownHandler extends GridKeyDownHandler { -} diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/HeaderKeyPressHandler.java b/client/src/com/vaadin/client/ui/grid/keyevents/HeaderKeyPressHandler.java deleted file mode 100644 index a2245b1dfe..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/HeaderKeyPressHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyPressHandler; - -/** - * Handler for {@link GridKeyPressEvent}s that happen when active cell is in the - * header of the Grid. - * - * @since - * @author Vaadin Ltd - */ -public interface HeaderKeyPressHandler extends GridKeyPressHandler { -} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/keyevents/HeaderKeyUpHandler.java b/client/src/com/vaadin/client/ui/grid/keyevents/HeaderKeyUpHandler.java deleted file mode 100644 index 405195ec94..0000000000 --- a/client/src/com/vaadin/client/ui/grid/keyevents/HeaderKeyUpHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.ui.grid.keyevents; - -import com.vaadin.client.ui.grid.keyevents.AbstractGridKeyEventHandler.GridKeyUpHandler; - -/** - * Handler for {@link GridKeyUpEvent}s that happen when active cell is in the - * header of the Grid. - * - * @since - * @author Vaadin Ltd - */ -public interface HeaderKeyUpHandler extends GridKeyUpHandler { -} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/grid/selection/MultiSelectionRenderer.java b/client/src/com/vaadin/client/ui/grid/selection/MultiSelectionRenderer.java index bfcc639a64..222c8ab806 100644 --- a/client/src/com/vaadin/client/ui/grid/selection/MultiSelectionRenderer.java +++ b/client/src/com/vaadin/client/ui/grid/selection/MultiSelectionRenderer.java @@ -41,10 +41,10 @@ import com.vaadin.client.ui.grid.DataAvailableEvent; import com.vaadin.client.ui.grid.DataAvailableHandler; import com.vaadin.client.ui.grid.FlyweightCell; import com.vaadin.client.ui.grid.Grid; -import com.vaadin.client.ui.grid.keyevents.BodyKeyDownHandler; -import com.vaadin.client.ui.grid.keyevents.BodyKeyUpHandler; -import com.vaadin.client.ui.grid.keyevents.GridKeyDownEvent; -import com.vaadin.client.ui.grid.keyevents.GridKeyUpEvent; +import com.vaadin.client.ui.grid.events.BodyKeyDownHandler; +import com.vaadin.client.ui.grid.events.BodyKeyUpHandler; +import com.vaadin.client.ui.grid.events.GridKeyDownEvent; +import com.vaadin.client.ui.grid.events.GridKeyUpEvent; import com.vaadin.client.ui.grid.renderers.ComplexRenderer; import com.vaadin.client.ui.grid.selection.SelectionModel.Multi.Batched; import com.vaadin.shared.ui.grid.ScrollDestination; diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java index 1bdbd76a20..14388aec6e 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java @@ -23,8 +23,10 @@ import java.util.Random; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.Label; import com.vaadin.client.ui.VLabel; import com.vaadin.client.ui.grid.Cell; import com.vaadin.client.ui.grid.FlyweightCell; @@ -39,18 +41,20 @@ import com.vaadin.client.ui.grid.GridHeader.HeaderRow; import com.vaadin.client.ui.grid.Renderer; import com.vaadin.client.ui.grid.datasources.ListDataSource; import com.vaadin.client.ui.grid.datasources.ListSorter; -import com.vaadin.client.ui.grid.keyevents.BodyKeyDownHandler; -import com.vaadin.client.ui.grid.keyevents.BodyKeyPressHandler; -import com.vaadin.client.ui.grid.keyevents.BodyKeyUpHandler; -import com.vaadin.client.ui.grid.keyevents.FooterKeyDownHandler; -import com.vaadin.client.ui.grid.keyevents.FooterKeyPressHandler; -import com.vaadin.client.ui.grid.keyevents.FooterKeyUpHandler; -import com.vaadin.client.ui.grid.keyevents.GridKeyDownEvent; -import com.vaadin.client.ui.grid.keyevents.GridKeyPressEvent; -import com.vaadin.client.ui.grid.keyevents.GridKeyUpEvent; -import com.vaadin.client.ui.grid.keyevents.HeaderKeyDownHandler; -import com.vaadin.client.ui.grid.keyevents.HeaderKeyPressHandler; -import com.vaadin.client.ui.grid.keyevents.HeaderKeyUpHandler; +import com.vaadin.client.ui.grid.events.BodyKeyDownHandler; +import com.vaadin.client.ui.grid.events.BodyKeyPressHandler; +import com.vaadin.client.ui.grid.events.BodyKeyUpHandler; +import com.vaadin.client.ui.grid.events.FooterKeyDownHandler; +import com.vaadin.client.ui.grid.events.FooterKeyPressHandler; +import com.vaadin.client.ui.grid.events.FooterKeyUpHandler; +import com.vaadin.client.ui.grid.events.GridKeyDownEvent; +import com.vaadin.client.ui.grid.events.GridKeyPressEvent; +import com.vaadin.client.ui.grid.events.GridKeyUpEvent; +import com.vaadin.client.ui.grid.events.HeaderKeyDownHandler; +import com.vaadin.client.ui.grid.events.HeaderKeyPressHandler; +import com.vaadin.client.ui.grid.events.HeaderKeyUpHandler; +import com.vaadin.client.ui.grid.events.ScrollEvent; +import com.vaadin.client.ui.grid.events.ScrollHandler; import com.vaadin.client.ui.grid.renderers.DateRenderer; import com.vaadin.client.ui.grid.renderers.HtmlRenderer; import com.vaadin.client.ui.grid.renderers.NumberRenderer; @@ -249,6 +253,7 @@ public class GridBasicClientFeaturesWidget extends createColumnsMenu(); createHeaderMenu(); createFooterMenu(); + createInternalsMenu(); grid.getElement().getStyle().setZIndex(0); addNorth(grid, 400); @@ -256,6 +261,32 @@ public class GridBasicClientFeaturesWidget extends createKeyHandlers(); } + private void createInternalsMenu() { + String[] listenersPath = { "Component", "Internals", "Listeners" }; + final Label label = new Label(); + addSouth(label, 20); + + addMenuCommand("Add scroll listener", new ScheduledCommand() { + private HandlerRegistration scrollHandler = null; + + @Override + public void execute() { + if (scrollHandler != null) { + return; + } + scrollHandler = grid.addScrollHandler(new ScrollHandler() { + @Override + public void onScroll(ScrollEvent event) { + @SuppressWarnings("hiding") + final Grid grid = (Grid) event.getSource(); + label.setText("scrollTop: " + grid.getScrollTop() + + ", scrollLeft: " + grid.getScrollLeft()); + } + }); + } + }, listenersPath); + } + private void createStateMenu() { String[] selectionModePath = { "Component", "State", "Selection mode" }; String[] primaryStyleNamePath = { "Component", "State",