Search in sources :

Example 96 with Preferences

use of org.osgi.service.prefs.Preferences in project n4js by eclipse.

the class WorkingSetManagerBrokerImpl method saveState.

private IStatus saveState() {
    final Preferences node = getPreferences();
    // Top level element.
    node.putBoolean(IS_WORKINGSET_TOP_LEVEL_KEY, workingSetTopLevel.get());
    // Active working set manager.
    final WorkingSetManager activeManager = getActiveManager();
    final String activeId = activeManager == null ? null : activeManager.getId();
    node.put(ACTIVE_MANAGER_KEY, Strings.nullToEmpty(activeId));
    try {
        node.flush();
        return OK_STATUS;
    } catch (final BackingStoreException e) {
        final String message = "Unexpected error when trying to persist working set broker state.";
        LOGGER.error(message, e);
        return statusHelper.createError(message, e);
    }
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 97 with Preferences

use of org.osgi.service.prefs.Preferences in project liferay-ide by liferay.

the class NewPortletClassOperation method execute.

@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    String defaultSuperclasses = INewPortletClassDataModelProperties.QUALIFIED_MVC_PORTLET + StringPool.COMMA + INewPortletClassDataModelProperties.QUALIFIED_LIFERAY_PORTLET + StringPool.COMMA + INewPortletClassDataModelProperties.QUALIFIED_GENERIC_PORTLET;
    try {
        Preferences preferences = PortletCore.getPreferences();
        String superclasses = preferences.get(PortletCore.PREF_KEY_PORTLET_SUPERCLASSES_USED, null);
        String superclass = getDataModel().getStringProperty(INewJavaClassDataModelProperties.SUPERCLASS);
        if (!defaultSuperclasses.contains(superclass)) {
            String newSuperclasses = null;
            if (superclasses == null) {
                newSuperclasses = superclass;
            } else if (!superclasses.contains(superclass)) {
                newSuperclasses = superclasses + StringPool.COMMA + superclass;
            }
            if (newSuperclasses != null) {
                preferences.put(PortletCore.PREF_KEY_PORTLET_SUPERCLASSES_USED, newSuperclasses);
                preferences.flush();
            }
        }
    } catch (BackingStoreException bse) {
        PortletCore.logError(bse);
    }
    return super.execute(monitor, info);
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 98 with Preferences

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

the class Shared method applyKnownWorkArounds.

/*
	 * For some boards that do not run out of the box we know how to fix it. This
	 * code fixes these things
	 */
public static void applyKnownWorkArounds() {
    /*
		 * for chipkit PONTECH UAV100 board boards.txt contains
		 * usbono_pic32.compiler.c.extra_flags=-G1024 -Danything=1 and platform.txt
		 * contains ... {compiler.define} "{compiler.cpp.extra_flags}"
		 * {build.extra_flags} ... resulting in ... "-G1024 -Danything=1" ... Arduino
		 * IDE magically makes this ... "-G1024" -Danything=1 ... But I refuse to do
		 * this type of smart parsing because modifying text files is lots easier
		 * therefore as a workaround I replace "{compiler.cpp.extra_flags}" in
		 * platform.txt with {compiler.cpp.extra_flags}
		 */
    java.nio.file.Path packageRoot = Paths.get(ConfigurationPreferences.getInstallationPathPackages().toOSString());
    java.nio.file.Path platform_txt = packageRoot.resolve("chipKIT").resolve("hardware").resolve("pic32").resolve("2.0.1").resolve("platform.txt");
    if (platform_txt.toFile().exists()) {
        FileModifiers.replaceInFile(platform_txt.toFile(), false, "\"{compiler.cpp.extra_flags}\"", "{compiler.cpp.extra_flags}");
    }
    /*
		 * oak on windows does not come with all required libraries and assumes arduino
		 * IDE has them available So I set sloeber_path_extension to the teensy root
		 *
		 */
    if (SystemUtils.IS_OS_WINDOWS) {
        java.nio.file.Path arduinoIDERoot = Paths.get(MySystem.getTeensyPlatform());
        if (arduinoIDERoot.toFile().exists()) {
            try {
                // /cater for null pointer
                arduinoIDERoot = arduinoIDERoot.getParent().getParent();
                IEnvironmentVariable var = new EnvironmentVariable("sloeber_path_extension", arduinoIDERoot.toString());
                IEclipsePreferences myScope = InstanceScope.INSTANCE.getNode("org.eclipse.cdt.core");
                Preferences t = myScope.node("environment").node("workspace").node(var.getName().toUpperCase());
                t.put("delimiter", var.getDelimiter());
                t.put("operation", "append");
                t.put("value", var.getValue());
                myScope.flush();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    /*
		 * oak on linux comes with a esptool2 in a wrong folder.
		 * As it is only 1 file I move the file
		 *
		 */
    if (SystemUtils.IS_OS_LINUX) {
        java.nio.file.Path esptool2root = packageRoot.resolve("digistump").resolve("tools").resolve("esptool2").resolve("0.9.1");
        java.nio.file.Path esptool2wrong = esptool2root.resolve("0.9.1").resolve("esptool2");
        java.nio.file.Path esptool2right = esptool2root.resolve("esptool2");
        if (esptool2wrong.toFile().exists()) {
            try {
                Files.move(esptool2wrong, esptool2right);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    /*
		 * Elector heeft core Platino maar de directory noemt platino.
		 * In windows geen probleem maar in case sensitive linux dus wel
		 */
    if (SystemUtils.IS_OS_LINUX) {
        java.nio.file.Path cores = packageRoot.resolve("Elektor").resolve("hardware").resolve("avr").resolve("1.0.0").resolve("cores");
        java.nio.file.Path coreWrong = cores.resolve("platino");
        java.nio.file.Path coreGood = cores.resolve("Platino");
        if (coreWrong.toFile().exists()) {
            coreWrong.toFile().renameTo(coreGood.toFile());
        }
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IEnvironmentVariable(org.eclipse.cdt.core.envvar.IEnvironmentVariable) EnvironmentVariable(org.eclipse.cdt.core.envvar.EnvironmentVariable) IEnvironmentVariable(org.eclipse.cdt.core.envvar.IEnvironmentVariable) IOException(java.io.IOException) Preferences(org.osgi.service.prefs.Preferences) ConfigurationPreferences(io.sloeber.core.common.ConfigurationPreferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException)

Example 99 with Preferences

use of org.osgi.service.prefs.Preferences in project jbosstools-openshift by jbosstools.

the class AccountModel method save.

@Override
public void save() {
    clusters.forEach(ICluster::save);
    Preferences accountRoot = getAccountsPreferences();
    ISecurePreferences accountSecureRoot = getSecureAccountsPreferences();
    removed.forEach(id -> {
        removeAccount(id, accountRoot, accountSecureRoot);
    });
    removed.clear();
}
Also used : ICluster(org.jboss.tools.openshift.io.core.model.ICluster) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences) Preferences(org.osgi.service.prefs.Preferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences)

Example 100 with Preferences

use of org.osgi.service.prefs.Preferences in project jbosstools-openshift by jbosstools.

the class AccountModel method loadModel.

private void loadModel() {
    ISecurePreferences secureAccountRoot = getSecureAccountsPreferences();
    Preferences accountsRoot = getAccountsPreferences();
    try {
        String[] ids = accountsRoot.childrenNames();
        for (String id : ids) {
            Cluster cluster = new Cluster(this, id);
            Preferences clusterNode = accountsRoot.node(id);
            ISecurePreferences secureClusterNode = secureAccountRoot.node(id);
            addCluster(cluster, clusterNode, secureClusterNode);
        }
    } catch (BackingStoreException e) {
        OpenShiftIOCoreActivator.logError(e.getLocalizedMessage(), e);
    }
    if (clusters.isEmpty()) {
        addCluster(createCluster("OpenShift.io"));
    }
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) ICluster(org.jboss.tools.openshift.io.core.model.ICluster) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences) Preferences(org.osgi.service.prefs.Preferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences)

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