use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class CSSProposalGeneratorForDeclarationValue method addImportant.
private void addImportant(List candidates) {
ICSSNode targetNode = fContext.getTargetNode();
while (targetNode instanceof ICSSPrimitiveValue) {
targetNode = targetNode.getParentNode();
}
if (!(targetNode instanceof ICSSStyleDeclItem)) {
return;
}
// 1. has no priority region
// 2. cursor position is after of last child
// 3. normal isMatch method
String priority = ((ICSSStyleDeclItem) targetNode).getPriority();
if (priority == null || priority.length() == 0) {
ICSSNode lastChild = targetNode.getLastChild();
if (lastChild instanceof IndexedRegion) {
int startOffset = ((IndexedRegion) lastChild).getStartOffset();
// int endOffset = ((IndexedRegion)lastChild).getEndOffset();
if (startOffset < fContext.getCursorPos() && isMatch(IMPORTANT)) {
CSSCACandidate item = new CSSCACandidate();
item.setReplacementString(IMPORTANT);
item.setCursorPosition(IMPORTANT.length());
item.setDisplayString(IMPORTANT);
item.setImageType(CSSImageType.VALUE_STRING);
appendSemiColon(item);
candidates.add(item);
}
}
}
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class CSSNodeAdapter method getMediaText.
private String getMediaText(CSSRule rule) {
// $NON-NLS-1$
String result = "";
ICSSNode child = (rule != null) ? ((ICSSNode) rule).getFirstChild() : null;
while (child != null) {
if (child.getNodeType() == ICSSNode.MEDIALIST_NODE) {
result = ((MediaList) child).getMediaText();
break;
}
child = child.getNextSibling();
}
return result;
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class CSSNodeAdapter method notifyChanged.
/**
* Called by the object being adapter (the notifier) when something has
* changed.
*/
public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
if (notifyQueue == null)
notifyQueue = new Vector();
// exec
if (notifier instanceof ICSSNode) {
Collection listeners = ((JFaceNodeAdapterFactoryCSS) adapterFactory).getListeners();
Iterator iterator = listeners.iterator();
while (iterator.hasNext()) {
Object listener = iterator.next();
// INodeNotifier.CHANGE && changedFeature == null))) {
if ((listener instanceof StructuredViewer) && ((eventType == INodeNotifier.STRUCTURE_CHANGED) || (eventType == INodeNotifier.CONTENT_CHANGED) || (eventType == INodeNotifier.CHANGE || (eventType == INodeNotifier.ADD) || (eventType == INodeNotifier.REMOVE)))) {
if (DEBUG) {
// $NON-NLS-1$
System.out.println("JFaceNodeAdapter notified on event type > " + eventType);
}
// refresh on structural and "unknown" changes
StructuredViewer structuredViewer = (StructuredViewer) listener;
// https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5230
if (structuredViewer.getControl() != null) {
getRefreshJob().refresh(structuredViewer, (ICSSNode) notifier);
}
}
}
}
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode 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.ICSSNode in project webtools.sourceediting by eclipse.
the class CSSNodeAdapter method addElements.
private void addElements(Object element, ArrayList v) {
ICSSNode node;
if (element instanceof ICSSModel) {
ICSSModel model = (ICSSModel) element;
ICSSDocument doc = model.getDocument();
node = doc.getFirstChild();
} else if (element instanceof ICSSNode) {
node = ((ICSSNode) element).getFirstChild();
} else
return;
while (node != null) {
if (node instanceof CSSRule) {
v.add(node);
}
node = node.getNextSibling();
}
}
Aggregations