diff options
author | kchan | 2005-10-26 20:31:06 +0000 |
---|---|---|
committer | kchan | 2005-10-26 20:31:06 +0000 |
commit | 8177bf63b39dcfbe019f33fceab0de228a8bf7ce (patch) | |
tree | b9865513419a9e7b0d41d12afa482cba5840fe0d /bundles/org.eclipse.jst.ws.consumption.ui/src | |
parent | 1c0a13dd1d5e8ae0cfb9991a945d39de3d1de2b3 (diff) | |
download | webtools.webservices-8177bf63b39dcfbe019f33fceab0de228a8bf7ce.tar.gz webtools.webservices-8177bf63b39dcfbe019f33fceab0de228a8bf7ce.tar.xz webtools.webservices-8177bf63b39dcfbe019f33fceab0de228a8bf7ce.zip |
[113874] Clean up EAR project defaulting and J2EE version selection
Diffstat (limited to 'bundles/org.eclipse.jst.ws.consumption.ui/src')
3 files changed, 193 insertions, 139 deletions
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/extension/PreClientDevelopCommand.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/extension/PreClientDevelopCommand.java index 81ca0daac..0c9faf734 100644 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/extension/PreClientDevelopCommand.java +++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/extension/PreClientDevelopCommand.java @@ -11,10 +11,14 @@ package org.eclipse.jst.ws.internal.consumption.ui.extension; +import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.jem.util.emf.workbench.ProjectUtilities; +import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; +import org.eclipse.jst.ws.internal.common.J2EEUtils; import org.eclipse.jst.ws.internal.consumption.command.common.CreateModuleCommand; import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils2; import org.eclipse.jst.ws.internal.data.TypeRuntimeServer; @@ -83,6 +87,7 @@ public class PreClientDevelopCommand extends AbstractDataModelOperation System.out.println("In Pre client develop command."); + j2eeLevel_ = getJ2EELevelFromExistingProject(); wsInfo.setJ2eeLevel(j2eeLevel_); wsInfo.setServerFactoryId(typeRuntimeServer_.getServerId()); wsInfo.setServerInstanceId(typeRuntimeServer_.getServerInstanceId()); @@ -126,6 +131,23 @@ public class PreClientDevelopCommand extends AbstractDataModelOperation return status; } + private String getJ2EELevelFromExistingProject() + { + IProject project = ProjectUtilities.getProject(project_); + if (project != null && project.exists()) + { + //If the project has the "jst.web", "jst.ejb", or "jst.appclient" facet, deduce a J2EE version. + int j2eeLevelInt = J2EEUtils.getJ2EEVersion(project); + if (j2eeLevelInt != -1) + { + return String.valueOf(j2eeLevelInt); + } + } + + //TODO Figure out the J2EE version from the facets to add to a project. + return String.valueOf(J2EEVersionConstants.J2EE_1_4_ID); //for now, just return something + } + private int convertModuleType(String type) { if (type.equals(IModuleConstants.JST_WEB_MODULE)) diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java index 8f4e687b9..dc0222a1e 100644 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java +++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java @@ -36,7 +36,9 @@ import org.eclipse.jst.ws.internal.consumption.ui.wsrt.RequiredFacetVersion; import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils; import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils2; import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeInfo; +import org.eclipse.jst.ws.internal.context.ProjectTopologyContext; import org.eclipse.jst.ws.internal.data.TypeRuntimeServer; +import org.eclipse.jst.ws.internal.plugin.WebServicePlugin; import org.eclipse.wst.command.internal.provisional.env.core.common.MessageUtils; import org.eclipse.wst.command.internal.provisional.env.core.common.StatusUtils; import org.eclipse.wst.command.internal.provisional.env.core.context.ResourceContext; @@ -134,6 +136,11 @@ public class ClientRuntimeSelectionWidgetDefaultingCommand extends AbstractDataM return clientEarProjectName_; } + public void setClientEarProjectName(String name) + { + clientEarProjectName_ = name; + } + public String getClientComponentType() { return clientComponentType_; @@ -190,8 +197,9 @@ public class ClientRuntimeSelectionWidgetDefaultingCommand extends AbstractDataM } // Set the EAR - clientEarProjectName_ = ""; // TODO fix this! - clientNeedEAR_ = false; + //clientEarProjectName_ = ""; // TODO fix this! + //clientNeedEAR_ = false; + // Set the server IStatus serverStatus = setClientDefaultServer(); @@ -201,6 +209,7 @@ public class ClientRuntimeSelectionWidgetDefaultingCommand extends AbstractDataM return serverStatus; } + setDefaultClientEarProject(); // Calculate default IWebServiceClient setDefaultsForExtension(env); @@ -216,6 +225,36 @@ public class ClientRuntimeSelectionWidgetDefaultingCommand extends AbstractDataM } } + private void setDefaultClientEarProject() + { + + //Determine if an ear selection is needed based on the server type. + boolean clientNeedEAR_ = true; + String serverId = clientIds_.getServerId(); + if (serverId != null) + { + //Use the server type + String serverTargetId = ServerUtils.getRuntimeTargetIdFromFactoryId(serverId); + if (serverTargetId!=null && serverTargetId.length()>0) + { + if (!ServerUtils.isTargetValidForEAR(serverTargetId,"13")) + { + //Default the EAR selection to be empty + clientNeedEAR_ = false; + } + } + } + + if (clientNeedEAR_) + { + clientEarProjectName_ = getDefaultClientEarProjectName(); + } + else + { + clientEarProjectName_ = ""; + } + } + private IStatus setClientDefaultServer() { //Choose an existing server the module is already associated with if possible @@ -914,56 +953,32 @@ public class ClientRuntimeSelectionWidgetDefaultingCommand extends AbstractDataM * */ - /* - protected String[] getDefaultEARFromClientProject(IProject project, String componentName) + + protected String getDefaultClientEarProjectName() { - String[] projectAndComp = new String[2]; - IVirtualComponent[] earComps = J2EEUtils.getReferencingEARComponents(project); + IProject clientProject = ProjectUtilities.getProject(clientProjectName_); + IVirtualComponent[] earComps = J2EEUtils.getReferencingEARComponents(clientProject); if (earComps.length>0) { //Pick the first one - IVirtualComponent earComp = earComps[0]; - projectAndComp[0] = earComp.getProject().getName(); - projectAndComp[1]= earComp.getName(); - return projectAndComp; - //getRuntime2ClientTypes().getChoice().getChoice().getChoice().getList().setSelectionValue(earProjectName); - //clientEarComponentName_ = earComponentName; + return earComps[0].getName(); } //Either project does not exist or component is not associated with any EARs, so pick the first EAR you see with the correct J2EE version. IVirtualComponent[] allEarComps = J2EEUtils.getAllEARComponents(); if (allEarComps.length>0) { - for (int i=0; i<allEarComps.length; i++) - { - if (clientJ2EEVersion_.equals(String.valueOf(J2EEUtils.getJ2EEVersion(allEarComps[i])))) - { - String earProjectName = allEarComps[i].getProject().getName(); - projectAndComp[0] = earProjectName; - projectAndComp[1] = allEarComps[i].getName(); - return projectAndComp; - //getRuntime2ClientTypes().getChoice().getChoice().getChoice().getList().setSelectionValue(earProjectName); - //clientEarComponentName_ = allEarComps[i].getName(); - - } - - } - projectAndComp[0] = ResourceUtils.getDefaultClientEARProjectName(); - projectAndComp[1] = ResourceUtils.getDefaultClientEARComponentName(); - return projectAndComp; - + //TODO Choose an existing EAR that can be added to the server and who's J2EE level in consistent with + //that of the selected project, if applicable. Picking the first one for now. + return allEarComps[0].getName(); } else { //there are no Ears. - projectAndComp[0] = ResourceUtils.getDefaultClientEARProjectName(); - projectAndComp[1] = ResourceUtils.getDefaultClientEARComponentName(); - return projectAndComp; - //getRuntime2ClientTypes().getChoice().getChoice().getChoice().getList().setSelectionValue(ResourceUtils.getDefaultClientEARProjectName()); - //clientEarComponentName_ = ResourceUtils.getDefaultClientEARComponentName(); + return ResourceUtils.getDefaultClientEARProjectName(); } } - */ + /* private IStatus setClientDefaultServer() diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils2.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils2.java index 28801ec71..d450b91c1 100644 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils2.java +++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils2.java @@ -1,18 +1,13 @@ package org.eclipse.jst.ws.internal.consumption.ui.wsrt; import java.util.ArrayList; -import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.Set; import java.util.Vector; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; import org.eclipse.jem.util.emf.workbench.ProjectUtilities; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jst.ws.internal.consumption.ui.common.FacetMatcher; @@ -25,18 +20,11 @@ import org.eclipse.wst.command.internal.provisional.env.core.selection.Selection import org.eclipse.wst.command.internal.provisional.env.core.selection.SelectionListChoices; import org.eclipse.wst.common.project.facet.core.IFacetedProject; import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action; -import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action.Type; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager; -import org.eclipse.wst.server.core.IRuntimeType; import org.eclipse.wst.server.core.IServer; import org.eclipse.wst.server.core.IServerType; import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.ServerUtil; import org.eclipse.wst.server.ui.ServerUICore; import org.eclipse.wst.ws.internal.provisional.wsrt.IWebServiceRuntime; import org.eclipse.wst.ws.internal.provisional.wsrt.WebServiceScenario; @@ -93,6 +81,33 @@ public class WebServiceRuntimeExtensionUtils2 IServer server = ServerCore.findServer( instanceId ); return server.getName(); } + + private static String[] getServerFactoryIdsByFacetRuntimes(Set facetRuntimes) + { + /* + ArrayList supportedServerFactoryIds = new ArrayList(); + String[] serverTypeIds = getAllServerFactoryIdsWithRuntimes(); + Iterator itr = facetRuntimes.iterator(); + while(itr.hasNext()) + { + IRuntime fRuntime = (IRuntime)itr.next(); + org.eclipse.wst.server.core.IRuntime sRuntime = FacetUtil.getRuntime(fRuntime); + for (int i=0; i<serverTypeIds.length; i++) + { + IServerType serverType = ServerCore.findServerType(serverTypeIds[i]); + String runtimeTypeId = serverType.getRuntimeType().getId(); + if (runtimeTypeId.equals(sRuntime.getRuntimeType().getId())) + { + supportedServerFactoryIds.add(serverTypeIds[i]); + } + } + } + + return (String[])supportedServerFactoryIds.toArray(new String[0]); + */ + //Temporarily return all factory ids with runtimes + return getAllServerFactoryIdsWithRuntimes(); + } //Service-side utilities public static WebServiceImpl getWebServiceImplById(String id) @@ -315,19 +330,22 @@ public class WebServiceRuntimeExtensionUtils2 { for (int i = 0; i < srts.length; i++) { - //Get the runtimes that work for the facets required for this service runtime - ServiceRuntimeDescriptor descriptor = getServiceRuntimeDescriptorById(srts[i]); - Set runtimes = getRuntimes(descriptor.getProjectFacetVersions()); - IServerType[] allServerTypes = ServerCore.getServerTypes(); - //TODO iterate over all the server types and see if their runtime types have an - //id that matches the runtime type of any of the runtimes. + //Get the runtimes that work for the facets required for this service runtime + String[] fIds = getServerFactoryIdsByServiceRuntime(srts[i]); + for (int j=0; j<fIds.length; j++) + { + if (!serverFactoryIds.contains(fIds[j])) + { + serverFactoryIds.add(fIds[j]); + } + } } } - //return (String[])serverFactoryIds.toArray(new String[]{}); + return (String[])serverFactoryIds.toArray(new String[]{}); //Temporarily return all server type ids. - return getAllServerFactoryIdsWithRuntimes(); + //return getAllServerFactoryIdsWithRuntimes(); } /* @@ -356,19 +374,16 @@ public class WebServiceRuntimeExtensionUtils2 } public static String[] getServerFactoryIdsByServiceRuntime(String serviceRuntimeId) - { - ArrayList serverFactoryIds = new ArrayList(); - + { ServiceRuntimeDescriptor desc = getServiceRuntimeDescriptorById(serviceRuntimeId); Set facetRuntimes = getRuntimes(desc.getProjectFacetVersions()); - - //TODO iterate over all the server types and see if their runtime types have an - //id that matches the runtime type of any of the runtimes. - //return (String[])serverFactoryIds.toArray(new String[]{}); //Temporarily return all server types - return getAllServerFactoryIdsWithRuntimes(); - } + //return getAllServerFactoryIdsWithRuntimes(); + return getServerFactoryIdsByFacetRuntimes(facetRuntimes); + } + + public static boolean doesServiceRuntimeSupportServer(String serviceRuntimeId, String serverFactoryId) @@ -472,16 +487,23 @@ public class WebServiceRuntimeExtensionUtils2 for (int i=0; i<serviceRuntimes.length; i++) { ServiceRuntimeDescriptor desc = getServiceRuntimeDescriptorById(serviceRuntimes[i]); - Set runtimes = getRuntimes(desc.getProjectFacetVersions()); - //TODO Iterate through the runtimes to see if there is a facet runtime that corresponds - //to a server runtime for this server type. - - //Temporarily return true - return true; - + if (desc.getRuntime().getId().equals(runtimeId)) + { + //Matches the type and the runtime. Check if it matches the server + Set runtimes = getRuntimes(desc.getProjectFacetVersions()); + String[] fIds = getServerFactoryIdsByFacetRuntimes(runtimes); + for (int j=0; j<fIds.length; j++) + { + if (fIds[j].equals(serverFactoryId)) + { + return true; + } + } + } } } + //didn't find a match. return false. return false; } @@ -508,18 +530,19 @@ public class WebServiceRuntimeExtensionUtils2 if (thisRuntimeId.equals(runtimeId)) { Set facetRuntimes = getRuntimes(desc.getProjectFacetVersions()); - //TODO Iterate over the facetRuntimes to see if any of them is a suitable server runtime for a - //server of the given type. If so, return true. - - //Temporarily return true - return true; + String[] fIds = getServerFactoryIdsByFacetRuntimes(facetRuntimes); + for (int j=0; j<fIds.length; j++) + { + if (fIds[j].equals(factoryId)) + { + return true; + } + } } } - //return false; - - //Always return true temporarily - return true; + //No service runtime matched. Return false. + return false; } /* @@ -538,22 +561,16 @@ public class WebServiceRuntimeExtensionUtils2 if (thisRuntimeId.equals(runtimeId)) { Set facetRuntimes = getRuntimes(desc.getProjectFacetVersions()); - IServerType[] allServerTypes = ServerCore.getServerTypes(); - //TODO iterate over all the server types and return the first server type that - //has a server runtime corresponding to a supported facet runtime. + String[] factoryIds = getServerFactoryIdsByFacetRuntimes(facetRuntimes); + if (factoryIds!=null && factoryIds.length >0) + { + return factoryIds[0]; + } } } - //Temporarliy return the first server type - String[] factoryIds = getAllServerFactoryIdsWithRuntimes(); - if (factoryIds!=null && factoryIds.length >0) - { - return factoryIds[0]; - } - else - { - return null; - } + //didn't get a single suitable server type id, return null. + return null; } public static String[] getProjectsForServiceTypeAndRuntime(String typeId, String runtimeId) @@ -858,18 +875,19 @@ public class WebServiceRuntimeExtensionUtils2 { for (int i = 0; i < crts.length; i++) { - //Get the runtimes that work for the facets required for this client runtime - ClientRuntimeDescriptor descriptor = getClientRuntimeDescriptorById(crts[i]); - Set runtimes = getRuntimes(descriptor.getProjectFacetVersions()); - IServerType[] allServerTypes = ServerCore.getServerTypes(); - //TODO iterate over all the server types and see if their runtime types have an - //id that matches the runtime type of any of the runtimes. - } + //Get the runtimes that work for the facets required for this service runtime + String[] fIds = getServerFactoryIdsByClientRuntime(crts[i]); + for (int j=0; j<fIds.length; j++) + { + if (!serverFactoryIds.contains(fIds[j])) + { + serverFactoryIds.add(fIds[j]); + } + } + } } - //return (String[])serverFactoryIds.toArray(new String[]{}); - //Temporarily return all server types - return getAllServerFactoryIdsWithRuntimes(); + return (String[])serverFactoryIds.toArray(new String[]{}); } /* @@ -899,18 +917,12 @@ public class WebServiceRuntimeExtensionUtils2 * */ public static String[] getServerFactoryIdsByClientRuntime(String clientRuntimeId) - { - ArrayList serverFactoryIds = new ArrayList(); - + { ClientRuntimeDescriptor desc = getClientRuntimeDescriptorById(clientRuntimeId); Set facetRuntimes = getRuntimes(desc.getProjectFacetVersions()); - - //TODO iterate over all the server types and see if their runtime types have an - //id that matches the runtime type of any of the runtimes. - - //return (String[])serverFactoryIds.toArray(new String[]{}); - //Temporarily return all server types - return getAllServerFactoryIdsWithRuntimes(); + + String[] fIds = getServerFactoryIdsByFacetRuntimes(facetRuntimes); + return fIds; } /* @@ -946,14 +958,18 @@ public class WebServiceRuntimeExtensionUtils2 if (thisRuntimeId.equals(runtimeId)) { Set facetRuntimes = getRuntimes(desc.getProjectFacetVersions()); - //TODO Iterate over the facetRuntimes to see if any of them is a suitable server runtime for a - //server of the given type. If so, return true. - - //Temporarliy return true - return true; + String[] fIds = getServerFactoryIdsByFacetRuntimes(facetRuntimes); + for (int i=0; i<fIds.length; i++) + { + if (fIds[i].equals(factoryId)) + { + return true; + } + } } } + //No match. return false; } @@ -973,22 +989,17 @@ public class WebServiceRuntimeExtensionUtils2 if (thisRuntimeId.equals(runtimeId)) { Set facetRuntimes = getRuntimes(desc.getProjectFacetVersions()); - IServerType[] allServerTypes = ServerCore.getServerTypes(); - //TODO iterate over all the server types and return the first server type that - //has a server runtime corresponding to a supported facet runtime. + String[] factoryIds = getServerFactoryIdsByFacetRuntimes(facetRuntimes); + if (factoryIds!=null && factoryIds.length >0) + { + return factoryIds[0]; + } } } - //Temporarliy return the first server type - String[] factoryIds = getAllServerFactoryIdsWithRuntimes(); - if (factoryIds!=null && factoryIds.length >0) - { - return factoryIds[0]; - } - else - { - return null; - } + //No suitable servers found. Return null. + return null; + } /* @@ -1006,16 +1017,22 @@ public class WebServiceRuntimeExtensionUtils2 for (int i=0; i<clientRuntimes.length; i++) { ClientRuntimeDescriptor desc = getClientRuntimeDescriptorById(clientRuntimes[i]); - Set runtimes = getRuntimes(desc.getProjectFacetVersions()); - //TODO Iterate through the runtimes to see if there is a facet runtime that corresponds - //to a server runtime for this server type. - - //Temporarily return true - return true; - + if (desc.getRuntime().getId().equals(runtimeId)) + { + //Matched type and runtime. Check the server. + String[] factoryIds = getServerFactoryIdsByClientRuntime(desc.getId()); + for (int j=0; j<factoryIds.length; j++) + { + if (factoryIds[j].equals(serverFactoryId)) + { + return true; + } + } + } } } + //No match found. return false. return false; } |