Search in sources :

Example 1 with CSSProfile

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

the class CSSProfileFinder method findProfileFor.

public CSSProfile findProfileFor(String baseLocation) {
    CSSProfileRegistry reg = CSSProfileRegistry.getInstance();
    CSSProfile profile = null;
    if (baseLocation != null) {
        IPath path = new Path(baseLocation);
        IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
        if (resource == null && path.segmentCount() > 1)
            resource = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
        if (resource != null) {
            String profileID = CSSContentProperties.getProperty(CSSContentProperties.CSS_PROFILE, resource, true);
            if (profileID != null && 0 < profileID.length()) {
                profile = reg.getProfile(profileID);
            }
        }
    }
    return (profile != null) ? profile : reg.getDefaultProfile();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) CSSProfile(org.eclipse.wst.css.core.internal.metamodel.CSSProfile) CSSProfileRegistry(org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry) IResource(org.eclipse.core.resources.IResource)

Example 2 with CSSProfile

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

the class CSSProfileTest method main.

/**
 * Test use only
 */
public static void main(String[] args) {
    if (args.length == 0)
        return;
    CSSMetaModel metamodel = null;
    try {
        // $NON-NLS-1$
        CSSProfile profile = new CSSProfileImpl("test", new URL(args[0]));
        metamodel = profile.getMetaModel();
    } catch (MalformedURLException e) {
        Logger.logException(e);
    }
    if (metamodel == null) {
        return;
    }
    /*
		 * CSSMMTypeCollector collector = new CSSMMTypeCollector();
		 * collector.apply(metamodel, CSSMMNode.TYPE_PROPERTY); Iterator
		 * iProperty = collector.getNodes(); while (iProperty.hasNext()) {
		 * CSSMMNode node = (CSSMMNode)iProperty.next();
		 * System.out.println("Property " + node.getName() + " can contain:");
		 * //$NON-NLS-2$ //$NON-NLS-1$ Iterator iValue =
		 * node.getDescendants(); while (iValue.hasNext()) {
		 * debugOut((CSSMMNode)iValue.next(), 0, false); } }
		 */
    debugOut(metamodel, 0, true);
}
Also used : MalformedURLException(java.net.MalformedURLException) CSSProfile(org.eclipse.wst.css.core.internal.metamodel.CSSProfile) CSSMetaModel(org.eclipse.wst.css.core.internal.metamodel.CSSMetaModel) URL(java.net.URL)

Example 3 with CSSProfile

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

the class WebContentSettingsPropertyPage method populateCSSProfileValues.

private void populateCSSProfileValues() {
    fProfileIds = new ArrayList();
    // add none first
    fProfileCombo.add(SELECT_NONE);
    fProfileIds.add(null);
    CSSProfileRegistry reg = CSSProfileRegistry.getInstance();
    Iterator i = reg.getProfiles();
    while (i.hasNext()) {
        CSSProfile profile = (CSSProfile) i.next();
        String id = profile.getProfileID();
        String name = profile.getProfileName();
        fProfileCombo.add(name);
        fProfileIds.add(id);
    }
}
Also used : CSSProfile(org.eclipse.wst.css.core.internal.metamodel.CSSProfile) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CSSProfileRegistry(org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry)

Example 4 with CSSProfile

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

the class CSSWebContentSettingsPropertyPage method populateValues.

private void populateValues() {
    fProfileIds = new ArrayList();
    // add none first
    fProfileCombo.add(SELECT_NONE);
    fProfileIds.add(null);
    CSSProfileRegistry reg = CSSProfileRegistry.getInstance();
    Iterator i = reg.getProfiles();
    while (i.hasNext()) {
        CSSProfile profile = (CSSProfile) i.next();
        String id = profile.getProfileID();
        String name = profile.getProfileName();
        fProfileCombo.add(name);
        fProfileIds.add(id);
    }
}
Also used : CSSProfile(org.eclipse.wst.css.core.internal.metamodel.CSSProfile) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CSSProfileRegistry(org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry)

Example 5 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