1 package net.sourceforge.blogentis.utils.tools;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import java.util.ArrayList;
26 import java.util.Collections;
27 import java.util.List;
28
29 import net.sourceforge.blogentis.plugins.BlogPluginService;
30 import net.sourceforge.blogentis.plugins.base.INavigationExtensionPoint;
31 import net.sourceforge.blogentis.turbine.BlogRunData;
32 import net.sourceforge.blogentis.turbine.BlogRunDataService;
33
34 import org.apache.turbine.services.pull.ApplicationTool;
35
36 /***
37 * Velocity tool to help with locating navigation lists. This is a per-request
38 * tool, keeping track of all the navigations that should be presented to the
39 * user.
40 *
41 * @author abas
42 */
43 public class NavigationListTool
44 implements ApplicationTool {
45 protected List navs = new ArrayList(10);
46
47 public static class Stripe {
48 String cssName;
49 String listName;
50 String templateName;
51
52 public String getCssName() {
53 return cssName;
54 }
55
56 public String getListName() {
57 return listName;
58 }
59
60 public String getTemplateName() {
61 return templateName;
62 }
63
64 Stripe(String cssName, String listName, String templateName) {
65 this.cssName = cssName;
66 this.listName = listName;
67 this.templateName = templateName;
68 }
69
70 Stripe(String cssName, String listName) {
71 this(cssName, listName, null);
72 }
73 }
74
75 public void init(Object data) {
76 navs.clear();
77 }
78
79 public void refresh() {
80 navs.clear();
81 }
82
83 public List getNav(String navName) {
84 BlogRunData data = BlogRunDataService.getCurrentRunData();
85 INavigationExtensionPoint inep = (INavigationExtensionPoint)BlogPluginService
86 .locateExtensionPoint(data.getBlog(),
87 INavigationExtensionPoint.class);
88 if (inep == null || navName == null)
89 return Collections.EMPTY_LIST;
90 return inep.buildNavigationList(data, navName);
91 }
92
93 public String addStripe(String cssName, String listName, String templateName) {
94 navs.add(new Stripe(cssName, listName, templateName));
95 return "";
96 }
97
98 public String addStripe(String cssName, String listName) {
99 navs.add(new Stripe(cssName, listName));
100 return "";
101 }
102
103 public List getStripes() {
104 return navs;
105 }
106 }