Skip to main content
summaryrefslogtreecommitdiffstats
blob: 8e581ef9e06429ead0815a1da7e1923628799cc3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*******************************************************************************
 * Copyright (c) 2001, 2008 Oracle Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Oracle Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.jsf.core.internal;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.jst.jsf.designtime.internal.view.model.TagRegistryFactory;

/**
 * Encapsulates information about tag registry extensions
 * 
 */
public final class TagRegistryFactoryInfo implements ITagRegistryFactoryInfo
{
    private final String             _description;
    private final String             _id;
    private final TagRegistryFactory _tagRegistry;
    private final Set<IContentType>  _contentTypes;

    /**
     * @param element
     * @throws CoreException
     */
    TagRegistryFactoryInfo(IConfigurationElement element)
            throws CoreException
    {
        // do this first since it has highest potential to fail
        _tagRegistry = (TagRegistryFactory) element
                .createExecutableExtension("class"); //$NON-NLS-1$

        final String localId = element.getAttribute("id"); //$NON-NLS-1$
        _id = element.getContributor().getName() + "." + localId; //$NON-NLS-1$

        _description = element.getAttribute("description"); //$NON-NLS-1$

        final IConfigurationElement[] contentTypes = element
                .getChildren("content-type"); //$NON-NLS-1$

        final IContentTypeManager typeManager = Platform
                .getContentTypeManager();
        _contentTypes = new HashSet<IContentType>();
        for (IConfigurationElement contentTypeElement : contentTypes)
        {
            final String contentTypeId = contentTypeElement
                    .getAttribute("contentTypeId"); //$NON-NLS-1$

            final IContentType contentType = typeManager
                    .getContentType(contentTypeId);
            _contentTypes.add(contentType);
        }
    }

    /**
     * @return the user displyable description
     */
    public String getDescription()
    {
        return _description;
    }

    /**
     * @return the unique of the extension
     */
    public String getId()
    {
        return _id;
    }

    /**
     * @return the registry
     */
    public TagRegistryFactory getTagRegistryFactory()
    {
        return _tagRegistry;
    }

    /**
     * Set is immutable.
     * 
     * @return the content types this registry is registered against.
     */
    public Set<IContentType> getContentTypes()
    {
        return Collections.unmodifiableSet(_contentTypes);
    }
}

Back to the top