use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSNodeAdapter method getElements.
/**
* Returns an enumeration with the elements belonging to the passed
* element. These elements can be presented as rows in a table, items in a
* list etc.
*/
public Object[] getElements(Object object) {
if (object instanceof ICSSModel) {
ArrayList v = new ArrayList();
// internalGetElements(object, v);
addElements(object, v);
Object[] elements = v.toArray();
for (int i = 0; i < elements.length; i++) {
/*
* Required to correctly connect the refreshing behavior to
* the tree
*/
if (elements[i] instanceof INodeNotifier) {
((INodeNotifier) elements[i]).getAdapterFor(IJFaceNodeAdapter.class);
}
}
return elements;
}
return new Object[0];
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSContentAssistContext method initialize.
/**
*/
private void initialize(ICSSDocument doc) {
if (doc == null) {
return;
}
ICSSModel model = doc.getModel();
fModel = model;
fStructuredDocument = model.getStructuredDocument();
initializeTargetPos();
initializeTargetText();
initializeTargetNode();
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSTextPropertyDescriptor method createPropertyEditor.
/**
* @return org.eclipse.jface.viewers.CellEditor
* @param parent
* org.eclipse.swt.widgets.Composite
*/
public CellEditor createPropertyEditor(Composite parent) {
ICSSModel model = fNode.getOwnerDocument().getModel();
if (model == null)
return null;
if (model.getStyleSheetType() == ICSSModel.EXTERNAL && findEditor(model) == null)
return null;
// check whether IFile is readonly to prohibit editing before
// validateEdit()
IStructuredModel structuredModel = model;
if (model.getStyleSheetType() != ICSSModel.EXTERNAL) {
structuredModel = ((IDOMNode) model.getOwnerDOMNode()).getModel();
if (structuredModel == null)
return null;
}
IFile file = CSSPathService.location2File(structuredModel.getBaseLocation());
if (file == null || file.isReadOnly())
return null;
return super.createPropertyEditor(parent);
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSFontFamilyTest method testFontFamilies.
public void testFontFamilies() throws IOException {
ICSSModel model = getModel();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.set(FileUtil.createString("src/org/eclipse/wst/css/core/tests/testfiles", "CSSFontFamilyTest.css"));
CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
CSSRuleList rules = sheet.getCssRules();
assertEquals(4, rules.getLength());
// Rule 1: No whitespace
CSSRule rule;
CSSStyleDeclaration declaration;
CSSValue value;
// Rule 1: No whitespace
rule = rules.item(0);
assertEquals(CSSRule.STYLE_RULE, rule.getType());
assertTrue(rule instanceof CSSStyleRule);
declaration = ((CSSStyleRule) rule).getStyle();
value = declaration.getPropertyCSSValue(FONT_FAMILY);
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "Courier"));
// Rule 2: Single whitespace
rule = rules.item(1);
assertEquals(CSSRule.STYLE_RULE, rule.getType());
assertTrue(rule instanceof CSSStyleRule);
declaration = ((CSSStyleRule) rule).getStyle();
value = declaration.getPropertyCSSValue(FONT_FAMILY);
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "Courier New"));
// Rule 3: In quotes
rule = rules.item(2);
assertEquals(CSSRule.STYLE_RULE, rule.getType());
assertTrue(rule instanceof CSSStyleRule);
declaration = ((CSSStyleRule) rule).getStyle();
value = declaration.getPropertyCSSValue(FONT_FAMILY);
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_STRING, "Courier New"));
// Rule 4: Tabs and spaces all over
rule = rules.item(3);
assertEquals(CSSRule.STYLE_RULE, rule.getType());
assertTrue(rule instanceof CSSStyleRule);
declaration = ((CSSStyleRule) rule).getStyle();
value = declaration.getPropertyCSSValue(FONT_FAMILY);
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "Comic Sans"));
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSPageRuleTest method testInsertText4.
public void testInsertText4() throws IOException {
ICSSModel model = getModel();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.set(FileUtil.createString("src/org/eclipse/wst/css/core/tests/testfiles", "CSSPageRuleTest.css"));
CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
CSSRuleList ruleList = sheet.getCssRules();
assertEquals(6, ruleList.getLength());
CSSRule rule;
CSSStyleDeclaration declaration;
CSSValue value;
// rule 4
rule = ruleList.item(3);
assertEquals(CSSRule.PAGE_RULE, rule.getType());
assertTrue(rule instanceof CSSPageRule);
assertEquals(":right", ((CSSPageRule) rule).getSelectorText());
declaration = ((CSSPageRule) rule).getStyle();
assertEquals(2, declaration.getLength());
value = declaration.getPropertyCSSValue("margin-left");
checkPrimitiveNumber(value, new PrimitiveNumber(CSSPrimitiveValue.CSS_CM, 3));
value = declaration.getPropertyCSSValue("margin-right");
checkPrimitiveNumber(value, new PrimitiveNumber(CSSPrimitiveValue.CSS_CM, 4));
}
Aggregations