use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class AbstractStyleSheetAdapter method removed.
/**
*/
public void removed() {
ICSSModel currentModel = getModel();
setModel(null);
// get ModelProvideAdapter
IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);
if (adapter != null)
adapter.modelRemoved(currentModel);
if (currentModel != null)
currentModel.releaseFromRead();
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class LinkElementAdapter method getModel.
/**
*/
public ICSSModel getModel() {
ICSSModel model = getExistingModel();
if (this.replaceModel) {
ICSSModel oldModel = model;
try {
model = retrieveModel();
setModel(model);
// release old model
if (oldModel != null) {
// get ModelProvideAdapter
IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);
if (adapter != null)
adapter.modelRemoved(oldModel);
}
} finally {
if (oldModel != null)
oldModel.releaseFromRead();
}
this.replaceModel = false;
}
return model;
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class LinkElementAdapter method setModel.
/**
*/
protected void setModel(ICSSModel model) {
ICSSModel oldModel = getExistingModel();
if (model == oldModel)
return;
super.setModel(model);
if (this.replaceModel)
this.replaceModel = false;
if (oldModel != null)
oldModel.removeStyleListener(this);
if (model != null)
model.addStyleListener(this);
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class LinkElementAdapter method removed.
/**
*/
public void removed() {
ICSSModel model = getExistingModel();
if (model != null) {
try {
setModel(null);
// get ModelProvideAdapter
IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);
if (adapter != null)
adapter.modelRemoved(model);
} finally {
model.releaseFromRead();
}
}
this.replaceModel = false;
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class LinkElementAdapter method retrieveModel.
/**
*/
private ICSSModel retrieveModel() {
if (!isValidAttribute()) {
return null;
}
// null,attr check is done in isValidAttribute()
Element element = getElement();
// $NON-NLS-1$
String href = element.getAttribute("href");
IDOMModel baseModel = ((IDOMNode) element).getModel();
if (baseModel == null)
return null;
Object id = baseModel.getId();
if (!(id instanceof String))
return null;
// String base = (String)id;
// get ModelProvideAdapter
IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(ModelProvideAdapterClass);
URLModelProvider provider = new URLModelProvider();
try {
IStructuredModel newModel = provider.getModelForRead(baseModel, href);
if (newModel == null)
return null;
if (!(newModel instanceof ICSSModel)) {
newModel.releaseFromRead();
return null;
}
// notify adapter
if (adapter != null)
adapter.modelProvided(newModel);
return (ICSSModel) newModel;
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
}
return null;
}
Aggregations