Package org.bladerunnerjs.model

Examples of org.bladerunnerjs.model.AssetLocation


   
    try {
      List<Locale> supportedLocales = Arrays.asList(bundleSet.getBundlableNode().app().appConf().getLocales());
     
      for(Asset cssAsset : bundleSet.getResourceFiles(cssAssetPlugin)) {
        AssetLocation cssAssetLocation = cssAsset.assetLocation();
        String themeName = (cssAssetLocation instanceof ThemedAssetLocation) ? ((ThemedAssetLocation) cssAssetLocation).getThemeName() : "common";
       
        Locale assetLocale = Locale.createLocaleFromFilepath(".*_", cssAsset.getAssetName());
       
        if(assetLocale.isEmptyLocale()) {
View Full Code Here


    return seedAssetLocationDirectories;
  }
 
  @Override
  public AssetLocation createAssetLocation(AssetContainer assetContainer, String dirPath, Map<String, AssetLocation> assetLocationsMap) {
    AssetLocation assetLocation;
    File dir = assetContainer.file(dirPath);
   
    switch(dirPath) {
      case "resources":
        assetLocation = new ResourcesAssetLocation(assetContainer.root(), assetContainer, dir, assetLocationsMap.get("."));
        break;
     
      case "tests":
        assetLocation = new TestSourceAssetLocation(assetContainer.root(), assetContainer, dir, assetLocationsMap.get("."), assetLocationsMap.get("resources"), assetLocationsMap.get("src-test"));
        break;
     
      case "src-test":
        assetLocation = new SourceAssetLocation(assetContainer.root(), assetContainer, dir, assetLocationsMap.get("."));
        break;
     
      default:
        String parentLocationPath = RelativePathUtility.get(brjs.getFileInfoAccessor(), assetContainer.dir(), dir.getParentFile());
        AssetLocation parentAssetLocation = assetLocationsMap.get(parentLocationPath);
       
        if((parentAssetLocation instanceof ChildSourceAssetLocation) || (parentAssetLocation instanceof SourceAssetLocation)) {
          assetLocation = new ChildSourceAssetLocation(assetContainer.root(), assetContainer, dir, parentAssetLocation, parentAssetLocation);
        }
        else {
View Full Code Here

    return seedAssetLocationDirectories;
  }
 
  @Override
  public AssetLocation createAssetLocation(AssetContainer assetContainer, String dirPath, Map<String, AssetLocation> assetLocationsMap) {
    AssetLocation assetLocation;
    File dir = assetContainer.file(dirPath);
   
   
    switch(dirPath) {
      case ".":
        assetLocation = (assetContainer instanceof JsLib) ? new BRJSConformantJsLibRootAssetLocation(assetContainer.root(), assetContainer, dir, null) :
          new BRJSConformantRootAssetLocation(assetContainer.root(), assetContainer, dir, null);
        break;
     
      case "resources":
        if (assetContainer instanceof Blade) {
          assetLocation = new BladeResourcesAssetLocation(assetContainer.root(), assetContainer, dir, assetLocationsMap.get("."));
        } else {
          assetLocation = new ResourcesAssetLocation(assetContainer.root(), assetContainer, dir, assetLocationsMap.get("."));
        }
        break;
     
      case "src":
        assetLocation = new SourceAssetLocation(assetContainer.root(), assetContainer, dir, assetLocationsMap.get("."), assetLocationsMap.get("resources"));
        break;
     
      case "src-test":
        assetLocation = new SourceAssetLocation(assetContainer.root(), assetContainer, dir, assetLocationsMap.get("."));
        break;
     
      default:
        if(dirPath.startsWith("themes")){
         
          String themeName = dirPath.substring(7);
          assetLocation = new ResourcesAssetLocation(assetContainer.root(), assetContainer, dir, assetLocationsMap.get("."), themeName);
          break;
        }
       
        String parentLocationPath = RelativePathUtility.get(brjs.getFileInfoAccessor(), assetContainer.dir(), dir.getParentFile());
        AssetLocation parentAssetLocation = assetLocationsMap.get(parentLocationPath);
       
        if((parentAssetLocation instanceof ChildSourceAssetLocation) || (parentAssetLocation instanceof SourceAssetLocation)) {
          assetLocation = new ChildSourceAssetLocation(assetContainer.root(), assetContainer, dir, parentAssetLocation, parentAssetLocation);
        }
        else {
View Full Code Here

 
  private String getTargetPath(File imageFile) throws ContentProcessingException
  {

    Node firstAncestorNode = brjs.locateFirstAncestorNode(imageFile);
    AssetLocation assetLocation  = null;
    AssetContainer assetContainer = null;
    if (firstAncestorNode instanceof AssetLocation){
       assetLocation = (AssetLocation)firstAncestorNode;
       assetContainer = assetLocation.assetContainer();
    } else {
      assetContainer = (AssetContainer) firstAncestorNode;
      assetLocation = assetContainer.assetLocation(".");
    }
    String targetPath = null;
   
    File assetLocationParentDir = assetLocation.dir().getParentFile();
    BRJS root = assetContainer.root();
    try {
      if(assetContainer instanceof Aspect) {
        Aspect aspect = (Aspect) assetContainer;
        if (assetLocation instanceof ThemedAssetLocation && assetLocationParentDir.getName().equals("themes")) {
          ThemedAssetLocation theme = (ThemedAssetLocation) assetLocation;
          String resourcePath = RelativePathUtility.get(root.getFileInfoAccessor(), theme.dir(), imageFile);
          targetPath = cssResourceContentPathParser.createRequest(CssResourceContentPlugin.ASPECT_THEME_REQUEST, ((Aspect) assetContainer).getName(), theme.dir().getName(), resourcePath);
        } else {
          String resourcePath = RelativePathUtility.get(root.getFileInfoAccessor(), assetContainer.dir(), imageFile);
          targetPath = cssResourceContentPathParser.createRequest(CssResourceContentPlugin.ASPECT_RESOURCE_REQUEST, aspect.getName(), resourcePath);
        }
      }
      else if(assetContainer instanceof Bladeset) {
        Bladeset bladeset = (Bladeset) assetContainer;
        if (assetLocation instanceof ThemedAssetLocation && assetLocationParentDir.getName().equals("themes")) {
            ThemedAssetLocation theme = (ThemedAssetLocation) assetLocation;
            String resourcePath = RelativePathUtility.get(root.getFileInfoAccessor(), theme.dir(), imageFile);
           
            targetPath = cssResourceContentPathParser.createRequest(CssResourceContentPlugin.BLADESET_THEME_REQUEST, bladeset.getName(), theme.dir().getName(), resourcePath);
        } else {
          String resourcePath = RelativePathUtility.get(root.getFileInfoAccessor(), bladeset.dir(), imageFile);
          targetPath = cssResourceContentPathParser.createRequest(CssResourceContentPlugin.BLADESET_RESOURCE_REQUEST, bladeset.getName(), resourcePath);
        }
      }
      else if(assetContainer instanceof Blade) {
        Blade blade = (Blade) assetContainer;
        Bladeset bladeset = blade.parent();
        if (assetLocation instanceof ThemedAssetLocation && assetLocationParentDir.getName().equals("themes")) {
            ThemedAssetLocation theme = (ThemedAssetLocation) assetLocation;
            String resourcePath = RelativePathUtility.get(root.getFileInfoAccessor(), theme.dir(), imageFile);
           
            targetPath = cssResourceContentPathParser.createRequest(CssResourceContentPlugin.BLADE_THEME_REQUEST, bladeset.getName(), blade.getName(), theme.dir().getName(), resourcePath);
        } else {
          String resourcePath = RelativePathUtility.get(root.getFileInfoAccessor(), blade.dir(), imageFile);
          targetPath = cssResourceContentPathParser.createRequest(CssResourceContentPlugin.BLADE_RESOURCE_REQUEST, bladeset.getName(), blade.getName(), resourcePath);
        }
      }
      else if(assetContainer instanceof Workbench) {
        Workbench workbench = (Workbench) assetContainer;
        Blade blade = workbench.parent();
        Bladeset bladeset = blade.parent();
       
        if (assetLocation instanceof ThemedAssetLocation && assetLocationParentDir.getName().equals("themes")) {
          String resourcePath = RelativePathUtility.get(root.getFileInfoAccessor(), assetLocation.file("resources"), imageFile);
          targetPath = cssResourceContentPathParser.createRequest(CssResourceContentPlugin.WORKBENCH_RESOURCE_REQUEST, bladeset.getName(), blade.getName(), resourcePath);
        } else {
          String resourcePath = RelativePathUtility.get(root.getFileInfoAccessor(), workbench.dir(), imageFile);
          targetPath = cssResourceContentPathParser.createRequest(CssResourceContentPlugin.WORKBENCH_RESOURCE_REQUEST, bladeset.getName(), blade.getName(), resourcePath);
        }
View Full Code Here

    return verifierChainer;
  }
 
  public VerifierChainer sourceModuleHasAssetLocation(String sourceModulePath, String assetLocationPath) throws Exception {
    SourceModule sourceModule = (SourceModule)aspect.getLinkedAsset(sourceModulePath);
    AssetLocation assetLocation = aspect.assetLocation(assetLocationPath);
   
    assertEquals("Source module '" + sourceModulePath + "' did not have the asset location '" + assetLocationPath + "'.", assetLocation.dir().getPath(), sourceModule.assetLocation().dir().getPath());
   
    return verifierChainer;
  }
View Full Code Here

   
    assertEquals("Asset location '" + assetLocation + "' was not expected to have any dependent asset locations.", 0, dependentAssetLocations.size());
  }
 
  public void assetLocationHasDependencies(String assetLocationPath, String[] expectedAssetLocationDependencies) {
    AssetLocation assetLocation = assetContainer.assetLocation(assetLocationPath);
    if(assetLocation == null) {
      throw new RuntimeException("asset location '" + assetLocationPath + "' does not exist.");
    }
   
    List<AssetLocation> actualDependentAssetLocations = assetLocation.dependentAssetLocations();
   
    assertEquals("Asset location '" + assetLocationPath + "' was expected to have " + expectedAssetLocationDependencies.length + " dependent asset locations.",
      expectedAssetLocationDependencies.length, actualDependentAssetLocations.size());
   
    int i = 0;
View Full Code Here

 
 
 
 
  protected File getSourceFile(String sourceClass) {
    AssetLocation assetLocation = node.assetLocation("src");
    if (assetLocation == null) {
      throw new RuntimeException("Cannot find asset location for the 'src' dir. Either it doesn't exist or there are no asset plugins to discover it.");
    }
    return assetLocation.file(sourceClass.replaceAll("\\.", "/") + ".js");
  }
View Full Code Here

TOP

Related Classes of org.bladerunnerjs.model.AssetLocation

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.