use of org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter 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.adapters.IModelProvideAdapter 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.adapters.IModelProvideAdapter 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.adapters.IModelProvideAdapter 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;
}
use of org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter in project webtools.sourceediting by eclipse.
the class CSSImportRuleImpl method getStyleSheet.
/**
* The style sheet referred to by this rule, if it has been loaded. The
* value of this attribute is <code>null</code> if the style sheet has
* not yet been loaded or if it will not be loaded (e.g. if the style
* sheet is for a media type not supported by the user agent).
*/
public CSSStyleSheet getStyleSheet() {
if (fDirty) {
// NOTE: try/catch block is a TEMP fix to avoid compile errors:
try {
closeStyleSheet();
if (getHref() == null || getHref().length() <= 0) {
fDirty = false;
return null;
}
IStructuredModel baseModel = getOwnerDocument().getModel();
if (getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED) {
// case
// STYLE
// tag
baseModel = ((IDOMNode) getOwnerDocument().getModel().getOwnerDOMNode()).getModel();
}
// get ModelProvideAdapter
IModelProvideAdapter adapter = (IModelProvideAdapter) getAdapterFor(IModelProvideAdapter.class);
// if (getOwnerDocument().getModel().getStyleSheetType() ==
// ICSSModel.EMBEDDED) { // case STYLE tag
// adapter = (ModelProvideAdapter)
// ((INodeNotifier)getOwnerDocument().getModel().getOwnerDOMNode()).getAdapterFor(ModelProvideAdapter.class);
// }
// load model from IModelManager
URLModelProviderCSS provider = new URLModelProviderCSS();
IStructuredModel newModel = provider.getModelForRead(baseModel, getHref());
fDirty = false;
if (newModel == null)
return null;
if (!(newModel instanceof ICSSModel)) {
newModel.releaseFromRead();
return null;
}
// notify adapter
if (adapter != null)
adapter.modelProvided(newModel);
fStyleSheet = (ICSSStyleSheet) ((ICSSModel) newModel).getDocument();
if (fStyleSheet != null)
fStyleSheet.getModel().addStyleListener(getOwnerDocument().getModel());
} catch (java.io.IOException e) {
Logger.logException(e);
}
}
return fStyleSheet;
}
Aggregations