1 11 package org.eclipse.help.internal.webapp.data; 12 13 import java.util.ArrayList ; 14 15 import javax.servlet.*; 16 import javax.servlet.http.*; 17 18 import org.eclipse.help.internal.HelpPlugin; 19 import org.eclipse.help.internal.base.*; 20 21 public class LayoutData extends RequestData { 22 23 private String query = ""; private View[] views; 25 26 public LayoutData(ServletContext context, HttpServletRequest request, 27 HttpServletResponse response) { 28 super(context, request, response); 29 30 String qs = request.getQueryString(); 32 if (qs != null && qs.length() > 0) 33 query = "?" + qs; } 35 36 public String getQuery() { 37 return query; 38 } 39 40 public String getBannerURL() { 41 String banner = preferences.getBanner(); 42 if (banner == null || banner.trim().length() == 0) { 43 banner = "about:blank"; } else if (banner.startsWith("http:/") || banner.startsWith("https:/")) { } else if (banner.startsWith("file:/") || banner.startsWith("jar:file:/")) { banner = "topic/" + banner; } else { 48 banner = "topic" + banner; } 50 return banner; 51 } 52 53 public String getBannerHeight() { 54 String height = preferences.getBannerHeight(); 55 if (height == null || height.length() == 0) { 56 height = "0"; } 58 return height; 59 } 60 61 public String getContentURL() { 62 String topicHref = request.getParameter("topic"); if (topicHref == null || topicHref.length() == 0) { 64 return UrlUtil.getHelpURL(preferences.getHelpHome()); 65 } 66 else { 67 TocData tocData = new TocData(context, request, response); 68 String topic = tocData.getSelectedTopic(); 69 return topic != null ? topic : UrlUtil.getHelpURL(preferences.getHelpHome()); 70 } 71 } 72 73 76 public View[] getViews() { 77 if (views != null) 78 return views; 79 80 View tocview = new View("toc", "", preferences.getImagesDirectory() + "/contents_view.gif", 'C', !HelpPlugin.getTocManager().isTocLoaded(getLocale())); View indexview = null; 84 View searchview = new View("search", "", preferences.getImagesDirectory() + "/search_results_view.gif", 'R', false); View linksview = null; 88 View bookmarksview = null; 89 90 if (preferences.isIndexView()) 91 indexview = new View("index", "", preferences.getImagesDirectory() + "/index_view.gif", 'I', false); if (preferences.isLinksView()) 95 linksview = new View("links", "", preferences.getImagesDirectory() + "/links_view.gif", (char)0, false); if (preferences.isBookmarksView()) 99 bookmarksview = new View("bookmarks", "", preferences.getImagesDirectory() + "/bookmarks_view.gif", (char)0, false); 103 ArrayList viewList = new ArrayList (); 104 viewList.add(tocview); 105 if (indexview != null) { 106 viewList.add(indexview); 107 } 108 viewList.add(searchview); 109 if (linksview != null) { 110 viewList.add(linksview); 111 } 112 if (bookmarksview !=null) { 113 viewList.add(bookmarksview); 114 } 115 116 views = (View[]) viewList.toArray(new View[viewList.size()]); 117 return views; 118 } 119 120 public String getVisibleView() { 121 String requestedView = request.getParameter("tab"); View[] allViews = getViews(); 123 for (int i = 0; i < allViews.length; i++) { 124 if (allViews[i].getName().equals(requestedView)) { 125 return requestedView; 126 } 127 } 128 return "toc"; } 130 131 public View getCurrentView() { 132 String name = request.getParameter("view"); views = getViews(); 134 for (int i = 0; i < views.length; i++) 135 if (views[i].getName().equals(name)) 136 return views[i]; 137 return null; 138 } 139 public String getWindowTitle() { 140 if (preferences.isWindowTitlePrefix()) { 141 return ServletResources.getString("browserTitle", BaseHelpSystem.getProductName(), request); 143 } 144 return BaseHelpSystem.getProductName(); 145 } 146 } 147 | Popular Tags |