1 16 package org.apache.cocoon.forms.formmodel; 17 18 import org.apache.cocoon.forms.event.ActionEvent; 19 import org.apache.cocoon.forms.event.ActionListener; 20 21 26 public class RowActionDefinition extends ActionDefinition { 27 28 public Widget createInstance() { 29 return new RowAction(this); 30 } 31 32 36 public static class DeleteRowDefinition extends RowActionDefinition { 37 38 public boolean hasActionListeners() { 39 return true; 41 } 42 43 public void fireActionEvent(ActionEvent event) { 44 super.fireActionEvent(event); 46 47 Repeater.RepeaterRow row = Repeater.getParentRow(event.getSourceWidget()); 49 Repeater repeater = (Repeater)row.getParent(); 50 repeater.removeRow(repeater.indexOf(row)); 51 } 52 } 53 54 58 public static class MoveUpDefinition extends RowActionDefinition { 59 public MoveUpDefinition() { 60 super.addActionListener(new ActionListener() { 61 62 public void actionPerformed(ActionEvent event) { 63 Repeater.RepeaterRow row = Repeater.getParentRow(event.getSourceWidget()); 64 Repeater repeater = (Repeater)row.getParent(); 65 repeater.moveRowLeft(repeater.indexOf(row)); 67 } 68 }); 69 } 70 } 71 72 76 public static class MoveDownDefinition extends RowActionDefinition { 77 public MoveDownDefinition() { 78 super.addActionListener(new ActionListener() { 79 80 public void actionPerformed(ActionEvent event) { 81 Repeater.RepeaterRow row = Repeater.getParentRow(event.getSourceWidget()); 82 Repeater repeater = (Repeater)row.getParent(); 83 repeater.moveRowRight(repeater.indexOf(row)); 85 } 86 }); 87 } 88 } 89 90 94 public static class AddAfterDefinition extends RowActionDefinition { 95 public AddAfterDefinition() { 96 super.addActionListener(new ActionListener() { 97 98 public void actionPerformed(ActionEvent event) { 99 Repeater.RepeaterRow row = Repeater.getParentRow(event.getSourceWidget()); 100 Repeater repeater = (Repeater)row.getParent(); 101 repeater.addRow(repeater.indexOf(row)+1); 102 } 103 }); 104 } 105 } 106 } 107 | Popular Tags |