Java Code Examples for org.eclipse.core.runtime.preferences.IEclipsePreferences#remove()

The following examples show how to use org.eclipse.core.runtime.preferences.IEclipsePreferences#remove() . 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: AbstractBuildParticipant.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void restoreDefaults()
{
	if (isRequired())
	{
		// no-op if required for now, since we don't do filters/etc here yet.
		return;
	}

	IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(getPreferenceNode());
	prefs.remove(getEnablementPreferenceKey(BuildType.BUILD));
	prefs.remove(getEnablementPreferenceKey(BuildType.RECONCILE));
	prefs.remove(getFiltersPreferenceKey());
	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(BuildPathCorePlugin.getDefault(), e);
	}
}
 
Example 2
Source File: AbstractPreferencePage.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Saves the 'use project settings' as a preference in the store using the
 * {@link #useProjectSettingsPreferenceName()} as the key. If not project specific, all affected keys are removed
 * from the project preferences.
 */
private void saveUseProjectSettings(boolean isProjectSpecific) throws IOException {
	final FixedScopedPreferenceStore store = (FixedScopedPreferenceStore) getPreferenceStore();
	if (!isProjectSpecific) {
		// remove all the keys (written by various field editors)
		IEclipsePreferences storePreferences = store.getStorePreferences();
		for (FieldEditor field : editors) {
			storePreferences.remove(field.getPreferenceName());
		}
		// Also remove the master key (i.e. use default/default == false when later reading).
		storePreferences.remove(useProjectSettingsPreferenceName());
	} else {
		store.setValue(useProjectSettingsPreferenceName(), Boolean.toString(isProjectSpecific));
	}
	store.save();
}
 
Example 3
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected void setSemanticToken(IEclipsePreferences prefs, Theme theme, String ourTokenType, String jdtToken,
		boolean revertToDefaults)
{
	String prefix = "semanticHighlighting."; //$NON-NLS-1$
	jdtToken = prefix + jdtToken;
	if (revertToDefaults)
	{
		prefs.remove(jdtToken + ".color"); //$NON-NLS-1$
		prefs.remove(jdtToken + ".bold"); //$NON-NLS-1$
		prefs.remove(jdtToken + ".italic"); //$NON-NLS-1$
		prefs.remove(jdtToken + ".underline"); //$NON-NLS-1$
		prefs.remove(jdtToken + ".strikethrough"); //$NON-NLS-1$
		prefs.remove(jdtToken + ".enabled"); //$NON-NLS-1$
	}
	else
	{
		TextAttribute attr = theme.getTextAttribute(ourTokenType);
		prefs.put(jdtToken + ".color", StringConverter.asString(attr.getForeground().getRGB())); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + ".bold", (attr.getStyle() & SWT.BOLD) != 0); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + ".italic", (attr.getStyle() & SWT.ITALIC) != 0); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + ".underline", (attr.getStyle() & TextAttribute.UNDERLINE) != 0); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + ".strikethrough", (attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + ".enabled", true); //$NON-NLS-1$
	}
}
 
Example 4
Source File: AbstractProfileManager.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) {
	IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
	for (int i = 0; i < projects.length; i++) {
		IScopeContext projectScope = fPreferencesAccess.getProjectScope(projects[i]);
		IEclipsePreferences node = projectScope.getNode(getNodeId());
		String profileId = node.get(fProfileKey, null);
		if (oldName.equals(profileId)) {
			if (newProfile == null) {
				node.remove(fProfileKey);
			} else {
				if (applySettings) {
					writeToPreferenceStore(newProfile, projectScope);
				} else {
					node.put(fProfileKey, newProfile.getID());
				}
			}
		}
	}

	IScopeContext instanceScope = fPreferencesAccess.getInstanceScope();
	final IEclipsePreferences uiPrefs = instanceScope.getNode(getNodeId());
	if (newProfile != null && oldName.equals(uiPrefs.get(fProfileKey, null))) {
		writeToPreferenceStore(newProfile, instanceScope);
	}
}
 
Example 5
Source File: ProfileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) {
	IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
	for (int i= 0; i < projects.length; i++) {
		IScopeContext projectScope= fPreferencesAccess.getProjectScope(projects[i]);
		IEclipsePreferences node= projectScope.getNode(JavaUI.ID_PLUGIN);
		String profileId= node.get(fProfileKey, null);
		if (oldName.equals(profileId)) {
			if (newProfile == null) {
				node.remove(fProfileKey);
			} else {
				if (applySettings) {
					writeToPreferenceStore(newProfile, projectScope);
				} else {
					node.put(fProfileKey, newProfile.getID());
				}
			}
		}
	}

	IScopeContext instanceScope= fPreferencesAccess.getInstanceScope();
	final IEclipsePreferences uiPrefs= instanceScope.getNode(JavaUI.ID_PLUGIN);
	if (newProfile != null && oldName.equals(uiPrefs.get(fProfileKey, null))) {
		writeToPreferenceStore(newProfile, instanceScope);
	}
}
 
Example 6
Source File: ShellExecutable.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public static void setPreferenceShellPath(IPath path)
{
	IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(CorePlugin.PLUGIN_ID);
	if (path != null)
	{
		prefs.put(ICorePreferenceConstants.PREF_SHELL_EXECUTABLE_PATH, path.toOSString());
	}
	else
	{
		prefs.remove(ICorePreferenceConstants.PREF_SHELL_EXECUTABLE_PATH);
	}
	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CorePlugin.getDefault(), "Saving preferences failed.", e); //$NON-NLS-1$
	}
	shellPath = null;
	shellEnvironment = null;
}
 
Example 7
Source File: ProfileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private boolean updatePreferences(IEclipsePreferences prefs, List<String> keys, Map<String, String> profileOptions) {
	boolean hasChanges= false;
	for (final Iterator<String> keyIter = keys.iterator(); keyIter.hasNext(); ) {
		final String key= keyIter.next();
		final String oldVal= prefs.get(key, null);
		final String val= profileOptions.get(key);
		if (val == null) {
			if (oldVal != null) {
				prefs.remove(key);
				hasChanges= true;
			}
		} else if (!val.equals(oldVal)) {
			prefs.put(key, val);
			hasChanges= true;
		}
	}
	return hasChanges;
}
 
Example 8
Source File: CommonEditorPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void performDefaults()
{
	IEclipsePreferences store = getPluginPreferenceStore();

	store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
	store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);

	setPluginDefaults();
	setTabSpaceCombo();
	super.performDefaults();
	try
	{
		store.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CommonEditorPlugin.getDefault(), e);
	}
}
 
Example 9
Source File: CommonEditorPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method removes the spaces for tabs and tab width preferences from the default scope of the plugin preference
 * store.
 */
protected void removePluginDefaults()
{
	IEclipsePreferences store = getDefaultPluginPreferenceStore();
	if (store == null)
	{
		return;
	}

	store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
	store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
	try
	{
		store.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CommonEditorPlugin.getDefault(), e);
	}
}
 
Example 10
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected void setWSTToken(IEclipsePreferences prefs, Theme theme, String ourEquivalentScope, String prefKey,
		boolean revertToDefaults)
{
	if (revertToDefaults)
	{
		prefs.remove(prefKey);
	}
	else
	{
		TextAttribute attr = theme.getTextAttribute(ourEquivalentScope);
		boolean bold = (attr.getStyle() & SWT.BOLD) != 0;
		boolean italic = (attr.getStyle() & SWT.ITALIC) != 0;
		boolean strikethrough = (attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0;
		boolean underline = (attr.getStyle() & TextAttribute.UNDERLINE) != 0;
		StringBuilder value = new StringBuilder();
		value.append(Theme.toHex(attr.getForeground().getRGB()));
		value.append('|');
		value.append(Theme.toHex(attr.getBackground().getRGB()));
		value.append('|');
		value.append(bold);
		value.append('|');
		value.append(italic);
		value.append('|');
		value.append(strikethrough);
		value.append('|');
		value.append(underline);
		prefs.put(prefKey, value.toString());
	}
}
 
Example 11
Source File: JavaModelManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Store the preferences value for the given option name.
 *
 * @param optionName The name of the option
 * @param optionValue The value of the option. If <code>null</code>, then
 * 	the option will be removed from the preferences instead.
 * @param eclipsePreferences The eclipse preferences to be updated
 * @param otherOptions more options being stored, used to avoid conflict between deprecated option and its compatible
 * @return <code>true</code> if the preferences have been changed,
 * 	<code>false</code> otherwise.
 */
public boolean storePreference(String optionName, String optionValue, IEclipsePreferences eclipsePreferences, Map otherOptions) {
	int optionLevel = this.getOptionLevel(optionName);
	if (optionLevel == UNKNOWN_OPTION) return false; // unrecognized option
	
	// Store option value
	switch (optionLevel) {
		case JavaModelManager.VALID_OPTION:
			if (optionValue == null) {
				eclipsePreferences.remove(optionName);
			} else {
				eclipsePreferences.put(optionName, optionValue);
			}
			break;
		case JavaModelManager.DEPRECATED_OPTION:
			// Try to migrate deprecated option
			eclipsePreferences.remove(optionName); // get rid off old preference
			String[] compatibleOptions = (String[]) this.deprecatedOptions.get(optionName);
			for (int co=0, length=compatibleOptions.length; co < length; co++) {
				if (otherOptions != null && otherOptions.containsKey(compatibleOptions[co]))
					continue; // don't overwrite explicit value of otherOptions at compatibleOptions[co]
				if (optionValue == null) {
					eclipsePreferences.remove(compatibleOptions[co]);
				} else {
					eclipsePreferences.put(compatibleOptions[co], optionValue);
				}
			}
			break;
		default:
			return false;
	}
	return true;
}
 
Example 12
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected void setHyperlinkValues(Theme theme, IEclipsePreferences prefs, boolean revertToDefaults)
{
	if (prefs == null || theme == null)
	{
		return;
	}
	if (revertToDefaults)
	{
		// Console preferences
		prefs.remove(JFacePreferences.HYPERLINK_COLOR);
		prefs.remove(JFacePreferences.ACTIVE_HYPERLINK_COLOR);

		// Editor preferences
		prefs.remove(DefaultHyperlinkPresenter.HYPERLINK_COLOR_SYSTEM_DEFAULT);
		prefs.remove(DefaultHyperlinkPresenter.HYPERLINK_COLOR);

	}
	else
	{
		TextAttribute editorHyperlink = theme.getTextAttribute("hyperlink"); //$NON-NLS-1$

		prefs.put(JFacePreferences.HYPERLINK_COLOR,
				StringConverter.asString(editorHyperlink.getForeground().getRGB()));
		JFaceResources.getColorRegistry().put(JFacePreferences.HYPERLINK_COLOR,
				editorHyperlink.getForeground().getRGB());
		prefs.put(JFacePreferences.ACTIVE_HYPERLINK_COLOR,
				StringConverter.asString(editorHyperlink.getForeground().getRGB()));
		JFaceResources.getColorRegistry().put(JFacePreferences.ACTIVE_HYPERLINK_COLOR,
				editorHyperlink.getForeground().getRGB());
		prefs.putBoolean(DefaultHyperlinkPresenter.HYPERLINK_COLOR_SYSTEM_DEFAULT, false);
		prefs.put(DefaultHyperlinkPresenter.HYPERLINK_COLOR,
				StringConverter.asString(editorHyperlink.getForeground().getRGB()));

	}

}
 
Example 13
Source File: UserLibraryManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void removeUserLibrary(String libName)  {
	synchronized (this.userLibraries) {
		IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences();
		String propertyName = CP_USERLIBRARY_PREFERENCES_PREFIX+libName;
		instancePreferences.remove(propertyName);
		try {
			instancePreferences.flush();
		} catch (BackingStoreException e) {
			Util.log(e, "Exception while removing user library " + libName); //$NON-NLS-1$
		}
	}
	// this.userLibraries was updated during the PreferenceChangeEvent (see preferenceChange(...))
}
 
Example 14
Source File: WebAppProjectProperties.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public static void setGwtMavenModuleName(IProject project, String gwtMavenModuleName) throws BackingStoreException {
  IEclipsePreferences prefs = getProjectProperties(project);
  if (gwtMavenModuleName == null) {
    try {
      prefs.remove(GWT_MAVEN_MODULE_NAME);
    } catch (Exception e) {
      e.printStackTrace();
    }
  } else {
    prefs.put(GWT_MAVEN_MODULE_NAME, gwtMavenModuleName);
    prefs.flush();
  }
}
 
Example 15
Source File: AbstractProfileManager.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void clearAllSettings(IScopeContext context) {
	for (int i = 0; i < fKeySets.length; i++) {
		updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), Collections.EMPTY_MAP);
	}
	final IEclipsePreferences uiPrefs = context.getNode(getNodeId());
	uiPrefs.remove(fProfileKey);
}
 
Example 16
Source File: ProfileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void clearAllSettings(IScopeContext context) {
	for (int i= 0; i < fKeySets.length; i++) {
        updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), Collections.<String, String>emptyMap());
       }

	final IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN);
	uiPrefs.remove(fProfileKey);
}
 
Example 17
Source File: CoreFilesTest.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Tests that we are not allowed to get metadata files
 */
@Test
public void testGetForbiddenFiles() throws IOException, SAXException, BackingStoreException {
	//enable global anonymous read
	IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(ServerConstants.PREFERENCE_SCOPE);
	String oldValue = prefs.get(ServerConstants.CONFIG_FILE_ANONYMOUS_READ, null);
	prefs.put(ServerConstants.CONFIG_FILE_ANONYMOUS_READ, "true");
	prefs.flush();
	try {
		//should not be allowed to get at file root
		WebRequest request = getGetRequest("file/");
		setAuthentication(request);
		WebResponse response = webConversation.getResponse(request);
		assertEquals("Should not be able to get the root", HttpURLConnection.HTTP_FORBIDDEN, response.getResponseCode());

		//should not be allowed to access the metadata directory
		request = getGetRequest("file/" + ".metadata");
		setAuthentication(request);
		response = webConversation.getResponse(request);
		assertEquals("Should not be able to get metadata", HttpURLConnection.HTTP_FORBIDDEN, response.getResponseCode());

		//should not be allowed to read specific metadata files
		request = getGetRequest("file/" + ".metadata/.plugins/org.eclipse.orion.server.core.search/index.generation");
		setAuthentication(request);
		response = webConversation.getResponse(request);
		assertEquals("Should not be able to get metadata", HttpURLConnection.HTTP_FORBIDDEN, response.getResponseCode());
	} finally {
		//reset the preference we messed with for the test
		if (oldValue == null)
			prefs.remove(ServerConstants.CONFIG_FILE_ANONYMOUS_READ);
		else
			prefs.put(ServerConstants.CONFIG_FILE_ANONYMOUS_READ, oldValue);
		prefs.flush();
	}
}
 
Example 18
Source File: AbstractScriptFormatterFactory.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Handle Tab-Size setting here. This settings will immediately effect all the editors of the kind we are
 * formatting. Since this method is also called when we load the preferences, we make sure we don't set anything
 * ahead of time.
 * <ul>
 * <li>In case the formatter settings indicate to use tabs - set the editor's prefs to tabs.</li>
 * <li>In case the settings indicate spaces, or mixed - set the editor's prefs to spaces.</li>
 * <li>When the workspace defaults settings match the formatter's settings, the editor preferences will indicate it.
 * </li>
 * </ul>
 * 
 * @param preferences
 * @param isInitializing
 */
/*
 * (non-Javadoc)
 * @see com.aptana.formatter.AbstractScriptFormatterFactory#updateEditorTabSize(java.util.Map, boolean)
 */
protected void updateEditorTabSize(Map<String, String> preferences, boolean isInitializing)
{
	IEclipsePreferences prefs = getEclipsePreferences();
	int editorTabSize = getEditorTabSize();
	if (CodeFormatterConstants.EDITOR.equals(getFormatterTabPolicy(preferences)))
	{
		// In case the formatter defines to follow the Editor's Tab-Policy, just update the preferences Map with the
		// editor-tab-size.
		preferences.put(getFormatterTabSizeKey(), String.valueOf(editorTabSize));
	}
	else
	{
		String prefTabSize = preferences.get(getFormatterTabSizeKey());
		int selectedTabValue = (prefTabSize != null) ? Integer.parseInt(prefTabSize) : 0;
		if (selectedTabValue == editorTabSize)
		{
			if (selectedTabValue == getDefaultEditorTabSize())
			{
				// Set the editor's settings to the default one.
				prefs.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
				prefs.putBoolean(USE_GLOBAL_DEFAULTS_KEY, true);
			}
		}
		else
		{
			if (isInitializing)
			{
				// fix the preferences value
				selectedTabValue = editorTabSize;
				preferences.put(getFormatterTabSizeKey(), String.valueOf(selectedTabValue));
			}
			prefs.putInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, selectedTabValue);
			prefs.putBoolean(USE_GLOBAL_DEFAULTS_KEY, selectedTabValue == getDefaultEditorTabSize());
		}
		try
		{
			prefs.flush();
		}
		catch (Exception e)
		{
			IdeLog.logError(FormatterPlugin.getDefault(), e);
		}
	}
}
 
Example 19
Source File: PreferenceInitializer.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void initializeDefaultPreferences()
{
	IEclipsePreferences prefs = EclipseUtil.defaultScope().getNode(JSCorePlugin.PLUGIN_ID);

	prefs.putDouble(IPreferenceConstants.JS_INDEX_VERSION, 0);

	// Warn on missing semicolons
	prefs.put(IPreferenceConstants.PREF_MISSING_SEMICOLON_SEVERITY, IProblem.Severity.WARNING.id());

	// Set up JS Parser validator to be on for build and reconcile
	prefs.putBoolean(PreferenceUtil.getEnablementPreferenceKey(JSParserValidator.ID, BuildType.BUILD), true);
	prefs.putBoolean(PreferenceUtil.getEnablementPreferenceKey(JSParserValidator.ID, BuildType.RECONCILE), true);

	// Set up JSLint prefs
	// Set default options
	// @formatter:off
	prefs.put(IPreferenceConstants.JS_LINT_OPTIONS, "{\n" + //$NON-NLS-1$
			"  \"laxLineEnd\": true,\n" + //$NON-NLS-1$
			"  \"undef\": true,\n" + //$NON-NLS-1$
			"  \"browser\": true,\n" + //$NON-NLS-1$
			"  \"jscript\": true,\n" + //$NON-NLS-1$
			"  \"debug\": true,\n" + //$NON-NLS-1$
			"  \"maxerr\": 100000,\n" + //$NON-NLS-1$
			"  \"white\": true,\n" + //$NON-NLS-1$
			"  \"predef\": [\n" + //$NON-NLS-1$
			"    \"Ti\",\n" + //$NON-NLS-1$
			"    \"Titanium\",\n" + //$NON-NLS-1$
			"    \"alert\",\n" + //$NON-NLS-1$
			"    \"require\",\n" + //$NON-NLS-1$
			"    \"exports\",\n" + //$NON-NLS-1$
			"    \"native\",\n" + //$NON-NLS-1$
			"    \"implements\",\n" + //$NON-NLS-1$
			"  ]\n" + //$NON-NLS-1$
			"}"); //$NON-NLS-1$
	// @formatter:on

	// Set default JSLint filters
	String[] defaultJSLintFilters = new String[] {
			"Missing space between .+", "Unexpected '\\(space\\)'\\.", //$NON-NLS-1$ //$NON-NLS-2$
			"Expected '.+' at column \\d+, not column \\d+\\.", "Unexpected space between .+", "Expected exactly one space between .+" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	prefs.put(PreferenceUtil.getFiltersKey(JSLintValidator.ID),
			PreferenceUtil.serializeFilters(defaultJSLintFilters));

	// Migrate the old filter prefs to new validator
	IEclipsePreferences cepPrefs = EclipseUtil.instanceScope().getNode("com.aptana.editor.common"); //$NON-NLS-1$
	String oldKey = MessageFormat.format("{0}:{1}", IJSConstants.CONTENT_TYPE_JS, //$NON-NLS-1$
			"com.aptana.editor.common.filterExpressions"); //$NON-NLS-1$
	String oldFilters = cepPrefs.get(oldKey, null);
	if (oldFilters != null)
	{
		try
		{
			String[] oldFilterArray = oldFilters.split(AbstractBuildParticipant.FILTER_DELIMITER);
			String[] combined = ArrayUtil.flatten(oldFilterArray, defaultJSLintFilters);

			IEclipsePreferences newPrefs = EclipseUtil.instanceScope().getNode(JSCorePlugin.PLUGIN_ID);
			newPrefs.put(PreferenceUtil.getFiltersKey(JSLintValidator.ID),
					PreferenceUtil.serializeFilters(combined));
			newPrefs.flush();
			cepPrefs.remove(oldKey);
		}
		catch (BackingStoreException e)
		{
			// ignore
		}
	}
}
 
Example 20
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
protected void setEditorValues(Theme theme, IEclipsePreferences prefs, boolean revertToDefaults)
{
	// FIXME Check for overrides in theme
	if (revertToDefaults)
	{
		prefs.remove("occurrenceIndicationColor"); //$NON-NLS-1$
		prefs.remove("writeOccurrenceIndicationColor"); //$NON-NLS-1$
		prefs.remove("currentIPColor"); //$NON-NLS-1$
		prefs.remove("secondaryIPColor"); //$NON-NLS-1$

		prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, true);
		prefs.remove(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
		prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, true);
		prefs.remove(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND);
		prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT, true);
		prefs.remove(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND);
		prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, true);
		prefs.remove(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND);
		prefs.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
	}
	else
	{
		prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, false);
		prefs.put(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, StringConverter.asString(theme.getBackground()));
		prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, false);
		prefs.put(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, StringConverter.asString(theme.getForeground()));
		prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT, false);
		prefs.put(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND,
				StringConverter.asString(theme.getSelectionAgainstBG()));
		prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, false);
		prefs.put(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND,
				StringConverter.asString(theme.getForeground()));

		prefs.put(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR,
				StringConverter.asString(theme.getLineHighlightAgainstBG()));

		prefs.put("occurrenceIndicationColor", StringConverter.asString(theme.getSelectionAgainstBG())); //$NON-NLS-1$
		prefs.put("writeOccurrenceIndicationColor", StringConverter.asString(theme.getSelectionAgainstBG())); //$NON-NLS-1$
		// Override the debug line highlight colors
		prefs.put("currentIPColor", StringConverter.asString(theme.getBackgroundAsRGB("meta.diff.header"))); //$NON-NLS-1$ //$NON-NLS-2$
		prefs.put("secondaryIPColor", StringConverter.asString(theme.getBackgroundAsRGB("meta.diff.header"))); //$NON-NLS-1$ //$NON-NLS-2$
	}

	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(ThemePlugin.getDefault(), e);
	}
}