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);
}
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);
}
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));
}
}
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;
}
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);
}
Aggregations