diff options
Diffstat (limited to 'server/src/com/vaadin/ui/Grid.java')
-rw-r--r-- | server/src/com/vaadin/ui/Grid.java | 82 |
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() { |