Search in sources :

Example 11 with IEncodedDocument

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);
}
Also used : HTMLDocumentLoader(org.eclipse.wst.html.core.internal.encoding.HTMLDocumentLoader) ContentTypeEncodingPreferences(org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences) Preferences(org.osgi.service.prefs.Preferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IEncodedDocument(org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument)

Example 12 with IEncodedDocument

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;
}
Also used : IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IEncodedDocument(org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument)

Example 13 with IEncodedDocument

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;
}
Also used : IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IEncodedDocument(org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument)

Example 14 with IEncodedDocument

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);
}
Also used : ContentTypeEncodingPreferences(org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences) Preferences(org.osgi.service.prefs.Preferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IEncodedDocument(org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument) JSPDocumentLoader(org.eclipse.jst.jsp.core.internal.encoding.JSPDocumentLoader)

Example 15 with IEncodedDocument

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);
}
Also used : XMLDocumentLoader(org.eclipse.wst.xml.core.internal.encoding.XMLDocumentLoader) ContentTypeEncodingPreferences(org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences) Preferences(org.osgi.service.prefs.Preferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IEncodedDocument(org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument)

Aggregations

IEncodedDocument (org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument)15 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)6 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)4 ContentTypeEncodingPreferences (org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences)4 Preferences (org.osgi.service.prefs.Preferences)4 CoreException (org.eclipse.core.runtime.CoreException)3 CodedReaderCreator (org.eclipse.wst.sse.core.internal.encoding.CodedReaderCreator)3 RegionParser (org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser)2 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)2 IOException (java.io.IOException)1 CharacterCodingException (java.nio.charset.CharacterCodingException)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 Document (org.eclipse.jface.text.Document)1 IDocument (org.eclipse.jface.text.IDocument)1 IDocumentExtension3 (org.eclipse.jface.text.IDocumentExtension3)1 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)1 JSPDocumentLoader (org.eclipse.jst.jsp.core.internal.encoding.JSPDocumentLoader)1 CSSDocumentLoader (org.eclipse.wst.css.core.internal.encoding.CSSDocumentLoader)1 HTMLDocumentLoader (org.eclipse.wst.html.core.internal.encoding.HTMLDocumentLoader)1 DocumentReader (org.eclipse.wst.sse.core.internal.document.DocumentReader)1