use of org.eclipse.core.runtime.preferences.IScopeContext in project liferay-ide by liferay.
the class LiferayUIPlugin method _installLiferayFormatterProfile.
@SuppressWarnings({ "rawtypes", "unchecked" })
private void _installLiferayFormatterProfile() {
PreferencesAccess access = PreferencesAccess.getOriginalPreferences();
ProfileVersioner profileVersioner = new ProfileVersioner();
IScopeContext instanceScope = access.getInstanceScope();
try {
FormatterProfileStore store = new FormatterProfileStore(profileVersioner);
List profiles = store.readProfiles(instanceScope);
if (profiles == null) {
profiles = new ArrayList();
}
// add liferay profile
Profile eclipseProfile = new CustomProfile("Liferay [plug-in]", getLiferaySettings(), profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
profiles.add(eclipseProfile);
store.writeProfiles(profiles, instanceScope);
// ProfileManager manager = new FormatterProfileManager(profiles,
// instanceScope, access, profileVersioner);
// manager.setSelected(eclipseProfile);
// manager.commitChanges(instanceScope);
instanceScope.getNode(JavaUI.ID_PLUGIN).flush();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
instanceScope.getNode(JavaCore.PLUGIN_ID).flush();
} catch (BackingStoreException bse) {
}
}
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project liferay-ide by liferay.
the class JSFModuleProjectProviderDefaultValueService method compute.
@Override
protected String compute() {
String defaultProjectBuildType = "maven-jsf";
IScopeContext[] prefContexts = { DefaultScope.INSTANCE, InstanceScope.INSTANCE };
String buildType = Platform.getPreferencesService().getString(ProjectCore.PLUGIN_ID, ProjectCore.PREF_DEFAULT_JSF_MODULE_PROJECT_BUILD_TYPE_OPTION, null, prefContexts);
if (buildType == null) {
return "maven-jsf";
}
ILiferayProjectProvider provider = LiferayCore.getProvider(buildType);
if (provider != null) {
return provider.getShortName();
}
return defaultProjectBuildType;
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project liferay-ide by liferay.
the class SDKUtil method getSDK.
public static SDK getSDK(IProject project) {
SDK retval = null;
// try to determine SDK based on project location
IPath projectLocation = project.getRawLocation();
if (projectLocation == null) {
projectLocation = project.getLocation();
}
if (projectLocation != null) {
IPath sdkLocation = projectLocation.removeLastSegments(2);
retval = SDKManager.getInstance().getSDK(sdkLocation);
if (retval == null) {
retval = createSDKFromLocation(sdkLocation);
if (retval != null) {
SDK newSDK = retval;
SDKManager.getInstance().addSDK(newSDK);
}
}
}
if (retval == null) {
/**
* this means the sdk could not be determined by location (user is
*using out-of-sdk style projects)
*so we should check to see if the sdk name is persisted to the
*project prefs
*/
IScopeContext[] context = { new ProjectScope(project) };
String sdkName = Platform.getPreferencesService().getString(SDKCorePlugin.PLUGIN_ID, SDKCorePlugin.PREF_KEY_SDK_NAME, null, context);
retval = SDKManager.getInstance().getSDK(sdkName);
}
return retval;
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project eclipse.jdt.ls 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.runtime.preferences.IScopeContext in project jbosstools-hibernate by jbosstools.
the class ContentAssistTest method testEnableHibernateNature.
@Test
public void testEnableHibernateNature() throws BackingStoreException, CoreException {
IJavaProject prj = hcth.getProject().getIJavaProject();
IScopeContext scope = new ProjectScope(prj.getProject());
Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
node.putBoolean(HibernatePropertiesConstants.HIBERNATE3_ENABLED, true);
// $NON-NLS-1$
node.put(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, "testcfg");
node.flush();
ProjectUtils.addProjectNature(prj.getProject(), HibernatePropertiesConstants.HIBERNATE_NATURE, new NullProgressMonitor());
ProjectUtils.removeProjectNature(prj.getProject(), HibernatePropertiesConstants.HIBERNATE_NATURE, new NullProgressMonitor());
}
Aggregations