private void prepareHelpSection(SectionStack stack, ServerPlugin plugin) { if (plugin.getHelp() != null && plugin.getHelp().length() > 0) { SectionStackSection section = new SectionStackSection(MSG.common_title_help()); section.setExpanded(true); Label help = new Label(plugin.getHelp()); section.setItems(help); helpSection = section; } ++initSectionCount; return; }
@Override protected LocatableVLayout defaultView() { LocatableVLayout vLayout = new LocatableVLayout(this.extendLocatorId("Default")); vLayout.setWidth100(); // TODO: Help icon. TitleBar titleBar = new TitleBar(this, MSG.common_title_help()); vLayout.addMember(titleBar); Label label = new Label(MSG.view_helpTop_description()); label.setPadding(10); vLayout.addMember(label); return vLayout; }
/** * The Help top-level view. * * @author Jay Shaughnessy */ public class HelpView extends AbstractSectionedLeftNavigationView { public static final ViewName VIEW_ID = new ViewName("Help", MSG.common_title_help()); private static final ViewName SECTION_PRODUCT_VIEW_ID = new ViewName("Product", MSG.view_help_section_product()); private final ProductInfo productInfo = CoreGUI.get().getProductInfo(); private final MessageConstants messageConstants = CoreGUI.getMessageConstants(); private boolean contentFromProductInfo; public HelpView() { // This is a top level view, so our locator id can simply be our view id. super(VIEW_ID.getName()); } @Override protected List<NavigationSection> getNavigationSections() { List<NavigationSection> sections = new ArrayList<NavigationSection>(); NavigationSection docSection = buildProductSection(); sections.add(docSection); addUrlSections(sections); return sections; } @Override protected LocatableVLayout defaultView() { LocatableVLayout vLayout = new LocatableVLayout(this.extendLocatorId("Default")); vLayout.setWidth100(); // TODO: Help icon. TitleBar titleBar = new TitleBar(this, MSG.common_title_help()); vLayout.addMember(titleBar); Label label = new Label(MSG.view_helpTop_description()); label.setPadding(10); vLayout.addMember(label); return vLayout; } private NavigationSection buildProductSection() { NavigationItem aboutItem = new NavigationItem( new ViewName("AboutBox", MSG.view_help_section_product_about()), "[SKIN]/../actions/help.png", new ViewFactory() { public Canvas createView() { final AboutModalWindow aboutModalWindow = new AboutModalWindow(extendLocatorId("AboutModalWindow")); aboutModalWindow.setTitle(MSG.view_aboutBox_title(productInfo.getFullName())); aboutModalWindow.show(); return aboutModalWindow; } }); aboutItem.setRefreshRequired(true); return new NavigationSection(SECTION_PRODUCT_VIEW_ID, aboutItem); } private void addUrlSections(List<NavigationSection> sections) { this.selectContentLocation(); int numSections = Integer.valueOf(this.getContent("view_help_section_count")); for (int i = 1; i <= numSections; ++i) { int numItems = Integer.valueOf(this.getContent("view_help_section_" + i + "_item_count")); NavigationItem[] items = new NavigationItem[numItems]; String sectionTitle = this.getContent("view_help_section_" + i + "_title"); for (int j = 1; j <= numItems; ++j) { String title = this.getContent("view_help_section_" + i + "_propTitle_" + j); final String url = this.getContent("view_help_section_" + i + "_propUrl_" + j); String icon; try { icon = this.getContent("view_help_section_" + i + "_propIcon_" + j); if (icon == null) { icon = "[SKIN]/../headerIcons/document.png"; } } catch (MissingResourceException e) { icon = "[SKIN]/../headerIcons/document.png"; } final String itemName = "Section" + i + "Item" + j; NavigationItem item = new NavigationItem( new ViewName(itemName, title), icon, new ViewFactory() { public Canvas createView() { return new FullHTMLPane(extendLocatorId(itemName), url); } }); items[j - 1] = item; } NavigationSection section = new NavigationSection(new ViewName("Section" + i, sectionTitle), items); sections.add(section); } } /** * Preselects content location. * * <p>I18N GWT bakes all the messages into the compiled Javascript (it is impossible to change * anything without recompiling the entire project). However, there is a need to dynamically * change the help content after the code is compiled and shipped. ProductInfo is dynamically * loaded at runtime from disk. This implementation allows runtime location selection for help * page content: 1) ProductInfo 2) I18N GWT system * * <p>NOTE: All the content is loaded from a single location and production info properties file * gets priority. */ private void selectContentLocation() { if (productInfo.getHelpViewContent().containsKey("view_help_section_count")) { // use the product info file for help content this.contentFromProductInfo = true; } else { // use the I18N mechanism for help content this.contentFromProductInfo = false; } } /** * Retrieves help view content from the selected content location. * * @return help view content */ private String getContent(String key) { if (this.contentFromProductInfo) { return productInfo.getHelpViewContent().get(key); } else { return messageConstants.getString(key); } } }