@Override
 public void init(FMLInitializationEvent e) {
   System.out.println("[Realms of Chaos] Registering Renderers");
   Renderers.init();
 }
Esempio n. 2
0
  public Dashboard loadDashboard(
      String wcdfPath,
      boolean debug,
      boolean absolute,
      String scheme,
      String absRoot,
      boolean bypassCache,
      String alias)
      throws FileNotFoundException {

    String dashboardPath = getDashboardPath(wcdfPath);
    IPentahoSession userSession = PentahoSessionHolder.getSession();
    XmlStructure structure = new XmlStructure(userSession);
    Dashboard dashboard = null;
    WcdfDescriptor wcdf = null;
    DashboardCacheKey key;
    /*
     * First we must figure out what dashboard we should
     * be handling. We do this by loading up its wcdf
     * descriptor.
     */
    try {
      if (!wcdfPath.isEmpty() && wcdfPath.endsWith(".wcdf")) {
        wcdf = structure.loadWcdfDescriptor(wcdfPath);
      } else {
        /* We didn't receive a valid path. We're in preview mode.
         * TODO: Support mobile preview mode (must remove dependency on setStyle())
         */
        wcdf = new WcdfDescriptor();
        if (wcdfPath != null && wcdfPath.endsWith(".cdfde")) {
          wcdf.setWcdfPath(wcdfPath);
        }
        wcdf.setStyle(CdfStyles.DEFAULTSTYLE);
        wcdf.setRendererType(Renderers.BLUEPRINT.toString());
        bypassCache = true; // no cache for preview
      }
    } catch (IOException ioe) {
      logger.error(ioe);
      return null;
    }

    /* Next, if we're using the cache, we try to find
     * the dashboard in there.
     */
    key =
        new DashboardCacheKey(
            dashboardPath, CdfStyles.getInstance().getResourceLocation(wcdf.getStyle()), debug);
    key.setAbs(absolute);
    key.setRoot(scheme, absRoot);
    if (!bypassCache) {
      dashboard = getDashboardFromCache(key);
    }

    /* If it's not there, or we're bypassing the cache,
     * we load it up, and cache the newly loaded dashboard.
     */
    if (dashboard == null) {
      Cache cache = getCache();
      try {
        switch (Renderers.valueOf(wcdf.getRendererType().toUpperCase())) {
          case MOBILE:
            dashboard = new MobileDashboard(wcdf, absolute, absRoot, debug, scheme);
            break;

            /* Until we consider it safe to assume that all dashboards have
             * their renderer type correctly identified, we'll have to default
             * to assuming they're blueprint-style dashboards.
             */
          case BLUEPRINT:
          default:
            if (wcdf.isWidget()) {
              dashboard = new BlueprintWidget(wcdf, absolute, absRoot, debug, scheme, alias);
            } else {
              dashboard = new BlueprintDashboard(wcdf, absolute, absRoot, debug, scheme);
            }
            break;
        }
      } catch (IllegalArgumentException e) {
        logger.error("Bad renderer type: " + wcdf.getRendererType());
        return null;
      }
      cache.put(new Element(key, dashboard));
    }
    return dashboard;
  }