Exemplo n.º 1
0
  @Handler(
      id = "getPluginIdFromViewId",
      input = {@HandlerInput(name = "viewId", type = String.class, required = true)},
      output = {@HandlerOutput(name = "pluginId", type = String.class)})
  public static void getPluginIdFromViewId(HandlerContext handlerCtx) {
    String viewId = (String) handlerCtx.getInputValue("viewId");
    if (viewId == null) {
      return;
    }
    ConsolePluginService cps = getPluginService(handlerCtx.getFacesContext());
    String pluginId = "common";
    int next = viewId.indexOf("/", 1);
    if (next > -1) {
      pluginId = viewId.substring(0, next);
      String resource = viewId.substring(next);

      if (pluginId.startsWith("/")) {
        pluginId = pluginId.substring(1);
      }

      ClassLoader cl = cps.getModuleClassLoader(pluginId);
      URL url = null;
      if (cl != null) {
        url = cl.getResource(resource);
      }
      if (url == null) {
        pluginId = "common";
      }
    }
    handlerCtx.setOutputValue("pluginId", pluginId);
  }
Exemplo n.º 2
0
  @Handler(
      id = "calculateHelpUrl",
      input = {
        @HandlerInput(name = "pluginId", type = String.class, required = true),
        @HandlerInput(name = "helpKey", type = String.class, required = true)
      },
      output = {@HandlerOutput(name = "url", type = String.class)})
  public static void calculateHelpUrl(HandlerContext handlerCtx) {
    String pluginId = (String) handlerCtx.getInputValue("pluginId");
    String helpKey = (String) handlerCtx.getInputValue("helpKey");
    ConsolePluginService cps = getPluginService(handlerCtx.getFacesContext());

    ClassLoader cl = cps.getModuleClassLoader(pluginId);

    // Try the viewRoot locale first
    String path =
        getHelpPathForResource(helpKey, handlerCtx.getFacesContext().getViewRoot().getLocale(), cl);
    if (path == null) {
      // Try the default locale
      path = getHelpPathForResource(helpKey, Locale.getDefault(), cl);

      // Default to en
      if (path == null) {
        path = "/en/help/" + helpKey;
      }
    }

    handlerCtx.setOutputValue("url", path);
  }
Exemplo n.º 3
0
 /**
  * This handler returns a <code>Map&lt;String id, List&lt;URL&gt;&gt;</code> containing all the
  * matches of the requested resource. Each <code>List</code> in the <code>Map</code> is associated
  * with a GUI Plugin, and the key to the <code>Map</code> is the plugin id.
  *
  * @param handlerCtx The <code>HandlerContext</code>.
  */
 @Handler(
     id = "getPluginResources",
     input = {@HandlerInput(name = "name", type = String.class, required = true)},
     output = {@HandlerOutput(name = "resources", type = Map.class)})
 public static void getPluginResources(HandlerContext handlerCtx) {
   String name = (String) handlerCtx.getInputValue("name");
   ConsolePluginService cps = getPluginService(handlerCtx.getFacesContext());
   handlerCtx.setOutputValue("resources", cps.getResources(name));
 }