Search in sources :

Example 31 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdi-studio-se by Talend.

the class AddFamilyFieldProjectMigrationTask method resetFamily.

/**
     * yzhang Comment method "resetFamily".
     * 
     * @param list
     */
private void resetFamily(EList list) {
    IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
    Set<IComponent> components = componentsFactory.getComponents();
    list.clear();
    for (IComponent component : components) {
        String[] families = component.getOriginalFamilyName().split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX);
        for (String family : families) {
            ComponentSetting setting = PropertiesFactory.eINSTANCE.createComponentSetting();
            setting.setFamily(family);
            setting.setName(component.getName());
            setting.setHidden(!component.isVisibleInComponentDefinition());
            list.add(setting);
        }
    }
    RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
    IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
    try {
        prf.saveProject(repositoryContext.getProject());
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : RepositoryContext(org.talend.core.context.RepositoryContext) IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) ComponentSetting(org.talend.core.model.properties.ComponentSetting) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

RepositoryContext (org.talend.core.context.RepositoryContext)31 Context (org.talend.core.context.Context)17 Project (org.talend.core.model.general.Project)12 PersistenceException (org.talend.commons.exception.PersistenceException)8 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)7 IProject (org.eclipse.core.resources.IProject)5 ECodeLanguage (org.talend.core.language.ECodeLanguage)5 File (java.io.File)3 CoreException (org.eclipse.core.runtime.CoreException)3 BeforeClass (org.junit.BeforeClass)3 ProcessItem (org.talend.core.model.properties.ProcessItem)3 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2