use of org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration in project webtools.sourceediting by eclipse.
the class BUG124835SetStyleAttributeValueTest method setInlineStyle.
private void setInlineStyle(Element element, String name, String value) {
ICSSStyleDeclaration decl = null;
try {
decl = (ICSSStyleDeclaration) ((ElementCSSInlineStyle) element).getStyle();
} catch (ClassCastException ex) {
// do nothing
}
if (decl != null) {
String priority = decl.getPropertyPriority(name);
decl.setProperty(name, value, priority);
}
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration in project webtools.sourceediting by eclipse.
the class BUG124835SetStyleAttributeValueTest method getInlineStyle.
private String getInlineStyle(Element element, String name) {
String value = null;
ICSSStyleDeclaration decl = null;
try {
decl = (ICSSStyleDeclaration) ((ElementCSSInlineStyle) element).getStyle();
} catch (ClassCastException ex) {
// do nothing
}
if (decl != null) {
value = decl.getPropertyValue(name);
}
return value;
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration in project webtools.sourceediting by eclipse.
the class CSSNodeAdapter method getChildren.
/**
* Returns an enumeration containing all child nodes of the given element,
* which represents a node in a tree. The difference to
* <code>IStructuredContentProvider.getElements(Object)</code> is as
* follows: <code>getElements</code> is called to obtain the tree
* viewer's root elements. Method <code>getChildren</code> is used to
* obtain the children of a given node in the tree, which can can be a
* root node, too.
*/
public Object[] getChildren(Object object) {
if (object instanceof ICSSNode) {
ICSSNode node = (ICSSNode) object;
short nodeType = node.getNodeType();
if (nodeType == ICSSNode.STYLERULE_NODE || nodeType == ICSSNode.PAGERULE_NODE || nodeType == ICSSNode.FONTFACERULE_NODE) {
for (node = node.getFirstChild(); node != null && !(node instanceof ICSSStyleDeclaration); node.getNextSibling()) {
// nop
}
}
List children = new ArrayList();
ICSSNode child = (node != null) ? node.getFirstChild() : null;
while (child != null) {
if (!(child instanceof ICSSPrimitiveValue) && !(child instanceof MediaList)) {
children.add(child);
}
/*
* Required to correctly connect the refreshing behavior to
* the tree
*/
if (child instanceof INodeNotifier) {
((INodeNotifier) child).getAdapterFor(IJFaceNodeAdapter.class);
}
child = child.getNextSibling();
}
return children.toArray();
}
return new Object[0];
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration in project webtools.sourceediting by eclipse.
the class CSSProposalArranger method buildProposals.
/**
*/
void buildProposals() {
fProposals.clear();
/*
* String text; ICompletionProposal item; text = "---- Test
* Information ----"; item = new CompletionProposal("",
* fContext.getReplaceBegin(), 0, 0, null, text, null, null);
* fProposals.add(item);
*
* text = "Target: \"" + fContext.getRegionText() + "\"";
*
* item = new CompletionProposal("", fContext.getReplaceBegin(), 0, 0,
* null, text, null, null); fProposals.add(item);
*
* text = fContext.getTargetNode().getClass().toString(); int
* lastPeriodPos = text.lastIndexOf('.'); text = "Node: " +
* text.substring(lastPeriodPos + 1); item = new
* CompletionProposal("", fContext.getReplaceBegin(), 0, 0, null,
* text, null, null); fProposals.add(item);
*/
ICSSNode targetNode = fContext.getTargetNode();
// int targetPos = fContext.getTargetPos();
if (targetNode instanceof ICSSStyleSheet) {
buildProposalsForAnyRule();
} else if ((targetNode instanceof ICSSMediaRule && fContext.isTargetPosAfterOf(CSSRegionContexts.CSS_LBRACE)) || (targetNode instanceof ICSSStyleRule && fContext.isTargetPosBeforeOf(CSSRegionContexts.CSS_LBRACE))) {
buildProposalsForAnyRule();
// buildProposalsForStyleRule();
} else if ((targetNode instanceof ICSSPageRule && fContext.isTargetPosBeforeOf(CSSRegionContexts.CSS_LBRACE))) {
buildProposalsForPageRulePseudoClass();
} else if ((targetNode instanceof ICSSStyleRule || targetNode instanceof CSSFontFaceRule || targetNode instanceof ICSSPageRule || targetNode instanceof ICSSStyleDeclaration) && (targetNode.getOwnerDocument() instanceof ICSSStyleDeclaration || fContext.targetFollows(CSSRegionContexts.CSS_DECLARATION_DELIMITER) || fContext.targetFollows(CSSRegionContexts.CSS_LBRACE))) {
buildProposalsForDeclarationName();
} else if (targetNode instanceof ICSSStyleDeclItem) {
if (fContext.isTargetPosAfterOf(CSSRegionContexts.CSS_DECLARATION_SEPARATOR)) {
buildProposalsForDeclarationValue();
} else {
buildProposalsForDeclarationName();
}
} else if (targetNode instanceof ICSSPrimitiveValue) {
buildProposalsForDeclarationValue();
}
/*
* else if (targetNode instanceof ICSSPrimitiveValue || ((targetNode
* instanceof ICSSStyleRule || targetNode instanceof CSSFontFaceRule ||
* targetNode instanceof ICSSStyleDeclaration || targetNode instanceof
* ICSSStyleDeclItem) &&
* fContext.isTargetPosAfterOf(CSSRegionContexts.COLON))) {
* buildProposalsForDeclarationValue(); }
*/
// for Test
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration in project webtools.sourceediting by eclipse.
the class CSSProposalGeneratorForDeclarationName method getCandidates.
/**
* getCandidates method comment.
*/
protected Iterator getCandidates() {
List candidates = new ArrayList();
Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
// $NON-NLS-1$
String preDelim = "";
for (int i = 0; i < preferences.getInt(CSSCorePreferenceNames.FORMAT_PROP_PRE_DELIM); i++) {
// $NON-NLS-1$
preDelim += ' ';
}
// $NON-NLS-1$
String postDelim = "";
for (int i = 0; i < preferences.getInt(CSSCorePreferenceNames.FORMAT_PROP_POST_DELIM); i++) {
// $NON-NLS-1$
postDelim += ' ';
}
ICSSNode targetNode = fContext.getTargetNode();
boolean bFontRule = false;
for (ICSSNode node = targetNode; node != null; node = node.getParentNode()) {
if (node instanceof org.w3c.dom.css.CSSFontFaceRule) {
bFontRule = true;
break;
}
}
List names = new ArrayList();
CSSMetaModelUtil util = new CSSMetaModelUtil(fContext.getMetaModel());
Iterator iNames = util.collectNodesByType((bFontRule) ? CSSMMNode.TYPE_DESCRIPTOR : CSSMMNode.TYPE_PROPERTY);
while (iNames.hasNext()) {
CSSMMNode node = (CSSMMNode) iNames.next();
names.add(node);
}
sortNames(names);
// Collections.sort(names);
boolean bAddColon = true;
if ((targetNode instanceof ICSSStyleRule || targetNode instanceof ICSSStyleDeclItem || targetNode instanceof ICSSStyleDeclaration) && fContext.targetHas(CSSRegionContexts.CSS_DECLARATION_SEPARATOR)) {
bAddColon = false;
}
Iterator i = names.iterator();
while (i.hasNext()) {
CSSMMNode node = (CSSMMNode) i.next();
String text = node.getName();
text = (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_NAME) == CSSCorePreferenceNames.UPPER) ? text.toUpperCase() : text.toLowerCase();
if (!isMatch(text)) {
continue;
}
int cursorPos = 0;
StringBuffer buf = new StringBuffer();
buf.append(text);
buf.append(preDelim);
cursorPos = buf.length();
if (bAddColon) {
// $NON-NLS-1$
buf.append(':');
buf.append(postDelim);
cursorPos += 1 + postDelim.length();
}
// if (! (targetNode instanceof ICSSStyleDeclItem)) {
// buf.append(';');//$NON-NLS-1$
// }
CSSCACandidate item = new CSSCACandidate();
item.setReplacementString(buf.toString());
item.setCursorPosition(cursorPos);
item.setDisplayString(text);
item.setMMNode(node);
item.setImageType(getCategoryImageType(node));
candidates.add(item);
}
return candidates.iterator();
}
Aggregations