use of org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue in project webtools.sourceediting by eclipse.
the class CSSStyleDeclItemImpl method setCssValueText.
/**
* @param value
* java.lang.String
* @exception org.w3c.dom.DOMException
* The exception description.
*/
public void setCssValueText(String value) throws DOMException {
ICSSNode child = getFirstChild();
while (child != null) {
ICSSNode next = child.getNextSibling();
if (child instanceof ICSSPrimitiveValue) {
removeChild((CSSNodeImpl) child);
}
child = next;
}
setCssValueTextCore(value);
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue in project webtools.sourceediting by eclipse.
the class CSSSourceFormatterFactory method getSourceFormatter.
/**
*/
public CSSSourceGenerator getSourceFormatter(INodeNotifier target) {
ICSSNode node = (ICSSNode) target;
short type = node.getNodeType();
switch(type) {
case ICSSNode.CHARSETRULE_NODE:
return CharsetRuleFormatter.getInstance();
case ICSSNode.FONTFACERULE_NODE:
return FontFaceRuleFormatter.getInstance();
case ICSSNode.IMPORTRULE_NODE:
return ImportRuleFormatter.getInstance();
case ICSSNode.MEDIALIST_NODE:
return MediaListFormatter.getInstance();
case ICSSNode.MEDIARULE_NODE:
return MediaRuleFormatter.getInstance();
case ICSSNode.PRIMITIVEVALUE_NODE:
ICSSPrimitiveValue value = (ICSSPrimitiveValue) node;
if (value.getPrimitiveType() == org.w3c.dom.css.CSSPrimitiveValue.CSS_COUNTER)
return CounterFormatter.getInstance();
else if (value.getPrimitiveType() == org.w3c.dom.css.CSSPrimitiveValue.CSS_RECT)
return RectFormatter.getInstance();
else if (value.getPrimitiveType() == org.w3c.dom.css.CSSPrimitiveValue.CSS_RGBCOLOR)
return RGBFormatter.getInstance();
else
return PrimitiveValueFormatter.getInstance();
case ICSSNode.PAGERULE_NODE:
return PageRuleFormatter.getInstance();
case ICSSNode.STYLEDECLARATION_NODE:
return StyleDeclarationFormatter.getInstance();
case ICSSNode.STYLEDECLITEM_NODE:
return StyleDeclItemFormatter.getInstance();
case ICSSNode.STYLERULE_NODE:
return StyleRuleFormatter.getInstance();
case ICSSNode.STYLESHEET_NODE:
return StyleSheetFormatter.getInstance();
case ICSSNode.ATTR_NODE:
return AttrFormatter.getInstance();
default:
return UnknownRuleFormatter.getInstance();
}
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue in project webtools.sourceediting by eclipse.
the class BackgroundPositionXSubStyleAdapter method get.
/**
*/
public String get(ICSS2Properties properties) {
String str = null;
Object obj = properties.get(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION));
if (obj != null) {
PropCMProperty propX = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X);
PropCMProperty propY = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y);
if (obj instanceof ICSSValueList) {
ICSSValueList list = (ICSSValueList) obj;
ICSSValue value = (ICSSValue) list.item(0);
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
ICSSPrimitiveValue prim = (ICSSPrimitiveValue) value;
if (prim.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
// check not top or bottom
if (!propX.canHave(prim.getStringValue()) && propY.canHave(prim.getStringValue())) {
// case order is vertical -> horizontal
value = (ICSSValue) list.item(1);
}
}
}
str = value.getCSSValueText();
} else if (obj instanceof ICSSValue) {
str = ((ICSSValue) obj).getCSSValueText();
if (str.equalsIgnoreCase(IValID.V_BOTTOM) || str.equalsIgnoreCase(IValID.V_TOP))
// $NON-NLS-1$
str = "";
} else {
str = obj.toString();
CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, str);
CSSTextToken[] tokens = parser.getTokens();
tokens = correctMeaningToken(tokens);
if (tokens.length == 0)
// $NON-NLS-1$
str = "";
else if (tokens.length == 1 && (tokens[0].image.equalsIgnoreCase(IValID.V_BOTTOM) || tokens[0].image.equalsIgnoreCase(IValID.V_TOP)))
// $NON-NLS-1$
str = "";
else
str = tokens[0].image;
}
}
// $NON-NLS-1$
return (str != null) ? str : "";
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue in project webtools.sourceediting by eclipse.
the class BackgroundPositionYSubStyleAdapter method get.
/**
*/
public String get(ICSS2Properties properties) {
String str = null;
Object obj = properties.get(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION));
if (obj != null) {
PropCMProperty propX = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X);
PropCMProperty propY = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y);
if (obj instanceof ICSSValueList) {
ICSSValueList list = (ICSSValueList) obj;
int index = 1;
ICSSValue value = (ICSSValue) list.item(0);
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
ICSSPrimitiveValue prim = (ICSSPrimitiveValue) value;
if (prim.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
// check not top or bottom
if (!propX.canHave(prim.getStringValue()) && propY.canHave(prim.getStringValue())) {
// case order is vertical -> horizontal
index = 0;
}
}
}
str = ((ICSSValue) list.item(index)).getCSSValueText();
} else if (obj instanceof ICSSValue) {
str = ((ICSSValue) obj).getCSSValueText();
if (!str.equalsIgnoreCase(IValID.V_BOTTOM) && !str.equalsIgnoreCase(IValID.V_TOP))
// $NON-NLS-1$
str = "";
} else {
str = obj.toString();
CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, str);
CSSTextToken[] tokens = parser.getTokens();
tokens = correctMeaningToken(tokens);
if (tokens.length == 1 && (tokens[0].image.equalsIgnoreCase(IValID.V_BOTTOM) || tokens[0].image.equalsIgnoreCase(IValID.V_TOP)))
str = tokens[0].image;
else if (tokens.length > 1)
str = tokens[1].image;
else
// $NON-NLS-1$
str = "";
}
}
// $NON-NLS-1$
return (str != null) ? str : "";
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue in project webtools.sourceediting by eclipse.
the class CSSContentSelectionProvider method getFilteredNode.
private Object getFilteredNode(Object object) {
// If the selection is a primitive value, get the property that contains it */
if (object instanceof ICSSPrimitiveValue) {
ICSSPrimitiveValue value = (ICSSPrimitiveValue) object;
object = value.getParentNode();
}
return object;
}
Aggregations