Search in sources :

Example 1 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project tdi-studio-se by Talend.

the class AutoConvertTypesUtils method getTypeFile.

public static File getTypeFile() {
    try {
        IProject project = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
        IPath settingPath = new ProjectScope(project).getLocation();
        //$NON-NLS-1$//$NON-NLS-2$;
        return new File(settingPath + "\\" + AUTO_CONVERSION_TYPES_RESOURCES + ".xml");
    } catch (PersistenceException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IPath(org.eclipse.core.runtime.IPath) PersistenceException(org.talend.commons.exception.PersistenceException) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IProject(org.eclipse.core.resources.IProject)

Example 2 with ProjectScope

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

the class PreferenceStoreWhitespaceInformationProvider method getLineSeparatorPreference.

protected String getLineSeparatorPreference(URI uri) {
    if (uri.isPlatformResource()) {
        IFile file = workspace.getRoot().getFile(new Path(uri.toPlatformString(true)));
        String delimiter = senseLineDelimiter(file);
        if (delimiter != null)
            return delimiter;
    }
    IProject project = null;
    if (uri.isPlatformResource()) {
        project = workspace.getRoot().getProject(uri.segment(1));
    } else {
        for (Pair<IStorage, IProject> storage : storage2UriMapper.getStorages(uri)) {
            project = storage.getSecond();
            break;
        }
    }
    if (project != null) {
        String result = getLineSeparatorPreference(new ProjectScope(project));
        if (result != null)
            return result;
    }
    @SuppressWarnings("all") String result = getLineSeparatorPreference(new InstanceScope());
    if (result != null)
        return result;
    return System.getProperty("line.separator");
}
Also used : Path(org.eclipse.core.runtime.Path) ProjectScope(org.eclipse.core.resources.ProjectScope) IFile(org.eclipse.core.resources.IFile) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) IStorage(org.eclipse.core.resources.IStorage) IProject(org.eclipse.core.resources.IProject)

Example 3 with ProjectScope

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

the class JavaProjectSetupUtil method setUnixLineEndings.

public static void setUnixLineEndings(IProject project) {
    IEclipsePreferences prefs = new ProjectScope(project).getNode(Platform.PI_RUNTIME);
    prefs.put(Platform.PREF_LINE_SEPARATOR, "\n");
    try {
        prefs.flush();
    } catch (BackingStoreException e) {
        throw new RuntimeException(e);
    }
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) BackingStoreException(org.osgi.service.prefs.BackingStoreException)

Example 4 with ProjectScope

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

the class AbstractPreferencePage method handleUseProjectSettings.

/**
 * Switches the search scope of the preference store to use [Project, Instance, Configuration] if values are project
 * specific, and [Instance, Configuration] otherwise. This implementation requires that the given preference store
 * is based on the Project preference store when the page is used as a Properties page. (This is done in
 * {@link #doGetPreferenceStore()}).
 */
@SuppressWarnings("deprecation")
private void handleUseProjectSettings() {
    // Note: uses the pre Eclipse 3.6 way of specifying search scopes (deprecated since 3.6)
    boolean isUseProjectSettings = useProjectSettingsButton.getSelection();
    link.setEnabled(!isUseProjectSettings);
    if (!isUseProjectSettings) {
        ((FixedScopedPreferenceStore) getPreferenceStore()).setSearchContexts(new IScopeContext[] { new InstanceScope(), new ConfigurationScope() });
    } else {
        ((FixedScopedPreferenceStore) getPreferenceStore()).setSearchContexts(new IScopeContext[] { new ProjectScope(currentProject()), new InstanceScope(), new ConfigurationScope() });
        setProjectSpecificValues();
    }
    updateFieldEditors(isUseProjectSettings);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 5 with ProjectScope

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

the class PreferenceStoreAccessImpl method getWritablePreferenceStore.

@Override
@SuppressWarnings("deprecation")
public IPreferenceStore getWritablePreferenceStore(Object context) {
    lazyInitialize();
    IProject project = getProject(context);
    if (project == null) {
        return getWritablePreferenceStore();
    }
    ProjectScope projectScope = new ProjectScope(project);
    FixedScopedPreferenceStore result = new FixedScopedPreferenceStore(projectScope, getQualifier());
    result.setSearchContexts(new IScopeContext[] { projectScope, new InstanceScope(), new ConfigurationScope() });
    return result;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) IProject(org.eclipse.core.resources.IProject) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Aggregations

ProjectScope (org.eclipse.core.resources.ProjectScope)90 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)42 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)31 IProject (org.eclipse.core.resources.IProject)28 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)23 Preferences (org.osgi.service.prefs.Preferences)18 DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)17 BackingStoreException (org.osgi.service.prefs.BackingStoreException)17 ScopedPreferenceStore (org.eclipse.ui.preferences.ScopedPreferenceStore)11 IFile (org.eclipse.core.resources.IFile)9 IResource (org.eclipse.core.resources.IResource)9 CoreException (org.eclipse.core.runtime.CoreException)8 IAdaptable (org.eclipse.core.runtime.IAdaptable)5 IPath (org.eclipse.core.runtime.IPath)5 HashSet (java.util.HashSet)4 Set (java.util.Set)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 Path (org.eclipse.core.runtime.Path)4 Test (org.junit.Test)4 File (java.io.File)3