Package freenet.pluginmanager

Examples of freenet.pluginmanager.FredPluginL10n


              isSelected = true;
            } else {
              sublistItem = subnavlist.addChild("li", "class", "submenuitem-not-selected");
            }
           
            FredPluginL10n l10n = menu.navigationLinkL10n.get(navigationLink);
            if(l10n == null) l10n = menu.plugin;
            if(l10n != null) {
              // From a plugin. Include the plugin name in the id.
              sublistItem.addAttribute("id", getPluginL10nCSSIdentifier(l10n, navigationTitle));

              if(navigationTitle != null) {
                String newNavigationTitle = l10n.getString(navigationTitle);
                if(newNavigationTitle == null) {
                  Logger.error(this, "Plugin '"+l10n+"' did return null in getString(key)!");
                } else {
                  navigationTitle = newNavigationTitle;
                }
              }
              if(navigationLink != null) {
                String newNavigationLink = l10n.getString(navigationLink);
                if(newNavigationLink == null) {
                  Logger.error(this, "Plugin '"+l10n+"' did return null in getString(key)!");
                } else {
                  navigationLink = newNavigationLink;
                }
              }
            } else {
              // Not from a plugin. Add the localization key as id.
              sublistItem.addAttribute("id", filterCSSIdentifier(navigationTitle));

              if(navigationTitle != null) navigationTitle = NodeL10n.getBase().getString(navigationTitle);
              if(navigationLink != null) navigationLink = NodeL10n.getBase().getString(navigationLink);
            }
            if(navigationTitle != null)
              sublistItem.addChild("a", new String[] { "href", "title" }, new String[] { navigationPath, navigationTitle }, navigationLink);
            else
              sublistItem.addChild("a", "href", navigationPath, navigationLink);
          }
          if(nonEmpty) {
            HTMLNode listItem;
            if(isSelected) {
              selected = menu;
              subnavlist.addAttribute("class", "subnavlist-selected");
              listItem = new HTMLNode("li", "class", "navlist-selected");
            } else {
              subnavlist.addAttribute("class", "subnavlist");
              listItem = new HTMLNode("li", "class", "navlist-not-selected");
            }
            String menuItemTitle = menu.defaultNavigationLinkTitle;
            String text = menu.navigationLinkText;
            if(menu.plugin == null) {
              // Not from a plugin. Add the localization key as id.
              listItem.addAttribute("id", filterCSSIdentifier(menuItemTitle));

              menuItemTitle = NodeL10n.getBase().getString(menuItemTitle);
              text = NodeL10n.getBase().getString(text);
            } else {
              /*
               * From a plugin. Include the plugin name in the id.
               *
               * Note that a plugin could misbehave and fail to register its
               * menu with proper localization keys.
               */
              listItem.addAttribute("id", getPluginL10nCSSIdentifier(menu.plugin, text));

              String newTitle = menu.plugin.getString(menuItemTitle);
              if(newTitle == null) {
                Logger.error(this, "Plugin '"+menu.plugin+"' did return null in getString(key)!");
              } else {
                menuItemTitle = newTitle;
              }
              String newText = menu.plugin.getString(text);
              if(newText == null) {
                Logger.error(this, "Plugin '"+menu.plugin+"' did return null in getString(key)!");
              } else {
                text = newText;
              }
            }
           
            listItem.addChild("a", new String[] { "href", "title" }, new String[] { menu.defaultNavigationLink, menuItemTitle }, text);
            listItem.addChild(subnavlist);
            navbarUl.addChild(listItem);
          }
        }
      }
      // Some themes want the selected submenu separately.
      if(selected != null) {
        HTMLNode div = new HTMLNode("div", "id", "selected-subnavbar");
        HTMLNode subnavlist = div.addChild("ul", "id", "selected-subnavbar-list");
        boolean nonEmpty = false;
        for (String navigationLink :  fullAccess ? selected.navigationLinkTexts : selected.navigationLinkTextsNonFull) {
          LinkEnabledCallback cb = selected.navigationLinkCallbacks.get(navigationLink);
          if(cb != null && !cb.isEnabled(ctx)) continue;
          nonEmpty = true;
          String navigationTitle = selected.navigationLinkTitles.get(navigationLink);
          String navigationPath = selected.navigationLinks.get(navigationLink);
          HTMLNode sublistItem;
          if(activePath.equals(navigationPath)) {
            sublistItem = subnavlist.addChild("li", "class", "submenuitem-selected");
          } else {
            sublistItem = subnavlist.addChild("li", "class", "submenuitem-not-selected");
          }
         
          FredPluginL10n l10n = selected.navigationLinkL10n.get(navigationLink);
          if (l10n == null) l10n = selected.plugin;
          if(l10n != null) {
            if(navigationTitle != null) navigationTitle = l10n.getString(navigationTitle);
            if(navigationLink != null) navigationLink = l10n.getString(navigationLink);
          } else {
            if(navigationTitle != null) navigationTitle = NodeL10n.getBase().getString(navigationTitle);
            if(navigationLink != null) navigationLink = NodeL10n.getBase().getString(navigationLink);
          }
          if(navigationTitle != null)
View Full Code Here

TOP

Related Classes of freenet.pluginmanager.FredPluginL10n

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.