Java Code Examples for org.osgi.service.prefs.BackingStoreException#printStackTrace()

The following examples show how to use org.osgi.service.prefs.BackingStoreException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodeCheckerProject.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Updates project related fields, and saves to the preferences.
 */
private void updateProjectRelated() {
    IScopeContext context = new ProjectScope(project);
    IEclipsePreferences preferences = context.getNode(CodeCheckerNature.NATURE_ID);

    for (ConfigTypes ctp : ConfigTypes.PROJECT_TYPE){
        String value = null;
        switch (ctp) {
            case CHECKER_WORKSPACE:
                value = codeCheckerWorkspace.toString();
                break;
            case IS_GLOBAL:
                value = Boolean.toString(isGlobal);
                break;
            default:
                break;
        }
        preferences.put(ctp.toString(), value);
    }
    try {
        preferences.flush();
    } catch (BackingStoreException e) {
        Logger.log(IStatus.ERROR, "Preferences cannot be saved!");
        e.printStackTrace();
    }
}
 
Example 2
Source File: CcConfiguration.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Loads project level preferences from disk.
 */
@Override
public void load() {
    validate();
    config = new HashMap<>();
    try {
        for (String configKey : preferences.keys()) {
            ConfigTypes ct = ConfigTypes.getFromString(configKey);
            if (ct != null) {
                if (ConfigTypes.COMMON_TYPE.contains(ct)) {
                    config.put((ConfigTypes)ct, preferences.get(configKey, STR_EMPTY));
                }
            }
        }
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
}
 
Example 3
Source File: CcConfiguration.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Validates preferences stored on disc for the project. At the time of the calling of this method,

 */
@Override
protected void validate() {
    if (preferences != null) {
        try {
            Set<String> storedProjPrefs = Sets.newHashSet(preferences.keys());
            ConfigLogger configLogger = new ConfigLogger("Missing keys in config", IStatus.WARNING);
            for (ConfigTypes key : ConfigTypes.COMMON_TYPE) {
                //if the key doesn't exist in preferences, put the corresponding kv in.
                if (!storedProjPrefs.contains(key.toString())){
                    preferences.put(key.toString(), CcGlobalConfiguration.getInstance().get(key));
                    configLogger.append(key.toString() + " " + CcGlobalConfiguration.getInstance().get(key));
                }
            }
            configLogger.log();
            if (project.isAccessible())
                preferences.flush(); // flush only saves changes, so no need for a change flag.
        } catch (BackingStoreException e) {
            e.printStackTrace();
        }
    }
}
 
Example 4
Source File: CcConfiguration.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Updates the persistent configuration.
 * @param config The new configuration to be saved.
 */
@Override
public void update(Map<ConfigTypes, String> config) {
    ConfigLogger configLogger = new ConfigLogger("Updated Project configuration with the following:");
    for (Map.Entry<ConfigTypes, String> entry : config.entrySet())
    {    
        preferences.put(entry.getKey().toString(), entry.getValue());
        this.config.put(entry.getKey(), entry.getValue());
        configLogger.append(entry);
    }
    configLogger.log();
    try {
        preferences.flush();
    } catch (BackingStoreException e) {
        Logger.log(IStatus.ERROR, e.getMessage());
        e.printStackTrace();
    }
    notifyListeners(config);
}
 
Example 5
Source File: CcGlobalConfiguration.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Initializes the plug-ins internal configuration, Call this method somewhere early.
 */
@Override
public void load() {
    preferences = ConfigurationScope.INSTANCE.getNode(CodeCheckerNature.NATURE_ID);
    validate();
    config = new ConcurrentHashMap<>();

    try {
        ConfigLogger configlogger = new ConfigLogger("Initialized GlobalConfig with:");
        for (String configKey : preferences.keys()) {
            ConfigTypes ct = ConfigTypes.getFromString(configKey);
            if (ct != null) config.put(ct, preferences.get(configKey, STR_EMPTY));
            configlogger.append(configKey + ConfigLogger.SEP + preferences.get(configKey, STR_EMPTY));
        }
        configlogger.log();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
}
 
Example 6
Source File: CcGlobalConfiguration.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Validates global preferences of the plug-in.
 */
@Override
protected void validate() {
    if (preferences != null) {
        try {
            Set<String> storedGlobalPrefs = Sets.newHashSet(preferences.keys());
            ConfigLogger configlogger = new ConfigLogger("Missing keys in global config were:", IStatus.WARNING);
            //These are the valid configuration keys.
            for (Map.Entry<ConfigTypes, String> entry : ConfigTypes.getCommonDefault().entrySet()) {
                //if the key doesn't exist in preferences, put the corresponding key-value in.
                if (!storedGlobalPrefs.contains(entry.getKey().toString())){
                    preferences.put(entry.getKey().toString(), entry.getValue());
                    configlogger.append(entry);
                }

            }
            configlogger.log();
            preferences.flush(); // flush only saves changes, so no need for a change flag.
        } catch (BackingStoreException e) {
            e.printStackTrace();
        }
    }
}
 
Example 7
Source File: CordovaEngineProvider.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private List<HybridMobileEngine> getPreferencesEngines(){
	List<HybridMobileEngine> preferencesEngines = new ArrayList<>();
	IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(HybridCore.PLUGIN_ID);
	try {
		for(String key: preferences.keys()){
			String value = preferences.get(key, "");
			preferencesEngines.add(createEngine(key, value));
			
		}
	} catch (BackingStoreException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return preferencesEngines;
}
 
Example 8
Source File: CompilerPreferenceInitializer.java    From solidity-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void initializeDefaultPreferences() {
	IEclipsePreferences preferenceStore = getPreferenceStore();
	boolean compilerInstalled = Platform.getBundle(SolidityCompilerActivator.PLUGIN_ID) != null;
	preferenceStore.putBoolean(ICompilerPreferences.COMPILER_ENABLED, compilerInstalled);
	preferenceStore.putBoolean(ICompilerPreferences.COMPILER_OUTPUT_ABI, false);
	preferenceStore.putBoolean(ICompilerPreferences.COMPILER_OUTPUT_BIN, true);
	preferenceStore.putBoolean(ICompilerPreferences.COMPILER_OUTPUT_ASM, false);
	preferenceStore.put(ICompilerPreferences.COMPILER_OUTPUT_PATH, DEFAULT_OUTPUT_PATH);
	try {
		preferenceStore.flush();
	} catch (BackingStoreException e) {
		e.printStackTrace();
	}
}
 
Example 9
Source File: GwtSdk.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the GWT SDK version.
 * And persist the version for the SDK install path.
 * This will speed version lookups once it's being used for the project.
 */
@Override
public String getVersion() {
  IPath installationPath = getInstallationPath();
  IEclipsePreferences prefs = getProjectProperties(javaProject.getProject());

  // Try getting the cached version for the install path
  String version = prefs.get(GWT_VERSION_PREF + installationPath.toOSString(), null);

  if (version == null || version.isEmpty()) {
    // Find/search for the version, using a classpath search
    version = super.getVersion();

    // Persist the GWT Version
    prefs.put(GWT_VERSION_PREF + installationPath.toOSString(), version);
    try {
      // persist the prefs
      prefs.flush();
    } catch (BackingStoreException e) {
      GWTPluginLog.logError(e, "Could not persist gwtVersion for sdk install path. installationPath="
          + installationPath + " version=" + version);
      e.printStackTrace();
    }
  }

  return version;
}
 
Example 10
Source File: DefaultResourceBlacklist.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public boolean save(IProject project, List<IResource> items) {
	ProjectScope projectScope = getPreferenceScope(project);
	IEclipsePreferences node = projectScope.getNode(SCT_RESOURCE_NODE);

	String blacklist = getBlacklistValue(items);
	node.put(SCT_BLACKLIST_KEY, blacklist);
	try {
		node.flush();
	} catch (BackingStoreException e) {
		e.printStackTrace();
		return false;
	}
	return true;
}
 
Example 11
Source File: PerspectiveUtil.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public static void switchToModelingPerspective(IWorkbenchWindow window) {
	IPreferenceStore prefs = UIPluginActivator.getDefault()
			.getPreferenceStore();
	boolean hide = prefs.getBoolean(AUTO_SWITCH_PERSPECTIVE);
	IWorkbenchPage page = window.getActivePage();
	if (!hide) {
		IWorkbench workbench = window.getWorkbench();
		IPerspectiveRegistry registry = workbench.getPerspectiveRegistry();
		IPerspectiveDescriptor descriptor = registry
				.findPerspectiveWithId(IYakinduSctPerspectives.ID_PERSPECTIVE_SCT_MODELING);
		if ((page != null) && (page.getPerspective() != descriptor)) {
			MessageDialogWithToggle dialog = MessageDialogWithToggle
					.openYesNoQuestion(
							window.getShell(),
							"Confirm Perspective Switch",
							"This kind of editor is associated with the YAKINDU Modeling perspective. Do you want to switch to this perspective now?",
							"Do not offer to switch perspective in the future",
							hide, prefs, AUTO_SWITCH_PERSPECTIVE);
			if (dialog.getReturnCode() == 2)
				page.setPerspective(descriptor);
			hide = dialog.getToggleState();
			prefs.setValue(AUTO_SWITCH_PERSPECTIVE, hide);
			try {
				InstanceScope.INSTANCE.getNode(UIPluginActivator.PLUGIN_ID)
						.flush();
			} catch (BackingStoreException e) {
				e.printStackTrace();
			}
		}
	}
}
 
Example 12
Source File: ReleaseNotes.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void setLastVersion(String version) {
	IEclipsePreferences node = ConfigurationScope.INSTANCE.getNode(ReleaseNotes.class.getName());
	node.put(Version.class.getSimpleName(), version);
	try {
		node.flush();
		return;
	} catch (BackingStoreException e) {
		e.printStackTrace();
	}
}
 
Example 13
Source File: LanguageConfigurationImportWizard.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean performFinish() {
	ILanguageConfigurationDefinition definition = mainPage.getDefinition();
	registryManager.registerLanguageConfigurationDefinition(definition);
	if (save) {
		try {
			registryManager.save();
		} catch (BackingStoreException e) {
			e.printStackTrace();
			return false;
		}
	}
	createdDefinition = definition;
	return true;
}
 
Example 14
Source File: CreateThemeAssociationWizard.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean performFinish() {
	IThemeAssociation association = mainPage.getThemeAssociation();
	themeManager.registerThemeAssociation(association);
	if (save) {
		try {
			themeManager.save();
		} catch (BackingStoreException e) {
			e.printStackTrace();
			return false;
		}
	}
	createdThemeAssociation = association;
	return true;
}
 
Example 15
Source File: TextMateGrammarImportWizard.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean performFinish() {
	IGrammarDefinition definition = mainPage.getGrammarDefinition();
	grammarRegistryManager.registerGrammarDefinition(definition);
	if (save) {
		try {
			grammarRegistryManager.save();
		} catch (BackingStoreException e) {
			e.printStackTrace();
			return false;
		}
	}
	createdDefinition = definition;
	return true;
}
 
Example 16
Source File: GrammarPreferencePage.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean performOk() {
	try {
		// Save the working copy if there are some changed.
		grammarRegistryManager.save();
		themeManager.save();
	} catch (BackingStoreException e) {
		e.printStackTrace();
		return false;
	}
	return super.performOk();
}
 
Example 17
Source File: ThemeContribution.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
private Action createAction(final String scopeName, final ITheme theme, boolean whenDark) {
	return new Action(theme.getName()) {
		@Override
		public void run() {
			IThemeManager manager = TMUIPlugin.getThemeManager();
			IThemeAssociation association = new ThemeAssociation(theme.getId(), scopeName, whenDark);
			manager.registerThemeAssociation(association);
			try {
				manager.save();
			} catch (BackingStoreException e) {
				e.printStackTrace();
			}
		}
	};
}