Search in sources :

Example 6 with CSSProfile

use of org.eclipse.wst.css.core.internal.metamodel.CSSProfile in project webtools.sourceediting by eclipse.

the class ProfileHandler method importProfile.

private void importProfile(String profileName) {
    URL profileURL = null;
    CSSProfileRegistry reg = CSSProfileRegistry.getInstance();
    CSSProfile profile = reg.getProfile(profileName);
    if (profile != null) {
        // first: find URL by ID
        profileURL = profile.getProfileURL();
    } else {
        // second: find URL by filename of profile URL
        Iterator i = reg.getProfiles();
        while (i.hasNext()) {
            profile = (CSSProfile) i.next();
            URL url = profile.getProfileURL();
            if (url.getFile().endsWith(profileName)) {
                profileURL = url;
                break;
            }
        }
    }
    if (profileURL == null) {
        // final: it may be url itself
        try {
            profileURL = new URL(profileName);
        } catch (MalformedURLException e) {
            Logger.logException(e);
        }
    }
    if (profileURL != null) {
        try {
            ProfileLoader.loadProfile(fMetaModel, profileURL.openStream(), fResourceBundle, fLogging);
        } catch (IOException e) {
            // $NON-NLS-1$
            Logger.logException(// $NON-NLS-1$
            "Cannot open stream for profile", e);
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) CSSProfile(org.eclipse.wst.css.core.internal.metamodel.CSSProfile) Iterator(java.util.Iterator) CSSProfileRegistry(org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry) IOException(java.io.IOException) URL(java.net.URL)

Example 7 with CSSProfile

use of org.eclipse.wst.css.core.internal.metamodel.CSSProfile in project webtools.sourceediting by eclipse.

the class RegistryReader method enumProfiles.

/**
 * We simply require an 'add' method, of what ever it is we are to read
 * into
 */
public Iterator enumProfiles() {
    Set set = new HashSet();
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
    if (point != null) {
        IConfigurationElement[] elements = point.getConfigurationElements();
        for (int i = 0; i < elements.length; i++) {
            CSSProfile info = readElement(elements[i]);
            // element
            if (info != null) {
                set.add(info);
            }
        }
    }
    return set.iterator();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CSSProfile(org.eclipse.wst.css.core.internal.metamodel.CSSProfile) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) HashSet(java.util.HashSet) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 8 with CSSProfile

use of org.eclipse.wst.css.core.internal.metamodel.CSSProfile in project webtools.sourceediting by eclipse.

the class ContentSettingsRegistry method setCSSMetaModelRegistryInto.

public static void setCSSMetaModelRegistryInto(ComboList combo) {
    // $NON-NLS-1$
    combo.add(NONE, "");
    CSSProfileRegistry reg = CSSProfileRegistry.getInstance();
    Iterator i = reg.getProfiles();
    while (i.hasNext()) {
        CSSProfile profile = (CSSProfile) i.next();
        String id = profile.getProfileID();
        String name = profile.getProfileName();
        combo.add(name, id);
    }
    combo.sortByKey(1);
}
Also used : CSSProfile(org.eclipse.wst.css.core.internal.metamodel.CSSProfile) Iterator(java.util.Iterator) CSSProfileRegistry(org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry)

Aggregations

CSSProfile (org.eclipse.wst.css.core.internal.metamodel.CSSProfile)8 CSSProfileRegistry (org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry)6 Iterator (java.util.Iterator)5 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 IResource (org.eclipse.core.resources.IResource)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 CSSMetaModel (org.eclipse.wst.css.core.internal.metamodel.CSSMetaModel)1