KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > woody > formmodel > RowActionDefinition


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.woody.formmodel;
17
18 import org.apache.cocoon.woody.event.ActionEvent;
19 import org.apache.cocoon.woody.event.ActionListener;
20
21 /**
22  *
23  * @author <a HREF="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
24  * @version CVS $Id: RowActionDefinition.java 30932 2004-07-29 17:35:38Z vgritsenko $
25  */

26 public class RowActionDefinition extends ActionDefinition {
27     
28     public Widget createInstance() {
29         return new RowAction(this);
30     }
31     
32     public static class DeleteRowDefinition extends RowActionDefinition {
33         public DeleteRowDefinition() {
34             super.addActionListener(new ActionListener() {
35
36                 public void actionPerformed(ActionEvent event) {
37                     Repeater.RepeaterRow row = Repeater.getParentRow(event.getSourceWidget());
38                     Repeater repeater = (Repeater)row.getParent();
39                     repeater.removeRow(repeater.indexOf(row));
40                 }
41             });
42         }
43     }
44     
45     public static class MoveUpDefinition extends RowActionDefinition {
46         public MoveUpDefinition() {
47             super.addActionListener(new ActionListener() {
48
49                 public void actionPerformed(ActionEvent event) {
50                     Repeater.RepeaterRow row = Repeater.getParentRow(event.getSourceWidget());
51                     Repeater repeater = (Repeater)row.getParent();
52                     // Rotation: up in a table is left in a list!
53
repeater.moveRowLeft(repeater.indexOf(row));
54                 }
55             });
56         }
57     }
58     
59     public static class MoveDownDefinition extends RowActionDefinition {
60         public MoveDownDefinition() {
61             super.addActionListener(new ActionListener() {
62
63                 public void actionPerformed(ActionEvent event) {
64                     Repeater.RepeaterRow row = Repeater.getParentRow(event.getSourceWidget());
65                     Repeater repeater = (Repeater)row.getParent();
66                     // Rotation : down in a table is right in a list!
67
repeater.moveRowRight(repeater.indexOf(row));
68                 }
69             });
70         }
71     }
72     
73     public static class AddAfterDefinition extends RowActionDefinition {
74         public AddAfterDefinition() {
75             super.addActionListener(new ActionListener() {
76
77                 public void actionPerformed(ActionEvent event) {
78                     Repeater.RepeaterRow row = Repeater.getParentRow(event.getSourceWidget());
79                     Repeater repeater = (Repeater)row.getParent();
80                     repeater.addRow(repeater.indexOf(row)+1);
81                 }
82             });
83         }
84     }
85
86
87 }
88
Popular Tags