Package com.adaptrex.core.config

Examples of com.adaptrex.core.config.AdaptrexConfig


  public Adaptrex() {
    //System.out.println("Initializing Adaptrex");
  }
 
  private void initConfig() {
    config = new AdaptrexConfig();
  }
View Full Code Here


  @Override
    public void encodeBegin(FacesContext context) throws IOException {
      try {
      Adaptrex adaptrex = Adaptrex.getAdaptrex();
     
      AdaptrexConfig config = adaptrex.getConfig();
          Map<String,Object> tagAttr = getAttributes();
       
      String contextPath = context.getExternalContext().getRequestContextPath();
      if (contextPath.isEmpty()) contextPath = "/";

      /*
       * Weblib path
       */
      String weblibPath = (String) tagAttr.get(AdaptrexConfig.WEBLIB);
      if (weblibPath == null) weblibPath = config.get(AdaptrexConfig.WEBLIB);
     
          /*
           * Read and configure ext path and build information
           */
      String extVersion = (String) tagAttr.get(AdaptrexConfig.EXT_VERSION);
      if (extVersion == null) extVersion = config.get(AdaptrexConfig.EXT_VERSION);
     
      String extBuild = (String) tagAttr.get(AdaptrexConfig.EXT_BUILD);
      if (extBuild == null) extBuild = config.get(AdaptrexConfig.EXT_BUILD, "production");     
     
      String extPath = (String) tagAttr.get(AdaptrexConfig.EXT_PATH);       
      if (extPath == null) extPath = config.get(AdaptrexConfig.EXT_PATH);
      if (extPath == null) {
        if (extVersion != null) {
          extPath = weblibPath + "/extjs-" + extVersion + "/ext" + (extBuild.equals("production") ? "" : "-" + extBuild) + ".js";
        }
      }
     
      /*
       * Write ext bootstrap code
       */
      if (extPath != null) {
        write("<script type='text/javascript' src='" + contextPath + extPath + "'></script>");
        String extFolder = extPath.substring(0, extPath.lastIndexOf("/"));
       
        String theme = (String) tagAttr.get(AdaptrexConfig.EXT_THEME);
        if (theme == null) theme = config.get(AdaptrexConfig.EXT_THEME, "all");
        if (!theme.contains("/")) {
          theme = extFolder + "/resources/css/ext-" + theme + ".css";
        }
       
        write("<link rel='stylesheet' type='text/css' href='" + contextPath + theme + "' />");
       
            if (theme.contains("neptune")) {
            write("<script type='text/javascript' src='" + contextPath + extFolder + "/ext-neptune.js'></script>");
          }
           
            /*
             * Bootstrap Ext classes we need for adaptrex stores and models
             */
            write ("<script type='text/javascript' src='" + contextPath + weblibPath + "/adaptrex-bootstrap-ext-" + extVersion + ".js'></script>");
      }

         
          /*
           * Set up adaptrex loader if we're in debug mode
           */
      String adaptrexFolder = contextPath + weblibPath + "/adaptrexjs";
      write("<script type='text/javascript' src='" + adaptrexFolder + "/adaptrex.js'></script>");
      write("<script type='text/javascript'>Adaptrex.Context={path:'" + contextPath + "'}</script>");
      if (config.get(AdaptrexConfig.DEBUG).equals("true")) {
        write("<script type='text/javascript'>" +
            "Ext.Loader.setPath('Adaptrex', '" + adaptrexFolder + "/src')</script>");
      }
     
          /*
           * Set up namespace
           */
          String namespace = (String) tagAttr.get(AdaptrexConfig.EXT_NAMESPACE);
      if (namespace == null) namespace = (String) tagAttr.get("ns");
      if (namespace == null) namespace = (String) tagAttr.get("namespace");
      if (namespace == null) namespace = config.get(AdaptrexConfig.EXT_NAMESPACE);
          if (namespace != null) {
            setAttribute("namespace", namespace);
            write("<script type='text/javascript'>Ext.ns('" + namespace + "')</script>");
          }
     
View Full Code Here

  @Override
    public void encodeBegin(FacesContext context) throws IOException {
      try {
      Adaptrex adaptrex = Adaptrex.getAdaptrex();
     
      AdaptrexConfig config = adaptrex.getConfig();
          Map<String,Object> tagAttr = getAttributes();
     
          /*
           * Read ext build configuration
           */
      String extBuild = (String) tagAttr.get(AdaptrexConfig.EXT_BUILD);
      if (extBuild == null) extBuild = config.get(AdaptrexConfig.EXT_BUILD, "production");     
     
      write("<script type='text/javascript' src='app" + (extBuild.equals("production") ? "-all" : "") + ".js'></script>");
     
      } catch (Exception e) {
        log.warn("Error", e);
View Full Code Here

  @Override
    public void encodeBegin(FacesContext context) throws IOException {
      try {
          Map<String,Object> a = getAttributes();
          ContextConfig contextConfig = CdiService.getContextConfig();
          AdaptrexConfig adaptrexConfig = CdiService.getAdaptrexConfig();
         
          Map<String,Object> extConfig = new HashMap<String,Object>();
          if (adaptrexConfig.get("ext") != null) {
            extConfig.putAll((Map<String,Object>) adaptrexConfig.get("ext"));
          }
          if (contextConfig.get("ext") != null) {
            extConfig.putAll((Map<String,Object>) contextConfig.get("ext"));
          }
         
View Full Code Here

  private static ObjectMapper mapper;
  private static ObjectWriter writer;
  public static String json(Object object) {
    if (mapper == null) mapper = new ObjectMapper();
    try {
      AdaptrexConfig config = CdiService.getAdaptrexConfig();
      if (config.get("debug") != null && (Boolean) config.get("debug")) {
        if (writer == null) {
          writer = mapper.writerWithDefaultPrettyPrinter();
        }
        return writer.writeValueAsString(object);
      } else {
View Full Code Here

  public Adaptrex() {
    //System.out.println("Initializing Adaptrex");
  }
 
  private void initConfig() {
    config = new AdaptrexConfig();
  }
View Full Code Here

  @Override
    public void encodeBegin(FacesContext context) throws IOException {
      try {
      Adaptrex adaptrex = Adaptrex.getAdaptrex();
     
      AdaptrexConfig config = adaptrex.getConfig();
          Map<String,Object> tagAttr = getAttributes();
       
      String contextPath = context.getExternalContext().getRequestContextPath();
      if (contextPath.isEmpty()) contextPath = "/";

      /*
       * Weblib path
       */
      String weblibPath = (String) tagAttr.get(AdaptrexConfig.WEBLIB);
      if (weblibPath == null) weblibPath = config.get(AdaptrexConfig.WEBLIB);
     
          /*
           * If we're configuring Ext, do it here
           */
      String extBuild = (String) tagAttr.get(AdaptrexConfig.EXT_BUILD);
      if (extBuild == null) extBuild = config.get(AdaptrexConfig.EXT_BUILD, "production");     
     
     
      String extPath = (String) tagAttr.get(AdaptrexConfig.EXT_PATH);       
      if (extPath == null) extPath = config.get(AdaptrexConfig.EXT_PATH);
      if (extPath == null) {
        String extVersion = (String) tagAttr.get(AdaptrexConfig.EXT_VERSION);
        if (extVersion == null) extVersion = config.get(AdaptrexConfig.EXT_VERSION);
       
        if (extVersion != null) {
          extPath = weblibPath + "/extjs-" + extVersion + "/ext" + (extBuild.equals("production") ? "" : "-" + extBuild) + ".js";
        }
      }
     
      if (extPath != null) {
        write("<script type='text/javascript' src='" + contextPath + extPath + "'></script>");
        String extFolder = extPath.substring(0, extPath.lastIndexOf("/"));
       
        String theme = (String) tagAttr.get(AdaptrexConfig.EXT_THEME);
        if (theme == null) theme = config.get(AdaptrexConfig.EXT_THEME, "all");
        if (!theme.contains("/")) {
          theme = extFolder + "/resources/css/ext-" + theme + ".css";
        }
       
        write("<link rel='stylesheet' type='text/css' href='" + contextPath + theme + "' />");
       
            if (theme.contains("neptune")) {
            write("<script type='text/javascript' src='" + contextPath + extFolder + "/ext-neptune.js'></script>");
          }
       
         if (!extBuild.equals("production")) {
          write("<script type='text/javascript' src='app.js'></script>");
         }       
      }

         
         
              /*
               * Set up adaptrex loader if we're in debug mode
               */
          String adaptrexFolder = contextPath + weblibPath + "/adaptrexjs";
          write("<script type='text/javascript' src='" + adaptrexFolder + "/adaptrex.js'></script>");
          write("<script type='text/javascript'>Adaptrex.Context={path:'" + contextPath + "'}</script>");
          if (config.get(AdaptrexConfig.DEBUG).equals("true")) {
            write("<script type='text/javascript'>" +
                "Ext.Loader.setPath('Adaptrex', '" + adaptrexFolder + "/src')</script>");
          }

//
//         if (tagAttr.get("touch") != null) {
//           setAttribute("touch", Boolean.parseBoolean((String) tagAttr.get("touch")));
//         } else {
//           setAttribute("touch", false);
//         }

     
          /*
           * Set up namespace
           */
          String namespace = (String) tagAttr.get(AdaptrexConfig.EXT_NAMESPACE);
      if (namespace == null) namespace = (String) tagAttr.get("ns");
      if (namespace == null) namespace = (String) tagAttr.get("namespace");
      if (namespace == null) namespace = config.get(AdaptrexConfig.EXT_NAMESPACE);
          if (namespace != null) {
            setAttribute("namespace", namespace);
          }
     
      } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.adaptrex.core.config.AdaptrexConfig

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.