Search in sources :

Example 6 with IStructuredCleanupPreferences

use of org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences in project webtools.sourceediting by eclipse.

the class CleanupTester method testCleanupJSPEmptyTags1.

public void testCleanupJSPEmptyTags1() throws UnsupportedEncodingException, IOException {
    // get model
    IStructuredModel structuredModel = getModel("login.jsp");
    // init CleanupPreferences
    IStructuredCleanupPreferences cleanupPreferences = fHTMLCleanupProcessor.getCleanupPreferences();
    cleanupPreferences.setTagNameCase(CommonModelPreferenceNames.UPPER);
    cleanupPreferences.setAttrNameCase(CommonModelPreferenceNames.LOWER);
    cleanupPreferences.setCompressEmptyElementTags(false);
    cleanupPreferences.setInsertRequiredAttrs(false);
    cleanupPreferences.setInsertMissingTags(true);
    cleanupPreferences.setQuoteAttrValues(true);
    cleanupPreferences.setFormatSource(true);
    cleanupPreferences.setConvertEOLCodes(false);
    // cleanup
    ((AbstractStructuredCleanupProcessor) fHTMLCleanupProcessor).refreshCleanupPreferences = false;
    fHTMLCleanupProcessor.cleanupModel(structuredModel);
    ((AbstractStructuredCleanupProcessor) fHTMLCleanupProcessor).refreshCleanupPreferences = true;
    // compare
    String cleaned = structuredModel.getStructuredDocument().get();
    String expectedFileName = "login.afterCleanup.jsp";
    String expected = getFile(expectedFileName);
    compare(expectedFileName, expected, cleaned);
    // release model
    structuredModel.releaseFromRead();
}
Also used : IStructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 7 with IStructuredCleanupPreferences

use of org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences in project webtools.sourceediting by eclipse.

the class CleanupProcessorXML method getCleanupPreferences.

public IStructuredCleanupPreferences getCleanupPreferences() {
    if (fCleanupPreferences == null) {
        fCleanupPreferences = new StructuredCleanupPreferences();
        Preferences preferences = getModelPreferences();
        if (preferences != null) {
            fCleanupPreferences.setCompressEmptyElementTags(preferences.getBoolean(XMLCorePreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS));
            fCleanupPreferences.setInsertRequiredAttrs(preferences.getBoolean(XMLCorePreferenceNames.INSERT_REQUIRED_ATTRS));
            fCleanupPreferences.setInsertMissingTags(preferences.getBoolean(XMLCorePreferenceNames.INSERT_MISSING_TAGS));
            fCleanupPreferences.setQuoteAttrValues(preferences.getBoolean(XMLCorePreferenceNames.QUOTE_ATTR_VALUES));
            fCleanupPreferences.setFormatSource(preferences.getBoolean(XMLCorePreferenceNames.FORMAT_SOURCE));
            fCleanupPreferences.setConvertEOLCodes(preferences.getBoolean(XMLCorePreferenceNames.CONVERT_EOL_CODES));
            fCleanupPreferences.setEOLCode(preferences.getString(XMLCorePreferenceNames.CLEANUP_EOL_CODE));
        }
    }
    return fCleanupPreferences;
}
Also used : IStructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences) StructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences) Preferences(org.eclipse.core.runtime.Preferences) IStructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences) StructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences)

Example 8 with IStructuredCleanupPreferences

use of org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences in project webtools.sourceediting by eclipse.

the class NodeCleanupHandler method getCleanupPreferences.

public IStructuredCleanupPreferences getCleanupPreferences() {
    if (fCleanupPreferences == null) {
        fCleanupPreferences = new StructuredCleanupPreferences();
        Preferences preferences = getModelPreferences();
        if (preferences != null) {
            fCleanupPreferences.setCompressEmptyElementTags(preferences.getBoolean(XMLCorePreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS));
            fCleanupPreferences.setInsertRequiredAttrs(preferences.getBoolean(XMLCorePreferenceNames.INSERT_REQUIRED_ATTRS));
            fCleanupPreferences.setInsertMissingTags(preferences.getBoolean(XMLCorePreferenceNames.INSERT_MISSING_TAGS));
            fCleanupPreferences.setQuoteAttrValues(preferences.getBoolean(XMLCorePreferenceNames.QUOTE_ATTR_VALUES));
            fCleanupPreferences.setFormatSource(preferences.getBoolean(XMLCorePreferenceNames.FORMAT_SOURCE));
            fCleanupPreferences.setConvertEOLCodes(preferences.getBoolean(XMLCorePreferenceNames.CONVERT_EOL_CODES));
            fCleanupPreferences.setEOLCode(preferences.getString(XMLCorePreferenceNames.CLEANUP_EOL_CODE));
        }
    }
    return fCleanupPreferences;
}
Also used : IStructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences) StructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences) Preferences(org.eclipse.core.runtime.Preferences) IStructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences) StructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences)

Example 9 with IStructuredCleanupPreferences

use of org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences in project webtools.sourceediting by eclipse.

the class AbstractNodeCleanupHandler method getCleanupPreferences.

public IStructuredCleanupPreferences getCleanupPreferences() {
    if (fCleanupPreferences == null) {
        fCleanupPreferences = new StructuredCleanupPreferences();
        Preferences preferences = getModelPreferences();
        if (preferences != null) {
            fCleanupPreferences.setTagNameCase(preferences.getInt(HTMLCorePreferenceNames.CLEANUP_TAG_NAME_CASE));
            fCleanupPreferences.setAttrNameCase(preferences.getInt(HTMLCorePreferenceNames.CLEANUP_ATTR_NAME_CASE));
            fCleanupPreferences.setCompressEmptyElementTags(preferences.getBoolean(HTMLCorePreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS));
            fCleanupPreferences.setInsertRequiredAttrs(preferences.getBoolean(HTMLCorePreferenceNames.INSERT_REQUIRED_ATTRS));
            fCleanupPreferences.setInsertMissingTags(preferences.getBoolean(HTMLCorePreferenceNames.INSERT_MISSING_TAGS));
            fCleanupPreferences.setQuoteAttrValues(preferences.getBoolean(HTMLCorePreferenceNames.QUOTE_ATTR_VALUES));
            fCleanupPreferences.setFormatSource(preferences.getBoolean(HTMLCorePreferenceNames.FORMAT_SOURCE));
            fCleanupPreferences.setConvertEOLCodes(preferences.getBoolean(HTMLCorePreferenceNames.CONVERT_EOL_CODES));
            fCleanupPreferences.setEOLCode(preferences.getString(HTMLCorePreferenceNames.CLEANUP_EOL_CODE));
        }
    }
    return fCleanupPreferences;
}
Also used : IStructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences) StructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences) Preferences(org.eclipse.core.runtime.Preferences) IStructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences) StructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences)

Example 10 with IStructuredCleanupPreferences

use of org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences in project webtools.sourceediting by eclipse.

the class CleanupTester method testCleanupHTML.

public void testCleanupHTML() throws UnsupportedEncodingException, IOException {
    // get model
    IStructuredModel structuredModel = getModel("cleanup.html");
    // init CleanupPreferences
    IStructuredCleanupPreferences cleanupPreferences = fHTMLCleanupProcessor.getCleanupPreferences();
    cleanupPreferences.setTagNameCase(HTMLCorePreferenceNames.UPPER);
    cleanupPreferences.setAttrNameCase(HTMLCorePreferenceNames.LOWER);
    cleanupPreferences.setCompressEmptyElementTags(false);
    cleanupPreferences.setInsertRequiredAttrs(false);
    cleanupPreferences.setInsertMissingTags(true);
    cleanupPreferences.setQuoteAttrValues(true);
    cleanupPreferences.setFormatSource(false);
    cleanupPreferences.setConvertEOLCodes(false);
    // cleanup
    ((AbstractStructuredCleanupProcessor) fHTMLCleanupProcessor).refreshCleanupPreferences = false;
    fHTMLCleanupProcessor.cleanupModel(structuredModel);
    ((AbstractStructuredCleanupProcessor) fHTMLCleanupProcessor).refreshCleanupPreferences = true;
    // compare
    String cleaned = structuredModel.getStructuredDocument().get();
    String expectedFileName = "cleanup.afterCleanup.html";
    String expected = getFile(expectedFileName);
    compare(expectedFileName, expected, cleaned);
    // release model
    structuredModel.releaseFromRead();
}
Also used : IStructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Aggregations

IStructuredCleanupPreferences (org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences)12 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)7 Preferences (org.eclipse.core.runtime.Preferences)4 StructuredCleanupPreferences (org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences)4 HTMLCleanupProcessorImpl (org.eclipse.wst.html.core.internal.cleanup.HTMLCleanupProcessorImpl)1