use of org.eclipse.core.resources.ProjectScope in project sling by apache.
the class ProjectUtil method getSyncDirectoryValue.
/**
* Returns the value of the sync directory configured for a project.
*
* <p>
* The value is returned as a relative path to the project's location. If the property value is not set, it defaults
* to {@value #PROPERTY_SYNC_ROOT_DEFAULT_VALUE}.
* </p>
*
* @param project the project, must not be null
* @return the value of the sync directory
*/
public static IPath getSyncDirectoryValue(IProject project) {
// for compatibility reasons, read the old value first
String oldValue = null;
try {
oldValue = project.getPersistentProperty(PROPERTY_SYNC_ROOT_OLD);
} catch (CoreException e) {
Activator.getDefault().getPluginLogger().trace("Failed retrieving old values for content sync root for project " + project.getName(), e);
}
// read a value from the new store, returning a default if none is found
IScopeContext projectScope = new ProjectScope(project);
IEclipsePreferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
if (projectNode == null) {
String value;
// try to read from old values
if (oldValue != null) {
value = oldValue;
} else {
value = PROPERTY_SYNC_ROOT_DEFAULT_VALUE;
}
return Path.fromOSString(value);
}
// if no new value if found and an old value exists, use the old value and save it in the new store
String value = projectNode.get(PROPERTY_SYNC_ROOT, null);
if (value == null && oldValue != null) {
value = oldValue;
setSyncDirectoryPath(project, Path.fromPortableString(value));
}
// it is now safe to delete the value from the old store
if (oldValue != null) {
try {
project.setPersistentProperty(PROPERTY_SYNC_ROOT_OLD, null);
} catch (CoreException e) {
Activator.getDefault().getPluginLogger().error(e.getMessage(), e);
}
}
// TODO central place for defaults
if (value == null) {
return Path.fromOSString(PROPERTY_SYNC_ROOT_DEFAULT_VALUE);
} else {
return Path.fromPortableString(value);
}
}
use of org.eclipse.core.resources.ProjectScope in project sling by apache.
the class ProjectUtil method getProvisioningModelPath.
public static IPath getProvisioningModelPath(IProject project) {
if (project == null || !project.isOpen() || !ProjectHelper.isLaunchpadProject(project)) {
return null;
}
IScopeContext projectScope = new ProjectScope(project);
IEclipsePreferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
if (projectNode == null) {
return null;
}
String propertyValue = projectNode.get(PROPERTY_PROVISIONING_MODEL_DIR, null);
if (propertyValue == null) {
return null;
}
return Path.fromPortableString(propertyValue);
}
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);
}
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);
}
Aggregations