use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class CSSEmbededStyleNotifyAdapter method styleUpdate.
/**
*/
public void styleUpdate(ICSSModel srcModel) {
IDOMNode node = (IDOMNode) model.getOwnerDOMNode();
if (node != null)
return;
INodeAdapter adapter = node.getAdapterFor(IStyleSheetAdapter.class);
if (adapter instanceof ICSSStyleListener) {
((ICSSStyleListener) adapter).styleUpdate(srcModel);
}
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class CSSEmbededStyleNotifyAdapter method styleChanged.
/**
*/
public void styleChanged(ICSSModel srcModel, ICSSSelector[] removed, ICSSSelector[] added, String media) {
IDOMNode node = (IDOMNode) model.getOwnerDOMNode();
if (node != null)
return;
INodeAdapter adapter = node.getAdapterFor(IStyleSheetAdapter.class);
if (adapter instanceof ICSSStyleListener) {
((ICSSStyleListener) adapter).styleChanged(srcModel, removed, added, media);
}
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class HTMLElementFormatter method getCSSModel.
/**
*/
private ICSSModel getCSSModel(Attr attr) {
if (attr == null)
return null;
INodeNotifier notifier = (INodeNotifier) attr.getOwnerElement();
if (notifier == null)
return null;
INodeAdapter adapter = notifier.getAdapterFor(IStyleDeclarationAdapter.class);
if (adapter == null)
return null;
if (!(adapter instanceof IStyleDeclarationAdapter))
return null;
IStyleDeclarationAdapter styleAdapter = (IStyleDeclarationAdapter) adapter;
return styleAdapter.getModel();
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class JFaceNodeAdapterForJs method getJsNode.
private Object getJsNode(Node parent, IJavaScriptElement root, Position position) {
JsJfaceNode instance = null;
if (root.getElementType() == IJavaScriptElement.TYPE) {
instance = new JsJfaceNode(parent, root, position, ((SourceRefElement) root).getElementName());
} else if (root.getElementType() == IJavaScriptElement.FIELD) {
/* Field refrence, possibly to a type may need to implement later */
instance = new JsJfaceNode(parent, root, position);
} else {
instance = new JsJfaceNode(parent, root, position);
}
String name = getJavaElementLabelProvider().getText(root);
instance.setName(name);
// ((JsJfaceNode)instance).setAdapterRegistry(registry);
INodeAdapter adapter = (instance).getAdapterFor(IJFaceNodeAdapter.class);
if (!(adapter instanceof JFaceNodeAdapterForJs)) {
(instance).removeAdapter(adapter);
(instance).addAdapter(this);
}
return instance;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapter in project webtools.sourceediting by eclipse.
the class RegionChangedAdapterNotificationTests method testAppendWhitespaceToAttributeValue.
public void testAppendWhitespaceToAttributeValue() throws IOException {
IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
try {
Document document = model.getDocument();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.setText(this, "<a b= c></a>");
Node before = document.getFirstChild();
final int[] changed = new int[] { -1 };
INodeAdapter adapter = new INodeAdapter() {
public boolean isAdapterForType(Object type) {
return type.equals(RegionChangedAdapterNotificationTests.class);
}
public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
changed[0] = eventType;
}
};
((INodeNotifier) before).addAdapter(adapter);
Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 7, 0, " ");
assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
assertTrue(fmEvent instanceof RegionChangedEvent);
Node after = document.getFirstChild();
assertEquals("Node replaced", before, after);
assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
assertEquals("unexpected document content", "<a b= c ></a>", structuredDocument.get());
} finally {
model.releaseFromEdit();
}
}
Aggregations