示例#1
0
 @Override
 public void unregisterContribution(
     Object contribution, String extensionPoint, ComponentInstance contributor) {
   if (contribution instanceof FlavorDescriptor) {
     FlavorDescriptor flavor = (FlavorDescriptor) contribution;
     flavorReg.removeContribution(flavor);
   } else if (contribution instanceof Resource) {
     Resource resource = (Resource) contribution;
     unregisterResource(resource);
   } else if (contribution instanceof SimpleStyle) {
     SimpleStyle style = (SimpleStyle) contribution;
     unregisterResource(getResourceFromStyle(style));
   } else if (contribution instanceof PageDescriptor) {
     PageDescriptor page = (PageDescriptor) contribution;
     if (page.hasResources() && !Framework.getRuntime().isShuttingDown()) {
       WebResourceManager wrm = Framework.getService(WebResourceManager.class);
       wrm.unregisterResourceBundle(page.getComputedResourceBundle());
     }
     pageReg.removeContribution(page);
   } else if (contribution instanceof NegotiationDescriptor) {
     NegotiationDescriptor neg = (NegotiationDescriptor) contribution;
     negReg.removeContribution(neg);
   } else {
     log.error(
         String.format(
             "Unknown contribution to the theme " + "styling service, extension point '%s': '%s",
             extensionPoint, contribution));
   }
 }
示例#2
0
 @Override
 public FlavorDescriptor getFlavor(String flavorName) {
   if (flavorReg != null) {
     FlavorDescriptor flavor = flavorReg.getFlavor(flavorName);
     if (flavor != null) {
       FlavorDescriptor clone = flavor.clone();
       clone.setLogo(computeLogo(flavor, new ArrayList<String>()));
       clone.setPalettePreview(computePalettePreview(flavor, new ArrayList<String>()));
       clone.setFavicons(computeIcons(flavor, new ArrayList<String>()));
       return clone;
     }
   }
   return null;
 }
示例#3
0
  protected void registerFlavor(FlavorDescriptor flavor, RuntimeContext extensionContext) {
    // set flavor presets files content
    List<FlavorPresets> presets = flavor.getPresets();
    if (presets != null) {
      for (FlavorPresets myPreset : presets) {
        String src = myPreset.getSrc();
        URL url = getUrlFromPath(src, extensionContext);
        if (url == null) {
          log.error(String.format("Could not find resource at '%s'", src));
        } else {
          String content;
          try {
            content = new String(FileUtils.readBytes(url));
          } catch (IOException e) {
            throw new RuntimeException(e);
          }
          myPreset.setContent(content);
        }
      }
    }

    // set flavor sass variables
    List<SassImport> sassVars = flavor.getSassImports();
    if (sassVars != null) {
      for (SassImport var : sassVars) {
        String src = var.getSrc();
        URL url = getUrlFromPath(src, extensionContext);
        if (url == null) {
          log.error(String.format("Could not find resource at '%s'", src));
        } else {
          String content;
          try {
            content = new String(FileUtils.readBytes(url));
          } catch (IOException e) {
            throw new RuntimeException(e);
          }
          var.setContent(content);
        }
      }
    }

    flavorReg.addContribution(flavor);
  }