use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class PageDirectiveAdapterImpl method adapt.
/**
* @see PageDirectiveAdapter#adapt(INodeNotifier, Object)
*/
public INodeAdapter adapt(INodeNotifier notifier, Object type) {
INodeAdapter result = null;
// then we can not adapt it.
if (embeddedTypeHandler != null) {
if (embeddedFactoryRegistry != null) {
Iterator iterator = embeddedFactoryRegistry.iterator();
INodeAdapterFactory factory = null;
while (iterator.hasNext()) {
factory = (INodeAdapterFactory) iterator.next();
if (factory.isFactoryForType(type)) {
result = factory.adapt(notifier);
break;
}
}
}
}
return result;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class DocumentStyleImpl method releaseStyleSheets.
protected void releaseStyleSheets() {
INodeAdapter adapter = getExistingAdapter(IStyleSheetListAdapter.class);
if (adapter == null)
return;
((IStyleSheetListAdapter) adapter).releaseStyleSheets();
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class StyleAdapterFactory method adapt.
/**
*/
public INodeAdapter adapt(INodeNotifier notifier) {
if (notifier == null)
return null;
Node node = (Node) notifier;
short nodeType = node.getNodeType();
if (nodeType == Node.DOCUMENT_NODE) {
INodeAdapter adapter = notifier.getExistingAdapter(IStyleSheetListAdapter.class);
if (adapter != null)
return adapter;
HTMLDocumentAdapter newAdapter = new HTMLDocumentAdapter();
newAdapter.setDocument((Document) node);
notifier.addAdapter(newAdapter);
return newAdapter;
}
if (nodeType != Node.ELEMENT_NODE)
return null;
Element element = (Element) node;
String tagName = element.getTagName();
if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE)) {
if (!isTagAvailable(element.getOwnerDocument(), HTML40Namespace.ElementName.STYLE)) {
return null;
}
// String type = element.getAttribute(HTML40Namespace.ATTR_NAME_TYPE);
// if (type != null && ! type.equalsIgnoreCase(CSS_CONTENT_TYPE)) {
// return null;
// }
INodeAdapter adapter = notifier.getExistingAdapter(IStyleSheetAdapter.class);
if (adapter != null)
return adapter;
StyleElementAdapter newAdapter = new StyleElementAdapter();
newAdapter.setElement(element);
notifier.addAdapter(newAdapter);
return newAdapter;
} else if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.LINK)) {
if (!isTagAvailable(element.getOwnerDocument(), HTML40Namespace.ElementName.LINK)) {
return null;
}
INodeAdapter adapter = notifier.getExistingAdapter(IStyleSheetAdapter.class);
if (adapter != null)
return adapter;
LinkElementAdapter newAdapter = new LinkElementAdapter();
newAdapter.setElement(element);
notifier.addAdapter(newAdapter);
return newAdapter;
}
INodeAdapter adapter = notifier.getExistingAdapter(IStyleDeclarationAdapter.class);
if (adapter != null)
return adapter;
if (!isAttributeAvailable(element, HTML40Namespace.ATTR_NAME_STYLE)) {
return null;
}
StyleAttrAdapter newAdapter = new StyleAttrAdapter();
newAdapter.setElement(element);
notifier.addAdapter(newAdapter);
return newAdapter;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class HTMLDocumentTypeAdapterFactory 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 result = null;
// only adapt IDOMDocument
if (notifier instanceof IDOMDocument) {
// if already has an adapter, no need to recreate/initialize.
// Note: this means if "doctype" for DOM changes,
// theDocumentTypeAdatper for that DOM
// should be removed (and released) and it will be re-created next
// time required.
DocumentTypeAdapter oldAdapter = (DocumentTypeAdapter) notifier.getExistingAdapter(DocumentTypeAdapter.class);
if (oldAdapter != null) {
result = oldAdapter;
} else {
// if there already was an adapter
// if(fAdapter != null)
// fAdapter.release();
// note, the factory is included in this case to have a central place
// to come back to for case preferences.
result = new HTMLDocumentTypeAdapter((IDOMDocument) notifier, this);
notifier.addAdapter(result);
}
}
return result;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class EmbeddedCSSFormatter method getCSSModel.
/**
*/
private ICSSModel getCSSModel(IDOMNode text) {
if (text == null)
return null;
INodeNotifier notifier = (INodeNotifier) text.getParentNode();
if (notifier == null)
return null;
INodeAdapter adapter = notifier.getAdapterFor(IStyleSheetAdapter.class);
if (adapter == null)
return null;
if (!(adapter instanceof IStyleSheetAdapter))
return null;
IStyleSheetAdapter styleAdapter = (IStyleSheetAdapter) adapter;
return styleAdapter.getModel();
}
Aggregations