Im trying to create a Table with Vaadin where you have different options in the context menu depending on if you have selected a single row or multiple rows.
It took me a while to do this but now i have a working solution. The problem is that is feel that its not good coding practice and I would gladly take any advice in how to perhaps split my "function" into smaller classes or functions. Could I perhaps create a standalone Action class?. Feel free to comment and advice and please do note that I just started with Vaadin =) !
Table contactList = new Table("Test table");
3 contactList.addListener(new Property.ValueChangeListener(){
4 public void valueChange(ValueChangeEvent event){
5 Set<?> value = (Set<?>) event.getProperty().getValue();
6 if(value == null || value.size() == 0){
7 getMainWindow().showNotification("NULL or 0");
8 }else if(value.size() == 1){
9 contactList.removeAllActionHandlers();
10 contactList.addActionHandler(new Action.Handler(){
11 public Action[] getActions(Object target, Object sender){
12 return ACTIONS_EDIT;
13 }
14 public void handleAction(Action action, Object sender, Object target){
15 getMainWindow().showNotification("ACTION_EDIT");
16 }
17 });
18 }else{
19 contactList.removeAllActionHandlers();
20 contactList.addActionHandler(new Action.Handler(){
21 public Action[] getActions(Object target, Object sender){
22 return ACTIONS_EDIT_ALL;
23 }
24 public void handleAction(Action action, Object sender, Object target){
25 getMainWindow().showNotification("ACTION_EDIT_ALL");
26 }
27 });
28 }
29 }
30 });
Thx for any help! /Marthin