Search in sources :

Example 1 with ContentTypeEncodingPreferences

use of org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences in project webtools.sourceediting by eclipse.

the class CSSCorePreferencesTest 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(ContentTypeIdForCSS.ContentTypeID_CSS);
    Preferences prefs = ContentBasedPreferenceGateway.getPreferences(ContentTypeIdForCSS.ContentTypeID_CSS);
    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
    CSSDocumentLoader loader = new CSSDocumentLoader();
    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 : CSSDocumentLoader(org.eclipse.wst.css.core.internal.encoding.CSSDocumentLoader) 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 2 with ContentTypeEncodingPreferences

use of org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences 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 3 with ContentTypeEncodingPreferences

use of org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences 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 4 with ContentTypeEncodingPreferences

use of org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences 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

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