KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > taglib > core > menu > context > ItemContainerSupport


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
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 com.blandware.atleap.webapp.taglib.core.menu.context;
17
18 import com.blandware.atleap.webapp.taglib.core.util.ContextMenuItem;
19
20 import javax.servlet.jsp.tagext.SimpleTagSupport JavaDoc;
21 import java.util.ArrayList JavaDoc;
22 import java.util.List JavaDoc;
23
24 /**
25  * <p>This class implements all common functionality of ItemContainer
26  * </p>
27  * <p><a HREF="ItemContainerSupport.java.htm"><i>View Source</i></a></p>
28  *
29  * @author Sergey Zubtcovskii <a HREF="mailto:sergey.zubtcovskii@blandware.com">&lt;sergey.zubtcovskii@blandware.com&gt;</a>
30  * @version $Revision: 1.2 $ $Date: 2005/09/21 13:46:05 $
31  */

32 public class ItemContainerSupport extends SimpleTagSupport JavaDoc implements ItemContainer {
33
34     // ~ Instance fields
35

36     /**
37      * List of items to include in menu. Each of them corresponds to row with
38      * its index. Each menu is a list of menu items.
39      */

40     protected List JavaDoc menus = new ArrayList JavaDoc();
41
42     /**
43      * Creates new instance of ContextMenuTag
44      */

45     public ItemContainerSupport() {
46     }
47
48     /**
49      * @see ItemContainer#storeItem(Integer, com.blandware.atleap.webapp.taglib.core.util.ContextMenuItem)
50      */

51     public void storeItem(Integer JavaDoc index, ContextMenuItem item) {
52         // firstly obtain (or create) menu for row with given index
53
List JavaDoc menu = new ArrayList JavaDoc();
54         int i = index.intValue();
55         if ( i < menus.size() ) {
56             menu = (List JavaDoc) menus.get(i);
57         }
58         // add item to that menu
59
menu.add(item);
60         // update (or add) that menu
61
if ( i < menus.size() ) {
62             menus.set(i, menu);
63         } else {
64             menus.add(menu);
65         }
66     }
67
68 }
69
Popular Tags