diff options
author | kchan | 2006-04-01 05:07:54 +0000 |
---|---|---|
committer | kchan | 2006-04-01 05:07:54 +0000 |
commit | e858a37075ae8f9cb154108a25670d99f3ef6350 (patch) | |
tree | 1a1adc67dc26d946453d4f158b050dc73759b9be | |
parent | 7ff536e1e224e4dc51c0097abfdf8cb0bceebd3a (diff) | |
download | webtools.webservices-e858a37075ae8f9cb154108a25670d99f3ef6350.tar.gz webtools.webservices-e858a37075ae8f9cb154108a25670d99f3ef6350.tar.xz webtools.webservices-e858a37075ae8f9cb154108a25670d99f3ef6350.zip |
[128827] Skeleton Merge.
19 files changed, 466 insertions, 32 deletions
diff --git a/bundles/org.eclipse.jst.ws.axis.creation.ui/src/org/eclipse/jst/ws/internal/axis/creation/ui/command/TDAxisInputCommand.java b/bundles/org.eclipse.jst.ws.axis.creation.ui/src/org/eclipse/jst/ws/internal/axis/creation/ui/command/TDAxisInputCommand.java index 183223875..45c8f59a9 100644 --- a/bundles/org.eclipse.jst.ws.axis.creation.ui/src/org/eclipse/jst/ws/internal/axis/creation/ui/command/TDAxisInputCommand.java +++ b/bundles/org.eclipse.jst.ws.axis.creation.ui/src/org/eclipse/jst/ws/internal/axis/creation/ui/command/TDAxisInputCommand.java @@ -1,12 +1,15 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation + * yyyymmdd bug Email and other contact information + * -------- -------- ----------------------------------------------------------- + * 20060330 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.jst.ws.internal.axis.creation.ui.command; @@ -17,6 +20,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; import org.eclipse.wst.ws.internal.wsrt.IWebService; +import org.eclipse.wst.ws.internal.wsrt.WebServiceInfo; public class TDAxisInputCommand extends AbstractDataModelOperation { @@ -27,6 +31,7 @@ public class TDAxisInputCommand extends AbstractDataModelOperation { private String serverServer_; private String serviceServerTypeID_; private String wsdlURI_; + private WebServiceInfo webServiceInfo_; /** * Default CTOR @@ -44,6 +49,7 @@ public class TDAxisInputCommand extends AbstractDataModelOperation { serverServer_ = ws_.getWebServiceInfo().getServerInstanceId(); serviceServerTypeID_ = ws_.getWebServiceInfo().getServerFactoryId(); wsdlURI_ = ws_.getWebServiceInfo().getWsdlURL(); + webServiceInfo_ = ws_.getWebServiceInfo(); return Status.OK_STATUS; } @@ -70,4 +76,8 @@ public class TDAxisInputCommand extends AbstractDataModelOperation { return wsdlURI_; } + public WebServiceInfo getWebServiceInfo() { + return webServiceInfo_; + } + } diff --git a/bundles/org.eclipse.jst.ws.axis.creation.ui/src/org/eclipse/jst/ws/internal/axis/creation/ui/task/BackupSkelImplCommand.java b/bundles/org.eclipse.jst.ws.axis.creation.ui/src/org/eclipse/jst/ws/internal/axis/creation/ui/task/BackupSkelImplCommand.java index 29afb32d2..96a35da87 100644 --- a/bundles/org.eclipse.jst.ws.axis.creation.ui/src/org/eclipse/jst/ws/internal/axis/creation/ui/task/BackupSkelImplCommand.java +++ b/bundles/org.eclipse.jst.ws.axis.creation.ui/src/org/eclipse/jst/ws/internal/axis/creation/ui/task/BackupSkelImplCommand.java @@ -6,7 +6,10 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation + * yyyymmdd bug Email and other contact information + * -------- -------- ----------------------------------------------------------- + * 20060330 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.jst.ws.internal.axis.creation.ui.task; @@ -15,6 +18,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; import javax.wsdl.Binding; import javax.wsdl.Definition; @@ -41,6 +45,7 @@ import org.eclipse.wst.common.environment.IEnvironment; import org.eclipse.wst.common.environment.IStatusHandler; import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser; +import org.eclipse.wst.ws.internal.wsrt.WebServiceInfo; public class BackupSkelImplCommand extends AbstractDataModelOperation { @@ -49,7 +54,9 @@ public class BackupSkelImplCommand extends AbstractDataModelOperation private final String BAK_EXT = "bak"; //$NON-NLS-1$ private final String JAVA = "java"; //$NON-NLS-1$ private WebServicesParser webServicesParser; - private JavaWSDLParameter javaWSDLParam; + private JavaWSDLParameter javaWSDLParam; + + private WebServiceInfo webServiceInfo; public BackupSkelImplCommand( ) { } @@ -83,6 +90,7 @@ public class BackupSkelImplCommand extends AbstractDataModelOperation // Compute the qualified name of the Java bean skeleton Service service = null; Port port = null; + ArrayList implURLList = new ArrayList(); if (definition != null) { StringBuffer beanName = new StringBuffer(); String beanPackageName = WSDLUtils.getPackageName(definition); @@ -108,7 +116,18 @@ public class BackupSkelImplCommand extends AbstractDataModelOperation String beanNamePathString = beanNameString.replace('.',IPath.SEPARATOR); IPath skelImplPath = new Path (javaWSDLParam.getJavaOutput()).append(new Path (beanNamePathString)).addFileExtension(JAVA); - if (skelImplPath.toFile().exists()) { + + // store the name of the implURL + String implURLString; + try { + implURLString = skelImplPath.toFile().toURL().toString(); + } catch (MalformedURLException e1) { + implURLString = PlatformUtils.getFileURLFromPath(skelImplPath); + } + implURLList.add( implURLString ); + + if (skelImplPath.toFile().exists()) { + IPath targetPath = skelImplPath.addFileExtension(BAK_EXT); try { finStream = new FileInputStream(skelImplPath.toString()); @@ -129,6 +148,11 @@ public class BackupSkelImplCommand extends AbstractDataModelOperation } } } + + if (context.isSkeletonMergeEnabled()) { + String[] implURLArray = new String[implURLList.size()]; + webServiceInfo.setImplURLs( (String[]) (implURLList.toArray(implURLArray))); + } } else { status = StatusUtils.errorStatus( NLS.bind(AxisConsumptionUIMessages.MSG_ERROR_WSDL_NO_DEFINITION, new String[] {wsdlURL})); @@ -153,6 +177,11 @@ public class BackupSkelImplCommand extends AbstractDataModelOperation public void setWebServicesParser(WebServicesParser webServicesParser) { this.webServicesParser = webServicesParser; } + + +public void setWebServiceInfo(WebServiceInfo webServiceInfo) { + this.webServiceInfo = webServiceInfo; +} } diff --git a/bundles/org.eclipse.jst.ws.axis.creation.ui/src/org/eclipse/jst/ws/internal/axis/creation/ui/wsrt/AxisWebService.java b/bundles/org.eclipse.jst.ws.axis.creation.ui/src/org/eclipse/jst/ws/internal/axis/creation/ui/wsrt/AxisWebService.java index d938c11ff..cafbeecb7 100644 --- a/bundles/org.eclipse.jst.ws.axis.creation.ui/src/org/eclipse/jst/ws/internal/axis/creation/ui/wsrt/AxisWebService.java +++ b/bundles/org.eclipse.jst.ws.axis.creation.ui/src/org/eclipse/jst/ws/internal/axis/creation/ui/wsrt/AxisWebService.java @@ -10,6 +10,7 @@ * yyyymmdd bug Email and other contact information * -------- -------- ----------------------------------------------------------- * 20060330 124667 kathy@ca.ibm.com - Kathy Chan + * 20060330 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.jst.ws.internal.axis.creation.ui.wsrt; @@ -309,6 +310,7 @@ public class AxisWebService extends AbstractWebService // BackupSkelImplCommand dataRegistry.addMapping(AxisSkeletonDefaultingCommand.class, "WebServicesParser", BackupSkelImplCommand.class); dataRegistry.addMapping(AxisSkeletonDefaultingCommand.class, "JavaWSDLParam", BackupSkelImplCommand.class); + dataRegistry.addMapping(TDAxisInputCommand.class, "WebServiceInfo", BackupSkelImplCommand.class); // Skeleton2WSDLCommand dataRegistry.addMapping(AxisSkeletonDefaultingCommand.class, "WebServicesParser", Skeleton2WSDLCommand.class); diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/Consumption.properties b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/Consumption.properties index ee0959e7c..36754615e 100644 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/Consumption.properties +++ b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/Consumption.properties @@ -10,6 +10,7 @@ # yyyymmdd bug Email and other contact information # -------- -------- ----------------------------------------------------------- # 20060217 126757 rsinha@ca.ibm.com - Rupam Kuehner +# 20060401 128827 kathy@ca.ibm.com - Kathy Chan ############################################################################### # @@ -185,3 +186,8 @@ MSG_ERROR_FIXED_FACETS=Unable to set the following facets as fixed on project {0 MSG_FACETS={0}, {1} MSG_ERROR_SETTING_RUNTIME=Unable to bind project {0} to the {1} runtime. + +# +# SkeletonMergeCommand Messages +# +MSG_ERROR_FILE_MERGE=Error in merging file {0}. diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/ConsumptionMessages.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/ConsumptionMessages.java index d06f48de2..aad43c21f 100644 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/ConsumptionMessages.java +++ b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/ConsumptionMessages.java @@ -10,6 +10,7 @@ * yyyymmdd bug Email and other contact information * -------- -------- ----------------------------------------------------------- * 20060217 126757 rsinha@ca.ibm.com - Rupam Kuehner + * 20060401 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.jst.ws.internal.consumption; @@ -108,6 +109,7 @@ public final class ConsumptionMessages extends NLS { public static String MSG_ERROR_FIXED_FACETS; public static String MSG_FACETS; public static String MSG_ERROR_SETTING_RUNTIME; + public static String MSG_ERROR_FILE_MERGE; static { diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/command/common/SkeletonMergeCommand.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/command/common/SkeletonMergeCommand.java new file mode 100644 index 000000000..a56482b5c --- /dev/null +++ b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/command/common/SkeletonMergeCommand.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * yyyymmdd bug Email and other contact information + * -------- -------- ----------------------------------------------------------- + * 20060330 128827 kathy@ca.ibm.com - Kathy Chan + *******************************************************************************/ +package org.eclipse.jst.ws.internal.consumption.command.common; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages; +import org.eclipse.jst.ws.internal.plugin.WebServicePlugin; +import org.eclipse.osgi.util.NLS; +import org.eclipse.wst.command.internal.env.common.FileResourceUtils; +import org.eclipse.wst.command.internal.env.core.common.StatusUtils; +import org.eclipse.wst.command.internal.env.core.context.ResourceContext; +import org.eclipse.wst.common.environment.IEnvironment; +import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; +import org.eclipse.wst.ws.internal.common.MergeUtils; + +public class SkeletonMergeCommand extends AbstractDataModelOperation +{ + private String[] urls_; + + public SkeletonMergeCommand() + { + } + + public void setUrls(String[] urls) + { + this.urls_ = urls; + } + + // Merge the content of the skeleton files (represented by urls_ with the previous version stored. + // The Web service extensions triggers the storing of the content of the old skeleton file by + // calling WebServiceInfo.setImplURLs() before the new skeleton is generated in the extension's + // develop() method. + + public IStatus execute(IProgressMonitor monitor, IAdaptable info) + { + + IStatus status = Status.OK_STATUS; + IEnvironment environment = getEnvironment(); + ResourceContext context = WebServicePlugin.getInstance().getResourceContext(); + if (context.isSkeletonMergeEnabled()) { + // merge the skeleton implementation file with the model stored earlier + + String mergedContent; + String filename; + InputStream inStream = null; + if (urls_ != null) { + for (int i = 0; i < urls_.length; i++) { + filename = MergeUtils.getFileFromURL(urls_[i]); + if (filename != null) { + mergedContent = MergeUtils.mergeFile(filename); + if (mergedContent != null) { + // write the merged content back into the file, respecting file overwrite preference + IPath targetPath = new Path(filename); + inStream = new ByteArrayInputStream(mergedContent.getBytes()); + + if (inStream != null) { + try { + FileResourceUtils.createFileAtLocation(context, targetPath.makeAbsolute(), inStream, + monitor, environment.getStatusHandler()); + } catch (CoreException e) { + e.printStackTrace();status = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_FILE_MERGE, urls_), e); + environment.getStatusHandler().reportError( status ); + } + } + } + } + } + } + } + + return status; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.ws.creation.ui/src/org/eclipse/jst/ws/internal/creation/ui/extension/PreServiceAssembleCommand.java b/bundles/org.eclipse.jst.ws.creation.ui/src/org/eclipse/jst/ws/internal/creation/ui/extension/PreServiceAssembleCommand.java index bb42e9cf9..90c375f00 100644 --- a/bundles/org.eclipse.jst.ws.creation.ui/src/org/eclipse/jst/ws/internal/creation/ui/extension/PreServiceAssembleCommand.java +++ b/bundles/org.eclipse.jst.ws.creation.ui/src/org/eclipse/jst/ws/internal/creation/ui/extension/PreServiceAssembleCommand.java @@ -1,15 +1,16 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation * yyyymmdd bug Email and other contact information * -------- -------- ----------------------------------------------------------- * 20060131 121071 rsinha@ca.ibm.com - Rupam Kuehner + * 20060330 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.jst.ws.internal.creation.ui.extension; @@ -21,10 +22,13 @@ import org.eclipse.core.runtime.Status; import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants; import org.eclipse.jst.ws.internal.consumption.command.common.AssociateModuleWithEARCommand; import org.eclipse.jst.ws.internal.consumption.command.common.CreateFacetedProjectCommand; +import org.eclipse.jst.ws.internal.consumption.command.common.SkeletonMergeCommand; import org.eclipse.jst.ws.internal.consumption.common.RequiredFacetVersion; import org.eclipse.wst.common.environment.IEnvironment; import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; +import org.eclipse.wst.ws.internal.wsrt.IContext; import org.eclipse.wst.ws.internal.wsrt.IWebService; +import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario; public class PreServiceAssembleCommand extends AbstractDataModelOperation { @@ -33,11 +37,29 @@ public class PreServiceAssembleCommand extends AbstractDataModelOperation private String module_; private String earProject_; private String ear_; + private IContext context_; public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable ) { - IEnvironment environment = getEnvironment(); - + IEnvironment environment = getEnvironment(); + IStatus status; + + // For top down scenarios, merge the content of the skeleton files with the previous version stored. + // The Web service extensions triggers the storing of the content of the old skeleton file by + // calling WebServiceInfo.setImplURLs() before the new skeleton is generated in the extension's + // develop() method. + + if (context_.getScenario().getValue() == WebServiceScenario.TOPDOWN) { + SkeletonMergeCommand skeletonMergeCommand = new SkeletonMergeCommand(); + skeletonMergeCommand.setUrls(webService_.getWebServiceInfo().getImplURLs()); + skeletonMergeCommand.setEnvironment(environment); + status = skeletonMergeCommand.execute( monitor, adaptable ); + if (status.getSeverity() == Status.ERROR) { + environment.getStatusHandler().reportError(status); + return status; + } + } + // Check if EAR module is req'd, ie. !=null if (earProject_==null) return Status.OK_STATUS; @@ -56,7 +78,7 @@ public class PreServiceAssembleCommand extends AbstractDataModelOperation command.setServerFactoryId(webService_.getWebServiceInfo().getServerFactoryId()); command.setServerInstanceId(webService_.getWebServiceInfo().getServerInstanceId()); - IStatus status = command.execute( monitor, adaptable ); + status = command.execute( monitor, adaptable ); if (status.getSeverity() == Status.ERROR) { environment.getStatusHandler().reportError( status ); @@ -103,4 +125,8 @@ public class PreServiceAssembleCommand extends AbstractDataModelOperation { webService_ = webService; } + + public void setContext (IContext context) { + context_ = context; + } } diff --git a/bundles/org.eclipse.jst.ws.creation.ui/src/org/eclipse/jst/ws/internal/creation/ui/extension/ServiceRootFragment.java b/bundles/org.eclipse.jst.ws.creation.ui/src/org/eclipse/jst/ws/internal/creation/ui/extension/ServiceRootFragment.java index b3d9c2cc1..2ab439ac4 100644 --- a/bundles/org.eclipse.jst.ws.creation.ui/src/org/eclipse/jst/ws/internal/creation/ui/extension/ServiceRootFragment.java +++ b/bundles/org.eclipse.jst.ws.creation.ui/src/org/eclipse/jst/ws/internal/creation/ui/extension/ServiceRootFragment.java @@ -11,6 +11,7 @@ * -------- -------- ----------------------------------------------------------- * 20060131 121071 rsinha@ca.ibm.com - Rupam Kuehner * 20060221 119111 rsinha@ca.ibm.com - Rupam Kuehner + * 20060331 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.jst.ws.internal.creation.ui.extension; @@ -101,6 +102,7 @@ public class ServiceRootFragment extends SequenceFragment registry.addMapping( PreServiceDevelopCommand.class, "Module", PreServiceAssembleCommand.class ); registry.addMapping( PreServiceDevelopCommand.class, "EarProject", PreServiceAssembleCommand.class ); registry.addMapping( PreServiceDevelopCommand.class, "Ear", PreServiceAssembleCommand.class ); + registry.addMapping( PreServiceDevelopCommand.class, "Context", PreServiceAssembleCommand.class ); registry.addMapping( PreServiceDevelopCommand.class, "Context", PreServiceDeployCommand.class ); diff --git a/bundles/org.eclipse.jst.ws.ui/src/org/eclipse/jst/ws/internal/ui/WSUIPlugin.properties b/bundles/org.eclipse.jst.ws.ui/src/org/eclipse/jst/ws/internal/ui/WSUIPlugin.properties index dfeb53e73..5e486121d 100644 --- a/bundles/org.eclipse.jst.ws.ui/src/org/eclipse/jst/ws/internal/ui/WSUIPlugin.properties +++ b/bundles/org.eclipse.jst.ws.ui/src/org/eclipse/jst/ws/internal/ui/WSUIPlugin.properties @@ -12,6 +12,7 @@ # 20060227 124392 rsinha@ca.ibm.com - Rupam Kuehner # 20060329 128827 kathy@ca.ibm.com - Kathy Chan # 20060329 124667 kathy@ca.ibm.com - Kathy Chan +# 20060331 128827 kathy@ca.ibm.com - Kathy Chan ############################################################################### # @@ -60,7 +61,7 @@ TOOLTIP_PPRM_PAGE=Set preferences that control resources used/generated by the W TOOLTIP_PPRM_CHECKBOX_OVERWRITE_FILES=Overwrite files without warning. TOOLTIP_PPRM_CHECKBOX_CREATE_FOLDERS=Create folders when necessary. TOOLTIP_PPRM_CHECKBOX_CHECK_OUT=Check out files without warning. -TOOLTIP_PPRM_SKELETON_MERGE=Enable merging of generated skeleton file. +TOOLTIP_PPRM_CHECKBOX_SKELETON_MERGE=Enable merging of generated skeleton file. BUTTON_CREATE_FOLDERS=&Create folders when necessary BUTTON_OVERWRITE_FILES=&Overwrite files without warning BUTTON_CHECKOUT_FILES=C&heck out files without warning diff --git a/bundles/org.eclipse.jst.ws.ui/src/org/eclipse/jst/ws/internal/ui/WSUIPluginMessages.java b/bundles/org.eclipse.jst.ws.ui/src/org/eclipse/jst/ws/internal/ui/WSUIPluginMessages.java index 2b178e422..b24cb2a0e 100644 --- a/bundles/org.eclipse.jst.ws.ui/src/org/eclipse/jst/ws/internal/ui/WSUIPluginMessages.java +++ b/bundles/org.eclipse.jst.ws.ui/src/org/eclipse/jst/ws/internal/ui/WSUIPluginMessages.java @@ -12,6 +12,7 @@ * 20060227 124392 rsinha@ca.ibm.com - Rupam Kuehner * 20060329 128827 kathy@ca.ibm.com - Kathy Chan * 20060329 124667 kathy@ca.ibm.com - Kathy Chan + * 20060331 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.jst.ws.internal.ui; @@ -47,7 +48,7 @@ public final class WSUIPluginMessages extends NLS { public static String TOOLTIP_PPRM_CHECKBOX_OVERWRITE_FILES; public static String TOOLTIP_PPRM_CHECKBOX_CREATE_FOLDERS; public static String TOOLTIP_PPRM_CHECKBOX_CHECK_OUT; - public static String TOOLTIP_PPRM_SKELETON_MERGE; + public static String TOOLTIP_PPRM_CHECKBOX_SKELETON_MERGE; public static String BUTTON_CREATE_FOLDERS; public static String BUTTON_OVERWRITE_FILES; public static String BUTTON_CHECKOUT_FILES; diff --git a/bundles/org.eclipse.jst.ws.ui/src/org/eclipse/jst/ws/internal/ui/preferences/ResourceManagmentPreferencePage.java b/bundles/org.eclipse.jst.ws.ui/src/org/eclipse/jst/ws/internal/ui/preferences/ResourceManagmentPreferencePage.java index 7c1f7c611..f8c6ac9d2 100644 --- a/bundles/org.eclipse.jst.ws.ui/src/org/eclipse/jst/ws/internal/ui/preferences/ResourceManagmentPreferencePage.java +++ b/bundles/org.eclipse.jst.ws.ui/src/org/eclipse/jst/ws/internal/ui/preferences/ResourceManagmentPreferencePage.java @@ -1,12 +1,15 @@ /******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. + * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation + * yyyymmdd bug Email and other contact information + * -------- -------- ----------------------------------------------------------- + * 20060331 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.jst.ws.internal.ui.preferences; @@ -44,6 +47,10 @@ public class ResourceManagmentPreferencePage extends PreferencePage implements I private Button checkoutFiles; /*CONTEXT_ID PPRM0004 for the checkout files check box on the Resource Management Preference Page*/ private String INFOPOP_PPRM_CHECKBOX_CHECK_OUT = WebServiceUIPlugin.ID + ".PPRM0004"; + + private Button skeletonMerge; + /*CONTEXT_ID PPRM0004 for the skeleton merge check box on the Resource Management Preference Page*/ + private String INFOPOP_PPRM_CHECKBOX_SKELETON_MERGE = WebServiceUIPlugin.ID + ".PPRM0005"; /** * Creates preference page controls on demand. @@ -71,6 +78,10 @@ public class ResourceManagmentPreferencePage extends PreferencePage implements I checkoutFiles = createCheckBox(parent, WSUIPluginMessages.BUTTON_CHECKOUT_FILES); checkoutFiles.setToolTipText(WSUIPluginMessages.TOOLTIP_PPRM_CHECKBOX_CHECK_OUT); helpSystem.setHelp(checkoutFiles, INFOPOP_PPRM_CHECKBOX_CHECK_OUT); + + skeletonMerge = createCheckBox(parent, WSUIPluginMessages.BUTTON_SKELETON_MERGE); + skeletonMerge.setToolTipText(WSUIPluginMessages.TOOLTIP_PPRM_CHECKBOX_SKELETON_MERGE); + helpSystem.setHelp(skeletonMerge, INFOPOP_PPRM_CHECKBOX_SKELETON_MERGE); initializeValues(); org.eclipse.jface.dialogs.Dialog.applyDialogFont(superparent); @@ -123,6 +134,7 @@ public class ResourceManagmentPreferencePage extends PreferencePage implements I overWriteFiles.setSelection( ResourceDefaults.getOverwriteFilesDefault()); createFolders.setSelection( ResourceDefaults.getCreateFoldersDefault()); checkoutFiles.setSelection( ResourceDefaults.getCheckoutFilesDefault()); + skeletonMerge.setSelection( ResourceDefaults.getSkeletonMergeDefault()); } /** @@ -134,7 +146,8 @@ public class ResourceManagmentPreferencePage extends PreferencePage implements I ResourceContext context = WebServicePlugin.getInstance().getResourceContext(); overWriteFiles.setSelection( context.isOverwriteFilesEnabled()); createFolders.setSelection( context.isCreateFoldersEnabled()); - checkoutFiles.setSelection( context.isCheckoutFilesEnabled()); + checkoutFiles.setSelection( context.isCheckoutFilesEnabled()); + skeletonMerge.setSelection( context.isSkeletonMergeEnabled()); } /** @@ -146,7 +159,8 @@ public class ResourceManagmentPreferencePage extends PreferencePage implements I ResourceContext context = WebServicePlugin.getInstance().getResourceContext(); context.setOverwriteFilesEnabled( overWriteFiles.getSelection() ); context.setCreateFoldersEnabled( createFolders.getSelection() ); - context.setCheckoutFilesEnabled( checkoutFiles.getSelection() ); + context.setCheckoutFilesEnabled( checkoutFiles.getSelection() ); + context.setSkeletonMergeEnabled( skeletonMerge.getSelection() ); } } diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/context/ResourceContext.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/context/ResourceContext.java index b36ecc2ca..1a573b566 100644 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/context/ResourceContext.java +++ b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/context/ResourceContext.java @@ -1,12 +1,15 @@ /******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. + * Copyright (c) 2001, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation + * yyyymmdd bug Email and other contact information + * -------- -------- ----------------------------------------------------------- + * 20060331 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.wst.command.internal.env.core.context; @@ -29,6 +32,12 @@ public interface ResourceContext * the plugins local preferences store. **/ public static final String PREFERENCE_CHECKOUT = "filesCheckout"; + + /** + * This constant string is used to lookup the enable skeleton merge general preference from + * the plugins local preferences store. +**/ +public static final String PREFERENCE_SKELETON_MERGE = "skeletonMerge"; /** * @@ -65,6 +74,19 @@ public interface ResourceContext * @return returns whether automatic checkout of files is enabled. */ public boolean isCheckoutFilesEnabled(); + + /** + * + * @param enable sets whether automatic checkout of files is enabled. + */ + + public void setSkeletonMergeEnabled( boolean enable); + + /** + * + * @return returns whether skeleton merge is enabled. + */ + public boolean isSkeletonMergeEnabled(); /** * diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/context/ResourceDefaults.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/context/ResourceDefaults.java index dad802626..22b6c8fbc 100644 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/context/ResourceDefaults.java +++ b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/context/ResourceDefaults.java @@ -1,12 +1,15 @@ /******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. + * Copyright (c) 2001, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation + * yyyymmdd bug Email and other contact information + * -------- -------- ----------------------------------------------------------- + * 20060331 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.wst.command.internal.env.core.context; @@ -15,6 +18,7 @@ public class ResourceDefaults private static final boolean PREFERENCE_OVERWRITE_DEFAULT = false; private static final boolean PREFERENCE_CREATE_FOLDERS_DEFAULT = true; private static final boolean PREFERENCE_CHECKOUT_DEFAULT = false; + private static final boolean PREFERENCE_SKELETON_MERGE_DEFAULT = false; /** * @@ -42,4 +46,13 @@ public class ResourceDefaults { return PREFERENCE_CHECKOUT_DEFAULT; } + + /** + * + * @return returns the default setting for skeleton merge. + */ + public static boolean getSkeletonMergeDefault() + { + return PREFERENCE_SKELETON_MERGE_DEFAULT; + } } diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/context/TransientResourceContext.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/context/TransientResourceContext.java index 1dffa025b..2d1504cca 100644 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/context/TransientResourceContext.java +++ b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/context/TransientResourceContext.java @@ -1,12 +1,15 @@ /******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. + * Copyright (c) 2001, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation + * yyyymmdd bug Email and other contact information + * -------- -------- ----------------------------------------------------------- + * 20060331 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.wst.command.internal.env.core.context; @@ -20,11 +23,13 @@ public class TransientResourceContext implements ResourceContext private boolean overWriteFiles; private boolean createFolders; private boolean checkOutFiles; + private boolean skeletonMerge; public TransientResourceContext() { setOverwriteFilesEnabled(ResourceDefaults.getOverwriteFilesDefault()); setCreateFoldersEnabled(ResourceDefaults.getCreateFoldersDefault()); setCheckoutFilesEnabled(ResourceDefaults.getCheckoutFilesDefault()); + setSkeletonMergeEnabled(ResourceDefaults.getSkeletonMergeDefault()); } /** @@ -70,6 +75,20 @@ public class TransientResourceContext implements ResourceContext } /** + * @see org.eclipse.wst.command.internal.env.core.context.ResourceContext#setSkeletonMergeEnabled(boolean) + */ + public void setSkeletonMergeEnabled(boolean enable) { + skeletonMerge = enable; + } + + /** + * @see org.eclipse.wst.command.internal.env.core.context.ResourceContext#isSkeletonMergeEnabled() + */ + public boolean isSkeletonMergeEnabled() { + return skeletonMerge; + } + + /** * @see org.eclipse.wst.command.internal.env.core.context.ResourceContext#copy() */ public ResourceContext copy() { @@ -77,6 +96,7 @@ public class TransientResourceContext implements ResourceContext cc.setOverwriteFilesEnabled(isOverwriteFilesEnabled()); cc.setCreateFoldersEnabled(isCreateFoldersEnabled()); cc.setCheckoutFilesEnabled(isCheckoutFilesEnabled()); + cc.setSkeletonMergeEnabled(isSkeletonMergeEnabled()); return cc; } } diff --git a/bundles/org.eclipse.wst.command.env/src/org/eclipse/wst/command/internal/env/context/PersistentResourceContext.java b/bundles/org.eclipse.wst.command.env/src/org/eclipse/wst/command/internal/env/context/PersistentResourceContext.java index a0675c409..1b1f9b6b4 100644 --- a/bundles/org.eclipse.wst.command.env/src/org/eclipse/wst/command/internal/env/context/PersistentResourceContext.java +++ b/bundles/org.eclipse.wst.command.env/src/org/eclipse/wst/command/internal/env/context/PersistentResourceContext.java @@ -1,12 +1,15 @@ /******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. + * Copyright (c) 2001, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation + * yyyymmdd bug Email and other contact information + * -------- -------- ----------------------------------------------------------- + * 20060331 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.wst.command.internal.env.context; @@ -43,6 +46,7 @@ public class PersistentResourceContext extends PersistentContext implements Reso setDefault(PREFERENCE_CREATE_FOLDERS, ResourceDefaults .getCreateFoldersDefault()); setDefault(PREFERENCE_CHECKOUT, ResourceDefaults.getCheckoutFilesDefault()); + setDefault(PREFERENCE_SKELETON_MERGE, ResourceDefaults.getSkeletonMergeDefault()); } public void setOverwriteFilesEnabled(boolean enable) @@ -74,6 +78,16 @@ public class PersistentResourceContext extends PersistentContext implements Reso { return getValueAsBoolean(PREFERENCE_CHECKOUT); } + + public void setSkeletonMergeEnabled(boolean enable) + { + setValue(PREFERENCE_SKELETON_MERGE, enable); + } + + public boolean isSkeletonMergeEnabled() + { + return getValueAsBoolean(PREFERENCE_SKELETON_MERGE); + } public ResourceContext copy() { @@ -81,6 +95,7 @@ public class PersistentResourceContext extends PersistentContext implements Reso cc.setOverwriteFilesEnabled(isOverwriteFilesEnabled()); cc.setCreateFoldersEnabled(isCreateFoldersEnabled()); cc.setCheckoutFilesEnabled(isCheckoutFilesEnabled()); + cc.setSkeletonMergeEnabled(isSkeletonMergeEnabled()); return cc; } } diff --git a/bundles/org.eclipse.wst.ws/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.ws/META-INF/MANIFEST.MF index 8385911e7..79d203d49 100644 --- a/bundles/org.eclipse.wst.ws/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.wst.ws/META-INF/MANIFEST.MF @@ -45,5 +45,6 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.commands, org.eclipse.wst.common.environment, org.eclipse.emf.ecore, - org.eclipse.emf.ecore.xmi + org.eclipse.emf.ecore.xmi, + org.eclipse.emf.codegen Eclipse-LazyStart: true diff --git a/bundles/org.eclipse.wst.ws/merge.xml b/bundles/org.eclipse.wst.ws/merge.xml new file mode 100644 index 000000000..2f63e2d49 --- /dev/null +++ b/bundles/org.eclipse.wst.ws/merge.xml @@ -0,0 +1,10 @@ +<!- Merge rules for JMerger -> +<?xml version="1.0" encoding="UTF-8"?> +<merge:options xmlns:merge= + "http://www.eclipse.org/org/eclipse/emf/codegen/jmerge/Options"> + + <merge:pull + sourceGet="Method/getBody" + targetPut="Method/setBody"/> + +</merge:options> diff --git a/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/common/MergeUtils.java b/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/common/MergeUtils.java new file mode 100644 index 000000000..22a4c2e9c --- /dev/null +++ b/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/common/MergeUtils.java @@ -0,0 +1,163 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * yyyymmdd bug Email and other contact information + * -------- -------- ----------------------------------------------------------- + * 20060330 128827 kathy@ca.ibm.com - Kathy Chan + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.common; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Hashtable; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.codegen.merge.java.JControlModel; +import org.eclipse.emf.codegen.merge.java.JMerger; +import org.eclipse.emf.codegen.merge.java.facade.FacadeHelper; +import org.eclipse.emf.codegen.util.CodeGenUtil; +import org.eclipse.wst.ws.internal.plugin.WSPlugin; + +public class MergeUtils { + private static Hashtable MergeModel; + private static final String MERGE_XML = "merge.xml"; + private static JControlModel jMergeControlModel = null; + + + /** + * Stores the JMerge model of the file represented by the URL strings + * @param urlStrings String representation of the URL for the file + */ + static public void storeMergeModels (String [] urlStrings) { + if (urlStrings != null) { + initialize(); + if (jMergeControlModel != null) { + MergeModel = new Hashtable(); + String filename; + for (int i = 0; i < urlStrings.length; i++) { + filename = getFileFromURL(urlStrings[i]); + if (filename != null) { + storeModel(filename); + } + } + } + } + } + + /** + * Stores the JMerge model of the file using the filename as key + * @param filename String representation of the file + */ + static public void storeModel (String filename) { + InputStream inStream = null; + JMerger jMerger; + File aFile; + try { + if (jMergeControlModel != null) { + aFile = new File (filename); + if (aFile.exists()) { + inStream = new FileInputStream(aFile); + jMerger = new JMerger(jMergeControlModel); + jMerger.setSourceCompilationUnit(jMerger.createCompilationUnitForInputStream(inStream)); + MergeModel.put(filename, jMerger); + } + } + } catch (FileNotFoundException e) { + // File not found, just ignore. Nothing to merge. + } finally { + if (inStream != null) { + try { + inStream.close(); + } catch (IOException e) { + } + } + } + + } + + /** + * Initializes the JMerge model + * File merge.xml in WebServicePlugin contains the rules for the merge. + * If the merge.xml file is not found, jMergeControlModel is leave as null. + */ + static private void initialize() { + if (jMergeControlModel == null) { + FacadeHelper facadeHelper = CodeGenUtil.instantiateFacadeHelper(JMerger.DEFAULT_FACADE_HELPER_CLASS); + + jMergeControlModel = new JControlModel(); + File mergeXML = null; + try { + String dir = new File(Platform.asLocalURL(WSPlugin.getInstance().getBundle().getEntry("/")).getFile()).toString(); + mergeXML = new File(dir + File.pathSeparator + MERGE_XML).getAbsoluteFile(); + } catch (IOException e) { + // Error reading merge.xml in org.eclipse.jst.ws.consumption plugin directory + } + + if (mergeXML != null) { + jMergeControlModel.initialize(facadeHelper, mergeXML.getAbsolutePath()); + } + } + return; + } + + /** + * Look up the model of this file stored earlier using the filename as key. + * Merge the content of this file with the earlier model. + * Returns the string representation of the merged content. + * Returns null if an earlier model for this file does not exist or if the new file does not exist. + * @param filename + * @return merge content + */ + static public String mergeFile(String filename) { + JMerger jMerger = (JMerger) MergeModel.get(filename); + String mergedContent = null; + if (jMerger != null) { + // a JMerger model of the file exists, merge the contents + InputStream inStream = null; + try { + inStream = new FileInputStream(new File (filename)); + jMerger.setTargetCompilationUnit(jMerger.createCompilationUnitForInputStream(inStream)); + jMerger.merge(); + mergedContent = jMerger.getTargetCompilationUnitContents(); + } catch (FileNotFoundException e) { + // File not found, just ignore. Nothing to merge. + } finally { + try { + if (inStream != null) { + inStream.close(); + } + } catch (IOException e) { + } + } + } + return mergedContent; + } + + /** + * Gets the file name of this URL + * @param urlString string representation of the URL + * @return file name string + */ + static public String getFileFromURL(String urlString) { + String fileString = null; + try { + URL url = new URL (urlString); + fileString = url.getFile(); + } catch (MalformedURLException e) { + } + return fileString; + } + +} diff --git a/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/wsrt/WebServiceInfo.java b/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/wsrt/WebServiceInfo.java index 517c44dfe..6fa1b01b9 100644 --- a/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/wsrt/WebServiceInfo.java +++ b/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/wsrt/WebServiceInfo.java @@ -10,10 +10,13 @@ * yyyymmdd bug Email and other contact information * -------- -------- ----------------------------------------------------------- * 20060221 128905 kathy@ca.ibm.com - Kathy Chan + * 20060330 128827 kathy@ca.ibm.com - Kathy Chan *******************************************************************************/ package org.eclipse.wst.ws.internal.wsrt; +import org.eclipse.wst.ws.internal.common.MergeUtils; + public class WebServiceInfo { private WebServiceState state; @@ -88,6 +91,7 @@ public class WebServiceInfo { public void setImplURLs(java.lang.String[] implURLs) { this.implURLs = implURLs; + MergeUtils.storeMergeModels(implURLs); } } |