/** * @return int */ public int getLength() { int i = 0; for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof CSSPrimitiveValueImpl) i++; } return i; }
CSSRuleImpl getIndexedRule(int index) { if (index < 0) return null; int i = 0; for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof CSSRule) { if (i++ == index) return (CSSRuleImpl) node; } } return null; }
CSSRuleImpl getIndexedRule(int index) { if (index < 0) return null; int i = 0; for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof CSSRule) { if (i++ == index) return (CSSRuleImpl) node; } } return null; }
/** * @return org.w3c.dom.css.CSSStyleDeclaration */ public CSSStyleDeclaration getStyle() { for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof CSSStyleDeclaration) return (CSSStyleDeclaration) node; } return null; } }
/** * A list of media types for this rule. */ public MediaList getMedia() { for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof MediaListImpl) return (MediaList) node; } return null; }
/** * @return int */ public int getLength() { int i = 0; ICSSNode node = getFirstChild(); while (node != null) { if (node instanceof CSSStyleDeclItemImpl) i++; node = node.getNextSibling(); } return i; }
/** * @return org.w3c.dom.css.CSSValue * @param index * int */ public CSSValue item(int index) { int i = 0; for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof CSSPrimitiveValueImpl) { if (i++ == index) return (CSSValue) node; } } return null; }
/** * */ void removeChildNodes() { ICSSNode nextChild = null; for (ICSSNode child = getFirstChild(); child != null; child = nextChild) { nextChild = child.getNextSibling(); removeChild((CSSNodeImpl) child); } }
public ICSSNodeList getChildNodes() { CSSNodeListImpl list = new CSSNodeListImpl(); for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { list.appendNode(node); } return list; }
/** * The list of all CSS rules contained within the style sheet. This * includes both rule sets and at-rules. */ public CSSRuleList getCssRules() { CSSRuleListImpl list = new CSSRuleListImpl(); for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof CSSRule) { list.appendNode(node); } } return list; }
/** * A list of all CSS rules contained within the media block. */ public CSSRuleList getCssRules() { CSSRuleListImpl list = new CSSRuleListImpl(); for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof CSSRule) list.appendNode(node); } return list; }
CSSNodeImpl getContainerNode(int offset) { if (!contains(offset)) return null; for (ICSSNode child = getFirstChild(); child != null; child = child.getNextSibling()) { ICSSNode found = ((CSSNodeImpl) child).getContainerNode(offset); if (found != null) return (CSSNodeImpl) found; } return this; }
/** * @return boolean * @param node * org.eclipse.wst.css.core.model.interfaces.ICSSNode */ static boolean diagnoseTree(ICSSNode parent, IStructuredDocument structuredDocument) { if (parent == null) { return false; } // check children for (ICSSNode child = parent.getFirstChild(); child != null; child = child.getNextSibling()) { diagnoseTree(child, structuredDocument); } diagnoseNode(parent, structuredDocument); return true; }
/** * @param value * java.lang.String * @exception org.w3c.dom.DOMException * The exception description. */ public void setCssValueText(String value) throws DOMException { ICSSNode child = getFirstChild(); while (child != null) { ICSSNode next = child.getNextSibling(); if (child instanceof ICSSPrimitiveValue) { removeChild((CSSNodeImpl) child); } child = next; } setCssValueTextCore(value); }
/** * currently public but may be made default access protected in future. */ protected void cloneChildNodes(ICSSNode newParent, boolean deep) { if (newParent == null || newParent == this) return; CSSNodeImpl container = (CSSNodeImpl) newParent; container.removeChildNodes(); for (ICSSNode child = getFirstChild(); child != null; child = child.getNextSibling()) { CSSNodeImpl cloned = (CSSNodeImpl) child.cloneNode(deep); if (cloned != null) container.appendChild(cloned); } }
/** * @param parent * org.eclipse.wst.css.core.model.interfaces.ICSSNode */ static void cleanupContainer(ICSSNode parent) { if (parent == null) { return; } for (ICSSNode child = parent.getFirstChild(); child != null; child = child.getNextSibling()) { cleanupContainer(child); } if (parent instanceof CSSStructuredDocumentRegionContainer) { ((CSSStructuredDocumentRegionContainer) parent).setRangeStructuredDocumentRegion(null, null); } else if (parent instanceof CSSRegionContainer) { ((CSSRegionContainer) parent).setRangeRegion(null, null, null); } }
/** * */ protected final void formatChildren(ICSSNode node, StringBuffer source) { ICSSNode child = node.getFirstChild(); boolean first = true; while (child != null) { // append child CSSSourceFormatter formatter = (CSSSourceFormatter) ((INodeNotifier) child).getAdapterFor(CSSSourceFormatter.class); if (formatter == null) { formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) child); } StringBuffer childSource = ((AbstractCSSSourceFormatter) formatter).formatProc(child); if (!first) { formatBefore(node, child, new String(childSource), source, null); } source.append(childSource); // append between children child = child.getNextSibling(); first = false; } }
/** * */ private CSSStructuredDocumentRegionContainer findContainer(CSSNodeImpl parent, IStructuredDocumentRegion flatNode) { if (parent instanceof CSSStructuredDocumentRegionContainer) { // Am i a container of flatNode? IStructuredDocumentRegion firstNode = ((CSSStructuredDocumentRegionContainer) parent).getFirstStructuredDocumentRegion(); IStructuredDocumentRegion lastNode = ((CSSStructuredDocumentRegionContainer) parent).getLastStructuredDocumentRegion(); int firstStart = getOriginalOffset(firstNode); int lastStart = getOriginalOffset(lastNode); int start = flatNode.getStart(); if (firstStart <= start && start <= lastStart) { // I am a container, is my child a container ? for (ICSSNode node = parent.getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof CSSNodeImpl) { CSSStructuredDocumentRegionContainer container = findContainer((CSSNodeImpl) node, flatNode); if (container != null) { return container; } } } return (CSSStructuredDocumentRegionContainer) parent; } } return null; }
/** * */ void shrinkContainer(CSSStructuredDocumentRegionContainer parent, CSSStructuredDocumentRegionContainer child) { if (child == null) { return; } boolean bModified = false; bModified = bModified || cleanupLastNode(child.getLastStructuredDocumentRegion(), parent); bModified = bModified || cleanupFirstNode(child.getFirstStructuredDocumentRegion(), parent); if (bModified) { if (parent != null) { for (ICSSNode node = parent.getFirstChild(); node != null; node = node.getNextSibling()) { if (child != node && node instanceof CSSStructuredDocumentRegionContainer) { ((CSSStructuredDocumentRegionContainer) node).propagateRangeStructuredDocumentRegion(); } } } } child.setRangeStructuredDocumentRegion(null, null); } }
/** * @return java.lang.String */ public java.lang.String getCSSValueText() { if (getFirstChild() == null) return "";//$NON-NLS-1$ // check whether children has flatnodes ICSSNode child = getFirstChild(); while (child != null) { if (((IndexedRegion) child).getEndOffset() <= 0) return generateValueSource(); child = child.getNextSibling(); } IStructuredDocumentRegion node = getFirstStructuredDocumentRegion(); int start = ((IndexedRegion) getFirstChild()).getStartOffset() - node.getStartOffset(); int end = ((IndexedRegion) getLastChild()).getEndOffset() - node.getStartOffset(); return node.getText().substring(start, end); }