use of org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument in project webtools.sourceediting by eclipse.
the class HTMLCorePreferencesTest method testDelimiterPreferences.
/**
* Tests line delimiter preferences by making sure document created
* follows line delimiter preference.
*/
public void testDelimiterPreferences() {
// check if content type preferences match
String preferredDelimiter = ContentTypeEncodingPreferences.getPreferredNewLineDelimiter(ContentTypeIdForHTML.ContentTypeID_HTML);
Preferences prefs = ContentBasedPreferenceGateway.getPreferences(ContentTypeIdForHTML.ContentTypeID_HTML);
String gatewayDelimiter = prefs.get(CommonEncodingPreferenceNames.END_OF_LINE_CODE, null);
assertEquals("ContentTypeEncodingPreferences and ContentBasedPreferenceGateway preferences do not match", gatewayDelimiter, preferredDelimiter);
// set a particular line delimiter
prefs.put(CommonEncodingPreferenceNames.END_OF_LINE_CODE, CommonEncodingPreferenceNames.LF);
// create document
HTMLDocumentLoader loader = new HTMLDocumentLoader();
IEncodedDocument document = loader.createNewStructuredDocument();
String documentDelimiter = document.getPreferredLineDelimiter();
// verify delimiter in document matches preference
assertEquals("Delimiter in document does not match preference", CommonEncodingPreferenceNames.STRING_LF, documentDelimiter);
// return to original preference
prefs.remove(CommonEncodingPreferenceNames.END_OF_LINE_CODE);
}
use of org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument in project webtools.sourceediting by eclipse.
the class AbstractModelLoader method load.
public void load(IFile file, IStructuredModel model) throws IOException, CoreException {
IEncodedDocument structuredDocument = model.getStructuredDocument();
if (file == null)
structuredDocument = getDocumentLoader().createNewStructuredDocument();
else
structuredDocument = getDocumentLoader().createNewStructuredDocument(file);
// TODO: need to straighten out IEncodedDocument mess
if (structuredDocument instanceof IStructuredDocument)
transformInstance(model.getStructuredDocument(), (IStructuredDocument) structuredDocument);
else
model.getStructuredDocument().set(structuredDocument.get());
// original hack
// model.setStructuredDocument((IStructuredDocument)
// structuredDocument);
// ((IStructuredDocument) structuredDocument).fireNewDocument(this);
documentLoaderInstance = null;
// technicq of future
// model.setStructuredDocument((IStructuredDocument)
// structuredDocument);
// documentLoaderInstance = null;
}
use of org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument in project webtools.sourceediting by eclipse.
the class AbstractModelLoader method createModel.
/**
* This method should perform all the model initialization required before
* it contains content, namely, it should call newModel, the
* createNewStructuredDocument(), then add those adapter factories which
* must be set before content is applied. This method should be called by
* "load" method. (this is tentative API)
*/
public IStructuredModel createModel() {
documentLoaderInstance = null;
IStructuredModel model = newModel();
IEncodedDocument structuredDocument = getDocumentLoader().createNewStructuredDocument();
if (structuredDocument instanceof IStructuredDocument) {
model.setStructuredDocument((IStructuredDocument) structuredDocument);
addFactories(model, getAdapterFactories());
//
initEmbeddedTypePre(model, (IStructuredDocument) structuredDocument);
initEmbeddedTypePost(model);
// For types with propagating adapters, its important
// that the propagating adapter be in place before the contents
// are set.
preLoadAdapt(model);
}
return model;
}
use of org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument in project webtools.sourceediting by eclipse.
the class JSPCorePreferencesTest method testDelimiterPreferences.
/**
* Tests line delimiter preferences by making sure document created
* follows line delimiter preference.
*/
public void testDelimiterPreferences() {
// check if content type preferences match
String preferredDelimiter = ContentTypeEncodingPreferences.getPreferredNewLineDelimiter(ContentTypeIdForJSP.ContentTypeID_JSP);
Preferences prefs = ContentBasedPreferenceGateway.getPreferences(ContentTypeIdForJSP.ContentTypeID_JSP);
String gatewayDelimiter = prefs.get(CommonEncodingPreferenceNames.END_OF_LINE_CODE, null);
assertEquals("ContentTypeEncodingPreferences and ContentBasedPreferenceGateway preferences do not match", gatewayDelimiter, preferredDelimiter);
// set a particular line delimiter
prefs.put(CommonEncodingPreferenceNames.END_OF_LINE_CODE, CommonEncodingPreferenceNames.LF);
// create document
JSPDocumentLoader loader = new JSPDocumentLoader();
IEncodedDocument document = loader.createNewStructuredDocument();
String documentDelimiter = document.getPreferredLineDelimiter();
// verify delimiter in document matches preference
assertEquals("Delimiter in document does not match preference", CommonEncodingPreferenceNames.STRING_LF, documentDelimiter);
// return to original preference
prefs.remove(CommonEncodingPreferenceNames.END_OF_LINE_CODE);
}
use of org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument in project webtools.sourceediting by eclipse.
the class XMLCorePreferencesTest method testDelimiterPreferences.
/**
* Tests line delimiter preferences by making sure document created
* follows line delimiter preference.
*/
public void testDelimiterPreferences() {
// check if content type preferences match
String preferredDelimiter = ContentTypeEncodingPreferences.getPreferredNewLineDelimiter(ContentTypeIdForXML.ContentTypeID_XML);
Preferences prefs = ContentBasedPreferenceGateway.getPreferences(ContentTypeIdForXML.ContentTypeID_XML);
String gatewayDelimiter = prefs.get(CommonEncodingPreferenceNames.END_OF_LINE_CODE, null);
assertEquals("ContentTypeEncodingPreferences and ContentBasedPreferenceGateway preferences do not match", gatewayDelimiter, preferredDelimiter);
// set a particular line delimiter
prefs.put(CommonEncodingPreferenceNames.END_OF_LINE_CODE, CommonEncodingPreferenceNames.LF);
// create document
XMLDocumentLoader loader = new XMLDocumentLoader();
IEncodedDocument document = loader.createNewStructuredDocument();
String documentDelimiter = document.getPreferredLineDelimiter();
// verify delimiter in document matches preference
assertEquals("Delimiter in document does not match preference", CommonEncodingPreferenceNames.STRING_LF, documentDelimiter);
// return to original preference
prefs.remove(CommonEncodingPreferenceNames.END_OF_LINE_CODE);
}
Aggregations