Search in sources :

Example 66 with Preferences

use of org.osgi.service.prefs.Preferences in project hale by halestudio.

the class ContentTypeSettings method setDefaultCharset.

public void setDefaultCharset(String userCharset) throws CoreException {
    Preferences contentTypeNode = ContentTypeManager.getInstance().getPreferences(context).node(contentType.getId());
    ContentType.setPreference(contentTypeNode, ContentType.PREF_DEFAULT_CHARSET, userCharset);
    try {
        contentTypeNode.flush();
    } catch (BackingStoreException bse) {
        String message = NLS.bind(ContentMessages.content_errorSavingSettings, contentType.getId());
        IStatus status = new Status(IStatus.ERROR, ContentMessages.OWNER_NAME, 0, message, bse);
        throw new CoreException(status);
    }
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 67 with Preferences

use of org.osgi.service.prefs.Preferences in project hale by halestudio.

the class ContentType method removeFileSpec.

@Override
public void removeFileSpec(String fileSpec, int type) throws CoreException {
    Assert.isLegal(type == FILE_EXTENSION_SPEC || type == FILE_NAME_SPEC || type == FILE_PATTERN_SPEC, // $NON-NLS-1$
    "Unknown type: " + type);
    synchronized (this) {
        if (!internalRemoveFileSpec(fileSpec, type | SPEC_USER_DEFINED))
            return;
    }
    // persist the change
    Preferences contentTypeNode = manager.getPreferences().node(id);
    final String[] userSet = getFileSpecs(type | IGNORE_PRE_DEFINED);
    String preferenceKey = getPreferenceKey(type);
    String newValue = Util.toListString(userSet);
    setPreference(contentTypeNode, preferenceKey, newValue);
    try {
        contentTypeNode.flush();
    } catch (BackingStoreException bse) {
        String message = NLS.bind(ContentMessages.content_errorSavingSettings, id);
        IStatus status = new Status(IStatus.ERROR, ContentMessages.OWNER_NAME, 0, message, bse);
        throw new CoreException(status);
    }
    // notify listeners
    manager.fireContentTypeChangeEvent(this);
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 68 with Preferences

use of org.osgi.service.prefs.Preferences in project hale by halestudio.

the class ContentType method addFileSpec.

@Override
public void addFileSpec(String fileSpec, int type) throws CoreException {
    Assert.isLegal(type == FILE_EXTENSION_SPEC || type == FILE_NAME_SPEC || type == FILE_PATTERN_SPEC, // $NON-NLS-1$
    "Unknown type: " + type);
    String[] userSet;
    synchronized (this) {
        if (!internalAddFileSpec(fileSpec, type | SPEC_USER_DEFINED))
            return;
        userSet = getFileSpecs(type | IGNORE_PRE_DEFINED);
    }
    // persist using preferences
    Preferences contentTypeNode = manager.getPreferences().node(id);
    String newValue = Util.toListString(userSet);
    // we are adding stuff, newValue must be non-null
    Assert.isNotNull(newValue);
    setPreference(contentTypeNode, getPreferenceKey(type), newValue);
    try {
        contentTypeNode.flush();
    } catch (BackingStoreException bse) {
        String message = NLS.bind(ContentMessages.content_errorSavingSettings, id);
        IStatus status = new Status(IStatus.ERROR, ContentMessages.OWNER_NAME, 0, message, bse);
        throw new CoreException(status);
    }
    // notify listeners
    manager.fireContentTypeChangeEvent(this);
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 69 with Preferences

use of org.osgi.service.prefs.Preferences in project arduino-eclipse-plugin by Sloeber.

the class Activator method testKnownIssues.

private static void testKnownIssues() {
    {
        org.osgi.service.prefs.Preferences myScope = InstanceScope.INSTANCE.getNode("org.eclipse.cdt.core").node("indexer");
        myScope.put("indexAllFiles", "false");
        myScope.put("indexUnusedHeadersWithDefaultLang", "false");
        try {
            myScope.flush();
        } catch (BackingStoreException e) {
            e.printStackTrace();
        }
    }
    String errorString = new String();
    String addString = new String();
    IPath installPath = ConfigurationPreferences.getInstallationPath();
    File installFile = installPath.toFile();
    if (installFile.exists()) {
        if (!installFile.canWrite()) {
            errorString += addString + "The folder " + installPath.toString() + " exists but Sloeber does not have write access to it.\n";
            errorString += "Alternatively use the environment var " + SLOEBER_HOME + ".";
            addString = "\nand\n";
        }
    } else {
        if (!installFile.getParentFile().canWrite()) {
            errorString += addString + "Sloeber does not have write access to " + installFile.getParentFile().toString() + " and therefore can not create the folder " + installPath.toString();
            errorString += "\nAlternatively use the environment var " + SLOEBER_HOME + ".";
            addString = "\nand\n";
        }
    }
    if (isInstallPathToLong()) {
        errorString += errorString + addString;
        errorString += "Due to issues with long pathnames on Windows, the Sloeber installation path must be less than 40 characters. \n";
        errorString += "Your current path: " + installPath.toString();
        errorString += " is too long and the plugin will no longer function correctly for all boards.\n";
        errorString += "Please visit issue #705 for details. https://github.com/Sloeber/arduino-eclipse-plugin/issues/705\n";
        errorString += "Alternatively use the environment var " + SLOEBER_HOME + ".";
        addString = "\nand\n";
    }
    if (installPath.toString().contains(" ")) {
        errorString += addString + "The installpath can not contain spaces " + installPath.toString();
        addString = "\nand\n";
    }
    String workSpacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();
    if (workSpacePath.contains(" ")) {
        errorString += addString + "The Workspacepath can not contain spaces " + workSpacePath;
        addString = "\nand\n";
    }
    Preferences myScope = InstanceScope.INSTANCE.getNode("org.eclipse.cdt.core").node("indexer");
    String indexAllFiles = myScope.get("indexAllFiles", new String());
    String indexUnusedHeaders = myScope.get("indexUnusedHeadersWithDefaultLang", new String());
    if (!"false".equalsIgnoreCase(indexAllFiles)) {
        errorString += addString + "The indexer option \"index source files not included in the build\" must be off in windows->preferences->C/C++->indexer ";
        addString = "\nand\n";
    }
    if (!"false".equalsIgnoreCase(indexUnusedHeaders)) {
        errorString += addString + "The indexer option \"index unused headers\" must be off in windows->preferences->C/C++->indexer ";
        addString = "\nand\n";
    }
    if (!errorString.isEmpty()) {
        errorString += "\n\nSloeber might still function but if you get strange results you know where to look.\n";
        errorString += "Do not create an issue if you see this!!!";
        Common.log(new Status(IStatus.ERROR, PLUGIN_ID, errorString));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IPath(org.eclipse.core.runtime.IPath) BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences) ConfigurationPreferences(io.sloeber.core.common.ConfigurationPreferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) InstancePreferences(io.sloeber.core.common.InstancePreferences) File(java.io.File)

Example 70 with Preferences

use of org.osgi.service.prefs.Preferences in project erlide_eclipse by erlang.

the class RuntimeInfoLoader method store.

public static void store(final RuntimeInfo info, final Preferences root) {
    final Preferences node = root.node(info.getName());
    final String code = PreferencesUtils.packList(info.getCodePath());
    node.put(RuntimeInfoLoader.CODE_PATH, code);
    node.put(RuntimeInfoLoader.HOME_DIR, info.getOtpHome());
    node.put(RuntimeInfoLoader.ARGS, info.getArgs());
}
Also used : Preferences(org.osgi.service.prefs.Preferences)

Aggregations

Preferences (org.osgi.service.prefs.Preferences)157 BackingStoreException (org.osgi.service.prefs.BackingStoreException)82 EclipsePreferences (org.eclipse.core.internal.preferences.EclipsePreferences)41 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)37 ProjectScope (org.eclipse.core.resources.ProjectScope)18 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)14 IStatus (org.eclipse.core.runtime.IStatus)10 IOException (java.io.IOException)7 Test (org.junit.Test)7 IProject (org.eclipse.core.resources.IProject)6 Status (org.eclipse.core.runtime.Status)6 PerformanceTestRunner (org.eclipse.core.tests.harness.PerformanceTestRunner)6 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)5 ISecurePreferences (org.eclipse.equinox.security.storage.ISecurePreferences)5 Field (java.lang.reflect.Field)4 ArrayList (java.util.ArrayList)4 ExportedPreferences (org.eclipse.core.internal.preferences.ExportedPreferences)4 IExportedPreferences (org.eclipse.core.runtime.preferences.IExportedPreferences)4 ContentTypeEncodingPreferences (org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences)4 IEncodedDocument (org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument)4