use of org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry 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();
}
use of org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry 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);
}
}
use of org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry 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);
}
}
use of org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry 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);
}
use of org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry 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);
}
}
}
Aggregations