use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion 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.IProjectFacetVersion in project webtools.sourceediting by eclipse.
the class DataModelFacetCreationWizardPage method createPrimaryFacetComposite.
protected void createPrimaryFacetComposite(Composite top) {
primaryProjectFacet = ProjectFacetsManager.getProjectFacet(getModuleTypeID());
if (primaryProjectFacet.getVersions().size() <= 1) {
// facet version to choose from (e.g. utility and static web)
return;
}
final Group group = new Group(top, SWT.NONE);
group.setLayoutData(gdhfill());
group.setLayout(new GridLayout(1, false));
group.setText(getPrimaryFacetCompositeLabel());
primaryVersionCombo = new Combo(group, SWT.BORDER | SWT.READ_ONLY);
primaryVersionCombo.setLayoutData(gdhfill());
updatePrimaryVersions();
primaryVersionCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
handlePrimaryFacetVersionSelectedEvent();
}
});
IFacetedProjectListener fpjwcListenerForPrimaryFacetCombo = new IFacetedProjectListener() {
@Override
public void handleEvent(IFacetedProjectEvent event) {
if (event.getType() == IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED) {
// this block is to update the combo when the underlying facet version changes
IProjectFacetsChangedEvent actionEvent = (IProjectFacetsChangedEvent) event;
Set<IProjectFacetVersion> changedVersions = actionEvent.getFacetsWithChangedVersions();
boolean foundComboVersion = false;
for (Iterator<IProjectFacetVersion> iterator = changedVersions.iterator(); iterator.hasNext() && !foundComboVersion; ) {
IProjectFacetVersion next = iterator.next();
if (next.getProjectFacet().equals(primaryProjectFacet)) {
foundComboVersion = true;
final IProjectFacetVersion selectedVersion = next;
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
String selectedText = primaryVersionCombo.getItem(primaryVersionCombo.getSelectionIndex());
if (!selectedText.equals(selectedVersion.getVersionString())) {
String[] items = primaryVersionCombo.getItems();
int selectedVersionIndex = -1;
for (int i = 0; i < items.length && selectedVersionIndex == -1; i++) {
if (items[i].equals(selectedVersion.getVersionString())) {
selectedVersionIndex = i;
primaryVersionCombo.select(selectedVersionIndex);
}
}
}
}
});
}
}
} else if (event.getType() == IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED) {
// this block updates the items in the combo when the runtime changes
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
updatePrimaryVersions();
}
});
}
}
};
this.facetedProjectListeners.add(fpjwcListenerForPrimaryFacetCombo);
fpjwc.addListener(fpjwcListenerForPrimaryFacetCombo, IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED, IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED);
}
use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion in project webtools.sourceediting by eclipse.
the class DataModelFacetCreationWizardPage method updatePrimaryVersions.
protected void updatePrimaryVersions() {
IProjectFacetVersion selectedVersion = fpjwc.getProjectFacetVersion(primaryProjectFacet);
SortedSet<IProjectFacetVersion> initialVersions = fpjwc.getAvailableVersions(primaryProjectFacet);
String[] items = new String[initialVersions.size()];
int i = 0;
int selectedVersionIndex = -1;
for (Iterator<IProjectFacetVersion> iterator = initialVersions.iterator(); iterator.hasNext(); i++) {
items[i] = iterator.next().getVersionString();
if (selectedVersionIndex == -1 && items[i].equals(selectedVersion.getVersionString())) {
selectedVersionIndex = i;
}
}
primaryVersionCombo.clearSelection();
primaryVersionCombo.setItems(items);
primaryVersionCombo.select(selectedVersionIndex);
}
use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion in project liferay-ide by liferay.
the class SDKPluginFacetUtil method configureProjectAsSDKProject.
public static void configureProjectAsSDKProject(IFacetedProjectWorkingCopy fpjwc, String pluginType, String sdkLocation, ProjectRecord projectRecord) throws CoreException {
IFacetedProjectTemplate template = getLiferayTemplateForProject(pluginType);
IPreset preset = getLiferayPresetForProject(pluginType);
if (preset == null) {
throw new CoreException(ProjectCore.createErrorStatus(NLS.bind(Msgs.noFacetPreset, fpjwc.getProjectName())));
}
IRuntime primaryRuntime = fpjwc.getPrimaryRuntime();
if (primaryRuntime != null) {
fpjwc.removeTargetedRuntime(primaryRuntime);
}
Set<IProjectFacetVersion> currentProjectFacetVersions = fpjwc.getProjectFacets();
Set<IProjectFacet> requiredFacets = template.getFixedProjectFacets();
for (IProjectFacet requiredFacet : requiredFacets) {
boolean hasRequiredFacet = false;
for (IProjectFacetVersion currentFacetVersion : currentProjectFacetVersions) {
if (currentFacetVersion.getProjectFacet().equals(requiredFacet)) {
// TODO how to check the bundle support status?
boolean requiredVersion = _isRequiredVersion(currentFacetVersion);
if (requiredVersion) {
hasRequiredFacet = true;
} else {
fpjwc.removeProjectFacet(currentFacetVersion);
}
break;
}
}
if (!hasRequiredFacet) {
IProjectFacetVersion requiredFacetVersion = _getRequiredFacetVersionFromPreset(requiredFacet, preset);
if (requiredFacetVersion != null) {
fpjwc.addProjectFacet(requiredFacetVersion);
if (ProjectUtil.isJavaFacet(requiredFacetVersion)) {
configureJavaFacet(fpjwc, requiredFacetVersion.getProjectFacet(), preset, projectRecord);
} else if (ProjectUtil.isDynamicWebFacet(requiredFacetVersion)) {
configureWebFacet(fpjwc, requiredFacetVersion.getProjectFacet(), preset);
}
}
} else {
if (ProjectUtil.isJavaFacet(requiredFacet)) {
configureJavaFacet(fpjwc, requiredFacet, preset, projectRecord);
} else if (ProjectUtil.isDynamicWebFacet(requiredFacet)) {
configureWebFacet(fpjwc, requiredFacet, preset);
}
}
}
}
use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion in project liferay-ide by liferay.
the class ValidProjectChecker method checkValidProjectTypes.
public void checkValidProjectTypes() {
IProject[] projects = CoreUtil.getAllProjects();
boolean hasValidProjectTypes = false;
boolean hasJsfFacet = false;
for (IProject project : projects) {
if (ProjectUtil.isLiferayFacetedProject(project)) {
Set<IProjectFacetVersion> facets = ProjectUtil.getFacetedProject(project).getProjectFacets();
if ((validProjectTypes != null) && (facets != null)) {
String[] validTypes = validProjectTypes.split(StringPool.COMMA);
for (String validProjectType : validTypes) {
for (IProjectFacetVersion facet : facets) {
String id = facet.getProjectFacet().getId();
if (jsfPortlet && id.equals("jst.jsf")) {
hasJsfFacet = true;
}
if (id.startsWith("liferay.") && id.equals("liferay." + validProjectType)) {
hasValidProjectTypes = true;
}
}
}
}
}
}
if (jsfPortlet) {
hasValidProjectTypes = hasJsfFacet && hasValidProjectTypes;
}
if (!hasValidProjectTypes) {
final Shell activeShell = Display.getDefault().getActiveShell();
Boolean openNewLiferayProjectWizard = MessageDialog.openQuestion(activeShell, NLS.bind(Msgs.newElement, wizardName), NLS.bind(Msgs.noSuitableLiferayProjects, wizardName));
if (openNewLiferayProjectWizard) {
final Action defaultAction = NewPluginProjectDropDownAction.getPluginProjectAction();
if (defaultAction != null) {
defaultAction.run();
checkValidProjectTypes();
}
}
}
}
Aggregations