Search in sources :

Example 51 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 52 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 53 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)

Example 54 with ProjectScope

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

the class ChangeMappingFileMigrationTask method execute.

@Override
public ExecutionResult execute(Project project) {
    try {
        URL s = MetadataTalendType.getSystemForderURLOfMappingsFile();
        changeSAPHanaMappingFile(s);
        //$NON-NLS-1$
        String dirPath = "/" + MetadataTalendType.INTERNAL_MAPPINGS_FOLDER;
        IProject _project = ResourceUtils.getProject(project);
        File projectMappingFolder = new ProjectScope(_project).getLocation().append(dirPath).toFile();
        if (projectMappingFolder.exists()) {
            URL p = MetadataTalendType.getProjectForderURLOfMappingsFile();
            changeSAPHanaMappingFile(p);
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
                ICoreService service = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
                service.synchronizeMapptingXML();
            }
        }
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) ICoreService(org.talend.core.ICoreService) File(java.io.File) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject)

Example 55 with ProjectScope

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

the class Log4jPrefsSettingManager method getLog4jPreferences.

public Preferences getLog4jPreferences(String log4jPrefsNode, boolean create) {
    try {
        IProject project = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
        if (create) {
            return new ProjectScope(project).getNode(Log4jPrefsConstants.LOG4J_RESOURCES).node(log4jPrefsNode);
        }
        Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE);
        if (!node.nodeExists(project.getName())) {
            return null;
        }
        node = node.node(project.getName());
        if (!node.nodeExists(Log4jPrefsConstants.LOG4J_RESOURCES)) {
            return null;
        }
        node = node.node(Log4jPrefsConstants.LOG4J_RESOURCES);
        if (!node.nodeExists(log4jPrefsNode)) {
            return null;
        }
        return node.node(log4jPrefsNode);
    } catch (BackingStoreException e) {
        ExceptionHandler.process(e);
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    return null;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) BackingStoreException(org.osgi.service.prefs.BackingStoreException) PersistenceException(org.talend.commons.exception.PersistenceException) Preferences(org.osgi.service.prefs.Preferences) IProject(org.eclipse.core.resources.IProject)

Aggregations

ProjectScope (org.eclipse.core.resources.ProjectScope)92 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)24 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