01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.woody.formmodel;
18:
19: import org.apache.cocoon.woody.event.ActionEvent;
20: import org.apache.cocoon.woody.event.ActionListener;
21:
22: /**
23: *
24: * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
25: * @version CVS $Id: RowActionDefinition.java 433543 2006-08-22 06:22:54Z crossley $
26: */
27: public class RowActionDefinition extends ActionDefinition {
28:
29: public Widget createInstance() {
30: return new RowAction(this );
31: }
32:
33: public static class DeleteRowDefinition extends RowActionDefinition {
34: public DeleteRowDefinition() {
35: super .addActionListener(new ActionListener() {
36:
37: public void actionPerformed(ActionEvent event) {
38: Repeater.RepeaterRow row = Repeater
39: .getParentRow(event.getSourceWidget());
40: Repeater repeater = (Repeater) row.getParent();
41: repeater.removeRow(repeater.indexOf(row));
42: }
43: });
44: }
45: }
46:
47: public static class MoveUpDefinition extends RowActionDefinition {
48: public MoveUpDefinition() {
49: super .addActionListener(new ActionListener() {
50:
51: public void actionPerformed(ActionEvent event) {
52: Repeater.RepeaterRow row = Repeater
53: .getParentRow(event.getSourceWidget());
54: Repeater repeater = (Repeater) row.getParent();
55: // Rotation: up in a table is left in a list!
56: repeater.moveRowLeft(repeater.indexOf(row));
57: }
58: });
59: }
60: }
61:
62: public static class MoveDownDefinition extends RowActionDefinition {
63: public MoveDownDefinition() {
64: super .addActionListener(new ActionListener() {
65:
66: public void actionPerformed(ActionEvent event) {
67: Repeater.RepeaterRow row = Repeater
68: .getParentRow(event.getSourceWidget());
69: Repeater repeater = (Repeater) row.getParent();
70: // Rotation : down in a table is right in a list!
71: repeater.moveRowRight(repeater.indexOf(row));
72: }
73: });
74: }
75: }
76:
77: public static class AddAfterDefinition extends RowActionDefinition {
78: public AddAfterDefinition() {
79: super .addActionListener(new ActionListener() {
80:
81: public void actionPerformed(ActionEvent event) {
82: Repeater.RepeaterRow row = Repeater
83: .getParentRow(event.getSourceWidget());
84: Repeater repeater = (Repeater) row.getParent();
85: repeater.addRow(repeater.indexOf(row) + 1);
86: }
87: });
88: }
89: }
90:
91: }
|