// Aaron's code -- to force the navigation tree to render fully expanded, and not offer links to non-leaf nodes
// todo this is pretty bad and should be replaced by a subclass of TabNavigation
// see http://svn.apache.org/repos/asf/portals/pluto/trunk/portal/src/java/org/apache/pluto/portalImpl/aggregation/navigation/
java.util.List list = new java.util.ArrayList();
java.util.Stack stack = new java.util.Stack();
Navigation root = fragment.getRootNavigation();
java.util.List childList = (java.util.List)root.getChildren();
java.util.Map map = new java.util.HashMap();
for(int i=childList.size()-1; i>=0; i--) {
stack.push(childList.get(i));
map.put(stack.peek(), new Integer(0));
}
while(!stack.isEmpty()) {
Navigation nav = (Navigation) stack.pop();
Integer depth = (Integer) map.get(nav);
list.add(new NavigationTreeBean(nav, nav.getChildren().size() > 0 || url.isPartOfGlobalNavigation(nav.getLinkedFragment().getId()), depth.intValue()));
childList = (java.util.List)nav.getChildren();
for(int i=childList.size()-1; i>=0; i--) {
stack.push(childList.get(i));
map.put(stack.peek(), new Integer(depth.intValue()+1));
}
}
tree = (NavigationTreeBean[]) list.toArray(new NavigationTreeBean[list.size()]);
// End Aaron's Code
for (int i=0; i<tree.length; i++) {
Navigation nav = tree[i].navigation;
String imageName = nav.getDescription();
int index = imageName.indexOf(" ");
if ((index == -1) || !imageName.substring(index-4, index).equals(GIF)) {
imageName = DEFAULT_GIF;
} else {
imageName = imageName.substring(0,index);
}
boolean partOfNav = tree[i].partOfGlobalNav;
if (tree[i].depth>0)
{
out.write("\n\t\t\t\t\t\t\t\t<tr><td><div class=\"Subselection\"><table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\"> \n <tr>\n <td class=\"Left\"> </td> \n <td class=\"Indent\"> </td> \n <td class=\"Middle\">\n");
for (int k=0; k<tree[i].depth; k++)
{
out.write("\n \t\t\t\t\t\t\t \n");
}
if (!partOfNav)
{
out.write("\n <a href=\"");
out.print(new PortalURL(request, nav.getLinkedFragment()).toString());
out.write("\"><img border=\"0\" src=\"");
out.print(request.getContextPath());
out.write("/images/");
out.print(imageName);
out.write("\"> ");
out.print(nav.getTitle());
out.write("</a>\n");
}
else
{
out.write(" <img border=\"0\" src=\"");
out.print(request.getContextPath());
out.write("/images/");
out.print(imageName);
out.write("\"> ");
out.print(nav.getTitle());
out.write('\n');
}
out.write("\n </td> \n <td class=\"Right\"> </td> \n </tr> \n\t\t\t\t\t\t\t\t</table></div></td></tr>\n");
}
else
{
out.write("\t\t\t\t\t\t\n\t\t\n \t\t\t\t\t\t<tr><td><div class=\"Selection\"><table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\">\n <tr>\n\t\t\t\t\t\t\t <td class=\"CollapsedLeft\"> </td>\n\t\t\t\t\t\t\t\t<td class=\"Indent\"> </td>\n\t\t\t\t\t\t\t <td class=\"TopMiddle\">\n");
if (!partOfNav)
{
out.write(" <a href=\"");
out.print(new PortalURL(request, nav.getLinkedFragment()).toString());
out.write("\"><img border=\"0\" src=\"");
out.print(request.getContextPath());
out.write("/images/");
out.print(imageName);
out.write("\"> ");
out.print(nav.getTitle());
out.write("</a>\n");
}
else
{
out.write(" <img border=\"0\" src=\"");
out.print(request.getContextPath());
out.write("/images/");
out.print(imageName);
out.write("\"> ");
out.print(nav.getTitle());
out.write('\n');
}
out.write("\n \t\t\t\t\t\t\t \n\t \t\t\t\t\t\t </td>\n <td class=\"CollapsedRight\"> </td> \n </tr>\n\t\t\t\t\t\t</table></div></td></tr>\n");