use of org.eclipse.wst.css.core.internal.provisional.document.ICSSValue 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.ICSSValue 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.ICSSValue in project webtools.sourceediting by eclipse.
the class CSSPropertyContext method applyModified.
/**
* This function exports modified property/value pairs to 'decl'
* declaration
*/
public void applyModified(ICSSStyleDeclaration decl) {
if (decl == null || fModified == null)
return;
Iterator it = fModified.iterator();
while (it.hasNext()) {
Object key = it.next();
Object val = fProperties.get(key);
String value = (val instanceof ICSSValue) ? ((ICSSValue) val).getCSSValueText() : ((val != null) ? val.toString() : null);
if (value == null || value.length() <= 0)
decl.removeProperty(key.toString());
else
// $NON-NLS-2$//$NON-NLS-1$
decl.setProperty(key.toString(), value.trim(), (val instanceof ValueData && ((ValueData) val).important) ? "!important" : "");
}
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSValue in project webtools.sourceediting by eclipse.
the class CSSContentOutlineConfiguration method getFilteredNode.
private Object getFilteredNode(Object o) {
ICSSNode node = null;
if (o instanceof ICSSNode) {
node = (ICSSNode) o;
short nodeType = node.getNodeType();
if (node instanceof ICSSValue) {
while (node != null && !(node instanceof ICSSStyleDeclItem)) {
node = node.getParentNode();
}
} else if (nodeType == ICSSNode.STYLEDECLARATION_NODE) {
node = node.getParentNode();
} else if (nodeType == ICSSNode.MEDIALIST_NODE) {
node = node.getParentNode();
}
}
return node;
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSValue in project webtools.sourceediting by eclipse.
the class CSSQueryContext method applyFull.
/**
*/
public void applyFull(ICSSStyleDeclaration decl) {
if (decl == null)
return;
Enumeration keys = fProperties.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object val = fProperties.get(key);
if (val instanceof CSSQueryDeclarationData) {
ICSSStyleDeclItem declItem = ((CSSQueryDeclarationData) val).getDeclItem();
if (declItem.getLength() <= 0) {
ICSSStyleDeclItem itemToRemove = decl.getDeclItemNode(key.toString());
if (itemToRemove != null) {
decl.removeDeclItemNode(itemToRemove);
}
} else {
decl.setDeclItemNode(declItem);
}
} else {
String value = (val instanceof ICSSValue) ? ((ICSSValue) val).getCSSValueText() : val.toString();
if (value == null || value.length() <= 0) {
ICSSStyleDeclItem itemToRemove = decl.getDeclItemNode(key.toString());
if (itemToRemove != null) {
decl.removeDeclItemNode(itemToRemove);
}
} else {
decl.setProperty(key.toString(), value, null);
}
}
}
}
Aggregations