use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.
the class CSSNodeAdapter method getElements.
/**
* Returns an enumeration with the elements belonging to the passed
* element. These elements can be presented as rows in a table, items in a
* list etc.
*/
public Object[] getElements(Object object) {
if (object instanceof ICSSModel) {
ArrayList v = new ArrayList();
// internalGetElements(object, v);
addElements(object, v);
Object[] elements = v.toArray();
for (int i = 0; i < elements.length; i++) {
/*
* Required to correctly connect the refreshing behavior to
* the tree
*/
if (elements[i] instanceof INodeNotifier) {
((INodeNotifier) elements[i]).getAdapterFor(IJFaceNodeAdapter.class);
}
}
return elements;
}
return new Object[0];
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.
the class TestPageDirective method testGetTarget.
public void testGetTarget() {
IDOMModel model = createUnmanagedHTMLModel();
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) model.getDocument().getAdapterFor(PageDirectiveAdapter.class);
INodeNotifier notifier = pageDirectiveAdapter.getTarget();
assertNotNull("target is null", notifier);
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.
the class JSPModelLoader method preLoadAdapt.
protected void preLoadAdapt(IStructuredModel structuredModel) {
super.preLoadAdapt(structuredModel);
IDOMModel domModel = (IDOMModel) structuredModel;
//
// document must have already been set for this to
// work.
Document document = domModel.getDocument();
Assert.isNotNull(document);
// 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());
if (Debug.debugNotificationAndEvents) {
propagatingAdapter.addAdaptOnCreateFactory(new DebugAdapterFactory());
}
// 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 JSPModelQueryImpl method getEmbeddedModelQuery.
// ISSUE: shouldn't this be private?
protected ModelQuery getEmbeddedModelQuery(Node node) {
ModelQuery embeddedModelQuery = null;
if (node instanceof INodeNotifier) {
Node ownerNode = node.getOwnerDocument();
if (ownerNode == null) {
// then must be the document itself
ownerNode = node;
}
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) ((INodeNotifier) ownerNode).getAdapterFor(PageDirectiveAdapter.class);
if (pageDirectiveAdapter != null) {
String effectiveContentType = null;
ModelQuery potentialModelQueryObject = null;
String familyId = pageDirectiveAdapter.getEmbeddedType().getFamilyId();
if (ContentTypeFamilyForHTML.HTML_FAMILY.equals(familyId)) {
effectiveContentType = "text/html";
} else {
effectiveContentType = pageDirectiveAdapter.getContentType();
}
potentialModelQueryObject = (ModelQuery) embeddedModelQueries.get(effectiveContentType);
if (potentialModelQueryObject == null) {
ModelQueryAdapter embeddedAdapter = (ModelQueryAdapter) pageDirectiveAdapter.adapt((INodeNotifier) node, ModelQueryAdapter.class);
if (embeddedAdapter != null) {
// we will cache one model query per content type
embeddedModelQuery = embeddedAdapter.getModelQuery();
embeddedModelQueries.put(effectiveContentType, embeddedModelQuery);
}
} else {
embeddedModelQuery = potentialModelQueryObject;
}
}
}
return embeddedModelQuery;
}
use of org.eclipse.wst.sse.core.internal.provisional.INodeNotifier in project webtools.sourceediting by eclipse.
the class JSPedCSSPropertySheetConfiguration 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;
}
Aggregations