Search in sources :

Example 81 with Preferences

use of org.eclipse.core.runtime.Preferences 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 82 with Preferences

use of org.eclipse.core.runtime.Preferences in project webtools.sourceediting by eclipse.

the class JSONCleanupStrategyImpl method initialize.

/**
 */
private void initialize() {
    Preferences prefs = JSONCorePlugin.getDefault().getPluginPreferences();
    // fIdentCase = getCleanupCaseValue(prefs
    // .getInt(JSONCorePreferenceNames.CLEANUP_CASE_IDENTIFIER));
    // fPropNameCase = getCleanupCaseValue(prefs
    // .getInt(JSONCorePreferenceNames.CLEANUP_CASE_PROPERTY_NAME));
    // fPropValueCase = getCleanupCaseValue(prefs
    // .getInt(JSONCorePreferenceNames.CLEANUP_CASE_PROPERTY_VALUE));
    // fSelectorTagCase = getCleanupCaseValue(prefs
    // .getInt(JSONCorePreferenceNames.CLEANUP_CASE_SELECTOR));
    // fIdCase = getCleanupCaseValue(prefs
    // .getInt(JSONCorePreferenceNames.CLEANUP_CASE_ID_SELECTOR));
    // fClassCase = getCleanupCaseValue(prefs
    // .getInt(JSONCorePreferenceNames.CLEANUP_CASE_CLASS_SELECTOR));
    fQuoteValues = prefs.getBoolean(JSONCorePreferenceNames.QUOTE_ATTR_VALUES);
    fFormatSource = prefs.getBoolean(JSONCorePreferenceNames.FORMAT_SOURCE);
}
Also used : Preferences(org.eclipse.core.runtime.Preferences)

Example 83 with Preferences

use of org.eclipse.core.runtime.Preferences in project webtools.sourceediting by eclipse.

the class StructuredTextViewerConfigurationHTML method getIndentPrefixes.

public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
    Vector vector = new Vector();
    // prefix[0] is either '\t' or ' ' x tabWidth, depending on preference
    Preferences preferences = HTMLCorePlugin.getDefault().getPluginPreferences();
    int indentationWidth = preferences.getInt(HTMLCorePreferenceNames.INDENTATION_SIZE);
    String indentCharPref = preferences.getString(HTMLCorePreferenceNames.INDENTATION_CHAR);
    boolean useSpaces = HTMLCorePreferenceNames.SPACE.equals(indentCharPref);
    for (int i = 0; i <= indentationWidth; i++) {
        StringBuffer prefix = new StringBuffer();
        boolean appendTab = false;
        if (useSpaces) {
            for (int j = 0; j + i < indentationWidth; j++) prefix.append(' ');
            if (i != 0)
                appendTab = true;
        } else {
            for (int j = 0; j < i; j++) prefix.append(' ');
            if (i != indentationWidth)
                appendTab = true;
        }
        if (appendTab) {
            prefix.append('\t');
            vector.add(prefix.toString());
            // remove the tab so that indentation - tab is also an indent
            // prefix
            prefix.deleteCharAt(prefix.length() - 1);
        }
        vector.add(prefix.toString());
    }
    // $NON-NLS-1$
    vector.add("");
    return (String[]) vector.toArray(new String[vector.size()]);
}
Also used : Preferences(org.eclipse.core.runtime.Preferences) Vector(java.util.Vector)

Example 84 with Preferences

use of org.eclipse.core.runtime.Preferences in project webtools.sourceediting by eclipse.

the class AutoEditStrategyForTabs method getIndentationWidth.

/**
 * Returns indentation width if using spaces for indentation, -1 otherwise
 *
 * @return
 */
private int getIndentationWidth() {
    int width = -1;
    Preferences preferences = HTMLCorePlugin.getDefault().getPluginPreferences();
    if (HTMLCorePreferenceNames.SPACE.equals(preferences.getString(HTMLCorePreferenceNames.INDENTATION_CHAR)))
        width = preferences.getInt(HTMLCorePreferenceNames.INDENTATION_SIZE);
    return width;
}
Also used : Preferences(org.eclipse.core.runtime.Preferences)

Example 85 with Preferences

use of org.eclipse.core.runtime.Preferences in project webtools.sourceediting by eclipse.

the class HTMLNodeActionManager method updateCase.

/**
 * Another HTML specific detail.
 */
protected void updateCase() {
    if (fModel != null) {
        String modelContentTypeId = fModel.getContentTypeIdentifier();
        if (modelContentTypeId != null) {
            if (modelContentTypeId.equals(ContentTypeIdForHTML.ContentTypeID_HTML)) {
                // $NON-NLS-1$
                Preferences prefs = HTMLCorePlugin.getDefault().getPluginPreferences();
                fTagCase = prefs.getInt(HTMLCorePreferenceNames.TAG_NAME_CASE);
                fAttrCase = prefs.getInt(HTMLCorePreferenceNames.ATTR_NAME_CASE);
            }
        }
    }
}
Also used : Preferences(org.eclipse.core.runtime.Preferences)

Aggregations

Preferences (org.eclipse.core.runtime.Preferences)113 ByteArrayInputStream (java.io.ByteArrayInputStream)7 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)7 IFile (org.eclipse.core.resources.IFile)6 PartInitException (org.eclipse.ui.PartInitException)6 CSSCleanupStrategy (org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy)6 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 OutputStreamWriter (java.io.OutputStreamWriter)5 IStructuredFormatPreferences (org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)5 ArrayList (java.util.ArrayList)4 CoreException (org.eclipse.core.runtime.CoreException)4 ICSSStyleDeclItem (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem)4 IStructuredCleanupPreferences (org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences)4 StructuredCleanupPreferences (org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences)4 List (java.util.List)3 Vector (java.util.Vector)3 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)3 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2