Skip to main content
summaryrefslogtreecommitdiffstats
blob: 21f725fda4c1b2037db71f7524d093b480a02890 (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
/*******************************************************************************
 * Copyright (c) 2005 Oracle Corporation.
 * 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:
 *    Debajit Adhikary - initial API and implementation
 *******************************************************************************/ 
package org.eclipse.jst.jsf.core.internal.project.facet;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;


/**
 * Utility class to provide an easy way to read the jsfFacetConfiguration 
 * extension-point (org.eclipse.jst.jsf.core.jsfFacetConfiguration).

 * @author Debajit Adhikary (Oracle)
 *
 */
public class JsfFacetConfigurationUtil
{
    private static final String JSF_FACES_CONFIG_EXTENSION_ID = "jsfFacetConfiguration"; //$NON-NLS-1$
    private static final String DISABLED_ATTR_NAME = "disabled"; //$NON-NLS-1$
    private static final String TRUE_STRING = "true"; //$NON-NLS-1$


    /**
     * @return True if the disabled attribute is not set to "true".
     */
    public static boolean isJsfFacetConfigurationEnabled ()
    {
        return !isJsfFacetConfigurationDisabled();
    }

    
    /**
     * @return True if disabled="true" is set in the extension point.
     */
    public static boolean isJsfFacetConfigurationDisabled ()
    {
        IExtensionPoint jsfFacetConfigExtensionPoint = JSFCorePlugin.getDefault().getExtension(JSF_FACES_CONFIG_EXTENSION_ID);
        for (final IExtension extension : jsfFacetConfigExtensionPoint.getExtensions())
        {
            for (final IConfigurationElement configElement : extension.getConfigurationElements())
            {
                if (configElement != null && configElement.getName().equals(JSF_FACES_CONFIG_EXTENSION_ID))
                {
                    final String attrValue = configElement.getAttribute(DISABLED_ATTR_NAME);
                    if(attrValue != null)
                    {
                        return attrValue.equalsIgnoreCase(TRUE_STRING);
                    }
                }
            }
        }

        return false;
    }


}

Back to the top