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

The following examples show how to use org.eclipse.core.runtime.preferences.IEclipsePreferences#node() . 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: Theme.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected void storeDefaults()
{
	// Don't store builtin themes default copy in prefs!
	if (getThemeManager().isBuiltinTheme(getName()))
	{
		return;
	}
	// Only save to defaults if it has never been saved there. Basically take a snapshot of first version and
	// use that as the "default"
	IEclipsePreferences prefs = EclipseUtil.defaultScope().getNode(ThemePlugin.PLUGIN_ID);
	if (prefs == null)
	{
		return; // TODO Log something?
	}
	Preferences preferences = prefs.node(ThemeManager.THEMES_NODE);
	if (preferences == null)
	{
		return;
	}
	String value = preferences.get(getName(), null);
	if (value == null)
	{
		save(EclipseUtil.defaultScope());
	}
}
 
Example 2
Source File: JavaCorePreferenceModifyListener.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public IEclipsePreferences preApply(IEclipsePreferences node) {
	// the node does not need to be the root of the hierarchy
	Preferences root = node.node("/"); //$NON-NLS-1$
	try {
		// we must not create empty preference nodes, so first check if the node exists
		if (root.nodeExists(InstanceScope.SCOPE)) {
			Preferences instance = root.node(InstanceScope.SCOPE);
			// we must not create empty preference nodes, so first check if the node exists
			if (instance.nodeExists(JavaCore.PLUGIN_ID)) {
				cleanJavaCore(instance.node(JavaCore.PLUGIN_ID));
			}
		}
	} catch (BackingStoreException e) {
		// do nothing
	}
	return super.preApply(node);
}
 
Example 3
Source File: PreferenceRecorder.java    From workspacemechanic with Eclipse Public License 1.0 5 votes vote down vote up
private void addListeners(IEclipsePreferences node) throws CoreException {
  addListener(node);

  try {
    for (String childName : node.childrenNames()) {
      IEclipsePreferences child = (IEclipsePreferences) node.node(childName);
      this.addListeners(child);
    }
  } catch (BackingStoreException e) {
    throw new CoreException(new Status(IStatus.ERROR, MechanicPlugin.PLUGIN_ID,
        "Could not read children for preference node", e));
  }
}
 
Example 4
Source File: Theme.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void delete(IScopeContext context)
{
	try
	{
		IEclipsePreferences prefs = context.getNode(ThemePlugin.PLUGIN_ID);
		Preferences preferences = prefs.node(ThemeManager.THEMES_NODE);
		preferences.remove(getName());
		preferences.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(ThemePlugin.getDefault(), e);
	}
}
 
Example 5
Source File: ThemeManager.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * laziliy init the set of theme names.
 */
public synchronized Set<String> getThemeNames()
{
	if (fThemeNames == null)
	{
		fThemeNames = new HashSet<String>();
		// Add names of themes from builtins...
		fThemeNames.addAll(getBuiltinThemeNames());

		// Look in prefs to see what user themes are stored there, garb their names
		IScopeContext[] scopes = new IScopeContext[] { EclipseUtil.instanceScope(), EclipseUtil.defaultScope() };
		for (IScopeContext scope : scopes)
		{
			IEclipsePreferences prefs = scope.getNode(ThemePlugin.PLUGIN_ID);
			Preferences preferences = prefs.node(ThemeManager.THEMES_NODE);
			try
			{
				String[] themeNames = preferences.keys();
				fThemeNames.addAll(Arrays.asList(themeNames));
			}
			catch (BackingStoreException e)
			{
				IdeLog.logError(ThemePlugin.getDefault(), e);
			}
		}
	}
	return fThemeNames;
}