Search in sources :

Example 1 with IIntroXHTMLContentProvider

use of org.eclipse.ui.intro.config.IIntroXHTMLContentProvider in project tesb-studio-se by Talend.

the class EsbStartingHelper method resolveDynamicContent.

private Document resolveDynamicContent(Document dom, IIntroContentProviderSite site) {
    // get all content provider elements in DOM.
    NodeList contentProviders = //$NON-NLS-1$
    dom.getElementsByTagNameNS(//$NON-NLS-1$
    "*", IntroContentProvider.TAG_CONTENT_PROVIDER);
    // get the array version of the nodelist to work around DOM api design.
    Node[] nodes = ModelUtil.getArray(contentProviders);
    for (int i = 0; i < nodes.length; i++) {
        Element contentProviderElement = (Element) nodes[i];
        IntroContentProvider provider = new IntroContentProvider(contentProviderElement, Activator.getDefault().getBundle());
        // If we've already loaded the content provider for this element,
        // retrieve it, otherwise load the class.
        IIntroXHTMLContentProvider providerClass = (IIntroXHTMLContentProvider) ContentProviderManager.getInst().getContentProvider(provider);
        if (providerClass == null)
            // content provider never created before, create it.
            providerClass = (IIntroXHTMLContentProvider) ContentProviderManager.getInst().createContentProvider(provider, site);
        if (providerClass != null) {
            // create a div with the same id as the contentProvider, pass it
            // as the parent to create the specialized content, and then
            // replace the contentProvider element with this div.
            Properties att = new Properties();
            att.setProperty(IIntroHTMLConstants.ATTRIBUTE_ID, provider.getId());
            Element contentDiv = ModelUtil.createElement(dom, ModelUtil.TAG_DIV, att);
            providerClass.createContent(provider.getId(), contentDiv);
            if (contentDiv.getChildNodes().getLength() != 0) {
                if (StartingConstants.OPTION_NAME.equals(provider.getId()) || StartingConstants.PRODUCT_NAME.equals(provider.getId())) {
                    contentProviderElement.getParentNode().replaceChild(contentDiv.getFirstChild(), contentProviderElement);
                } else {
                    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 : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) IntroContentProvider(org.eclipse.ui.internal.intro.impl.model.IntroContentProvider) IIntroXHTMLContentProvider(org.eclipse.ui.intro.config.IIntroXHTMLContentProvider) Properties(java.util.Properties)

Example 2 with IIntroXHTMLContentProvider

use of org.eclipse.ui.intro.config.IIntroXHTMLContentProvider 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)

Example 3 with IIntroXHTMLContentProvider

use of org.eclipse.ui.intro.config.IIntroXHTMLContentProvider in project tdi-studio-se by Talend.

the class TutorialsHelper method resolveDynamicContent.

private Document resolveDynamicContent(Document dom, IIntroContentProviderSite site) {
    // get all content provider elements in DOM.
    NodeList contentProviders = //$NON-NLS-1$
    dom.getElementsByTagNameNS(//$NON-NLS-1$
    "*", IntroContentProvider.TAG_CONTENT_PROVIDER);
    // get the array version of the nodelist to work around DOM api design.
    // Node[] nodes = ModelUtil.getArray(contentProviders);
    Node[] nodes = TalendHtmlModelUtil.getArray(contentProviders);
    for (Node node : nodes) {
        Element contentProviderElement = (Element) node;
        IntroContentProvider provider = new IntroContentProvider(contentProviderElement, TutorialsPlugin.getDefault().getBundle());
        // If we've already loaded the content provider for this element,
        // retrieve it, otherwise load the class.
        IIntroXHTMLContentProvider providerClass = (IIntroXHTMLContentProvider) ContentProviderManager.getInst().getContentProvider(provider);
        if (providerClass == null) {
            // content provider never created before, create it.
            providerClass = (IIntroXHTMLContentProvider) ContentProviderManager.getInst().createContentProvider(provider, site);
        }
        if (providerClass != null) {
            // create a div with the same id as the contentProvider, pass it
            // as the parent to create the specialized content, and then
            // replace the contentProvider element with this div.
            // Properties att = new Properties();
            // Element countryListElement = dom.getElementById(ContentConstants.COUNTRY_LIST_ID);
            Element element = provider.getElement();
            // att.setProperty(IIntroHTMLConstants.ATTRIBUTE_ID, provider.getId());
            // Element contentDiv = ModelUtil.createElement(dom, ModelUtil.TAG_DIV, att);
            providerClass.createContent(provider.getId(), element);
        } 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 : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) IntroContentProvider(org.eclipse.ui.internal.intro.impl.model.IntroContentProvider) IIntroXHTMLContentProvider(org.eclipse.ui.intro.config.IIntroXHTMLContentProvider)

Aggregations

IntroContentProvider (org.eclipse.ui.internal.intro.impl.model.IntroContentProvider)3 IIntroXHTMLContentProvider (org.eclipse.ui.intro.config.IIntroXHTMLContentProvider)3 Element (org.w3c.dom.Element)3 NodeList (org.w3c.dom.NodeList)3 Properties (java.util.Properties)2 Node (org.w3c.dom.Node)2 ArrayList (java.util.ArrayList)1 List (java.util.List)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