Search in sources :

Example 1 with DownloadExtensionProvider

use of org.talend.designer.components.exchange.ui.htmlcontent.DownloadExtensionProvider in project tdi-studio-se by Talend.

the class ExchangeManager method resolveDynamicContent.

/**
     * 
     * DOC talend Comment method "resolveDynamicContent".
     * 
     * @param dom
     * @param nodes original contentProvider nods parsed from html file
     * @return
     */
private Document resolveDynamicContent(Document dom, Node[] nodes) {
    for (int i = 0; i < nodes.length; i++) {
        Element contentProviderElement = (Element) nodes[i];
        IntroContentProvider provider = new IntroContentProvider(contentProviderElement, ExchangePlugin.getDefault().getBundle());
        IIntroXHTMLContentProvider providerClass = (IIntroXHTMLContentProvider) ContentProviderManager.getInst().getContentProvider(provider);
        if (providerClass == null)
            providerClass = (IIntroXHTMLContentProvider) ContentProviderManager.getInst().createContentProvider(provider, null);
        if (providerClass != null) {
            if (providerClass instanceof ExchangeContentProvider) {
                if (getSelectedExtension() != null) {
                    ((ExchangeContentProvider) providerClass).setComponentExtension(getSelectedExtension());
                } else {
                    ((ExchangeContentProvider) providerClass).setComponentExtension(getSelectedExtension());
                }
            } else if (providerClass instanceof AvailableCompositeProvider) {
                if (getAvialableFilter() == null) {
                    ((AvailableCompositeProvider) providerClass).setfAvailableExtensions(fAvailableExtensions);
                } else {
                    List<ComponentExtension> fAvailableExtensionsFilter = new ArrayList<ComponentExtension>();
                    for (ComponentExtension Extension : fAvailableExtensions) {
                        if (Extension.getLabel().toUpperCase().contains(getAvialableFilter().toUpperCase())) {
                            fAvailableExtensionsFilter.add(Extension);
                        }
                    }
                    ((AvailableCompositeProvider) providerClass).setfAvailableExtensions(fAvailableExtensionsFilter);
                }
            } else if (providerClass instanceof DownloadExtensionProvider) {
                loadDownloadedExtensionsFromFile();
                ((DownloadExtensionProvider) providerClass).setfInstalledExtensions(fInstalledExtensions);
                ((DownloadExtensionProvider) providerClass).setfDownloadedExtensions(fDownloadedExtensions);
            } else if (providerClass instanceof MyExchangeContentProvider) {
                ((MyExchangeContentProvider) providerClass).setComponentExtension(getSelectedExtension());
                ((MyExchangeContentProvider) providerClass).setfContributeExtensions(new ArrayList<ComponentExtension>(fContributedExtensions));
            }
            // revert the content contentprovider before generate the dynamic content
            reinjectDynamicContent(dom, contentProviderElement);
            Properties att = new Properties();
            att.setProperty(IIntroHTMLConstants.ATTRIBUTE_ID, provider.getId());
            // Element contentDiv = ModelUtil.createElement(dom, ModelUtil.TAG_DIV, att);
            Element contentDiv = TalendHtmlModelUtil.createElement(dom, TalendHtmlModelUtil.TAG_DIV, att);
            providerClass.createContent(provider.getId(), contentDiv);
            contentProviderElement.getParentNode().replaceChild(contentDiv, contentProviderElement);
        } else {
        // we couldn't load the content provider, so add any alternate
        // text content if there is any.
        // INTRO: do it. 3.0 intro content style uses text element as
        // alt text. We can load XHTML content here.
        }
    }
    return dom;
}
Also used : ExchangeContentProvider(org.talend.designer.components.exchange.ui.htmlcontent.ExchangeContentProvider) MyExchangeContentProvider(org.talend.designer.components.exchange.ui.htmlcontent.MyExchangeContentProvider) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) IIntroXHTMLContentProvider(org.eclipse.ui.intro.config.IIntroXHTMLContentProvider) Properties(java.util.Properties) AvailableCompositeProvider(org.talend.designer.components.exchange.ui.htmlcontent.AvailableCompositeProvider) DownloadExtensionProvider(org.talend.designer.components.exchange.ui.htmlcontent.DownloadExtensionProvider) IntroContentProvider(org.eclipse.ui.internal.intro.impl.model.IntroContentProvider) ComponentExtension(org.talend.designer.components.exchange.model.ComponentExtension) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) MyExchangeContentProvider(org.talend.designer.components.exchange.ui.htmlcontent.MyExchangeContentProvider)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Properties (java.util.Properties)1 IntroContentProvider (org.eclipse.ui.internal.intro.impl.model.IntroContentProvider)1 IIntroXHTMLContentProvider (org.eclipse.ui.intro.config.IIntroXHTMLContentProvider)1 ComponentExtension (org.talend.designer.components.exchange.model.ComponentExtension)1 AvailableCompositeProvider (org.talend.designer.components.exchange.ui.htmlcontent.AvailableCompositeProvider)1 DownloadExtensionProvider (org.talend.designer.components.exchange.ui.htmlcontent.DownloadExtensionProvider)1 ExchangeContentProvider (org.talend.designer.components.exchange.ui.htmlcontent.ExchangeContentProvider)1 MyExchangeContentProvider (org.talend.designer.components.exchange.ui.htmlcontent.MyExchangeContentProvider)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1