use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.
the class EMF2DOMSSEAdapter method primGetExistingAdapter.
protected EMF2DOMAdapter primGetExistingAdapter(Node aNode, Translator childMap) {
INodeNotifier sseNode = (INodeNotifier) aNode;
Collection adapters = sseNode.getAdapters();
for (Iterator iterator = adapters.iterator(); iterator.hasNext(); ) {
INodeAdapter adapter = (INodeAdapter) iterator.next();
// First Check if it's an EMF2DOMAdapter
if (adapter != null && adapter.isAdapterForType(EMF2DOMAdapter.ADAPTER_CLASS)) {
// Cast to EMF2DOMAdapter
EMF2DOMSSEAdapter e2DAdapter = (EMF2DOMSSEAdapter) adapter;
Object adapterTarget = e2DAdapter.getTarget();
// Handle the cases where either adapter's target is null
if ((getTarget() == null) || (adapterTarget == null))
if (resourceClass != null && resourceClass.equals(e2DAdapter.getResourceClass()))
return e2DAdapter;
else
continue;
// Check if target is an EMF resource
if (getTarget() instanceof Resource) {
/*
* Now check if it's the right one (Multiple resources
* could be attached)
*/
if (adapterTarget != null && adapterTarget == getTarget()) {
return e2DAdapter;
}
} else {
// Check if targets are EObjects with the same resources
EObject myTarget = (EObject) getTarget();
/*
* Now check if it's the right one (Multiple resources could
* be attached)
*/
if (adapterTarget != null && ((EObject) adapterTarget).eResource() == myTarget.eResource()) {
return e2DAdapter;
}
}
if (adapterTarget instanceof EObject) {
if (((EObject) e2DAdapter.getTarget()).eResource() == null && e2DAdapter.fTranslator == childMap) {
return e2DAdapter;
}
}
}
}
return null;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.
the class EMF2DOMSSEAdapter method primGetExistingAdapter.
protected EMF2DOMAdapter primGetExistingAdapter(Node aNode) {
INodeNotifier sseNode = (INodeNotifier) aNode;
Collection adapters = sseNode.getAdapters();
for (Iterator iterator = adapters.iterator(); iterator.hasNext(); ) {
INodeAdapter adapter = (INodeAdapter) iterator.next();
// First Check if it's an EMF2DOMAdapter
if (adapter != null && adapter.isAdapterForType(EMF2DOMAdapter.ADAPTER_CLASS)) {
// Cast to EMF2DOMAdapter
EMF2DOMSSEAdapter e2DAdapter = (EMF2DOMSSEAdapter) adapter;
Object adapterTarget = e2DAdapter.getTarget();
// Handle the cases where either adapter's target is null
if ((getTarget() == null) || (adapterTarget == null))
if (resourceClass != null && resourceClass.equals(e2DAdapter.getResourceClass()))
return e2DAdapter;
else
continue;
// Check if target is an EMF resource
if (getTarget() instanceof Resource) {
/*
* Now check if it's the right one (Multiple resources
* could be attached)
*/
if (adapterTarget != null && adapterTarget == getTarget()) {
return e2DAdapter;
}
} else {
// Check if targets are EObjects with the same resources
EObject myTarget = (EObject) getTarget();
/*
* Now check if it's the right one (Multiple resources could
* be attached)
*/
if (adapterTarget != null && ((EObject) adapterTarget).eResource() == myTarget.eResource()) {
return e2DAdapter;
}
}
if (adapterTarget instanceof EObject) {
if (((EObject) e2DAdapter.getTarget()).eResource() == null) {
return e2DAdapter;
}
}
}
}
return null;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.
the class EMF2DOMSSERenderer method getExistingDOMAdapter.
public EMF2DOMAdapter getExistingDOMAdapter(Node node) {
// IDOMNode xNode = (IDOMNode) node;
// return (EMF2DOMSSEAdapter) xNode.getAdapterFor(EMF2DOMAdapter.ADAPTER_CLASS);
INodeNotifier sseNode = (INodeNotifier) node;
Collection adapters = sseNode.getAdapters();
for (Iterator iterator = adapters.iterator(); iterator.hasNext(); ) {
INodeAdapter adapter = (INodeAdapter) iterator.next();
// First Check if it's an EMF2DOMAdapter
if (adapter != null && adapter.isAdapterForType(EMF2DOMAdapter.ADAPTER_CLASS)) {
// Cast to EMF2DOMSSEAdapter
EMF2DOMSSEAdapter e2DAdapter = (EMF2DOMSSEAdapter) adapter;
// Use the resourceClass to make sure the resource type is identical
if (getResource() == null || e2DAdapter.getTarget() == null)
if (resourceClass.equals(e2DAdapter.getResourceClass()))
return e2DAdapter;
else
continue;
// First check if targets are resources
if (e2DAdapter.getTarget() instanceof Resource) {
/*
* Now check if it's the right one (Multiple resources
* could be attached)
*/
if (e2DAdapter.getTarget() == getResource()) {
return e2DAdapter;
}
} else {
// Check if targets are EObjects with the same resources
TranslatorResource myTarget = getResource();
EObject adapterTarget = (EObject) e2DAdapter.getTarget();
/*
* Now check if it's the right one (Multiple resources could
* be attached)
*/
if (adapterTarget.eResource() == myTarget || adapterTarget.eResource() == null) {
return e2DAdapter;
}
}
}
}
return null;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.
the class CSSPropertySheetConfiguration method getInputSelection.
public ISelection getInputSelection(IWorkbenchPart selectingPart, ISelection selection) {
// remove UI refresh adapters
if (fSelectedNotifiers != null) {
for (int i = 0; i < fSelectedNotifiers.length; i++) {
fSelectedNotifiers[i].removeAdapter(fRefreshAdapter);
}
fSelectedNotifiers = null;
}
ISelection preferredSelection = super.getInputSelection(selectingPart, selection);
if (preferredSelection instanceof IStructuredSelection) {
Object[] selectedObjects = new Object[((IStructuredSelection) selection).size()];
System.arraycopy(((IStructuredSelection) selection).toArray(), 0, selectedObjects, 0, selectedObjects.length);
for (int i = 0; i < selectedObjects.length; i++) {
if (selectedObjects[i] instanceof ICSSNode) {
ICSSNode node = (ICSSNode) selectedObjects[i];
while (node.getNodeType() == ICSSNode.PRIMITIVEVALUE_NODE || node.getNodeType() == ICSSNode.STYLEDECLITEM_NODE) {
node = node.getParentNode();
selectedObjects[i] = node;
}
}
}
/*
* Add UI refresh adapters and remember notifiers for later
* removal
*/
if (selectedObjects.length > 0) {
List selectedNotifiers = new ArrayList(1);
for (int i = 0; i < selectedObjects.length; i++) {
if (selectedObjects[i] instanceof INodeNotifier) {
selectedNotifiers.add(selectedObjects[i]);
((INodeNotifier) selectedObjects[i]).addAdapter(fRefreshAdapter);
}
}
fSelectedNotifiers = (INodeNotifier[]) selectedNotifiers.toArray(new INodeNotifier[selectedNotifiers.size()]);
}
preferredSelection = new StructuredSelection(selectedObjects);
}
return preferredSelection;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.
the class CSSTextNodeCleanupHandler method getCSSContent.
/**
*/
private String getCSSContent(Node 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.cleanup(document);
if (buffer == null)
return null;
return buffer.toString();
}
Aggregations