KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > portalImpl > aggregation > navigation > TabNavigation


1 /*
2  * Copyright 2003,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 /*
17
18  */

19
20 package org.apache.pluto.portalImpl.aggregation.navigation;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.List JavaDoc;
25
26 import javax.servlet.ServletConfig JavaDoc;
27
28 import org.apache.pluto.portalImpl.core.PortalURL;
29
30 public class TabNavigation extends AbstractNavigationFragment {
31
32     public TabNavigation(String JavaDoc id,
33                          ServletConfig JavaDoc config,
34                          org.apache.pluto.portalImpl.aggregation.Fragment parent,
35                          org.apache.pluto.portalImpl.om.page.Fragment fragDesc,
36                          org.apache.pluto.portalImpl.aggregation.navigation.Navigation navigation)
37     throws Exception JavaDoc
38     {
39         super(id, config, parent, fragDesc, navigation);
40     }
41
42     public NavigationTreeBean[] getNavigationView(PortalURL url) {
43         List JavaDoc result = new ArrayList JavaDoc();
44         for (Iterator JavaDoc it = getRootNavigation().getChildren().iterator(); it.hasNext();) {
45             Navigation child = (Navigation) it.next();
46             walkTree(child, url , result, 0);
47         }
48         return(NavigationTreeBean[]) result.toArray(new NavigationTreeBean[0]);
49     }
50
51     private static void walkTree(Navigation nav, PortalURL url, List JavaDoc path, int depth)
52     {
53         if (url.isPartOfGlobalNavigation(nav.getLinkedFragment().getId())) {
54             path.add(new NavigationTreeBean(nav, true, depth));
55             for (Iterator JavaDoc it = nav.getChildren().iterator(); it.hasNext();) {
56                 Navigation child = (Navigation) it.next();
57                 walkTree(child, url, path, depth+1);
58             }
59         } else {
60             path.add(new NavigationTreeBean(nav, false, depth));
61         }
62     }
63
64
65 }
66
Popular Tags