Search in sources :

Example 71 with Preferences

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

the class CSSSourcePreferencePage method initializeValuesForFormattingGroup.

private void initializeValuesForFormattingGroup() {
    // Formatting
    Preferences prefs = getModelPreferences();
    fLineWidthText.setText(prefs.getString(CSSCorePreferenceNames.LINE_WIDTH));
    fPropertyPerLine.setSelection(prefs.getBoolean(CSSCorePreferenceNames.WRAPPING_ONE_PER_LINE));
    fNowrapAttr.setSelection(prefs.getBoolean(CSSCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR));
    spaceBetweenSelectors.setSelection(prefs.getBoolean(CSSCorePreferenceNames.FORMAT_SPACE_BETWEEN_SELECTORS));
    if (CSSCorePreferenceNames.TAB.equals(getModelPreferences().getString(CSSCorePreferenceNames.INDENTATION_CHAR))) {
        fIndentUsingTabs.setSelection(true);
        fIndentUsingSpaces.setSelection(false);
    } else {
        fIndentUsingSpaces.setSelection(true);
        fIndentUsingTabs.setSelection(false);
    }
    fIndentationSize.setSelection(getModelPreferences().getInt(CSSCorePreferenceNames.INDENTATION_SIZE));
}
Also used : Preferences(org.eclipse.core.runtime.Preferences)

Example 72 with Preferences

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

the class CSSProposalGenerator method getIndentString.

private String getIndentString() {
    StringBuffer indent = new StringBuffer();
    Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
    if (preferences != null) {
        char indentChar = ' ';
        String indentCharPref = preferences.getString(CSSCorePreferenceNames.INDENTATION_CHAR);
        if (CSSCorePreferenceNames.TAB.equals(indentCharPref)) {
            indentChar = '\t';
        }
        int indentationWidth = preferences.getInt(CSSCorePreferenceNames.INDENTATION_SIZE);
        for (int i = 0; i < indentationWidth; i++) {
            indent.append(indentChar);
        }
    }
    return indent.toString();
}
Also used : Preferences(org.eclipse.core.runtime.Preferences)

Example 73 with Preferences

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

the class CSSProposalGeneratorForDeclarationName method getCandidates.

/**
 * getCandidates method comment.
 */
protected Iterator getCandidates() {
    List candidates = new ArrayList();
    Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
    // $NON-NLS-1$
    String preDelim = "";
    for (int i = 0; i < preferences.getInt(CSSCorePreferenceNames.FORMAT_PROP_PRE_DELIM); i++) {
        // $NON-NLS-1$
        preDelim += ' ';
    }
    // $NON-NLS-1$
    String postDelim = "";
    for (int i = 0; i < preferences.getInt(CSSCorePreferenceNames.FORMAT_PROP_POST_DELIM); i++) {
        // $NON-NLS-1$
        postDelim += ' ';
    }
    ICSSNode targetNode = fContext.getTargetNode();
    boolean bFontRule = false;
    for (ICSSNode node = targetNode; node != null; node = node.getParentNode()) {
        if (node instanceof org.w3c.dom.css.CSSFontFaceRule) {
            bFontRule = true;
            break;
        }
    }
    List names = new ArrayList();
    CSSMetaModelUtil util = new CSSMetaModelUtil(fContext.getMetaModel());
    Iterator iNames = util.collectNodesByType((bFontRule) ? CSSMMNode.TYPE_DESCRIPTOR : CSSMMNode.TYPE_PROPERTY);
    while (iNames.hasNext()) {
        CSSMMNode node = (CSSMMNode) iNames.next();
        names.add(node);
    }
    sortNames(names);
    // Collections.sort(names);
    boolean bAddColon = true;
    if ((targetNode instanceof ICSSStyleRule || targetNode instanceof ICSSStyleDeclItem || targetNode instanceof ICSSStyleDeclaration) && fContext.targetHas(CSSRegionContexts.CSS_DECLARATION_SEPARATOR)) {
        bAddColon = false;
    }
    Iterator i = names.iterator();
    while (i.hasNext()) {
        CSSMMNode node = (CSSMMNode) i.next();
        String text = node.getName();
        text = (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_NAME) == CSSCorePreferenceNames.UPPER) ? text.toUpperCase() : text.toLowerCase();
        if (!isMatch(text)) {
            continue;
        }
        int cursorPos = 0;
        StringBuffer buf = new StringBuffer();
        buf.append(text);
        buf.append(preDelim);
        cursorPos = buf.length();
        if (bAddColon) {
            // $NON-NLS-1$
            buf.append(':');
            buf.append(postDelim);
            cursorPos += 1 + postDelim.length();
        }
        // if (! (targetNode instanceof ICSSStyleDeclItem)) {
        // buf.append(';');//$NON-NLS-1$
        // }
        CSSCACandidate item = new CSSCACandidate();
        item.setReplacementString(buf.toString());
        item.setCursorPosition(cursorPos);
        item.setDisplayString(text);
        item.setMMNode(node);
        item.setImageType(getCategoryImageType(node));
        candidates.add(item);
    }
    return candidates.iterator();
}
Also used : CSSMetaModelUtil(org.eclipse.wst.css.core.internal.metamodel.util.CSSMetaModelUtil) ICSSStyleDeclaration(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration) ArrayList(java.util.ArrayList) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode) ICSSStyleRule(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule) CSSMMNode(org.eclipse.wst.css.core.internal.metamodel.CSSMMNode) ICSSStyleDeclItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Preferences(org.eclipse.core.runtime.Preferences)

Example 74 with Preferences

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

the class TestJSPContentFormatter method resetPreferencesToDefault.

private void resetPreferencesToDefault() {
    Preferences preferences = HTMLCorePlugin.getDefault().getPluginPreferences();
    preferences.setToDefault(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS);
    preferences.setToDefault(HTMLCorePreferenceNames.LINE_WIDTH);
    preferences.setToDefault(HTMLCorePreferenceNames.INDENTATION_CHAR);
    preferences.setToDefault(HTMLCorePreferenceNames.INDENTATION_SIZE);
    preferences.setToDefault(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES);
}
Also used : Preferences(org.eclipse.core.runtime.Preferences)

Example 75 with Preferences

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

the class SSECorePlugin method initializeDefaultPluginPreferences.

/**
 * Set default non-UI
 */
protected void initializeDefaultPluginPreferences() {
    Preferences prefs = getDefault().getPluginPreferences();
    // set model preference defaults
    prefs.setDefault(CommonEncodingPreferenceNames.USE_3BYTE_BOM_WITH_UTF8, false);
    prefs.setDefault(CommonModelPreferenceNames.TASK_TAG_ENABLE, false);
    // $NON-NLS-1$
    prefs.setDefault(CommonModelPreferenceNames.TASK_TAG_TAGS, "TODO,FIXME,XXX");
    // $NON-NLS-1$
    prefs.setDefault(CommonModelPreferenceNames.TASK_TAG_PRIORITIES, "1,2,1");
}
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