org.eclipse.core.runtime.preferences.IScopeContext#getNode ( )源码实例Demo

下面列出了org.eclipse.core.runtime.preferences.IScopeContext#getNode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: eclipse   文件: BazelProjectSupport.java
private static void addSettings(IProject project, String workspaceRoot, List<String> targets,
    List<String> buildFlags) throws BackingStoreException {
  IScopeContext projectScope = new ProjectScope(project);
  Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
  int i = 0;
  for (String target : targets) {
    projectNode.put("target" + i, target);
    i++;
  }
  projectNode.put("workspaceRoot", workspaceRoot);
  i = 0;
  for (String flag : buildFlags) {
    projectNode.put("buildFlag" + i, flag);
    i++;
  }
  projectNode.flush();
}
 
/**
 * 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();
    }
}
 
源代码3 项目: xtext-xtend   文件: AbstractProfileManager.java
/**
 * Update all formatter settings with the settings of the specified profile.
 * 
 * @param profile
 *            The profile to write to the preference store
 */
private void writeToPreferenceStore(Profile profile, IScopeContext context) {
	final Map profileOptions = profile.getSettings();

	for (int i = 0; i < fKeySets.length; i++) {
		updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), profileOptions);
	}

	final IEclipsePreferences uiPrefs = context.getNode(getNodeId());
	if (uiPrefs.getInt(fProfileVersionKey, 0) != fProfileVersioner.getCurrentVersion()) {
		uiPrefs.putInt(fProfileVersionKey, fProfileVersioner.getCurrentVersion());
	}

	if (context.getName() == InstanceScope.SCOPE) {
		uiPrefs.put(fProfileKey, profile.getID());
	} else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) {
		uiPrefs.put(fProfileKey, profile.getID());
	}
}
 
源代码4 项目: xtext-xtend   文件: AbstractProfileManager.java
@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);
	}
}
 
源代码5 项目: eclipse   文件: BazelProjectSupport.java
/**
 * List targets configure for <code>project</code>. Each project configured for Bazel is
 * configured to track certain targets and this function fetch this list from the project
 * preferences.
 */
public static List<String> getTargets(IProject project) throws BackingStoreException {
  // Get the list of targets from the preferences
  IScopeContext projectScope = new ProjectScope(project);
  Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
  ImmutableList.Builder<String> builder = ImmutableList.builder();
  for (String s : projectNode.keys()) {
    if (s.startsWith("target")) {
      builder.add(projectNode.get(s, ""));
    }
  }
  return builder.build();
}
 
源代码6 项目: APICloud-Studio   文件: Theme.java
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);
	}
}
 
源代码7 项目: eclipse   文件: BazelProjectSupport.java
/**
 * Return the {@link BazelInstance} corresponding to the given <code>project</code>. It looks for
 * the instance that runs for the workspace root configured for that project.
 *
 * @throws BazelNotFoundException
 */
public static BazelCommand.BazelInstance getBazelCommandInstance(IProject project)
    throws BackingStoreException, IOException, InterruptedException, BazelNotFoundException {
  IScopeContext projectScope = new ProjectScope(project.getProject());
  Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
  File workspaceRoot =
      new File(projectNode.get("workspaceRoot", project.getLocation().toFile().toString()));
  return Activator.getDefault().getCommand().getInstance(workspaceRoot);
}
 
源代码8 项目: eclipse   文件: BazelProjectSupport.java
/**
 * Convert an Eclipse JDT project into an IntelliJ project view
 */
public static ProjectView getProjectView(IProject project)
    throws BackingStoreException, JavaModelException {
  com.google.devtools.bazel.e4b.projectviews.Builder builder = ProjectView.builder();
  IScopeContext projectScope = new ProjectScope(project);
  Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
  for (String s : projectNode.keys()) {
    if (s.startsWith("buildArgs")) {
      builder.addBuildFlag(projectNode.get(s, ""));
    } else if (s.startsWith("target")) {
      builder.addTarget(projectNode.get(s, ""));
    }
  }

  IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
  for (IClasspathEntry entry : ((IJavaProject) project).getRawClasspath()) {
    switch (entry.getEntryKind()) {
      case IClasspathEntry.CPE_SOURCE:
        IResource res = root.findMember(entry.getPath());
        if (res != null) {
          builder.addDirectory(res.getProjectRelativePath().removeFirstSegments(1).toOSString());
        }
        break;
      case IClasspathEntry.CPE_CONTAINER:
        String path = entry.getPath().toOSString();
        if (path.startsWith(STANDARD_VM_CONTAINER_PREFIX)) {
          builder.setJavaLanguageLevel(
              Integer.parseInt(path.substring(STANDARD_VM_CONTAINER_PREFIX.length())));
        }
        break;
    }
  }
  return builder.build();
}
 
源代码9 项目: xds-ide   文件: PreferenceKey.java
public static void addChangeListener(IScopeContext context, IWorkingCopyManager manager, 
                                     String qualifier, IPreferenceChangeListener listener) 
{
    IEclipsePreferences node= context.getNode(qualifier);
    if (manager != null) {
        node =  manager.getWorkingCopy(node);
    }
    node.addPreferenceChangeListener(listener);
}
 
源代码10 项目: xds-ide   文件: PreferenceKey.java
public static void removeChangeListener(IScopeContext context, IWorkingCopyManager manager, 
                                        String qualifier, IPreferenceChangeListener listener) 
{
    IEclipsePreferences node= context.getNode(qualifier);
    if (manager != null) {
        node =  manager.getWorkingCopy(node);
    }
    node.removePreferenceChangeListener(listener);
}
 
源代码11 项目: xds-ide   文件: PreferenceKey.java
private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager) {
    IEclipsePreferences node= context.getNode(fQualifier);
    if (manager != null) {
        return manager.getWorkingCopy(node);
    }
    return node;
}
 
源代码12 项目: xds-ide   文件: PreferenceCommons.java
/**
 * TODO : implement better architecture for storing preferences.
 * 
 * @param scope
 * @param qualifier
 * @see org.osgi.service.prefs.Preferences#flush
 */
public static void flush(IScopeContext scope, String qualifier) {
	try {
           IEclipsePreferences node = scope.getNode(qualifier);
           node.flush();
       } catch (BackingStoreException e) {
           LogHelper.logError(e);
       }
}
 
/**
 * Initializes project related fields.
 *  - Is the last used configuration was local or global.
 */
private void initProjectRelated() {
    IScopeContext context = new ProjectScope(project);
    IEclipsePreferences preferences = context.getNode(CodeCheckerNature.NATURE_ID);

    isGlobal = preferences.getBoolean(ConfigTypes.IS_GLOBAL.toString(), true);
}
 
源代码14 项目: APICloud-Studio   文件: PreferenceKey.java
public void flush(IScopeContext context)
{
	IEclipsePreferences node = context.getNode(fQualifier);
	if (node != null)
	{
		try
		{
			node.flush();
		}
		catch (BackingStoreException e)
		{
			IdeLog.logError(FormatterPlugin.getDefault(), "Error flushing a node", e, IDebugScopes.DEBUG); //$NON-NLS-1$
		}
	}
}
 
源代码15 项目: xtext-xtend   文件: AbstractProfileManager.java
/**
 * Only to read project specific settings to find out to what profile it matches.
 * 
 * @param context
 *            The project context
 */
private Map readFromPreferenceStore(IScopeContext context, Profile workspaceProfile) {
	final Map profileOptions = new HashMap();
	IEclipsePreferences uiPrefs = context.getNode(getNodeId());

	int version = uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion());
	if (version != fProfileVersioner.getCurrentVersion()) {
		Map allOptions = new HashMap();
		for (int i = 0; i < fKeySets.length; i++) {
			addAll(context.getNode(fKeySets[i].getNodeName()), allOptions);
		}
		CustomProfile profile = new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$
		fProfileVersioner.update(profile);
		return profile.getSettings();
	}

	boolean hasValues = false;
	for (int i = 0; i < fKeySets.length; i++) {
		KeySet keySet = fKeySets[i];
		IEclipsePreferences preferences = context.getNode(keySet.getNodeName());
		for (final Iterator keyIter = keySet.getKeys().iterator(); keyIter.hasNext();) {
			final String key = (String) keyIter.next();
			Object val = preferences.get(key, null);
			if (val != null) {
				hasValues = true;
			} else {
				val = workspaceProfile.getSettings().get(key);
			}
			profileOptions.put(key, val);
		}
	}

	if (!hasValues) {
		return null;
	}

	setLatestCompliance(profileOptions);
	return profileOptions;
}
 
private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager) {
	IEclipsePreferences node = context.getNode(fQualifier);
	if (manager != null) {
		return manager.getWorkingCopy(node);
	}
	return node;
}
 
源代码17 项目: statecharts   文件: DefaultResourceBlacklist.java
protected String getPersistentValues(IProject project) {
	IScopeContext projectScope = getPreferenceScope(project);
	IEclipsePreferences node = projectScope.getNode(SCT_RESOURCE_NODE);

	String string = node.get(SCT_BLACKLIST_KEY, SCT_BLACKLIST_DEFAULT);
	return string;
}
 
源代码18 项目: gwt-eclipse-plugin   文件: GwtSdk.java
private static IEclipsePreferences getProjectProperties(IProject project) {
  IScopeContext projectScope = new ProjectScope(project);
  return projectScope.getNode(GWTPlugin.PLUGIN_ID);
}
 
源代码19 项目: gwt-eclipse-plugin   文件: GWTProjectProperties.java
private static IEclipsePreferences getProjectProperties(IProject project) {
  IScopeContext projectScope = new ProjectScope(project);
  return projectScope.getNode(GWTPlugin.PLUGIN_ID);
}
 
private static IEclipsePreferences getProjectProperties(IProject project) {
  IScopeContext projectScope = new ProjectScope(project);
  return projectScope.getNode(CorePlugin.PLUGIN_ID);
}