use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.
the class JSPDocumentLoader method preLoadAdapt.
protected void preLoadAdapt(IStructuredModel structuredModel) {
IDOMModel domModel = (IDOMModel) structuredModel;
//
// document must have already been set for this to
// work.
Document document = domModel.getDocument();
Assert.isNotNull(document, JSPCoreMessages.JSPDocumentLoader_1);
// if there is a model in the adapter, this will adapt it to
// first node. After that the PropagatingAdater spreads over the
// children being
// created. Each time that happends, a side effect is to
// also "spread" sprecific registered adapters,
// they two can propigate is needed.
// This 'get' causes first to be be attached.
PropagatingAdapter propagatingAdapter = (PropagatingAdapter) ((INodeNotifier) document).getAdapterFor(PropagatingAdapter.class);
// may make this easier to use in futue
propagatingAdapter.addAdaptOnCreateFactory(new PageDirectiveWatcherFactory());
// For JSPs, the ModelQueryAdapter must be "attached" to the document
// before content is set in the model, so taglib initization can
// take place.
((INodeNotifier) document).getAdapterFor(ModelQueryAdapter.class);
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.
the class HTMLContentAssistProcessor method getXHTML.
/**
* Determine if this Document is an XHTML Document. Oprates solely off of
* the Document Type declaration
*/
protected boolean getXHTML(Node node) {
if (node == null)
return false;
Document doc = null;
if (node.getNodeType() != Node.DOCUMENT_NODE)
doc = node.getOwnerDocument();
else
doc = ((Document) node);
if (doc instanceof IDOMDocument)
return ((IDOMDocument) doc).isXMLType();
if (doc instanceof INodeNotifier) {
ModelQueryAdapter adapter = (ModelQueryAdapter) ((INodeNotifier) doc).getAdapterFor(ModelQueryAdapter.class);
CMDocument cmdoc = null;
if (adapter != null && adapter.getModelQuery() != null)
cmdoc = adapter.getModelQuery().getCorrespondingCMDocument(doc);
if (cmdoc != null) {
// model
if (cmdoc instanceof HTMLCMDocument)
return false;
if (cmdoc.supports(HTMLCMProperties.IS_XHTML))
return Boolean.TRUE.equals(cmdoc.getProperty(HTMLCMProperties.IS_XHTML));
}
}
// this should never be reached
DocumentType docType = doc.getDoctype();
// $NON-NLS-1$
return docType != null && docType.getPublicId() != null && docType.getPublicId().indexOf("-//W3C//DTD XHTML ") == 0;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.
the class EmbeddedCSSFormatter method getCSSContent.
/**
*/
private String getCSSContent(IDOMNode text) {
ICSSModel model = getCSSModel(text);
if (model == null)
return null;
ICSSNode document = model.getDocument();
if (document == null)
return null;
INodeNotifier notifier = (INodeNotifier) document;
CSSSourceFormatter formatter = (CSSSourceFormatter) notifier.getAdapterFor(CSSSourceFormatter.class);
// try another way to get formatter
if (formatter == null)
formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(notifier);
if (formatter == null)
return null;
StringBuffer buffer = formatter.format(document);
if (buffer == null)
return null;
return buffer.toString();
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier 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();
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project jbosstools-hibernate by jbosstools.
the class ObserverAdapterFactory method createAdapter.
protected INodeAdapter createAdapter(INodeNotifier target) {
Node n = (Node) target;
String nodeName = n.getNodeName();
INodeAdapter result = null;
Object key = DOMAdapter.class;
if ("hibernate-reverse-engineering".equals(nodeName)) {
// $NON-NLS-1$
result = new UnknownNodeAdapter(key, revEngDefinition) {
public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
observer.hibernateMappingChanged();
}
};
} else if ("table-filter".equals(nodeName)) {
// $NON-NLS-1$
result = new TableFilterAdapter((Node) target, revEngDefinition);
} else if ("type-mapping".equals(nodeName)) {
// $NON-NLS-1$
result = new UnknownNodeAdapter(key, revEngDefinition) {
public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
observer.typeMappingChanged(notifier);
}
};
} else if ("sql-type".equals(nodeName)) {
// $NON-NLS-1$
result = new TypeMappingAdapter((Node) target, revEngDefinition);
} else if ("table".equals(nodeName)) {
// $NON-NLS-1$
result = new RevEngTableAdapter((Node) target, revEngDefinition);
} else if ("column".equals(nodeName) || "key-column".equals(nodeName)) {
// $NON-NLS-1$ //$NON-NLS-2$
result = new RevEngColumnAdapter((Node) target, revEngDefinition);
} else if ("primary-key".equals(nodeName)) {
// $NON-NLS-1$
result = new RevEngPrimaryKeyAdapter((Node) target, revEngDefinition);
} else if ("generator".equals(nodeName)) {
// $NON-NLS-1$
result = new RevEngGeneratorAdapter((Node) target, revEngDefinition);
} else if ("param".equals(nodeName)) {
// $NON-NLS-1$
result = new RevEngParamAdapter((Node) target, revEngDefinition);
} else if (// $NON-NLS-1$
"foreign-key".equals(nodeName) || // $NON-NLS-1$
"column-ref".equals(nodeName)) {
result = new UnknownNodeAdapter(key, revEngDefinition) {
public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
observer.tablesChanged(notifier);
}
};
}
if (result == null) {
result = new UnknownNodeAdapter(key, revEngDefinition);
}
if (result != null) {
adaptChildren((Node) target);
}
return result;
}
Aggregations