use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime in project webtools.sourceediting by eclipse.
the class NewProjectDataModelFacetWizard method createPageControls.
@Override
public void createPageControls(Composite container) {
super.createPageControls(container);
final IPreset preset = this.template.getInitialPreset();
final IRuntime runtime = (IRuntime) model.getProperty(FACET_RUNTIME);
if (preset == null) {
// If no preset is specified, select the runtime and it's default
// facets.
setRuntimeAndDefaultFacets(runtime);
} else {
// If preset is specified, select the runtime only if supports all
// of the facets included in the preset.
getFacetedProjectWorkingCopy().setSelectedPreset(preset.getId());
boolean supports = false;
if (runtime != null) {
supports = true;
for (Iterator itr = preset.getProjectFacets().iterator(); itr.hasNext(); ) {
final IProjectFacetVersion fv = (IProjectFacetVersion) itr.next();
if (!runtime.supports(fv)) {
supports = false;
break;
}
}
}
if (supports) {
getFacetedProjectWorkingCopy().setTargetedRuntimes(Collections.singleton(runtime));
} else {
model.setProperty(FACET_RUNTIME, null);
}
}
synchRuntimes();
}
use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime in project webtools.sourceediting by eclipse.
the class DataModelFacetCreationWizardPage method restoreRuntimeSettings.
public static void restoreRuntimeSettings(IDialogSettings settings, IDataModel model) {
if (settings != null) {
if (!model.isPropertySet(IFacetProjectCreationDataModelProperties.FACET_RUNTIME)) {
boolean runtimeSet = false;
String[] mruRuntimeArray = settings.getArray(MRU_RUNTIME_STORE);
DataModelPropertyDescriptor[] descriptors = model.getValidPropertyDescriptors(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
List mruRuntimes = new ArrayList();
if (mruRuntimeArray == null) {
List defRuntimes = ProductManager.getDefaultRuntimes();
for (Iterator iter = defRuntimes.iterator(); iter.hasNext(); ) mruRuntimes.add(((IRuntime) iter.next()).getName());
} else {
mruRuntimes.addAll(Arrays.asList(mruRuntimeArray));
}
if (!mruRuntimes.isEmpty()) {
for (int i = 0; i < mruRuntimes.size() && !runtimeSet; i++) {
for (int j = 0; j < descriptors.length - 1 && !runtimeSet; j++) {
if (mruRuntimes.get(i).equals(((IRuntime) descriptors[j].getPropertyValue()).getName())) {
model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, descriptors[j].getPropertyValue());
runtimeSet = true;
}
}
if (!runtimeSet && mruRuntimes.get(i).equals(NULL_RUNTIME)) {
model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, descriptors[descriptors.length - 1].getPropertyValue());
runtimeSet = true;
}
}
}
if (!runtimeSet && descriptors.length > 0) {
model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, descriptors[0].getPropertyValue());
}
}
}
}
use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime in project webtools.sourceediting by eclipse.
the class ProductManager method getMatchingRuntime.
private static IRuntime getMatchingRuntime(String defaultProductRuntimeProperty, Set<IRuntime> runtimes) {
String defaultProductRuntimeKey = getProperty(defaultProductRuntimeProperty);
if (defaultProductRuntimeKey == null || defaultProductRuntimeKey.length() == 0) {
return null;
}
// The defaultProductRuntimeKey needs to be in the following format
// <facet runtime id>:<facet version>.
int seperatorIndex = defaultProductRuntimeKey.indexOf(RUNTIME_SEPARATOR);
if (seperatorIndex < 0 && seperatorIndex < defaultProductRuntimeKey.length()) {
// Consider throwing an exception here.
// $NON-NLS-1$
WSTWebPlugin.logError("Invalid default product runtime id. It should follow the format <facet runtime id>:<facet version>. Id processed: " + defaultProductRuntimeKey);
return null;
}
String defaultRuntimeID = defaultProductRuntimeKey.substring(0, seperatorIndex);
String defaultFacetVersion = defaultProductRuntimeKey.substring(seperatorIndex + 1);
for (Iterator<IRuntime> runtimeIt = runtimes.iterator(); runtimeIt.hasNext(); ) {
IRuntime runtime = runtimeIt.next();
List<IRuntimeComponent> runtimeComps = runtime.getRuntimeComponents();
if (!runtimeComps.isEmpty()) {
for (Iterator<IRuntimeComponent> compsIter = runtimeComps.iterator(); compsIter.hasNext(); ) {
IRuntimeComponent runtimeComp = compsIter.next();
if (defaultRuntimeID.equals(runtimeComp.getRuntimeComponentType().getId()) && (defaultFacetVersion.equals(runtimeComp.getRuntimeComponentVersion().getVersionString()))) {
return runtime;
}
}
}
}
// No matches found.
return null;
}
use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime in project webtools.sourceediting by eclipse.
the class DataModelFacetCreationWizardPage method handlePrimaryFacetVersionSelectedEvent.
protected void handlePrimaryFacetVersionSelectedEvent() {
final IProjectFacetVersion fv = getPrimaryFacetVersion();
if (fv != null) {
String presetID = null;
IRuntime runtime = (IRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
if (runtime != null) {
if (runtime.getRuntimeComponents().size() > 0) {
IRuntimeComponent runtimeComponent = runtime.getRuntimeComponents().get(0);
String facetRuntimeTypeID = runtimeComponent.getRuntimeComponentType().getId();
String facetRuntimeVersion = runtimeComponent.getRuntimeComponentVersion().getVersionString();
String facetID = fv.getProjectFacet().getId();
String facetVersion = fv.getVersionString();
presetID = RuntimePresetMappingRegistry.INSTANCE.getPresetID(facetRuntimeTypeID, facetRuntimeVersion, facetID, facetVersion);
}
}
if (presetID == null) {
final Set<IProjectFacetVersion> facets = getFacetConfiguration(fv);
this.fpjwc.setProjectFacets(facets);
} else {
// setting the facets prior to setting the preset is to let the dynamic presets adjust
final Set<IProjectFacetVersion> facets = getFacetConfiguration(fv);
this.fpjwc.setProjectFacets(facets);
this.fpjwc.setSelectedPreset(presetID);
}
}
}
use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime in project webtools.sourceediting by eclipse.
the class DataModelFacetCreationWizardPage method saveRuntimeSettings.
public static void saveRuntimeSettings(IDialogSettings settings, IDataModel model) {
if (settings != null) {
String[] mruRuntimeArray = settings.getArray(MRU_RUNTIME_STORE);
List mruRuntimes = new ArrayList();
if (mruRuntimeArray != null)
mruRuntimes.addAll(Arrays.asList(mruRuntimeArray));
IRuntime runtime = (IRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
String runtimeName = runtime == null ? NULL_RUNTIME : runtime.getName();
if (mruRuntimes.contains(runtimeName)) {
mruRuntimes.remove(runtimeName);
}
mruRuntimes.add(0, runtimeName);
while (mruRuntimes.size() > 5) {
mruRuntimes.remove(5);
}
mruRuntimeArray = new String[mruRuntimes.size()];
for (int i = 0; i < mruRuntimeArray.length; i++) {
mruRuntimeArray[i] = (String) mruRuntimes.get(i);
}
settings.put(MRU_RUNTIME_STORE, mruRuntimeArray);
}
}
Aggregations