View Javadoc

1   package net.sourceforge.blogentis.utils.tools;
2   
3   //-----------------------------------------------------------------------
4   //Blogentis - a blog publishing platform.
5   //Copyright (C) 2004 Tassos Bassoukos <abassouk@gmail.com>
6   //
7   //This library is free software; you can redistribute it and/or
8   //modify it under the terms of the GNU Lesser General Public
9   //License as published by the Free Software Foundation; either
10  //version 2.1 of the License, or (at your option) any later version.
11  //
12  //This library is distributed in the hope that it will be useful,
13  //but WITHOUT ANY WARRANTY; without even the implied warranty of
14  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  //Lesser General Public License for more details.
16  //
17  //You should have received a copy of the GNU Lesser General Public
18  //License along with this library; if not, write to the Free Software
19  //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  //-----------------------------------------------------------------------
21  //
22  //$Id: NavigationListTool.java,v 1.1 2004/10/22 17:34:15 tassos Exp $
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 }