Search in sources :

Example 16 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project jop by jop-devel.

the class JOPUIUtils method getProjectSetting.

public static String getProjectSetting(ILaunchConfiguration configuration, String key, String def) {
    String projectName = getProjectName(configuration);
    if (projectName == null) {
        return def;
    }
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    IScopeContext scopeContext = new ProjectScope(project);
    Preferences projectPrefs = scopeContext.getNode(IJOPUIConstants.PLUGIN_ID);
    return projectPrefs.get(key, def);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) Preferences(org.osgi.service.prefs.Preferences) IProject(org.eclipse.core.resources.IProject)

Example 17 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project che by eclipse.

the class PreferenceConstants method getPreference.

//	/**
//	 * Sets the completion proposal categories which are excluded from the
//	 * default proposal list and reloads the registry.
//	 *
//	 * @param categories the array with the IDs of the excluded categories
//	 * @see #CODEASSIST_EXCLUDED_CATEGORIES
//	 * @since 3.4
//	 */
//	public static void setExcludedCompletionProposalCategories(String[] categories) {
//		Assert.isLegal(categories != null);
//		StringBuffer buf = new StringBuffer(50 * categories.length);
//		for (int i = 0; i < categories.length; i++) {
//			buf.append(categories[i]);
//			buf.append('\0');
//		}
//		getPreferenceStore().setValue(CODEASSIST_EXCLUDED_CATEGORIES, buf.toString());
//		CompletionProposalComputerRegistry.getDefault().reload();
//	}
/**
	 * Returns the value for the given key in the given context.
	 * @param key The preference key
	 * @param project The current context or <code>null</code> if no context is available and the
	 * workspace setting should be taken. Note that passing <code>null</code> should
	 * be avoided.
	 * @return Returns the current value for the string.
	 * @since 3.1
	 */
public static String getPreference(String key, IJavaProject project) {
    String val;
    if (project != null) {
        val = new ProjectScope(project.getProject()).getNode(ID_PLUGIN).get(key, null);
        if (val != null && !val.isEmpty()) {
            return val;
        }
    }
    val = InstanceScope.INSTANCE.getNode(ID_PLUGIN).get(key, null);
    if (val != null) {
        return val;
    }
    return getPreferenceStore().getString(key);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope)

Example 18 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project che by eclipse.

the class ImportOrganizeTest method setOrganizeImportSettings.

protected void setOrganizeImportSettings(String[] order, int threshold, int staticThreshold, IJavaProject project) {
    IEclipsePreferences scope = new ProjectScope(project.getProject()).getNode("org.eclipse.jdt.ui");
    if (order == null) {
        scope.remove(PreferenceConstants.ORGIMPORTS_IMPORTORDER);
        scope.remove(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD);
    } else {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < order.length; i++) {
            buf.append(order[i]);
            buf.append(';');
        }
        scope.put(PreferenceConstants.ORGIMPORTS_IMPORTORDER, buf.toString());
        scope.put(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD, String.valueOf(threshold));
        scope.put(PreferenceConstants.ORGIMPORTS_STATIC_ONDEMANDTHRESHOLD, String.valueOf(staticThreshold));
    }
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 19 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project che by eclipse.

the class JavaProject method getEclipsePreferences.

/**
     * Returns the project custom preference pool.
     * Project preferences may include custom encoding.
     * @return IEclipsePreferences or <code>null</code> if the project
     * 	does not have a java nature.
     */
public IEclipsePreferences getEclipsePreferences() {
    if (!org.eclipse.jdt.internal.core.JavaProject.hasJavaNature(this.project))
        return null;
    // Get cached preferences if exist
    PerProjectInfo perProjectInfo = getJavaModelManager().getPerProjectInfo(this.project, true);
    if (perProjectInfo.preferences != null)
        return perProjectInfo.preferences;
    // Init project preferences
    IScopeContext context = new ProjectScope(getProject());
    final IEclipsePreferences eclipsePreferences = context.getNode(JavaCore.PLUGIN_ID);
    //        updatePreferences(eclipsePreferences);
    perProjectInfo.preferences = eclipsePreferences;
    //        eclipsePreferences.addPreferenceChangeListener(this.preferencesChangeListener);
    return eclipsePreferences;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) PerProjectInfo(org.eclipse.jdt.internal.core.JavaModelManager.PerProjectInfo) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 20 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project che by eclipse.

the class StubUtility method getLineDelimiterPreference.

public static String getLineDelimiterPreference(IProject project) {
    IScopeContext[] scopeContext;
    if (project != null) {
        // project preference
        scopeContext = new IScopeContext[] { new ProjectScope(project) };
        String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
        if (lineDelimiter != null)
            return lineDelimiter;
    }
    // workspace preference
    scopeContext = new IScopeContext[] { InstanceScope.INSTANCE };
    //$NON-NLS-1$ //$NON-NLS-2$
    String platformDefault = System.getProperty("line.separator", "\n");
    return Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, platformDefault, scopeContext);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext)

Aggregations

ProjectScope (org.eclipse.core.resources.ProjectScope)28 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)13 IProject (org.eclipse.core.resources.IProject)11 ScopedPreferenceStore (org.eclipse.ui.preferences.ScopedPreferenceStore)9 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)6 Preferences (org.osgi.service.prefs.Preferences)5 IResource (org.eclipse.core.resources.IResource)3 CoreException (org.eclipse.core.runtime.CoreException)3 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)3 BackingStoreException (org.osgi.service.prefs.BackingStoreException)3 File (java.io.File)2 IFile (org.eclipse.core.resources.IFile)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IPath (org.eclipse.core.runtime.IPath)2 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)2 ILaunch (org.eclipse.debug.core.ILaunch)2 Launch (org.eclipse.debug.core.Launch)2 Before (org.junit.Before)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 IOException (java.io.IOException)1