Search in sources :

Example 6 with IComponentsFactory

use of org.talend.core.model.components.IComponentsFactory in project tdi-studio-se by Talend.

the class TalendEditorPaletteFactoryTest method testFullMatch.

@Test
public void testFullMatch() {
    IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
    String keyword = "tjava";
    List<IComponent> componentHits = TalendEditorPaletteFactory.getRelatedComponents(componentsFactory, keyword);
    /**
         * NOTE: the expect result may change if we add/change some new components in someday
         */
    assert (componentHits.get(0).getName().equals(TJAVA));
    assert (1 < componentHits.size());
}
Also used : IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) Test(org.junit.Test)

Example 7 with IComponentsFactory

use of org.talend.core.model.components.IComponentsFactory in project tdi-studio-se by Talend.

the class TestComponentsAction method initialize.

public void initialize() {
    Job job = new //$NON-NLS-1$
    Job(//$NON-NLS-1$
    "Component Test") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                // IProgressMonitor monitorWrap = new CodeGeneratorProgressMonitor(monitor);
                //$NON-NLS-1$
                monitor.beginTask("Component Test Running", 1100);
                IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
                Set<IComponent> components = componentsFactory.getComponents();
                monitor.worked(100);
                RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
                ECodeLanguage codeLanguage = repositoryContext.getProject().getLanguage();
                String path = getPath();
                // TODO
                int taskTotal = components.size();
                for (IComponent component : components) {
                    String templateURI = path + File.separatorChar + component.getName() + File.separatorChar + TestParameter.GENERATE_TEST;
                    File templateFile = new File(templateURI);
                    // System.out.println(templateFile + " " + templateFile.exists());
                    if (templateFile.exists()) {
                        File[] fileArray = getFile(templateFile, codeLanguage);
                        //$NON-NLS-1$ //$NON-NLS-2$
                        generateCode(fileArray, templateURI.replace("\\", "/"));
                    }
                    monitor.worked(1 * 1000 / taskTotal);
                }
            } catch (Exception e) {
                //$NON-NLS-1$
                log.error("Exception during test Initialization", e);
            }
            monitor.done();
            return Status.OK_STATUS;
        }
    };
    job.schedule();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RepositoryContext(org.talend.core.context.RepositoryContext) IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) Job(org.eclipse.core.runtime.jobs.Job) File(java.io.File) ProcessorException(org.talend.designer.runprocess.ProcessorException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 8 with IComponentsFactory

use of org.talend.core.model.components.IComponentsFactory in project tdi-studio-se by Talend.

the class DownloadComponenentsAction method confirmInstallation.

private void confirmInstallation() {
    IComponent emfcomponent = null;
    FileFilter propertiesFilter = new FileFilter() {

        // gcui:search xml file.
        @Override
        public boolean accept(File file) {
            //$NON-NLS-1$
            return file.getName().endsWith("_java.xml");
        }
    };
    String location = getComponentsFolder().getAbsolutePath();
    File folder = ExchangeComponentsProvider.searchComponentFolder(new File(location));
    File[] files = folder.listFiles(propertiesFilter);
    if (files == null || files.length == 0) {
        return;
    }
    IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
    emfcomponent = componentsFactory.get(files[0].getParentFile().getName());
    if (emfcomponent == null) {
        return;
    }
    String componentName = null;
    StringBuilder message = new StringBuilder();
    String name = null;
    String family = null;
    if (emfcomponent != null) {
        name = emfcomponent.getName();
        family = emfcomponent.getOriginalFamilyName();
    }
    //String family = prop.getProperty("FAMILY"); //$NON-NLS-1$
    if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(family)) {
        componentName = name;
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        message.append("Component ").append(name).append(" installed at ").append(family).append(".\n");
    }
    if (componentName != null) {
        // see 0005051: [exchange view] select component in the palette once component is installed
        selectPaletteEntry(componentName);
    }
    MessageDialog.openInformation(null, Messages.getString("DownloadComponenentsAction.installExchange"), //$NON-NLS-1$ //$NON-NLS-2$
    Messages.getString("ExchangeWebService.downloadingExtensionSuccessful"));
    ComponentManager.saveResource();
}
Also used : IComponent(org.talend.core.model.components.IComponent) IComponentsFactory(org.talend.core.model.components.IComponentsFactory) FileFilter(java.io.FileFilter) File(java.io.File)

Example 9 with IComponentsFactory

use of org.talend.core.model.components.IComponentsFactory in project tdi-studio-se by Talend.

the class JetSkeletonManager method updateSkeletonPersistenceData.

/**
     * DOC xtan
     * <p>
     * check the skeleton file whether changed or not, and save the SkeletonUpdateCache file again.
     * </p>
     * 
     * @return true if there is one skeleton file changed.
     */
public static boolean updateSkeletonPersistenceData() {
    boolean doUpdate = false;
    JetSkeletonManager localInstance = JetSkeletonManager.getInstance();
    localInstance.load();
    IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
    List<String> skeletons = new ArrayList<String>();
    List<String> systemSkeletons = getSystemSkeletons();
    List<String> componentSkeletons = componentsFactory.getSkeletons();
    if (systemSkeletons != null && !systemSkeletons.isEmpty()) {
        skeletons.addAll(systemSkeletons);
    }
    if (componentSkeletons != null && !componentSkeletons.isEmpty()) {
        skeletons.addAll(componentSkeletons);
    }
    for (String jetSkeleton : skeletons) {
        // System.out.println(jetSkeleton);
        try {
            File file = new File(jetSkeleton);
            if (localInstance.checkAndUpdateCache(file)) {
                doUpdate = true;
            // System.out.println("need check:" + jetSkeleton);
            }
        } catch (Exception e) {
            IStatus status = new Status(IStatus.WARNING, CodeGeneratorActivator.PLUGIN_ID, Messages.getString("JetSkeletonManager.updateProblem"), //$NON-NLS-1$
            e);
            CodeGeneratorActivator.getDefault().getLog().log(status);
            localInstance.save();
            return true;
        }
    }
    localInstance.save();
    return doUpdate;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IComponentsFactory(org.talend.core.model.components.IComponentsFactory) ArrayList(java.util.ArrayList) IFile(org.eclipse.core.resources.IFile) File(java.io.File) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 10 with IComponentsFactory

use of org.talend.core.model.components.IComponentsFactory in project tdi-studio-se by Talend.

the class TalendEditorComponentCreationUtil method readComponentsInCategory.

/**
     * read all components belongs to some category (DI, CAMEL etc.) then store it into a map which can be reused
     * 
     * @param categoryName
     * @param entries
     */
/*
     * TODO this can be improved after refactoring org.talend.core.model.components.IComponentsHandler implementation in
     * each editor
     */
private static void readComponentsInCategory(String categoryName, Map<String, IComponent> entries) {
    IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
    Set<IComponent> allComponents = componentsFactory.getComponents();
    for (IComponent component : allComponents) {
        String compType = component.getPaletteType();
        if (!component.isTechnical() && compType != null && categoryName.equals(compType)) {
            entries.put(component.getName(), component);
        }
    }
    DummyComponent noteComponent = new DummyComponent("Note");
    noteComponent.setIcon16(ImageProvider.getImageDesc(ECoreImage.CODE_ICON));
    noteComponent.setOriginalFamilyName("Misc");
    entries.put("Note", noteComponent);
}
Also used : DummyComponent(org.talend.designer.core.model.components.DummyComponent) IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent)

Aggregations

IComponentsFactory (org.talend.core.model.components.IComponentsFactory)16 IComponent (org.talend.core.model.components.IComponent)12 Test (org.junit.Test)5 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 RepositoryContext (org.talend.core.context.RepositoryContext)2 FileFilter (java.io.FileFilter)1 LinkedHashSet (java.util.LinkedHashSet)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 Job (org.eclipse.core.runtime.jobs.Job)1 PaletteRoot (org.eclipse.gef.palette.PaletteRoot)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 ComponentDefinition (org.talend.components.api.component.ComponentDefinition)1 ECodeLanguage (org.talend.core.language.ECodeLanguage)1