org.eclipse.e4.ui.css.core_0.10.2.v20120912-132817

exicalUnit();
    }
  }
  
  public int getLength()
  {
    return values.size();
  }
  
  public CSSValue item(int index)
  {
    return (CSSValue)values.get(index);
  }
  
  public String getCssText()
  {
    StringBuilder buffer = new StringBuilder();
    for (CSSValue value : values)
    {
      buffer.append(value.getCssText());
      buffer.append(" ");
    }
    return buffer.toString().trim();
  }
  
  public short getCssValueType()
  {
    return 2;
  }
  
  public void setCssText(String arg0)
    throws DOMException
  {
    throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.CSSValueListImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom;

import java.io.Serializable;
import org.w3c.dom.css.Counter;

public class CounterImpl
  implements Counter, Serializable
{
  public String getIdentifier()
  {
    throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
  }
  
  public String getListStyle()
  {
    throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
  }
  
  public String getSeparator()
  {
    throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.CounterImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.e4.ui.css.core.dom.ExtendedCSSRule;
import org.eclipse.e4.ui.css.core.dom.ExtendedDocumentCSS;
import org.w3c.css.sac.Condition;
import org.w3c.css.sac.ConditionalSelector;
import org.w3c.css.sac.Selector;
import org.w3c.css.sac.SelectorList;
import org.w3c.dom.Element;
import org.w3c.dom.css.CSSRule;
import org.w3c.dom.css.CSSRuleList;
import org.w3c.dom.css.CSSStyleDeclaration;
import org.w3c.dom.css.CSSStyleSheet;
import org.w3c.dom.stylesheets.StyleSheet;
import org.w3c.dom.stylesheets.StyleSheetList;

public class DocumentCSSImpl
  implements ExtendedDocumentCSS
{
  private StyleSheetListImpl styleSheetList = new StyleSheetListImpl();
  private Map styleDeclarationMap = null;
  
  public StyleSheetList getStyleSheets()
  {
    return styleSheetList;
  }
  
  public CSSStyleDeclaration getOverrideStyle(Element element, String s)
  {
    return null;
  }
  
  public void addStyleSheet(StyleSheet styleSheet)
  {
    styleSheetList.addStyleSheet(styleSheet);
  }
  
  public void removeAllStyleSheets()
  {
    styleSheetList.removeAllStyleSheets();
    styleDeclarationMap = null;
  }
  
  public List queryConditionSelector(int conditionType)
  {
    return querySelector(0, conditionType);
  }
  
  public List querySelector(int selectorType, int conditionType)
  {
    List list = getCSSStyleDeclarationList(selectorType, conditionType);
    if (list != null) {
      return list;
    }
    int l = styleSheetList.getLength();
    for (int i = 0; i < l; i++)
    {
      CSSStyleSheet styleSheet = (CSSStyleSheet)styleSheetList.item(i);
      CSSRuleList ruleList = styleSheet.getCssRules();
      list = querySelector(ruleList, selectorType, conditionType);
      setCSSStyleDeclarationList(list, selectorType, conditionType);
    }
    return list;
  }
  
  protected List querySelector(CSSRuleList ruleList, int selectorType, int selectorConditionType)
  {
    List list = new ArrayList();
    int length = ruleList.getLength();
    for (int i = 0; i < length; i++)
    {
      CSSRule rule = ruleList.item(i);
      switch (rule.getType())
      {
      case 1: 
        if ((rule instanceof ExtendedCSSRule))
        {
          ExtendedCSSRule r = (ExtendedCSSRule)rule;
          SelectorList selectorList = r.getSelectorList();
          
          int l = selectorList.getLength();
          for (int j = 0; j < l; j++)
          {
            Selector selector = selectorList.item(j);
            if (selector.getSelectorType() == selectorType) {
              switch (selectorType)
              {
              case 0: 
                ConditionalSelector conditionalSelector = (ConditionalSelector)selector;
                short conditionType = conditionalSelector
                  .getCondition().getConditionType();
                if (selectorConditionType == conditionType) {
                  list.add(selector);
                }
                break;
              }
            }
          }
        }
        break;
      }
    }
    return list;
  }
  
  protected List getCSSStyleDeclarationList(int selectorType, int conditionType)
  {
    Integer key = getKey(selectorType, conditionType);
    return (List)getStyleDeclarationMap().get(key);
  }
  
  protected void setCSSStyleDeclarationList(List list, int selectorType, int conditionType)
  {
    Integer key = getKey(selectorType, conditionType);
    getStyleDeclarationMap().put(key, list);
  }
  
  protected Integer getKey(int selectorType, int conditionType)
  {
    if (selectorType == 0)
    {
      if (conditionType == SAC_CLASS_CONDITION.intValue()) {
        return SAC_CLASS_CONDITION;
      }
      if (conditionType == SAC_ID_CONDITION.intValue()) {
        return SAC_ID_CONDITION;
      }
      if (conditionType == SAC_PSEUDO_CLASS_CONDITION.intValue()) {
        return SAC_PSEUDO_CLASS_CONDITION;
      }
      return OTHER_SAC_CONDITIONAL_SELECTOR;
    }
    return OTHER_SAC_SELECTOR;
  }
  
  protected Map getStyleDeclarationMap()
  {
    if (styleDeclarationMap == null) {
      styleDeclarationMap = new HashMap();
    }
    return styleDeclarationMap;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.DocumentCSSImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom;

import org.w3c.css.sac.LexicalUnit;
import org.w3c.dom.DOMException;

public class Measure
  extends CSSValueImpl
{
  LexicalUnit value;
  
  public Measure(LexicalUnit value)
  {
    this.value = value;
  }
  
  public float getFloatValue(short valueType)
    throws DOMException
  {
    if (value.getLexicalUnitType() == 13) {
      return value.getIntegerValue();
    }
    return value.getFloatValue();
  }
  
  public int getIntegerValue(short valueType)
    throws DOMException
  {
    return value.getIntegerValue();
  }
  
  public String getStringValue()
    throws DOMException
  {
    short lexicalUnit = value.getLexicalUnitType();
    if ((lexicalUnit == 35) || 
      (lexicalUnit == 36) || 
      (lexicalUnit == 24)) {
      return value.getStringValue();
    }
    throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
  }
  
  public short getPrimitiveType()
  {
    switch (value.getLexicalUnitType())
    {
    case 35: 
      return 21;
    case 13: 
    case 14: 
      return 1;
    case 24: 
      return 20;
    case 23: 
      return 2;
    case 17: 
      return 5;
    case 19: 
      return 6;
    case 15: 
      return 3;
    case 16: 
      return 4;
    case 18: 
      return 8;
    case 36: 
      return 19;
    case 42: 
      return 18;
    case 0: 
      return 3;
    case 12: 
      return 0;
    }
    throw new UnsupportedOperationException("NOT YET IMPLEMENTED - LexicalUnit type: " + value.getLexicalUnitType());
  }
  
  public String getCssText()
  {
    switch (value.getLexicalUnitType())
    {
    case 13: 
      return String.valueOf(value.getIntegerValue());
    case 14: 
      return String.valueOf(value.getFloatValue());
    case 15: 
    case 16: 
    case 17: 
    case 18: 
    case 19: 
    case 21: 
    case 22: 
    case 23: 
    case 28: 
      return String.valueOf(value.getFloatValue()) + value.getDimensionUnitText();
    case 24: 
      return "url(" + value.getStringValue() + ")";
    case 0: 
      return ",";
    case 12: 
      return "inherit";
    }
    return value.getStringValue();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.Measure
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.w3c.css.sac.SACMediaList;
import org.w3c.dom.DOMException;
import org.w3c.dom.stylesheets.MediaList;

public class MediaListImpl
  implements MediaList, Serializable
{
  private List mediaList = null;
  
  public MediaListImpl(SACMediaList media)
  {
    mediaList = new ArrayList();
    for (int i = 0; i < media.getLength(); i++) {
      mediaList.add(media.item(i));
    }
  }
  
  public void appendMedium(String newMedium)
    throws DOMException
  {
    if (mediaList.contains(newMedium)) {
      mediaList.remove(newMedium);
    }
    mediaList.add(newMedium);
  }
  
  public void deleteMedium(String oldMedium)
    throws DOMException
  {
    mediaList.remove(oldMedium);
  }
  
  public int getLength()
  {
    return mediaList != null ? mediaList.size() : 0;
  }
  
  public String getMediaText()
  {
    String media = "";
    int size = mediaList.size();
    if (size > 0)
    {
      media = media + mediaList.get(0);
      for (int i = 1; i < mediaList.size(); i++) {
        media = media + ", " + mediaList.get(i);
      }
    }
    return media;
  }
  
  public String item(int index)
  {
    if (index > mediaList.size()) {
      return null;
    }
    return (String)mediaList.get(index);
  }
  
  public void setMediaText(String mediaText)
    throws DOMException
  {
    while (mediaText.length() > 0)
    {
      int next = mediaText.indexOf(',');
      if (next == -1) {
        next = mediaText.length();
      }
      String media = mediaText.substring(0, next);
      appendMedium(media.trim());
      if (next + 1 >= mediaText.length()) {
        break;
      }
      mediaText = mediaText.substring(next + 1, mediaText.length());
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.MediaListImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom;

import java.io.Serializable;
import org.w3c.css.sac.LexicalUnit;
import org.w3c.dom.DOMException;
import org.w3c.dom.css.CSSPrimitiveValue;
import org.w3c.dom.css.RGBColor;

public class RGBColorImpl
  extends CSSValueImpl
  implements RGBColor, Serializable
{
  private CSSPrimitiveValue red;
  private CSSPrimitiveValue green;
  private CSSPrimitiveValue blue;
  
  public RGBColorImpl(LexicalUnit lexicalUnit)
  {
    LexicalUnit nextUnit = lexicalUnit.getParameters();
    red = new Measure(nextUnit);
    nextUnit = nextUnit.getNextLexicalUnit().getNextLexicalUnit();
    green = new Measure(nextUnit);
    nextUnit = nextUnit.getNextLexicalUnit().getNextLexicalUnit();
    blue = new Measure(nextUnit);
  }
  
  public CSSPrimitiveValue getRed()
  {
    return red;
  }
  
  public CSSPrimitiveValue getGreen()
  {
    return green;
  }
  
  public CSSPrimitiveValue getBlue()
  {
    return blue;
  }
  
  public RGBColor getRGBColorValue()
    throws DOMException
  {
    return this;
  }
  
  public short getPrimitiveType()
  {
    return 25;
  }
  
  public String getCssText()
  {
    return 
      "rgb(" + red.getCssText() + ", " + green.getCssText() + ", " + blue.getCssText() + ")";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.RGBColorImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom;

import java.io.Serializable;
import org.w3c.dom.css.CSSPrimitiveValue;
import org.w3c.dom.css.Rect;

public class RectImpl
  implements Rect, Serializable
{
  public CSSPrimitiveValue getBottom()
  {
    throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
  }
  
  public CSSPrimitiveValue getLeft()
  {
    throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
  }
  
  public CSSPrimitiveValue getRight()
  {
    throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
  }
  
  public CSSPrimitiveValue getTop()
  {
    throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.RectImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom;

import java.util.ArrayList;
import java.util.List;
import org.w3c.dom.stylesheets.StyleSheet;
import org.w3c.dom.stylesheets.StyleSheetList;

public class StyleSheetListImpl
  implements StyleSheetList
{
  private List styleSheets = null;
  
  public int getLength()
  {
    return styleSheets != null ? styleSheets.size() : 0;
  }
  
  public StyleSheet item(int index)
  {
    return styleSheets != null ? (StyleSheet)styleSheets.get(index) : 
      null;
  }
  
  public void addStyleSheet(StyleSheet styleSheet)
  {
    if (styleSheets == null) {
      styleSheets = new ArrayList();
    }
    styleSheets.add(styleSheet);
  }
  
  public void removeAllStyleSheets()
  {
    styleSheets = null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.StyleSheetListImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom;

import java.util.Comparator;

class StyleWrapper$StyleWrapperComparator
  implements Comparator
{
  public int compare(Object object1, Object object2)
  {
    int result = 0;
    StyleWrapper wrapper1 = (StyleWrapper)object1;
    StyleWrapper wrapper2 = (StyleWrapper)object2;
    if (specificity > specificity) {
      result = 1;
    } else if (specificity < specificity) {
      result = -1;
    } else if (position > position) {
      result = 1;
    } else if (position < position) {
      result = -1;
    }
    return result;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.StyleWrapper.StyleWrapperComparator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom;

import java.util.Comparator;
import org.w3c.dom.css.CSSStyleDeclaration;

final class StyleWrapper
{
  private static class StyleWrapperComparator
    implements Comparator
  {
    public int compare(Object object1, Object object2)
    {
      int result = 0;
      StyleWrapper wrapper1 = (StyleWrapper)object1;
      StyleWrapper wrapper2 = (StyleWrapper)object2;
      if (specificity > specificity) {
        result = 1;
      } else if (specificity < specificity) {
        result = -1;
      } else if (position > position) {
        result = 1;
      } else if (position < position) {
        result = -1;
      }
      return result;
    }
  }
  
  public static final StyleWrapperComparator COMPARATOR = new StyleWrapperComparator(null);
  public final CSSStyleDeclaration style;
  public final int specificity;
  public final int position;
  
  public StyleWrapper(CSSStyleDeclaration style, int specificity, int position)
  {
    this.style = style;
    this.specificity = specificity;
    this.position = position;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.StyleWrapper
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.e4.ui.css.core.dom.ExtendedCSSRule;
import org.eclipse.e4.ui.css.core.impl.sac.ExtendedSelector;
import org.w3c.css.sac.Selector;
import org.w3c.css.sac.SelectorList;
import org.w3c.dom.Element;
import org.w3c.dom.css.CSSRule;
import org.w3c.dom.css.CSSRuleList;
import org.w3c.dom.css.CSSStyleDeclaration;
import org.w3c.dom.css.CSSStyleRule;
import org.w3c.dom.css.CSSStyleSheet;
import org.w3c.dom.css.DocumentCSS;
import org.w3c.dom.css.ViewCSS;
import org.w3c.dom.stylesheets.StyleSheetList;
import org.w3c.dom.views.DocumentView;

public class ViewCSSImpl
  implements ViewCSS
{
  protected DocumentCSS documentCSS;
  
  public ViewCSSImpl(DocumentCSS documentCSS)
  {
    this.documentCSS = documentCSS;
  }
  
  public DocumentView getDocument()
  {
    return null;
  }
  
  public CSSStyleDeclaration getComputedStyle(Element elt, String pseudoElt)
  {
    StyleSheetList styleSheetList = documentCSS.getStyleSheets();
    int l = styleSheetList.getLength();
    for (int i = 0; i < l; i++)
    {
      CSSStyleSheet styleSheet = (CSSStyleSheet)styleSheetList.item(i);
      CSSStyleDeclaration styleDeclaration = getComputedStyle(styleSheet, 
        elt, pseudoElt);
      if (styleDeclaration != null) {
        return styleDeclaration;
      }
    }
    return null;
  }
  
  public CSSStyleDeclaration getComputedStyle(CSSStyleSheet styleSheet, Element elt, String pseudoElt)
  {
    List styleDeclarations = null;
    StyleWrapper firstStyleDeclaration = null;
    CSSRuleList ruleList = styleSheet.getCssRules();
    int length = ruleList.getLength();
    int position = 0;
    for (int i = 0; i < length; i++)
    {
      CSSRule rule = ruleList.item(i);
      switch (rule.getType())
      {
      case 1: 
        CSSStyleRule styleRule = (CSSStyleRule)rule;
        if ((rule instanceof ExtendedCSSRule))
        {
          ExtendedCSSRule r = (ExtendedCSSRule)rule;
          SelectorList selectorList = r.getSelectorList();
          
          int l = selectorList.getLength();
          for (int j = 0; j < l; j++)
          {
            Selector selector = selectorList.item(j);
            if ((selector instanceof ExtendedSelector))
            {
              ExtendedSelector extendedSelector = (ExtendedSelector)selector;
              if (extendedSelector.match(elt, pseudoElt))
              {
                CSSStyleDeclaration style = styleRule
                  .getStyle();
                int specificity = extendedSelector
                  .getSpecificity();
                StyleWrapper wrapper = new StyleWrapper(style, 
                  specificity, position++);
                if (firstStyleDeclaration == null)
                {
                  firstStyleDeclaration = wrapper;
                }
                else
                {
                  if (styleDeclarations == null)
                  {
                    styleDeclarations = new ArrayList();
                    styleDeclarations
                      .add(firstStyleDeclaration);
                  }
                  styleDeclarations.add(wrapper);
                }
              }
            }
          }
        }
        break;
      }
    }
    if (styleDeclarations != null) {
      return new CSSComputedStyleImpl(styleDeclarations);
    }
    if (firstStyleDeclaration != null) {
      return style;
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.ViewCSSImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom.parsers;

import java.io.IOException;
import java.util.Stack;
import org.eclipse.e4.ui.css.core.dom.parsers.CSSParser;
import org.eclipse.e4.ui.css.core.impl.dom.CSSStyleDeclarationImpl;
import org.eclipse.e4.ui.css.core.impl.dom.CSSValueFactory;
import org.eclipse.e4.ui.css.core.sac.DocumentHandlerFactory;
import org.eclipse.e4.ui.css.core.sac.ExtendedDocumentHandler;
import org.eclipse.e4.ui.css.core.sac.ISACParserFactory;
import org.eclipse.e4.ui.css.core.sac.ParserNotFoundException;
import org.eclipse.e4.ui.css.core.sac.SACParserFactory;
import org.w3c.css.sac.ConditionFactory;
import org.w3c.css.sac.InputSource;
import org.w3c.css.sac.Parser;
import org.w3c.css.sac.SelectorFactory;
import org.w3c.css.sac.SelectorList;
import org.w3c.dom.css.CSSRule;
import org.w3c.dom.css.CSSStyleDeclaration;
import org.w3c.dom.css.CSSStyleSheet;
import org.w3c.dom.css.CSSValue;

public class AbstractCSSParser
  implements CSSParser
{
  private static DocumentHandlerFactory defaultDocumentHandlerFactory = ;
  private static ISACParserFactory defaultParserFactory = SACParserFactory.newInstance();
  private Parser parser = null;
  private DocumentHandlerFactory documentHandlerFactory;
  private ISACParserFactory parserFactory;
  private ConditionFactory conditionFactory = null;
  private SelectorFactory selectorFactory = null;
  
  public CSSStyleSheet parseStyleSheet(InputSource source)
    throws IOException
  {
    ExtendedDocumentHandler documentHandler = getDocumentHandlerFactory()
      .makeDocumentHandler();
    Parser parser = getParser();
    parser.setDocumentHandler(documentHandler);
    parser.parseStyleSheet(source);
    return (CSSStyleSheet)documentHandler.getNodeRoot();
  }
  
  public CSSStyleDeclaration parseStyleDeclaration(InputSource source)
    throws IOException
  {
    CSSStyleDeclarationImpl styleDeclaration = new CSSStyleDeclarationImpl(
      null);
    parseStyleDeclaration(styleDeclaration, 
      source);
    return styleDeclaration;
  }
  
  public void parseStyleDeclaration(CSSStyleDeclaration styleDeclaration, InputSource source)
    throws IOException
  {
    Stack stack = new Stack();
    stack.push(styleDeclaration);
    ExtendedDocumentHandler documentHandler = getDocumentHandlerFactory()
      .makeDocumentHandler();
    documentHandler.setNodeStack(stack);
    Parser parser = getParser();
    parser.setDocumentHandler(documentHandler);
    parser.parseStyleDeclaration(source);
  }
  
  public CSSValue parsePropertyValue(InputSource source)
    throws IOException
  {
    Parser parser = getParser();
    ExtendedDocumentHandler documentHandler = getDocumentHandlerFactory()
      .makeDocumentHandler();
    parser.setDocumentHandler(documentHandler);
    return CSSValueFactory.newValue(parser.parsePropertyValue(source));
  }
  
  public CSSRule parseRule(InputSource source)
    throws IOException
  {
    return null;
  }
  
  public SelectorList parseSelectors(InputSource source)
    throws IOException
  {
    ExtendedDocumentHandler documentHandler = getDocumentHandlerFactory()
      .makeDocumentHandler();
    Parser parser = getParser();
    parser.setDocumentHandler(documentHandler);
    return parser.parseSelectors(source);
  }
  
  public void setParentStyleSheet(CSSStyleSheet parentStyleSheet) {}
  
  public DocumentHandlerFactory getDocumentHandlerFactory()
  {
    if (documentHandlerFactory == null) {
      return defaultDocumentHandlerFactory;
    }
    return documentHandlerFactory;
  }
  
  public void setDocumentHandlerFactory(DocumentHandlerFactory documentHandlerFactory)
  {
    this.documentHandlerFactory = documentHandlerFactory;
  }
  
  public Parser getParser()
  {
    if (parser == null) {
      try
      {
        parser = getSACParserFactory().makeParser();
        if (conditionFactory != null) {
          parser.setConditionFactory(conditionFactory);
        }
        if (selectorFactory != null) {
          parser.setSelectorFactory(selectorFactory);
        }
      }
      catch (Exception e)
      {
        throw new ParserNotFoundException(e);
      }
    }
    return parser;
  }
  
  public void setParser(Parser parser)
  {
    this.parser = parser;
  }
  
  public ISACParserFactory getSACParserFactory()
  {
    if (parserFactory == null) {
      return defaultParserFactory;
    }
    return parserFactory;
  }
  
  public void setSACParserFactory(ISACParserFactory parserFactory)
  {
    this.parserFactory = parserFactory;
  }
  
  public ConditionFactory getConditionFactory()
  {
    return conditionFactory;
  }
  
  public void setConditionFactory(ConditionFactory conditionFactory)
  {
    this.conditionFactory = conditionFactory;
  }
  
  public SelectorFactory getSelectorFactory()
  {
    return selectorFactory;
  }
  
  public void setSelectorFactory(SelectorFactory selectorFactory)
  {
    this.selectorFactory = selectorFactory;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.parsers.AbstractCSSParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom.parsers;

import org.eclipse.e4.ui.css.core.dom.parsers.CSSParser;
import org.eclipse.e4.ui.css.core.dom.parsers.CSSParserFactory;

public class CSSParserFactoryImpl
  extends CSSParserFactory
{
  public CSSParser makeCSSParser()
  {
    return new CSSParserImpl();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.parsers.CSSParserFactoryImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom.parsers;

public class CSSParserImpl
  extends AbstractCSSParser
{}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.parsers.CSSParserImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.dom.properties;

import org.eclipse.e4.ui.css.core.dom.properties.CSSBorderProperties;
import org.w3c.dom.css.CSSPrimitiveValue;

public class CSSBorderPropertiesImpl
  implements CSSBorderProperties
{
  private CSSPrimitiveValue color;
  private int width = 0;
  private String style;
  
  public CSSPrimitiveValue getColor()
  {
    return color;
  }
  
  public void setColor(CSSPrimitiveValue color)
  {
    this.color = color;
  }
  
  public int getWidth()
  {
    return width;
  }
  
  public void setWidth(int width)
  {
    this.width = width;
  }
  
  public String getStyle()
  {
    return style;
  }
  
  public void setStyle(String style)
  {
    this.style = style;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.core.impl.dom.properties.CSSBorderPropertiesImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.core.impl.engine;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.e4.ui.css.core.dom.CSSStylableElement;
import org.eclipse.e4.ui.css.core.dom.ExtendedCSSRule;
import org.eclipse.e4.ui.css.core.dom.ExtendedDocumentCSS;
import org.eclipse.e4.ui.css.core.dom.IElementProvider;
import org.eclipse.e4.ui.css.core.dom.parsers.CSSParser;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyCompositeHandler;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler2;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler2Delegate;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandlerProvider;
import org.eclipse.e4.ui.css.core.dom.properties.converters.ICSSValueConverter;
import org.eclipse.e4.ui.css.core.engine.CSSElementContext;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.css.core.engine.CSSErrorHandler;
import org.eclipse.e4.ui.css.core.exceptions.UnsupportedPropertyException;
import org.eclipse.e4.ui.css.core.impl.dom.CSSRuleListImpl;
import org.eclipse.e4.ui.css.core.impl.dom.CSSStyleSheetImpl;
import org.eclipse.e4.ui.css.core.impl.dom.DocumentCSSImpl;
import org.eclipse.e4.ui.css.core.impl.dom.ViewCSSImpl;
import org.eclipse.e4.ui.css.core.impl.sac.ExtendedSelector;
import org.eclipse.e4.ui.css.core.resources.CSSResourcesHelpers;
import org.eclipse.e4.ui.css.core.resources.IResourcesRegistry;
import org.eclipse.e4.ui.css.core.util.impl.resources.ResourcesLocatorManager;
import org.eclipse.e4.ui.css.core.util.resources.IResourcesLocatorManager;
import org.eclipse.e4.ui.css.core.utils.StringUtils;
import org.w3c.css.sac.AttributeCondition;
import org.w3c.css.sac.Condition;
import org.w3c.css.sac.ConditionalSelector;
import org.w3c.css.sac.InputSource;
import org.w3c.css.sac.Selector;
import org.w3c.css.sac.SelectorList;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.css.CSSImportRule;
import org.w3c.dom.css.CSSRule;
import org.w3c.dom.css.CSSRuleList;
import org.w3c.dom.css.CSSStyleDeclaration;
import org.w3c.dom.css.CSSStyleSheet;
import org.w3c.dom.css.CSSValue;
import org.w3c.dom.css.DocumentCSS;
import org.w3c.dom.css.ViewCSS;
import org.w3c.dom.stylesheets.StyleSheet;

public abstract class AbstractCSSEngine
  implements CSSEngine
{
  private static final IResourcesLocatorManager defaultResourcesLocatorManager = ResourcesLocatorManager.INSTANCE;
  private ExtendedDocumentCSS documentCSS;
  private ViewCSS viewCSS;
  private IElementProvider elementProvider;
  protected boolean computeDefaultStyle = false;
  private Map<Object, CSSElementContext> elementsContext = null;
  private CSSErrorHandler errorHandler;
  private IResourcesLocatorManager resourcesLocatorManager;
  private IResourcesRegistry resourcesRegistry;
  protected List<ICSSPropertyHandlerProvider> propertyHandlerProviders = new ArrayList();
  private Map<String, String> currentCSSPropertiesApplyed;
  private boolean throwError;
  private Map<Object, ICSSValueConverter> valueConverters = null;
  protected HashMap widgetsMap = new HashMap();
  private boolean parseImport;
  
  public AbstractCSSEngine()
  {
    this(new DocumentCSSImpl());
  }
  
  public AbstractCSSEngine(ExtendedDocumentCSS documentCSS)
  {
    this.documentCSS = documentCSS;
    viewCSS = new ViewCSSImpl(documentCSS);
  }
  
  public StyleSheet parseStyleSheet(Reader reader)
    throws IOException
  {
    InputSource source = new InputSource();
    source.setCharacterStream(reader);
    return parseStyleSheet(source);
  }
  
  public StyleSheet parseStyleSheet(InputStream stream)
    throws IOException
  {
    InputSource source = new InputSource();
    source.setByteStream(stream);
    return parseStyleSheet(source);
  }
  
  public StyleSheet parseStyleSheet(InputSource source)
    throws IOException
  {
    checkInputSource(source);
    CSSParser parser = makeCSSParser();
    CSSStyleSheet styleSheet = parser.parseStyleSheet(source);
    
    CSSRuleList rules = styleSheet.getCssRules();
    int length = rules.getLength();
    CSSRuleListImpl masterList = new CSSRuleListImpl();
    for (int counter = 0; counter < length; counter++)
    {
      CSSRule rule = rules.item(counter);
      if (rule.getType() != 3) {
        break;
      }
      Path p = new Path(source.getURI());
      IPath trim = p.removeLastSegments(1);
      
      URL url = FileLocator.resolve(new URL(trim.addTrailingSeparator().toString() + ((CSSImportRule)rule).getHref()));
      File testFile = new File(url.getFile());
      if (!testFile.exists())
      {
        String path = getResourcesLocatorManager().resolve(((CSSImportRule)rule).getHref());
        testFile = new File(new URL(path).getFile());
        if (testFile.exists()) {
          url = new URL(path);
        }
      }
      InputStream stream = url.openStream();
      InputSource tempStream = new InputSource();
      tempStream.setURI(url.toString());
      tempStream.setByteStream(stream);
      parseImport = true;
      styleSheet = (CSSStyleSheet)parseStyleSheet(tempStream);
      parseImport = false;
      CSSRuleList tempRules = styleSheet.getCssRules();
      for (int j = 0; j < tempRules.getLength(); j++) {
        masterList.add(tempRules.item(j));
      }
    }
    for (int i = counter; i < length; i++) {
      masterList.add(rules.item(i));
    }
    CSSStyleSheetImpl s = new CSSStyleSheetImpl();
    s.setRuleList(masterList);
    if (((documentCSS instanceof ExtendedDocumentCSS)) && 
      (!parseImport)) {
      documentCSS.addStyleSheet(s);
    }
    return s;
  }
  
  private void checkInputSource(InputSource source)
    throws IOException
  {
    Reader reader = source.getCharacterStream();
    InputStream stream = source.getByteStream();
    if ((reader == null) && (stream == null)) {
      throw new IOException(
        "CharacterStream or ByteStream cannot be null for the InputSource.");
    }
  }
  
  public CSSStyleDeclaration parseStyleDeclaration(String style)
    throws IOException
  {
    Reader reader = new StringReader(style);
    return parseStyleDeclaration(reader);
  }
  
  public CSSStyleDeclaration parseStyleDeclaration(Reader reader)
    throws IOException
  {
    InputSource source = new InputSource();
    source.setCharacterStream(reader);
    return parseStyleDeclaration(source);
  }
  
  public CSSStyleDeclaration parseStyleDeclaration(InputStream stream)
    throws IOException
  {
    InputSource source = new InputSource();
    source.setByteStream(stream);
    return parseStyleDeclaration(source);
  }
  
  public CSSStyleDeclaration parseStyleDeclaration(InputSource source)
    throws IOException
  {
    checkInputSource(source);
    CSSParser parser = makeCSSParser();
    CSSStyleDeclaration styleDeclaration = parser
      .parseStyleDeclaration(source);
    return styleDeclaration;
  }
  
  public SelectorList parseSelectors(String selector)
    throws IOException
  {
    Reader reader = new StringReader(selector);
    return parseSelectors(reader);
  }
  
  public SelectorList parseSelectors(Reader reader)
    throws IOException
  {
    InputSource source = new InputSource();
    source.setCharacterStream(reader);
    return parseSelectors(source);
  }
  
  public SelectorList parseSelectors(InputStream stream)
    throws IOException
  {
    InputSource source = new InputSource();
    source.setByteStream(stream);
    return parseSelectors(source);
  }
  
  public SelectorList parseSelectors(InputSource source)
    throws IOException
  {
    checkInputSource(source);
    CSSParser parser = makeCSSParser();
    SelectorList list = parser.parseSelectors(source);
    return list;
  }
  
  public CSSValue parsePropertyValue(Reader reader)
    throws IOException
  {
    InputSource source = new InputSource();
    source.setCharacterStream(reader);
    return parsePropertyValue(source);
  }
  
  public CSSValue parsePropertyValue(InputStream stream)
    throws IOException
  {
    InputSource source = new InputSource();
    source.setByteStream(stream);
    return parsePropertyValue(source);
  }
  
  public CSSValue parsePropertyValue(String value)
    throws IOException
  {
    Reader reader = new StringReader(value);
    return parsePropertyValue(reader);
  }
  
  public CSSValue parsePropertyValue(InputSource source)
    throws IOException
  {
    checkInputSource(source);
    CSSParser parser = makeCSSParser();
    return parser.parsePropertyValue(source);
  }
  
  public void applyStyles(Object element, boolean applyStylesToChildNodes)
  {
    applyStyles(element, applyStylesToChildNodes, computeDefaultStyle);
  }
  
  public void applyStyles(Object element, boolean applyStylesToChildNodes, boolean computeDefaultStyle)
  {
    Element elt = getElement(element);
    if (elt != null)
    {
      CSSStyleDeclaration style = viewCSS.getComputedStyle(elt, null);
      if (computeDefaultStyle)
      {
        if (applyStylesToChildNodes) {
          this.computeDefaultStyle = computeDefaultStyle;
        }
        applyDefaultStyleDeclaration(element, false, style, null);
      }
      String[] pseudoInstances = getStaticPseudoInstances(elt);
      if (pseudoInstances != null) {
        for (int i = 0; i < pseudoInstances.length; i++)
        {
          String pseudoInstance = pseudoInstances[i];
          CSSStyleDeclaration styleWithPseudoInstance = viewCSS
            .getComputedStyle(elt, pseudoInstance);
          if (computeDefaultStyle) {
            applyDefaultStyleDeclaration(element, false, 
              styleWithPseudoInstance, pseudoInstance);
          }
          if (styleWithPseudoInstance != null)
          {
            CSSRule parentRule = styleWithPseudoInstance.getParentRule();
            if ((parentRule instanceof ExtendedCSSRule)) {
              applyConditionalPseudoStyle((ExtendedCSSRule)parentRule, pseudoInstance, element, styleWithPseudoInstance);
            } else {
              applyStyleDeclaration(elt, styleWithPseudoInstance, pseudoInstance);
            }
          }
        }
      }
      if (style != null) {
        applyStyleDeclaration(elt, style, null);
      }
      try
      {
        applyInlineStyle(elt, false);
      }
      catch (Exception e)
      {
        handleExceptions(e);
      }
      if (applyStylesToChildNodes)
      {
        NodeList nodes = elt.getChildNodes();
        if (nodes != null)
        {
          for (int k = 0; k < nodes.getLength(); k++) {
            applyStyles(nodes.item(k), applyStylesToChildNodes);
          }
          onStylesAppliedToChildNodes(elt, nodes);
        }
      }
    }
  }
  
  private void applyConditionalPseudoStyle(ExtendedCSSRule parentRule, String pseudoInstance, Object element, CSSStyleDeclaration styleWithPseudoInstance)
  {
    SelectorList selectorList = parentRule.getSelectorList();
    for (int j = 0; j < selectorList.getLength(); j++)
    {
      Selector item = selectorList.item(j);
      if ((item instanceof ConditionalSelector))
      {
        Condition condition = ((ConditionalSelector)item).getCondition();
        if ((condition instanceof AttributeCondition))
        {
          String value = ((AttributeCondition)condition).getValue();
          if (value.equals(pseudoInstance))
          {
            applyStyleDeclaration(element, styleWithPseudoInstance, 
              pseudoInstance);
            return;
          }
        }
      }
    }
  }
  
  protected String[] getStaticPseudoInstances(Element element)
  {
    if ((element instanceof CSSStylableElement))
    {
      CSSStylableElement stylableElement = (CSSStylableElement)element;
      return stylableElement.getStaticPseudoInstances();
    }
    return null;
  }
  
  protected void onStylesAppliedToChildNodes(Element element, NodeList nodes)
  {
    if ((element instanceof CSSStylableElement)) {
      ((CSSStylableElement)element).onStylesApplied(nodes);
    }
  }
  
  public void applyStyleDeclaration(Object element, CSSStyleDeclaration style, String pseudo)
  {
    boolean avoidanceCacheInstalled = currentCSSPropertiesApplyed == null;
    if (avoidanceCacheInstalled) {
      currentCSSPropertiesApplyed = new HashMap();
    }
    List<ICSSPropertyHandler2> handlers2 = null;
    for (int i = 0; i < style.getLength(); i++)
    {
      String property = style.item(i);
      CSSValue value = style.getPropertyCSSValue(property);
      try
      {
        ICSSPropertyHandler handler = applyCSSProperty(element, 
          property, value, pseudo);
        ICSSPropertyHandler2 propertyHandler2 = null;
        if ((handler instanceof ICSSPropertyHandler2)) {
          propertyHandler2 = (ICSSPropertyHandler2)handler;
        } else if ((handler instanceof ICSSPropertyHandler2Delegate)) {
          propertyHandler2 = 
            ((ICSSPropertyHandler2Delegate)handler).getCSSPropertyHandler2();
        }
        if (propertyHandler2 != null)
        {
          if (handlers2 == null) {
            handlers2 = new ArrayList();
          }
          if (!handlers2.contains(propertyHandler2)) {
            handlers2.add(propertyHandler2);
          }
        }
      }
      catch (Exception e)
      {
        if ((throwError) || (
          (!throwError) && (!(e instanceof UnsupportedPropertyException)))) {
          handleExceptions(e);
        }
      }
    }
    if (handlers2 != null) {
      for (Iterator<ICSSPropertyHandler2> iterator = handlers2.iterator(); iterator
            .hasNext();)
      {
        ICSSPropertyHandler2 handler2 = 
          (ICSSPropertyHandler2)iterator.next();
        try
        {
          handler2.onAllCSSPropertiesApplyed(element, this);
        }
        catch (Exception e)
        {
          handleExceptions(e);
        }
      }
    }
    if (avoidanceCacheInstalled) {
      currentCSSPropertiesApplyed = null;
    }
  }
  
  public CSSStyleDeclaration parseAndApplyStyleDeclaration(Object node, Reader reader)
    throws IOEx
1 2 3 4 5 6 7 8 9

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd