KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > forms > formmodel > RowAction


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.forms.formmodel;
17
18 import java.util.Locale JavaDoc;
19
20 import org.xml.sax.ContentHandler JavaDoc;
21 import org.xml.sax.SAXException JavaDoc;
22
23 /**
24  *
25  * @author <a HREF="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
26  * @version $Id: RowAction.java 151179 2005-02-03 16:55:16Z tim $
27  */

28 public class RowAction extends Action {
29     public RowAction(RowActionDefinition definition) {
30         super(definition);
31     }
32     
33     public static class MoveUpAction extends RowAction {
34         public MoveUpAction(RowActionDefinition.MoveUpDefinition definition) {
35             super(definition);
36         }
37
38         public void generateSaxFragment(ContentHandler JavaDoc contentHandler, Locale JavaDoc locale) throws SAXException JavaDoc {
39             
40             // Only generate if we're not at the top
41
Repeater.RepeaterRow row = Repeater.getParentRow(this);
42             if (((Repeater)row.getParent()).indexOf(row) > 0) {
43                 super.generateSaxFragment(contentHandler, locale);
44             }
45         }
46     }
47
48     public static class MoveDownAction extends RowAction {
49         public MoveDownAction(RowActionDefinition.MoveDownDefinition definition) {
50             super(definition);
51         }
52
53         public void generateSaxFragment(ContentHandler JavaDoc contentHandler, Locale JavaDoc locale) throws SAXException JavaDoc {
54             
55             // Only generate if we're not at the bottom
56
Repeater.RepeaterRow row = Repeater.getParentRow(this);
57             Repeater repeater = (Repeater)row.getParent();
58             
59             if (repeater.indexOf(row) < repeater.getSize() - 1) {
60                 super.generateSaxFragment(contentHandler, locale);
61             }
62         }
63     }
64 }
65
66
Popular Tags