Search in sources :

Example 21 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 22 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)

Example 23 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project sling by apache.

the class ProjectUtil method setPathPersistentProperty.

private static void setPathPersistentProperty(IProject project, IPath path, String propertyName) {
    IScopeContext projectScope = new ProjectScope(project);
    IEclipsePreferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
    if (projectNode != null) {
        projectNode.put(propertyName, path.toPortableString());
        try {
            projectNode.flush();
        } catch (BackingStoreException e) {
            Activator.getDefault().getPluginLogger().error(e.getMessage(), e);
        }
    }
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) BackingStoreException(org.osgi.service.prefs.BackingStoreException)

Example 24 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project eclipse.platform.text by eclipse.

the class FileDocumentProvider method getLineDelimiterPreference.

/**
 * Returns the default line delimiter preference for the given file.
 *
 * @param file the file
 * @return the default line delimiter
 * @since 3.1
 */
private String getLineDelimiterPreference(IFile file) {
    IScopeContext[] scopeContext;
    if (file != null && file.getProject() != null) {
        // project preference
        scopeContext = new IScopeContext[] { new ProjectScope(file.getProject()) };
        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 };
    return Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext)

Example 25 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project linuxtools by eclipse.

the class GprofLaunchTest method setUp.

@Before
public void setUp() throws Exception {
    // $NON-NLS-1$
    proj = createProjectAndBuild(FrameworkUtil.getBundle(this.getClass()), "fibTest");
    ProjectScope ps = new ProjectScope(proj.getProject());
    ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps, ProviderProfileConstants.PLUGIN_ID);
    scoped.setSearchContexts(new IScopeContext[] { ps, InstanceScope.INSTANCE });
    scoped.setValue(ProviderProfileConstants.PREFS_KEY + GPROF_CATEGORY, GPROF_PROVIDER_ID);
    scoped.setValue(ProviderProfileConstants.USE_PROJECT_SETTINGS + GPROF_CATEGORY, true);
    scoped.save();
    IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(LAUNCH_SHORT_EXTPT);
    IConfigurationElement[] configs = extPoint.getConfigurationElements();
    for (IConfigurationElement cfg : configs) {
        if (cfg.getAttribute("id").equals(ID)) {
            // $NON-NLS-1$
            try {
                // $NON-NLS-1$
                shortcut = (ProviderLaunchShortcut) cfg.createExecutableExtension("class");
                // $NON-NLS-1$
                launchConfigTypeId = cfg.getChildren("class")[0].getChildren("parameter")[1].getAttribute("value");
            } catch (Exception e) {
                fail(e.getMessage());
            }
        }
    }
    config = createConfiguration(proj.getProject());
    // (otherwise test hangs on 'enable GGprof support' dialogue. )
    enableGprofSupport();
    // ---- Continue with launch.
    launch = new Launch(config, ILaunchManager.PROFILE_MODE, null);
    wc = config.getWorkingCopy();
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) Launch(org.eclipse.debug.core.Launch) ILaunch(org.eclipse.debug.core.ILaunch) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore) CoreException(org.eclipse.core.runtime.CoreException) Before(org.junit.Before)

Aggregations

ProjectScope (org.eclipse.core.resources.ProjectScope)28 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)13 IProject (org.eclipse.core.resources.IProject)11 ScopedPreferenceStore (org.eclipse.ui.preferences.ScopedPreferenceStore)9 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)6 Preferences (org.osgi.service.prefs.Preferences)5 IResource (org.eclipse.core.resources.IResource)3 CoreException (org.eclipse.core.runtime.CoreException)3 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)3 BackingStoreException (org.osgi.service.prefs.BackingStoreException)3 File (java.io.File)2 IFile (org.eclipse.core.resources.IFile)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IPath (org.eclipse.core.runtime.IPath)2 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)2 ILaunch (org.eclipse.debug.core.ILaunch)2 Launch (org.eclipse.debug.core.Launch)2 Before (org.junit.Before)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 IOException (java.io.IOException)1