Search in sources :

Example 26 with IStructuredFormatPreferences

use of org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences in project webtools.sourceediting by eclipse.

the class TestFormatProcessorXML method resetPreferencesToDefault.

private void resetPreferencesToDefault() {
    IStructuredFormatPreferences formatPreferences = formatProcessor.getFormatPreferences();
    formatPreferences.setLineWidth(MAX_LINE_WIDTH);
    formatPreferences.setClearAllBlankLines(CLEAR_ALL_BLANK_LINES);
    formatPreferences.setIndent(INDENT);
    ((StructuredFormatPreferencesXML) formatPreferences).setSplitMultiAttrs(SPLIT_MULTI_ATTRS);
}
Also used : StructuredFormatPreferencesXML(org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML) IStructuredFormatPreferences(org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)

Example 27 with IStructuredFormatPreferences

use of org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences in project webtools.sourceediting by eclipse.

the class TestFormatProcessorXML method testAlignEndBracketFormat.

public void testAlignEndBracketFormat() throws UnsupportedEncodingException, IOException, CoreException {
    // BUG113584
    IStructuredFormatPreferences formatPreferences = formatProcessor.getFormatPreferences();
    ((StructuredFormatPreferencesXML) formatPreferences).setSplitMultiAttrs(false);
    ((StructuredFormatPreferencesXML) formatPreferences).setAlignEndBracket(true);
    formatAndAssertEquals("testfiles/xml/multiattributes.xml", "testfiles/xml/multiattributes-nosplit-yesalign-fmt.xml", false);
    ((StructuredFormatPreferencesXML) formatPreferences).setSplitMultiAttrs(true);
    ((StructuredFormatPreferencesXML) formatPreferences).setAlignEndBracket(true);
    formatAndAssertEquals("testfiles/xml/multiattributes.xml", "testfiles/xml/multiattributes-yessplit-yesalign-fmt.xml", false);
}
Also used : StructuredFormatPreferencesXML(org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML) IStructuredFormatPreferences(org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)

Example 28 with IStructuredFormatPreferences

use of org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences in project webtools.sourceediting by eclipse.

the class HTMLFormatter method getFormatPreferences.

public IStructuredFormatPreferences getFormatPreferences() {
    if (fFormatPreferences == null) {
        fFormatPreferences = new StructuredFormatPreferencesXML();
        Preferences preferences = HTMLCorePlugin.getDefault().getPluginPreferences();
        if (preferences != null) {
            fFormatPreferences.setLineWidth(preferences.getInt(HTMLCorePreferenceNames.LINE_WIDTH));
            ((StructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
            ((StructuredFormatPreferencesXML) fFormatPreferences).setAlignEndBracket(preferences.getBoolean(HTMLCorePreferenceNames.ALIGN_END_BRACKET));
            fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
            char indentChar = ' ';
            String indentCharPref = preferences.getString(HTMLCorePreferenceNames.INDENTATION_CHAR);
            if (HTMLCorePreferenceNames.TAB.equals(indentCharPref)) {
                indentChar = '\t';
            }
            int indentationWidth = preferences.getInt(HTMLCorePreferenceNames.INDENTATION_SIZE);
            StringBuffer indent = new StringBuffer();
            for (int i = 0; i < indentationWidth; i++) {
                indent.append(indentChar);
            }
            fFormatPreferences.setIndent(indent.toString());
        }
    }
    return fFormatPreferences;
}
Also used : StructuredFormatPreferencesXML(org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML) IStructuredFormatPreferences(org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences) Preferences(org.eclipse.core.runtime.Preferences)

Aggregations

IStructuredFormatPreferences (org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)28 StructuredFormatPreferencesXML (org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML)26 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)17 Preferences (org.eclipse.core.runtime.Preferences)4