Java Code Examples for org.eclipse.core.resources.ProjectScope#getNode()

The following examples show how to use org.eclipse.core.resources.ProjectScope#getNode() . 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: UserAgentManager.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Given a project, return the list of active user agent IDs. The current implementation processes only the first
 * (primary) nature ID of the given project. Secondary natures may be taken into consideration at a later point in
 * time
 * 
 * @param project
 *            An {@link IProject}.
 * @return Returns an array of user agent IDs for the main mature of the given project. In case the given project is
 *         null, an empty string array is returned.
 */
public String[] getActiveUserAgentIDs(IProject project)
{
	if (project == null)
	{
		return ArrayUtil.NO_STRINGS;
	}
	// Extract the natures from the given project
	String[] natureIDs = getProjectNatures(project);

	// Look at the project-scope preferences for the active agents.
	ProjectScope scope = new ProjectScope(project);
	IEclipsePreferences node = scope.getNode(CommonEditorPlugin.PLUGIN_ID);
	if (node != null)
	{
		String agents = node.get(IPreferenceConstants.USER_AGENT_PREFERENCE, null);
		if (agents != null)
		{
			Map<String, String[]> userAgents = extractUserAgents(agents);
			return getActiveUserAgentIDs(userAgents, natureIDs);
		}
	}
	// In case we did not find any project-specific settings, use the project's nature IDs to grab the agents that
	// were set in the workspace settings.
	return getActiveUserAgentIDs(natureIDs);
}
 
Example 2
Source File: BinFolderConfigurator.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Read a setting from the project scope (higher prio) or the instance scope (lower prio) to decide if Eclipse should use its own output
 * dir or compile to the maven standard output directories.
 * 
 * Defaults to {@code false}.
 */
private boolean compileToBin(IProject project) {
	String pluginId = "org.eclipse.xtext.m2e";
	String key = "compileToBin";
	ProjectScope projectScope = new ProjectScope(project);
	IEclipsePreferences projectPreferences = projectScope.getNode(pluginId);
	String value = projectPreferences.get(key, null);
	if (value != null) {
		return "true".equals(value);
	}
	IEclipsePreferences instancePreferences = InstanceScope.INSTANCE.getNode(pluginId);
	return "true".equals(instancePreferences.get(key, "false"));
}
 
Example 3
Source File: XtextProjectConfigurator.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void configureLanguage(ProjectScope projectPreferences, Language language, ProjectConfigurationRequest request) throws CoreException {
	if (language.getOutputConfigurations().isEmpty()) return;
	
	IEclipsePreferences languagePreferences = projectPreferences.getNode(language.name());
	languagePreferences.putBoolean(OptionsConfigurationBlock.isProjectSpecificPropertyKey(BuilderConfigurationBlock.PROPERTY_PREFIX), true);
	languagePreferences.putBoolean(PREF_AUTO_BUILDING, true);
	for (OutputConfiguration outputConfiguration : language.getOutputConfigurations()) {
		configureOutlet(languagePreferences, outputConfiguration, request);
	}
	try {
		languagePreferences.flush();
	} catch (BackingStoreException e) {
		throw new RuntimeException(e);
	}
}
 
Example 4
Source File: XtendProjectConfigurator.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private void writePreferences(OutputConfiguration configuration,
		IProject project) {
	ProjectScope projectPreferences = new ProjectScope(project);
	IEclipsePreferences languagePreferences = projectPreferences
			.getNode("org.eclipse.xtend.core.Xtend");
	languagePreferences.putBoolean(
			OptionsConfigurationBlock.isProjectSpecificPropertyKey(BuilderConfigurationBlock.PROPERTY_PREFIX), true);
	languagePreferences.putBoolean(
			getKey(configuration, INSTALL_DSL_AS_PRIMARY_SOURCE),
			configuration.isInstallDslAsPrimarySource());
	languagePreferences.putBoolean(
			getKey(configuration, HIDE_LOCAL_SYNTHETIC_VARIABLES),
			configuration.isHideSyntheticLocalVariables());
	languagePreferences.putBoolean(
			getKey(configuration, USE_OUTPUT_PER_SOURCE_FOLDER),
			true);
	for (SourceMapping sourceMapping : configuration.getSourceMappings()) {
		languagePreferences.put(
				getOutputForSourceFolderKey(configuration,
						sourceMapping.getSourceFolder()),
				Strings.nullToEmpty(sourceMapping.getOutputDirectory()));
	}

	try {
		languagePreferences.flush();
	} catch (BackingStoreException e) {
		throw new RuntimeIOException(e);
	}
}
 
Example 5
Source File: PreferenceStoreHelper.java    From tlaplus with MIT License 5 votes vote down vote up
/**
    * Retrieves project preference node
    * @param project 
    * @return
    */
private static IEclipsePreferences getProjectPreferences(IProject project)
   {
       if (project == null ) 
       {
           return null;
       }
       ProjectScope scope = new ProjectScope(project);
       
       
       //store.get
       
       IEclipsePreferences projectNode = scope.getNode(Activator.PLUGIN_ID);
       return projectNode;
   }
 
Example 6
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 7
Source File: ContentAssistPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean hasProjectSpecificOptions(IProject project)
{
	ProjectScope scope = new ProjectScope(project);
	IEclipsePreferences node = scope.getNode(CommonEditorPlugin.PLUGIN_ID);
	if (node != null)
	{
		return node.get(com.aptana.editor.common.contentassist.IPreferenceConstants.USER_AGENT_PREFERENCE, null) != null;
	}
	return false;
}