use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class AbstractCSSModelAdapter method notifyStyleChanged.
/**
*/
protected void notifyStyleChanged(Element target) {
INodeNotifier notifier = (INodeNotifier) target;
if (notifier == null)
return;
Collection adapters = notifier.getAdapters();
if (adapters == null)
return;
Iterator it = adapters.iterator();
if (it == null)
return;
while (it.hasNext()) {
INodeAdapter adapter = (INodeAdapter) it.next();
if (adapter instanceof StyleListener) {
StyleListener listener = (StyleListener) adapter;
listener.styleChanged();
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class HTMLDocumentAdapter method notifyStyleSheetsChanged.
/**
*/
private void notifyStyleSheetsChanged(Document target) {
INodeNotifier notifier = (INodeNotifier) target;
if (notifier == null)
return;
Collection adapters = notifier.getAdapters();
if (adapters == null)
return;
Iterator it = adapters.iterator();
if (it == null)
return;
while (it.hasNext()) {
INodeAdapter adapter = (INodeAdapter) it.next();
if (adapter instanceof StyleListener) {
StyleListener listener = (StyleListener) adapter;
listener.styleChanged();
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter 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.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class HTMLStyleSelectorAdapterFactory method adapt.
/**
* Method that returns the adapter associated with the given object.
* It may be a singleton or not ... depending on the needs of the INodeAdapter ...
* but in general it is recommended for an adapter to be stateless,
* so the efficiencies of a singleton can be gained.
*
* The implementation of this method should call addAdapter on the adapted
* object with the correct instance of the adapter.
*/
public INodeAdapter adapt(INodeNotifier notifier) {
INodeAdapter adapter = notifier.getExistingAdapter(IStyleSelectorAdapter.class);
if (adapter != null)
return adapter;
adapter = HTMLStyleSelectorAdapter.getInstance();
notifier.addAdapter(adapter);
return adapter;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class HTMLModelParserAdapterFactory method adapt.
/**
* Method that returns the adapter associated with the given object. It
* may be a singleton or not ... depending on the needs of the
* INodeAdapter ... but in general it is recommended for an adapter to be
* stateless, so the efficiencies of a singleton can be gained.
*
* The implementation of this method should call addAdapter on the adapted
* object with the correct instance of the adapter.
*/
public INodeAdapter adapt(INodeNotifier notifier) {
INodeAdapter adapter = null;
if (notifier != null) {
if (notifier instanceof IDOMDocument) {
adapter = notifier.getExistingAdapter(ModelParserAdapter.class);
if (adapter == null) {
adapter = new HTMLModelParserAdapter();
notifier.addAdapter(adapter);
}
}
}
return adapter;
}
Aggregations