use of com.vaadin.event.ContextClickEvent in project VaadinUtils by rlsutton1.
the class GridContextMenu method setAsGridContextMenu.
/**
* Assigns this as the context menu of given table. Allows context menu to
* appear only on certain parts of the table.
*
* @param table
* @param onRow
* show context menu when row is clicked
* @param onHeader
* show context menu when header is clicked
* @param onFooter
* show context menu when footer is clicked
*/
public void setAsGridContextMenu(final Grid grid, final boolean onRow, final boolean onHeader, final boolean onFooter) {
this.grid = grid;
extend(grid);
setOpenAutomatically(false);
grid.addContextClickListener(new ContextClickListener() {
private static final long serialVersionUID = -2197393292360426242L;
@Override
public void contextClick(ContextClickEvent event) {
if (!(event instanceof GridContextClickEvent)) {
return;
}
final GridContextClickEvent e = (GridContextClickEvent) event;
switch(e.getSection()) {
case BODY:
if (onRow) {
openContext(e);
}
break;
case FOOTER:
if (onFooter) {
openContext(e);
}
break;
case HEADER:
if (onHeader) {
openContext(e);
}
break;
default:
break;
}
}
});
}
use of com.vaadin.event.ContextClickEvent in project VaadinUtils by rlsutton1.
the class TreeContextMenu method setAsTreeContextMenu.
@Override
public void setAsTreeContextMenu(final Tree tree) {
this.tree = tree;
extend(tree);
setOpenAutomatically(false);
tree.addContextClickListener(new ContextClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void contextClick(ContextClickEvent event) {
if (event.getButton() == MouseButton.RIGHT) {
openContext((TreeContextClickEvent) event);
open(event.getClientX(), event.getClientY());
}
}
});
}
use of com.vaadin.event.ContextClickEvent in project VaadinUtils by rlsutton1.
the class ButtonContextMenu method setAsButtonContextMenu.
/**
* Assigns this as the context menu of a button.
*/
public void setAsButtonContextMenu(final Button button, final E targetEntity) {
this.targetEntity = targetEntity;
extend(button);
setOpenAutomatically(false);
button.addContextClickListener(new ContextClickListener() {
private static final long serialVersionUID = 4777762727944373063L;
@Override
public void contextClick(ContextClickEvent event) {
openContext(event.getClientX(), event.getClientY());
}
});
}
Aggregations