use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel 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;
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class JSPedCSSSourceParserTest method readModelOpen.
private ICSSModel readModelOpen(String filename) throws IOException {
String source = createString(FILES_DIR, filename);
// $NON-NLS-1$
ICSSModel model = createModel(filename.endsWith("jspf"));
IStructuredDocument document = model.getStructuredDocument();
document.replaceText(null, 0, 0, source);
return model;
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class JSPedCSSSourceParserTest method readModelInsert.
private ICSSModel readModelInsert(String filename) throws IOException {
String source = createString(FILES_DIR, filename);
// $NON-NLS-1$
ICSSModel model = createModel(filename.endsWith("jspf"));
IStructuredDocument document = model.getStructuredDocument();
for (int i = 0; i < source.length(); i++) {
int textIndex = source.length() - i - 1;
document.replaceText(null, 0, 0, source.substring(textIndex, textIndex + 1));
}
return model;
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class JSPedCSSSourceParserTest method sourceParserTest.
private void sourceParserTest(String filename, String mode) throws IOException {
ICSSModel model = null;
if (mode.equals(MODE_OPEN)) {
model = readModelOpen(filename);
} else if (mode.equals(MODE_APPEND)) {
model = readModelAppend(filename);
} else if (mode.equals(MODE_INSERT)) {
model = readModelInsert(filename);
}
String result = dumpRegions(model.getStructuredDocument());
// $NON-NLS-1$
compareResult(result, "JSPedCSSSourceParserTest-" + filename);
closeModel(model);
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class JSPedCSSSourceParserTest method readModelAppend.
private ICSSModel readModelAppend(String filename) throws IOException {
String source = createString(FILES_DIR, filename);
// $NON-NLS-1$
ICSSModel model = createModel(filename.endsWith("jspf"));
IStructuredDocument document = model.getStructuredDocument();
for (int i = 0; i < source.length(); i++) {
document.replaceText(null, i, 0, source.substring(i, i + 1));
}
return model;
}
Aggregations