summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-01-09 14:55:13 +0200
committerVaadin Code Review <review@vaadin.com>2015-01-14 10:25:13 +0000
commit35372dc1d3ede9d2005ac8bda5d5a7e4f3aba98d (patch)
tree9a387eeef20e858d9d586c7c02141f6273277945 /server
parentdcfebeb46143d8e9c21424c572c48d2217c80477 (diff)
downloadvaadin-framework-35372dc1d3ede9d2005ac8bda5d5a7e4f3aba98d.tar.gz
vaadin-framework-35372dc1d3ede9d2005ac8bda5d5a7e4f3aba98d.zip
Add ItemClickEvents to Grid (#15449)
Change-Id: I743f4de9fd11c5d81b11a3b8f2e0957293c5587c
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/ui/Grid.java41
1 files changed, 40 insertions, 1 deletions
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java
index 0843fb6ec1..443e51fba3 100644
--- a/server/src/com/vaadin/ui/Grid.java
+++ b/server/src/com/vaadin/ui/Grid.java
@@ -56,6 +56,9 @@ import com.vaadin.data.sort.SortOrder;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.data.util.converter.ConverterUtil;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.event.ItemClickEvent.ItemClickNotifier;
import com.vaadin.event.SelectionEvent;
import com.vaadin.event.SelectionEvent.SelectionListener;
import com.vaadin.event.SelectionEvent.SelectionNotifier;
@@ -68,11 +71,13 @@ import com.vaadin.server.ErrorMessage;
import com.vaadin.server.JsonCodec;
import com.vaadin.server.KeyMapper;
import com.vaadin.server.VaadinSession;
+import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.data.sort.SortDirection;
import com.vaadin.shared.ui.grid.EditorClientRpc;
import com.vaadin.shared.ui.grid.EditorServerRpc;
import com.vaadin.shared.ui.grid.GridClientRpc;
import com.vaadin.shared.ui.grid.GridColumnState;
+import com.vaadin.shared.ui.grid.GridConstants;
import com.vaadin.shared.ui.grid.GridServerRpc;
import com.vaadin.shared.ui.grid.GridState;
import com.vaadin.shared.ui.grid.GridState.SharedSelectionMode;
@@ -155,7 +160,7 @@ import elemental.json.JsonValue;
* @author Vaadin Ltd
*/
public class Grid extends AbstractComponent implements SelectionNotifier,
- SortNotifier, SelectiveRenderer {
+ SortNotifier, SelectiveRenderer, ItemClickNotifier {
/**
* Custom field group that allows finding property types before an item has
@@ -2712,6 +2717,16 @@ public class Grid extends AbstractComponent implements SelectionNotifier,
((SelectionModel.Multi) getSelectionModel()).selectAll();
}
+
+ @Override
+ public void itemClick(String rowKey, String columnId,
+ MouseEventDetails details) {
+ Object itemId = getKeyMapper().getItemId(rowKey);
+ Item item = datasource.getItem(itemId);
+ Object propertyId = getPropertyIdByColumnId(columnId);
+ fireEvent(new ItemClickEvent(Grid.this, item, itemId,
+ propertyId, details));
+ }
});
registerRpc(new EditorServerRpc() {
@@ -4524,4 +4539,28 @@ public class Grid extends AbstractComponent implements SelectionNotifier,
public void setEditorFieldFactory(FieldGroupFieldFactory fieldFactory) {
editorFieldGroup.setFieldFactory(fieldFactory);
}
+
+ @Override
+ public void addItemClickListener(ItemClickListener listener) {
+ addListener(GridConstants.ITEM_CLICK_EVENT_ID, ItemClickEvent.class,
+ listener, ItemClickEvent.ITEM_CLICK_METHOD);
+ }
+
+ @Override
+ @Deprecated
+ public void addListener(ItemClickListener listener) {
+ addItemClickListener(listener);
+ }
+
+ @Override
+ public void removeItemClickListener(ItemClickListener listener) {
+ removeListener(GridConstants.ITEM_CLICK_EVENT_ID, ItemClickEvent.class,
+ listener);
+ }
+
+ @Override
+ @Deprecated
+ public void removeListener(ItemClickListener listener) {
+ removeItemClickListener(listener);
+ }
}