summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-09-29 13:59:06 +0300
committerHenri Sara <hesara@vaadin.com>2015-10-05 07:38:40 +0000
commitdd029323df6d7ec11b85716601ad9c446c720602 (patch)
tree729230f82ed9a672416a1e9c50926fcf4ab670b9 /server
parenta97534f4c2588e68ecc2584d77db482a5277d599 (diff)
downloadvaadin-framework-dd029323df6d7ec11b85716601ad9c446c720602.tar.gz
vaadin-framework-dd029323df6d7ec11b85716601ad9c446c720602.zip
Add GridContextClickEvent with item ids, properties and section (#16855)
Change-Id: I03091a3a7a22a921c127ed0b37fe792871ba5edd
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/ui/Grid.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java
index 469f85d947..f0e7b664e0 100644
--- a/server/src/com/vaadin/ui/Grid.java
+++ b/server/src/com/vaadin/ui/Grid.java
@@ -68,6 +68,7 @@ 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.ContextClickEvent;
import com.vaadin.event.ItemClickEvent;
import com.vaadin.event.ItemClickEvent.ItemClickListener;
import com.vaadin.event.ItemClickEvent.ItemClickNotifier;
@@ -92,6 +93,7 @@ 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.GridConstants.Section;
import com.vaadin.shared.ui.grid.GridServerRpc;
import com.vaadin.shared.ui.grid.GridState;
import com.vaadin.shared.ui.grid.GridStaticCellType;
@@ -386,6 +388,73 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
}
/**
+ * ContextClickEvent for the Grid Component.
+ *
+ * @since
+ */
+ public static class GridContextClickEvent extends ContextClickEvent {
+
+ private final Object itemId;
+ private final int rowIndex;
+ private final Object propertyId;
+ private final Section section;
+
+ public GridContextClickEvent(Grid source,
+ MouseEventDetails mouseEventDetails, Section section,
+ int rowIndex, Object itemId, Object propertyId) {
+ super(source, mouseEventDetails);
+ this.itemId = itemId;
+ this.propertyId = propertyId;
+ this.section = section;
+ this.rowIndex = rowIndex;
+ }
+
+ /**
+ * Returns the item id of context clicked row.
+ *
+ * @return item id of clicked row; <code>null</code> if header or footer
+ */
+ public Object getItemId() {
+ return itemId;
+ }
+
+ /**
+ * Returns property id of clicked column.
+ *
+ * @return property id
+ */
+ public Object getPropertyId() {
+ return propertyId;
+ }
+
+ /**
+ * Return the clicked section of Grid.
+ *
+ * @return section of grid
+ */
+ public Section getSection() {
+ return section;
+ }
+
+ /**
+ * Returns the clicked row index relative to Grid section. In the body
+ * of the Grid the index is the item index in the Container. Header and
+ * Footer rows for index can be fetched with
+ * {@link Grid#getHeaderRow(int)} and {@link Grid#getFooterRow(int)}.
+ *
+ * @return row index in section
+ */
+ public int getRowIndex() {
+ return rowIndex;
+ }
+
+ @Override
+ public Grid getComponent() {
+ return (Grid) super.getComponent();
+ }
+ }
+
+ /**
* An event which is fired when saving the editor fails
*/
public static class CommitErrorEvent extends Component.Event {
@@ -4239,6 +4308,19 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
fireEvent(new EditorCloseEvent(Grid.this, getKeyMapper().get(
rowKey)));
}
+
+ @Override
+ public void contextClick(int rowIndex, String rowKey,
+ String columnId, Section section, MouseEventDetails details) {
+ Object itemId = null;
+ if (rowKey != null) {
+ itemId = getKeyMapper().get(rowKey);
+ }
+
+ fireEvent(new GridContextClickEvent(Grid.this, details,
+ section, rowIndex, itemId,
+ getPropertyIdByColumnId(columnId)));
+ }
});
registerRpc(new EditorServerRpc() {