Search in sources :

Example 1 with IPreview

use of org.talend.core.repository.model.preview.IPreview in project tdi-studio-se by Talend.

the class JSONShadowProcessHelper method createPreview.

/**
     * DOC amaumont Comment method "createPreview".
     * 
     * @param configurationElements
     * @return
     * @throws CoreException
     */
private static IPreview createPreview(String type) throws CoreException {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    // use the org.talend.repository.filepreview_provider
    IConfigurationElement[] configurationElements = registry.getConfigurationElementsFor(//$NON-NLS-1$
    "org.talend.core.runtime.filepreview_provider");
    // When start a new preview. need stop before preview.
    forceStopPreview();
    IPreview preview = null;
    if (configurationElements.length > 0) {
        //$NON-NLS-1$
        preview = (IPreview) configurationElements[0].createExecutableExtension("class");
    }
    for (IConfigurationElement configurationElement : configurationElements) {
        //$NON-NLS-1$
        String fileType = configurationElement.getAttribute("type");
        // to do this just make sure the code behaviour is same like before
        if (type == null && fileType != null) {
            // current type(null value, means should use the default)
            continue;
        } else if (type != null) {
            // want to create a specified previewer for a specified type
            if (fileType == null) {
                // means this is a gereral previewer, not good for a specified type
                continue;
            } else if (!fileType.equals(type)) {
                continue;
            }
        }
        //$NON-NLS-1$
        IPreview pre = (IPreview) configurationElement.createExecutableExtension("class");
        if (!PluginChecker.isOnlyTopLoaded() && !pre.isTopPreview()) {
            preview = pre;
        }
    }
    if (preview == null) {
        log.error(//$NON-NLS-1$
        Messages.getString("ShadowProcessHelper.logError.previewIsNull01") + //$NON-NLS-1$
        Messages.getString("ShadowProcessHelper.logError.previewIsNull02"));
    }
    currentPreview = preview;
    return preview;
}
Also used : IPreview(org.talend.core.repository.model.preview.IPreview) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 2 with IPreview

use of org.talend.core.repository.model.preview.IPreview in project tdi-studio-se by Talend.

the class JSONShadowProcessHelper method getCsvArray.

/**
     * parse a file describe by a processDescription in XmlArray.
     * 
     * @param processDescription
     * @return xmlArray
     */
public static CsvArray getCsvArray(final ProcessDescription processDescription, String type) throws CoreException {
    CsvArray csvArray = null;
    IPreview preview = createPreview(type);
    if (preview != null) {
        csvArray = preview.preview(processDescription, type);
    }
    return csvArray;
}
Also used : CsvArray(org.talend.core.utils.CsvArray) IPreview(org.talend.core.repository.model.preview.IPreview)

Example 3 with IPreview

use of org.talend.core.repository.model.preview.IPreview in project tdi-studio-se by Talend.

the class JSONShadowProcessHelper method getCsvArray.

/**
     * parse a file describe by a processDescription in XmlArray.
     * 
     * @param processDescription
     * @return xmlArray
     */
public static CsvArray getCsvArray(final ProcessDescription processDescription, String type, boolean errorOutoutAsException) throws CoreException {
    CsvArray csvArray = null;
    IPreview preview = createPreview();
    if (preview != null) {
        csvArray = preview.preview(processDescription, type, errorOutoutAsException);
    }
    return csvArray;
}
Also used : CsvArray(org.talend.core.utils.CsvArray) IPreview(org.talend.core.repository.model.preview.IPreview)

Aggregations

IPreview (org.talend.core.repository.model.preview.IPreview)3 CsvArray (org.talend.core.utils.CsvArray)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)1