Dynamic table actions

Hi

I want that context menu actions change depending on the selected values. AFAIK actions are got when row is painted. I want to change only actions of those selected rows, but the other rows’ actions remain as it were.

I’ve tried to repaint the table, but in that case no actions are shown.

Is there a way to force those selected rows or even all the rows.

Thanks

Try using ContextMenu add-on with ItemClickListener.
i.e.

final ContextMenu menu = new ContextMenu();
// Generate main level items
ContextMenuItem photos = menu.addItem("Photos");final ContextMenuItem albums = menu.addItem("Albums");
final ContextMenuItem report = menu.addItem("Report");
table.addListener(new ItemClickEvent.ItemClickListener() {
			private static final long serialVersionUID = 1L;

			@Override
			public void itemClick(ItemClickEvent event) {
				if(event.getButton() == ItemClickEvent.BUTTON_RIGHT) {
					if(!VaadinApplication.this.getSelectedItemIds(table).contains(event.getItemId()))
						//also handle right click item selection if item not already selected via simple/multi select
                                                table.setValue(null);
						table.select(event.getItemId());
					if(VaadinApplication.this.countSelectedItems(table) == 1){
						albums.setEnabled(true);	
						report.setEnabled(true);
					}
					else if(VaadinApplication.this.countSelectedItems(table) > 1) {
						albums.setEnabled(false);	
						report.setEnabled(false);
					} else if (VaadinApplication.this.countSelectedItems(table) == 0) {
					}
					menu.show(event.getClientX(), event.getClientY());
				}
			}
		});

private int countSelectedItems(Table t) {
		if(t.isMultiSelect()) {
			final Set<Object> s = (Set<Object>) t.getValue();
			return s.size();
		}
		
		return t.getValue() != null ? 1 : 0;
	}
	
private Set<Object> getSelectedItemIds(Table t) {
			return (Set<Object>) t.getValue();
	}

ContextMenu is not popping up for me when show() is invoked. Did you have to do anything else than what is in the above code fragment to make it show up for a Table?
Thanks

Try Application.getMainWindow.addComponent(menu);