Package com.google.gwt.resources.css.ast.CssProperty

Examples of com.google.gwt.resources.css.ast.CssProperty.ListValue


   */
  private static void validateValue(TreeLogger logger,
      JClassType resourceBundleType, Value value)
      throws UnableToCompleteException {

    ListValue list = value.isListValue();
    if (list != null) {
      for (Value v : list.getValues()) {
        validateValue(logger, resourceBundleType, v);
      }
      return;
    }

View Full Code Here


    return false;
  }

  private void setImageProperty(Value value) {
    StringValue stringValue;
    ListValue listValue;

    if ((stringValue = value.isStringValue()) != null) {
      String s = stringValue.getValue();

      // Allow the user to use both raw idents and quoted strings
      if (s.startsWith("\"")) {
        s = s.substring(1, s.length() - 1);
      }

      resourceFunction = new DotPathValue(s);

    } else if ((listValue = value.isListValue()) != null) {
      List<Value> values = listValue.getValues();
      if (values.size() == 1) {
        setImageProperty(values.get(0));
      }

    } else {
View Full Code Here

      List<Value> values = new ArrayList<Value>();
      if (value != null) {
        extractValueOf(values, value);
      }
      currentRule.getProperties().add(
          new CssProperty(escapeIdent(name), new ListValue(values), important));
    }
View Full Code Here

      }

      // for logging purpose
      String selector = x.getSelectors().toString();

      ListValue listValue = visitListValue(cssProperty.getValues(), cssPropertyName, selector);

      cssProperty.setValue(listValue);
    }

    return false;
View Full Code Here

      if (value.isListValue() != null) {
        newValues.add(visitListValue(value.isListValue(), cssPropertyName, selector));

      } else if (value.isFunctionValue() != null) {
        FunctionValue functionValue = value.isFunctionValue();
        ListValue listValue = visitListValue(functionValue.getValues(), cssPropertyName,
            selector);

        newValues.add(new FunctionValue(functionValue.getName(), listValue));

      } else if (value.isIdentValue() != null) {
        newValues.add(visitIdentValue(value.isIdentValue(), cssPropertyName, selector));

      } else {
        newValues.add(value);
      }
    }

    return new ListValue(newValues);
  }
View Full Code Here

   */
  private static void validateValue(TreeLogger logger,
      JClassType resourceBundleType, Value value)
      throws UnableToCompleteException {

    ListValue list = value.isListValue();
    if (list != null) {
      for (Value v : list.getValues()) {
        validateValue(logger, resourceBundleType, v);
      }
      return;
    }

View Full Code Here

        } else {
          List<Value> parameters = new ArrayList<Value>();
          extractValueOf(parameters, value.getParameters());
          return new FunctionValue(value.getFunctionName(),
              new ListValue(parameters));
        }
      }
      case LexicalUnit.SAC_INHERIT:
        return new IdentValue("inherit");
      case LexicalUnit.SAC_OPERATOR_EXP:
View Full Code Here

      List<Value> values = new ArrayList<Value>();
      if (value != null) {
        extractValueOf(values, value);
      }
      currentRule.getProperties().add(
          new CssProperty(escapeIdent(name), new ListValue(values), important));
    }
View Full Code Here

  private static Pattern ESCAPE_TEST = Pattern.compile("^[^'\"].*\\s.*[^'\"]$");
  @Override
  public boolean visit(CssProperty x, Context ctx) {

    if ("font-family".equals(x.getName())) {
      ListValue values = x.getValues();
      String css = values.toCss();
      StringBuilder valueBuilder = new StringBuilder();

      boolean first = true;

      for (String subProperty : Splitter.on(",").trimResults().omitEmptyStrings().split(css)) {
View Full Code Here

    List<Value> result = new ArrayList<Value>(listValue.getValues().size());
    for (Value val : listValue.getValues()) {
      if (val.isFunctionValue() != null) {
        // Recursively perform substitution on a function's values
        FunctionValue fnVal = val.isFunctionValue();
        ListValue newVals = substituteDefs(fnVal.getValues());
        result.add(new FunctionValue(fnVal.getName(), newVals));
        continue;
      }

      IdentValue maybeIdent = val.isIdentValue();
      if (maybeIdent == null) {
        // Not an ident, append as-is to result
        result.add(val);
        continue;
      }

      String identStr = maybeIdent.getIdent();
      CssDef def = substitutions.get(identStr);

      if (def == null) {
        // No substitution found, append as-is to result
        result.add(val);
        continue;
      } else if (def instanceof CssUrl) {
        assert def.getValues().size() == 1;
        assert def.getValues().get(0).isDotPathValue() != null;
        DotPathValue functionName = def.getValues().get(0).isDotPathValue();

        JType methodType = null;
        try {
          methodType = ResourceGeneratorUtil.getMethodByPath(context.getClientBundleType(),
              functionName.getParts(), null).getReturnType();
        } catch (NotFoundException e) {
          logger.log(TreeLogger.ERROR, e.getMessage());
          throw new CssCompilerException("Cannot find data method");
        }

        if (!(methodType instanceof JClassType) ||
            (!dataResourceType.isAssignableFrom((JClassType) methodType) &&
            !imageResourceType.isAssignableFrom((JClassType) methodType))) {
          String message = "Invalid method type for url substitution: " + methodType + ". " +
              "Only DataResource and ImageResource are supported.";
          logger.log(TreeLogger.ERROR, message);
          throw new CssCompilerException(message);
        }

        StringBuilder expression = new StringBuilder();
        expression.append("\"url('\" + ");
        expression.append(context.getImplementationSimpleSourceName());
        expression.append(".this.");
        expression.append(functionName.getExpression());
        expression.append(".getSafeUri().asString()");
        expression.append(" + \"')\"");
        result.add(new ExpressionValue(expression.toString()));
      } else {
        for (Value defValue : def.getValues()) {
          result.add(defValue);
        }
      }
    }
    return new ListValue(result);
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.resources.css.ast.CssProperty.ListValue

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.