use of org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter in project webtools.sourceediting by eclipse.
the class CSSStyleSheetImpl method getOwnerNodes.
/**
* @return org.w3c.dom.NodeList
* @param doc
* org.w3c.dom.Document
*/
public NodeList getOwnerNodes(Document doc) {
List list = (getModel().getStyleListeners() != null) ? new Vector(getModel().getStyleListeners()) : null;
if (list == null)
return null;
InternalNodeList nodes = new InternalNodeList();
Iterator it = list.iterator();
while (it.hasNext()) {
Object obj = it.next();
if (obj instanceof IStyleSheetAdapter) {
Element ele = ((IStyleSheetAdapter) obj).getElement();
if (ele.getOwnerDocument() == doc)
nodes.nodes.add(ele);
}
}
if (nodes.getLength() > 0)
return nodes;
else
return null;
}
use of org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter in project webtools.sourceediting by eclipse.
the class HTMLDocumentAdapter method releaseStyleSheets.
/**
*/
public void releaseStyleSheets() {
releaseOldStyleSheets();
if (this.styleAdapters == null)
return;
Iterator it = this.styleAdapters.iterator();
while (it.hasNext()) {
IStyleSheetAdapter adapter = (IStyleSheetAdapter) it.next();
if (adapter != null)
adapter.released();
}
this.styleAdapters = null;
}
use of org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter in project webtools.sourceediting by eclipse.
the class HTMLDocumentAdapter method addStyleSheet.
/**
*/
private void addStyleSheet(Element node) {
IDOMElement element = (IDOMElement) node;
String tagName = element.getTagName();
if (tagName == null)
return;
boolean isContainer = false;
if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HTML) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HEAD) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.NOSCRIPT) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.BASE) || tagName.equalsIgnoreCase(JSP11Namespace.ElementName.ROOT) || (!element.isGlobalTag() && element.isContainer())) {
isContainer = true;
} else if (element.isCommentTag()) {
Node parent = element.getParentNode();
if (parent == element.getOwnerDocument()) {
// This condition is too severe, actually do not work for JSF template.
// But above (! globalTag() && isContainer()) cover JSF template + tpl template
isContainer = true;
} else if (parent.getNodeType() == Node.ELEMENT_NODE) {
tagName = ((Element) parent).getTagName();
if (tagName != null && tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HEAD)) {
isContainer = true;
}
}
} else {
String localName = element.getLocalName();
if (localName != null && localName.equalsIgnoreCase(HTML40Namespace.ElementName.HTML)) {
// taglib html tag
isContainer = true;
} else {
INodeNotifier notifier = element;
INodeAdapter adapter = notifier.getAdapterFor(IStyleSheetAdapter.class);
if (adapter != null && adapter instanceof IStyleSheetAdapter) {
this.styleAdapters.addElement(adapter);
}
}
}
if (isContainer) {
INodeNotifier notifier = element;
if (notifier.getExistingAdapter(IStyleSheetListAdapter.class) == null) {
notifier.addAdapter(this);
}
for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
if (child.getNodeType() != Node.ELEMENT_NODE)
continue;
addStyleSheet((Element) child);
}
}
}
use of org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter in project webtools.sourceediting by eclipse.
the class HTMLDocumentAdapter method item.
/**
*/
public StyleSheet item(int index) {
if (this.styleAdapters == null)
return null;
List validAdapters = getValidAdapters();
if (index < 0 || index >= validAdapters.size())
return null;
StyleSheet sheet = ((IStyleSheetAdapter) validAdapters.get(index)).getSheet();
if (sheet == null) {
// for LINK element whose link is broken
ICSSModel model = ((AbstractStyleSheetAdapter) validAdapters.get(index)).createModel();
sheet = ((model != null) ? (StyleSheet) model.getDocument() : null);
}
return sheet;
}
use of org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter in project webtools.sourceediting by eclipse.
the class HTMLDocumentAdapter method releaseOldStyleSheets.
/**
*/
private void releaseOldStyleSheets() {
if (this.oldStyleAdapters == null)
return;
Iterator it = this.oldStyleAdapters.iterator();
while (it.hasNext()) {
IStyleSheetAdapter adapter = (IStyleSheetAdapter) it.next();
if (adapter == null)
continue;
// do not release
if (this.styleAdapters != null && this.styleAdapters.contains(adapter))
continue;
adapter.released();
}
this.oldStyleAdapters = null;
}
Aggregations