protected ICSSModel createModel() {
// create phantom(broken link) external CSS model
if (getElement() == null)
return null;
IStructuredModel baseModel = ((IDOMNode) getElement()).getModel();
ICSSModel newModel = (ICSSModel) baseModel.getModelManager().createUnManagedStructuredModelFor(CSS_ID);
// calculate base location and set
// get resolver in Model
URIResolver resolver = baseModel.getResolver();
// resolve to absolute url : this need not exact location of css file. It is important that absurl is not null.
String ref = getElement().getAttribute(HTML40Namespace.ATTR_NAME_HREF);
String absurl = (resolver != null && ref != null && ref.length() > 0) ? resolver.getLocationByURI(ref, true) : null;
if ((absurl == null) || (absurl.length() == 0)) {
IPath basePath = new Path(baseModel.getBaseLocation());
URLHelper helper = new URLHelper(basePath.removeLastSegments(1).toString());
absurl = helper.toAbsolute(ref == null ? "" : ref);//$NON-NLS-1$
}
if ((absurl == null) || (absurl.length() == 0)) {
absurl = ref;
}
if (absurl == null) {
absurl = "";//$NON-NLS-1$
}
newModel.setBaseLocation(absurl);
// set style listener
newModel.addStyleListener(this);
return newModel;
}