use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class CSSModelUpdateContext method getCSSFontFaceRule.
/**
*/
CSSFontFaceRuleImpl getCSSFontFaceRule() {
ICSSNode node = getNode();
if (node instanceof CSSFontFaceRuleImpl) {
return (CSSFontFaceRuleImpl) node;
} else {
CSSUtil.debugOut(// $NON-NLS-1$
"CSSFontFaceRuleImpl is expected, but " + CSSUtil.getClassString(node));
ungetNode();
// $NON-NLS-1$
throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");
}
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class CSSModelUpdateContext method getCSSPrimitiveValue.
/**
*/
CSSPrimitiveValueImpl getCSSPrimitiveValue(short type) {
ICSSNode node = getNode();
if (node instanceof CSSPrimitiveValueImpl) {
short nodeType = ((CSSPrimitiveValueImpl) node).getPrimitiveType();
if (nodeType == type || ((nodeType == CSSPrimitiveValue.CSS_NUMBER || nodeType == ICSSPrimitiveValue.CSS_INTEGER) && (type == CSSPrimitiveValue.CSS_NUMBER || type == ICSSPrimitiveValue.CSS_INTEGER))) {
return (CSSPrimitiveValueImpl) node;
}
}
if (node instanceof CSSPrimitiveValueImpl) {
CSSPrimitiveValueImpl value = (CSSPrimitiveValueImpl) node;
CSSUtil.debugOut(// $NON-NLS-1$
"CSSPrimitiveValueImpl [" + type + // $NON-NLS-1$
"] is expected, but type is [" + value.getPrimitiveType() + "]: \"" + value.generateSource() + // $NON-NLS-2$//$NON-NLS-1$
"\"");
} else {
CSSUtil.debugOut(// $NON-NLS-1$
"CSSPrimitiveValueImpl(" + type + // $NON-NLS-1$
") is expected, but " + CSSUtil.getClassString(node));
}
ungetNode();
// $NON-NLS-1$
throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class CSSNodeImpl method removeChildNodes.
/**
*/
void removeChildNodes() {
ICSSNode nextChild = null;
for (ICSSNode child = getFirstChild(); child != null; child = nextChild) {
nextChild = child.getNextSibling();
removeChild((CSSNodeImpl) child);
}
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class HTMLDocumentAdapter method getClasses.
/**
*/
public Enumeration getClasses() {
StyleSheetList sheetList = getStyleSheets();
int nSheets = sheetList.getLength();
final ArrayList classes = new ArrayList();
CSSClassTraverser traverser = new CSSClassTraverser();
traverser.setTraverseImported(true);
for (int i = 0; i < nSheets; i++) {
org.w3c.dom.stylesheets.StyleSheet sheet = sheetList.item(i);
if (sheet instanceof ICSSNode) {
traverser.apply((ICSSNode) sheet);
}
}
classes.addAll(traverser.getClassNames());
return new Enumeration() {
int i = 0;
public boolean hasMoreElements() {
return i < classes.size();
}
public Object nextElement() {
return classes.get(i++);
}
};
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class EmbeddedCSSFormatter method getCSSContent.
/**
*/
private String getCSSContent(IDOMNode text) {
ICSSModel model = getCSSModel(text);
if (model == null)
return null;
ICSSNode document = model.getDocument();
if (document == null)
return null;
INodeNotifier notifier = (INodeNotifier) document;
CSSSourceFormatter formatter = (CSSSourceFormatter) notifier.getAdapterFor(CSSSourceFormatter.class);
// try another way to get formatter
if (formatter == null)
formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(notifier);
if (formatter == null)
return null;
StringBuffer buffer = formatter.format(document);
if (buffer == null)
return null;
return buffer.toString();
}
Aggregations