use of org.eclipse.wst.css.core.internal.util.URLModelProviderCSS 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