Examples of BindingProperty


Examples of com.google.gwt.dev.cfg.BindingProperty

  public SelectionProperty getSelectionProperty(TreeLogger logger,
      String propertyName) throws BadPropertyValueException {
    Property prop = getProperty(propertyName);
    if (prop instanceof BindingProperty) {
      final BindingProperty cprop = (BindingProperty) prop;
      final String name = cprop.getName();
      final String value;
      if (prevAnswers.containsKey(propertyName)) {
        value = prevAnswers.get(propertyName);
      } else {
        value = computePropertyValue(logger, propertyName, cprop);
        prevAnswers.put(propertyName, value);
      }
      final String fallback = cprop.getFallback();
      final SortedSet<String> possibleValues = new TreeSet<String>();
      for (String v : cprop.getDefinedValues()) {
        possibleValues.add(v);
      }
      return new DefaultSelectionProperty(value, fallback, name,
          possibleValues);
    } else {
View Full Code Here

Examples of com.google.gwt.dev.cfg.BindingProperty

  void compileForWebMode(ModuleDef module, String... userAgents) throws UnableToCompleteException {
    if (userAgents != null && userAgents.length > 0) {
      Properties props = module.getProperties();
      Property userAgent = props.find("user.agent");
      if (userAgent instanceof BindingProperty) {
        BindingProperty bindingProperty = (BindingProperty) userAgent;
        bindingProperty.setAllowedValues(bindingProperty.getRootCondition(), userAgents);
      }
    }
    if (!new Compiler(options).run(getTopLogger(), module)) {
      throw new UnableToCompleteException();
    }
View Full Code Here

Examples of com.google.gwt.dev.cfg.BindingProperty

  void compileForWebMode(ModuleDef module, String... userAgents) throws UnableToCompleteException {
    if (userAgents != null && userAgents.length > 0) {
      Properties props = module.getProperties();
      Property userAgent = props.find("user.agent");
      if (userAgent instanceof BindingProperty) {
        BindingProperty bindingProperty = (BindingProperty) userAgent;
        bindingProperty.setAllowedValues(bindingProperty.getRootCondition(), userAgents);
      }
    }
    if (!new Compiler(options).run(getTopLogger(), module)) {
      throw new UnableToCompleteException();
    }
View Full Code Here

Examples of com.google.gwt.dev.cfg.BindingProperty

  void compileForWebMode(ModuleDef module, String... userAgents) throws UnableToCompleteException {
    if (userAgents != null && userAgents.length > 0) {
      Properties props = module.getProperties();
      Property userAgent = props.find("user.agent");
      if (userAgent instanceof BindingProperty) {
        BindingProperty bindingProperty = (BindingProperty) userAgent;
        bindingProperty.setAllowedValues(bindingProperty.getRootCondition(), userAgents);
      }
    }
    if (!new Compiler(options).run(getTopLogger(), module)) {
      throw new UnableToCompleteException();
    }
View Full Code Here

Examples of com.google.gwt.dev.cfg.BindingProperty

  private static String maybeSetBinding(TreeLogger logger, ModuleDef module, String propName,
      String newValue) {

    logger = logger.branch(TreeLogger.Type.INFO, "binding: " + propName + "=" + newValue);

    BindingProperty binding = module.getProperties().findBindingProp(propName);
    if (binding == null) {
      logger.log(TreeLogger.Type.WARN, "undefined property: '" + propName + "'");
      return null;
    }

    if (!binding.isAllowedValue(newValue)) {

      String[] allowedValues = binding.getAllowedValues(binding.getRootCondition());
      logger.log(TreeLogger.Type.WARN, "property '" + propName +
          "' cannot be set to '" + newValue + "'");
      logger.log(TreeLogger.Type.INFO, "allowed values: " +
          Joiner.on(", ").join(allowedValues));

      // See if we can fall back on a reasonable default.
      if (allowedValues.length == 1) {
        // There is only one possibility, so use it.
        newValue = allowedValues[0];
      } else if (binding.getName().equals("locale")) {
        // TODO: come up with a more general solution. Perhaps fail
        // the compile and give the user a way to override the property?
        newValue = chooseDefault(binding, "default", "en", "en_US");
      } else {
        // There is more than one. Continue and possibly compile multiple permutations.
        logger.log(TreeLogger.Type.INFO, "continuing without " + propName +
            ". Sourcemaps may not work.");
        return null;
      }

      logger.log(TreeLogger.Type.INFO, "recovered with " + propName + "=" + newValue);
    }

    binding.setRootGeneratedValues(newValue);
    return newValue;
  }
View Full Code Here

Examples of com.google.gwt.dev.cfg.BindingProperty

  /**
   * Sets a binding even if it's set to a different value in the GWT application.
   */
  private static void overrideBinding(ModuleDef module, String propName, String newValue) {
    BindingProperty binding = module.getProperties().findBindingProp(propName);
    if (binding != null) {
      // This sets both allowed and generated values, which is needed since the module
      // might have explicitly disallowed the value.
      // It persists over multiple compiles but that's okay since we set it the same way
      // every time.
      binding.setValues(binding.getRootCondition(), newValue);
    }
  }
View Full Code Here

Examples of com.google.gwt.dev.cfg.BindingProperty

  public void processModule(ModuleDef module) {
    computePropertiesMap();
    if (properties.size() > 0) {
      Properties props = module.getProperties();
      for (Property property : properties) {
        BindingProperty binding = props.createBinding(property.name());
        if (!binding.isDefinedValue(property.value())) {
          binding.addTargetLibraryDefinedValue(binding.getRootCondition(), property.value());
        }
        binding.setValues(
            binding.getRootCondition(), property.value());
      }
    }
  }
View Full Code Here

Examples of com.google.gwt.dev.cfg.BindingProperty

      throws UnableToCompleteException {
    if (userAgents != null && !userAgents.isEmpty()) {
      Properties props = module.getProperties();
      Property userAgent = props.find("user.agent");
      if (userAgent instanceof BindingProperty) {
        BindingProperty bindingProperty = (BindingProperty) userAgent;
        bindingProperty.setRootGeneratedValues(userAgents.toArray(new String[0]));
      }
    }
    boolean success = false;
    try {
      success = new Compiler(options).run(getTopLogger(), module);
View Full Code Here

Examples of com.google.gwt.dev.cfg.BindingProperty

  private static final TreeLogger logger = new FailErrorLogger();

  private static final SortedSet<ConfigurationProperty> configProperties = new TreeSet<ConfigurationProperty>();

  public void testNoFallback() throws UnableToCompleteException {
    BindingProperty bp = new BindingProperty("doesNotUseFallback");
    PropertyProvider provider = new PropertyProvider(PROVIDER_NOFALLBACK);
    bp.setProvider(provider);
    StandardSelectionProperty property = new StandardSelectionProperty(bp);
    assertEquals(PROVIDER_NOFALLBACK, property.getPropertyProvider(logger,
        configProperties));

    provider = new PropertyProvider(PROVIDER_MULTIFALLBACK);
    bp.setProvider(provider);
    property = new StandardSelectionProperty(bp);
    assertEquals(PROVIDER_MULTIFALLBACK_EMPTY, property.getPropertyProvider(
        logger, configProperties));
  }
View Full Code Here

Examples of com.google.gwt.dev.cfg.BindingProperty

    assertEquals(PROVIDER_MULTIFALLBACK_EMPTY, property.getPropertyProvider(
        logger, configProperties));
  }

  public void testPropertyProviderGenerator() throws UnableToCompleteException {
    BindingProperty bp = new BindingProperty("providerGenerator");
    bp.setFallback(FBV);
    PropertyProvider provider = new PropertyProvider("bad");
    bp.setProvider(provider);
    bp.setProviderGenerator(MyProviderGenerator.class);
    StandardSelectionProperty property = new StandardSelectionProperty(bp);
    assertEquals("good " + FBV, property.getPropertyProvider(logger,
        configProperties));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.