Search in sources :

Example 26 with Preferences

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

the class GotoAnnotationAction method isNavigationTarget.

/**
 * Returns whether the given annotation is configured as a target for the
 * "Go to Next/Previous Annotation" actions
 *
 * @param annotation
 *            the annotation
 * @return <code>true</code> if this is a target, <code>false</code>
 *         otherwise
 * @see Eclipse 3.0
 */
protected boolean isNavigationTarget(Annotation annotation) {
    Preferences preferences = EditorsUI.getPluginPreferences();
    AnnotationPreference preference = EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
    // See bug 41689
    // String key= forward ? preference.getIsGoToNextNavigationTargetKey()
    // : preference.getIsGoToPreviousNavigationTargetKey();
    String key = preference == null ? null : preference.getIsGoToNextNavigationTargetKey();
    return (key != null && preferences.getBoolean(key));
}
Also used : Preferences(org.eclipse.core.runtime.Preferences) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Example 27 with Preferences

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

the class CSSLinkConverter method addFunc.

/**
 */
public static String addFunc(String value) {
    if (!value.trim().toLowerCase().startsWith(URL_BEGIN)) {
        // pa_TODO css pref
        Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
        String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
        value = CSSUtil.stripQuotes(value);
        quote = CSSUtil.detectQuote(value, quote);
        String str = URL_BEGIN;
        if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER)
            str = str.toUpperCase();
        StringBuffer buf = new StringBuffer(str);
        buf.append(quote);
        buf.append(value);
        buf.append(quote);
        buf.append(URL_END);
        return buf.toString();
    }
    return value;
}
Also used : Preferences(org.eclipse.core.runtime.Preferences)

Example 28 with Preferences

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

the class NewHTMLWizard method performFinish.

public boolean performFinish() {
    boolean performedOK = false;
    // save user options for next use
    fNewFileTemplatesPage.saveLastSavedPreferences();
    // no file extension specified so add default extension
    String fileName = fNewFilePage.getFileName();
    if (fileName.lastIndexOf('.') == -1) {
        String newFileName = fNewFilePage.addDefaultExtension(fileName);
        fNewFilePage.setFileName(newFileName);
    }
    // create a new empty file
    IFile file = fNewFilePage.createNewFile();
    // sure to check
    if (file != null) {
        if (!file.isLinked()) {
            // put template contents into file
            String templateString = fNewFileTemplatesPage.getTemplateString();
            if (templateString != null) {
                templateString = applyLineDelimiter(file, templateString);
                // determine the encoding for the new file
                Preferences preference = HTMLCorePlugin.getDefault().getPluginPreferences();
                String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
                try {
                    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                    OutputStreamWriter outputStreamWriter = null;
                    if (charSet == null || charSet.trim().equals("")) {
                        // $NON-NLS-1$
                        // just use default encoding
                        outputStreamWriter = new OutputStreamWriter(outputStream);
                    } else {
                        outputStreamWriter = new OutputStreamWriter(outputStream, charSet);
                    }
                    outputStreamWriter.write(templateString);
                    outputStreamWriter.flush();
                    outputStreamWriter.close();
                    ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
                    file.setContents(inputStream, true, false, null);
                    inputStream.close();
                } catch (Exception e) {
                    // $NON-NLS-1$
                    Logger.log(Logger.WARNING_DEBUG, "Could not create contents for new HTML file", e);
                }
            }
        }
        // open the file in editor
        openEditor(file);
        // everything's fine
        performedOK = true;
    }
    return performedOK;
}
Also used : IFile(org.eclipse.core.resources.IFile) ByteArrayInputStream(java.io.ByteArrayInputStream) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Preferences(org.eclipse.core.runtime.Preferences) PartInitException(org.eclipse.ui.PartInitException)

Example 29 with Preferences

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

the class CodedResourcePlugin method initializeDefaultPluginPreferences.

protected void initializeDefaultPluginPreferences() {
    Preferences prefs = getPluginPreferences();
    prefs.setDefault(CommonEncodingPreferenceNames.USE_3BYTE_BOM_WITH_UTF8, false);
}
Also used : Preferences(org.eclipse.core.runtime.Preferences)

Example 30 with Preferences

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

the class JSPNodeActionManager method updateCase.

protected void updateCase() {
    if (fModel != null) {
        String modelContentTypeId = fModel.getContentTypeIdentifier();
        if (modelContentTypeId != null) {
            if (modelContentTypeId.equals(ContentTypeIdForJSP.ContentTypeID_JSP)) {
                // $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