Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets')
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/AbstractHandlersWidgetDefaultingCmd.java121
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/AbstractObjectSelectionLaunchable.java53
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/AddHandlerDialog.java265
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/CheckWSDLValidationCommand.java106
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientHandlersWidgetDefaultingCommand.java329
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientHandlersWidgetOutputCommand.java207
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientWizardWidget.java563
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientWizardWidgetDefaultingCommand.java159
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientWizardWidgetOutputCommand.java180
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ConfigClientHandlersTableWidget.java637
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ConfigServiceHandlersTableWidget.java685
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/HandlersDefaultingCommand.java78
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/IObjectSelectionLaunchable.java93
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/IPackable.java26
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ImportWSILWidget.java234
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/JavaBeanSelectionLaunchable.java215
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/PreferencesSelectionWidget.java81
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ProjectSelectionDialog.java123
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/PublishToPrivateUDDICommandFragment.java101
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/PublishWSWidget.java152
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ServiceHandlersWidgetDefaultingCommand.java376
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ServiceHandlersWidgetOutputCommand.java244
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/TableViewerWidget.java639
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/TimedWSDLSelectionConditionCommand.java100
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionConditionCommand.java135
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionDialog.java97
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionOutputCommand.java138
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionTreeWidget.java291
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionWidgetDefaultingCommand.java215
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionWidgetWrapper.java144
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WebServiceClientTypeWidget.java1080
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ClientWidgetBinding.java486
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ConfigClientHandlersWidgetBinding.java140
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ConfigServiceHandlersWidgetBinding.java139
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ConfigureHandlersWidgetBinding.java256
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/GenSampleWidgetBinding.java493
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ImportWSILWidgetBinding.java88
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ImportWSWidgetBinding.java103
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionDefaultingCommand.java691
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionFragment.java40
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionOutputCommand.java79
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ServerExtensionDefaultingCommand.java475
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ServerExtensionFragment.java41
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ServerExtensionOutputCommand.java115
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/AbstractObjectSelectionWidget.java67
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/EJBSelectionTransformer.java71
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/EJBSelectionWidget.java392
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/EJBTableViewer.java122
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/HandlerTableItem.java114
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/IObjectSelectionWidget.java94
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/JavaBeanSelectionTransformer.java87
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/JavaBeanSelectionWidget.java281
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionFragment.java92
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionOutputCommand.java296
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionRegistry.java157
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionWidget.java258
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/Timer.java75
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ValidateWSDLJob.java88
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ValidationMessageViewerWidget.java244
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/WSDLSelectionTransformer.java147
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/WSDLSelectionWidget.java736
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/WSDLSelectionWrapper.java32
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java1619
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ProjectSelectionWidget.java790
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestDelegateCommand.java377
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestFragment.java85
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestWidget.java806
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/CopyWebServiceUtilsJarCommand.java137
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/FinishDefaultCommand.java87
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/FinishJavaTestFragment.java64
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/FinishTestFragment.java109
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/TestClientDepartureInitCommand.java52
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/TestDefaultingFragment.java141
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/TestWebServiceClient.java54
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WSDLFinishFragment.java30
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WSDLTestLaunchCommand.java189
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WebServiceClientTestArrivalCommand.java287
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WebServiceTestClientDepartureFragment.java50
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/ExplorerServiceTestCommand.java97
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/WSEGenerateCommand.java60
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/WSEWebServiceTester.java34
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/WebServiceExplorerExecutable.java35
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/AddModuleDependenciesCommand.java248
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCGenerateCommand.java180
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCLaunchCommand.java233
-rw-r--r--core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCWebServiceTester.java41
86 files changed, 20171 insertions, 0 deletions
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/AbstractHandlersWidgetDefaultingCmd.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/AbstractHandlersWidgetDefaultingCmd.java
new file mode 100644
index 000000000..d92f6ab83
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/AbstractHandlersWidgetDefaultingCmd.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import java.util.List;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+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.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+
+
+/**
+ * AbstractHandlersWidgetDefaultingCmd
+ *
+ * Initialize and load the handlers data
+ */
+public abstract class AbstractHandlersWidgetDefaultingCmd extends AbstractDataModelOperation
+{
+
+ private IStructuredSelection initialSelection_;
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+ IStatus status = Status.OK_STATUS;
+
+ IStructuredSelection selection = initialSelection_;
+ if (selection == null) {
+ status = StatusUtils.errorStatus( ConsumptionUIMessages.MSG_ERROR_TASK_EXCEPTED );
+ env.getStatusHandler().reportError(status);
+ return status;
+ }
+
+
+ return status;
+
+ }
+
+
+ public List getClientHandlers(){
+ return null;
+ }
+
+ public void setInitialSelection(IStructuredSelection initSelection){
+ this.initialSelection_ = initSelection;
+ }
+
+ public IStructuredSelection getInitialSelection(){
+ return this.initialSelection_;
+ }
+
+ protected IResource getResourceFromInitialSelection()
+ {
+ if (initialSelection_ != null && initialSelection_.size() == 1)
+ {
+ Object obj = initialSelection_.getFirstElement();
+ if (obj != null)
+ {
+ try
+ {
+ IResource resource = ResourceUtils.getResourceFromSelection(obj);
+ return resource;
+ } catch(CoreException e)
+ {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ public IProject getProject(){
+
+ IResource resource = getResourceFromInitialSelection();
+ if (resource != null)
+ {
+ return ResourceUtils.getProjectOf( resource.getFullPath() );
+ }
+
+ return null;
+ }
+
+ public String getComponentName(){
+ IResource resource = getResourceFromInitialSelection();
+ if (resource!=null) {
+ IPath absolutePath = resource.getFullPath();
+ if (absolutePath.isAbsolute()) {
+ return absolutePath.segment(1);
+ }
+ }
+ return null;
+ }
+
+// public WebServiceEditModel getWebServiceEditModel() {
+// WebServicesManager wsm = new WebServicesManager();
+// IProject project = getProject();
+// return wsm.getWSEditModel(project);
+// }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/AbstractObjectSelectionLaunchable.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/AbstractObjectSelectionLaunchable.java
new file mode 100644
index 000000000..1c00cca66
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/AbstractObjectSelectionLaunchable.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060420 135912 joan@ca.ibm.com - Joan Haggarty
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+
+public abstract class AbstractObjectSelectionLaunchable implements IObjectSelectionLaunchable {
+
+ public int launch(Shell shell) {
+ return -1;
+ }
+
+ public IStatus validateSelection(IStructuredSelection objectSelection) {
+ // subclass should override this method
+ return Status.OK_STATUS;
+ }
+
+ public IStructuredSelection getObjectSelection() {
+ // subclass should override this method
+ return new StructuredSelection();
+ }
+
+ public void setInitialSelection(IStructuredSelection initialSelection) {
+ // subclass should override this method
+ }
+
+ public String getObjectSelectionDisplayableString()
+ {
+ // subclass should override this method
+ return "";
+ }
+
+ public boolean validate(String s) {
+ // subclass should override this method
+ return true;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/AddHandlerDialog.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/AddHandlerDialog.java
new file mode 100644
index 000000000..045aa362b
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/AddHandlerDialog.java
@@ -0,0 +1,265 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu
+ * 20060529 143518 sengpl@ca.ibm.com - Seng Phung-Lu
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.ui.common.UIUtils;
+import org.eclipse.jst.ws.internal.ui.dialog.DialogUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+
+public class AddHandlerDialog extends Dialog implements Listener {
+
+ private String pluginId_ = "org.eclipse.jst.ws.consumption.ui";
+
+ private boolean validateOn_;
+ private boolean isClient_;
+ private boolean isMultipleServices_;
+ private String className;
+ private String name;
+ private String selectedPortName;
+
+ private Text classNameText;
+ private Text nameText;
+ private Combo portNameCombo;
+
+ // ----TOOLTIPS Section----
+ /* CONTEXT_ID AHDL0001 for the Handler Config Page */
+ private final String INFOPOP_TEXT_HANDLER_NAME = "AHDL0001"; //$NON-NLS-1$
+
+ /* CONTEXT_ID AHDL0002 for the Handler Config Page */
+ private final String INFOPOP_TEXT_HANDLER_CLASS = "AHDL0002"; //$NON-NLS-1$
+
+ /* CONTEXT_ID AHDL0001 for the Handler Config Page */
+ private final String INFOPOP_TEXT_HANDLER_PORT = "AHDL0003"; //$NON-NLS-1$
+
+ private Button beanClassBrowseButton_;
+ /*CONTEXT_ID PBCL0003 for the Bean Class Browse button of the Bean Selection Page*/
+ private String INFOPOP_PBCL_BUTTON_BEAN_CLASS_BROWSE = "PBCL0003";
+
+ public AddHandlerDialog( Shell shell, boolean isClientHandler)
+ {
+ super(shell);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ isClient_ = isClientHandler;
+ }
+
+ protected Control createContents(Composite parent) {
+ Composite comp = (Composite) super.createContents(parent);
+ parent.getShell().pack();
+ return comp;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ validateOn_ = false;
+ UIUtils uiUtils = new UIUtils(pluginId_);
+
+ Shell thisShell = parent.getShell();
+ if (thisShell == null) {
+ thisShell = createShell();
+ }
+ thisShell.setText(ConsumptionUIMessages.DIALOG_TITLE_WS_ADD_HANDLER);
+
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ Composite sourceLocationComp = uiUtils.createComposite(composite, 3);
+
+ classNameText = uiUtils.createText(sourceLocationComp, ConsumptionUIMessages.LABEL_TEXT_HANDLER_CLASS, ConsumptionUIMessages.TOOLTIP_TEXT_HANDLER_CLASS, INFOPOP_TEXT_HANDLER_CLASS, SWT.SINGLE | SWT.BORDER);
+ classNameText.addListener(SWT.Modify,this);
+
+ beanClassBrowseButton_ = uiUtils.createPushButton( sourceLocationComp, ConsumptionUIMessages.BUTTON_BROWSE_CLASSES,
+ ConsumptionUIMessages.TOOLTIP_PBCL_BUTTON_BEAN_CLASS_BROWSE,
+ INFOPOP_PBCL_BUTTON_BEAN_CLASS_BROWSE );
+ beanClassBrowseButton_.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent evt )
+ {
+ handleBrowseClasses();
+ }
+ } );
+
+ nameText = uiUtils.createText(sourceLocationComp, ConsumptionUIMessages.LABEL_TEXT_HANDLER_NAME, ConsumptionUIMessages.TOOLTIP_TEXT_HANDLER_NAME, INFOPOP_TEXT_HANDLER_NAME, SWT.SINGLE | SWT.BORDER );
+ nameText.addListener(SWT.Modify, this);
+
+ // dummy label for column 3.
+ new Label( sourceLocationComp, SWT.NONE );
+
+ if (!isClient_ && !isMultipleServices_){
+ portNameCombo = uiUtils.createCombo(sourceLocationComp, ConsumptionUIMessages.LABEL_TEXT_HANDLER_PORT, ConsumptionUIMessages.TOOLTIP_TEXT_HANDLER_PORT, INFOPOP_TEXT_HANDLER_PORT, SWT.SINGLE | SWT.BORDER );
+ portNameCombo.addListener(SWT.Modify, this);
+
+ // dummy label for column 3.
+ new Label( sourceLocationComp, SWT.NONE );
+ }
+ validateOn_ = true;
+ return composite;
+ }
+
+ private void handleBrowseClasses()
+ {
+ Shell shell = getShell();
+ IType itype = DialogUtils.browseClassesAsIType(shell, ResourcesPlugin.getWorkspace().getRoot().getProjects(), new ProgressMonitorDialog(shell));
+
+ if( itype != null )
+ {
+ classNameText.setText(itype.getFullyQualifiedName());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ public void handleEvent(Event event) {
+ if (!validateOn_)
+ return;
+ if (classNameText == event.widget) {
+ handleClassNameTextEvent();
+ validateTextFieldEntries();
+ return;
+ }
+ if (nameText == event.widget) {
+ handleNameTextEvent();
+ validateTextFieldEntries();
+ return;
+ }
+ if (portNameCombo == event.widget) {
+ handlePortNameTextEvent();
+ validateTextFieldEntries();
+ return;
+ }
+ }
+
+ private void handleClassNameTextEvent(){
+ className = classNameText.getText();
+ if (className.lastIndexOf(".java") != -1){
+ nameText.setText(className.substring(0, className.lastIndexOf(".java")));
+ }
+ else {
+ nameText.setText(className);
+ }
+
+ if (className.lastIndexOf(".") != -1){
+ nameText.setText(className.substring(className.lastIndexOf(".")+1, className.length()));
+ }
+ name = nameText.getText();
+ }
+
+ private void handleNameTextEvent() {
+ name = nameText.getText();
+
+ }
+
+ private void handlePortNameTextEvent(){
+ selectedPortName = portNameCombo.getText();
+ }
+
+ private void disableOKButton() {
+ if (getButton(0) != null)
+ getButton(0).setEnabled(false);
+ }
+
+ private void enableOKButton() {
+ if (getButton(0) != null)
+ getButton(0).setEnabled(true);
+ }
+
+ private void validateTextFieldEntries(){
+ if (classNameText.getText().equals("")){
+ disableOKButton();
+ return;
+ }
+ if (nameText.getText().equals("")){
+ disableOKButton();
+ return;
+ }
+ if (!isClient_ && !isMultipleServices_){
+ if (portNameCombo.getText()!=null && portNameCombo.getText().equals("")){
+ disableOKButton();
+ return;
+ }
+ else if (portNameCombo.getText()==null) {
+ disableOKButton();
+ return;
+ }
+ }
+
+ enableOKButton();
+
+
+ }
+
+ /**
+ * @return Returns the className.
+ */
+ public String getClassName() {
+ if (className.lastIndexOf(".java") != -1){
+ return className.substring(0, className.lastIndexOf(".java"));
+ }
+ else {
+ return className;
+ }
+ }
+ /**
+ * @param className The className to set.
+ */
+ public void setClassName(String className) {
+ this.className = className;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the portName.
+ */
+ public String getPortName() {
+ return selectedPortName;
+ }
+ /**
+ * @param portName The portName to set.
+ */
+ public void setPortNames(String[] portNames) {
+ portNameCombo.setItems(portNames);
+ portNameCombo.select(0);
+ }
+
+ public void setIsMultipleServices(boolean isMultipleServices){
+ this.isMultipleServices_ = isMultipleServices;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/CheckWSDLValidationCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/CheckWSDLValidationCommand.java
new file mode 100644
index 000000000..3962d82e5
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/CheckWSDLValidationCommand.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060420 120714 kathy@ca.ibm.com - Kathy Chan
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobManager;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.ValidateWSDLJob;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.common.environment.Choice;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.plugin.WSPlugin;
+
+
+public class CheckWSDLValidationCommand extends AbstractDataModelOperation
+{
+
+ public CheckWSDLValidationCommand () {
+ }
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+
+ IJobManager jobManager = Platform.getJobManager();
+ Job[] jobs = jobManager.find( ValidateWSDLJob.VALIDATE_WSDL_JOB_FAMILY );
+ ValidateWSDLJob existingValidateWSDLJob = null;
+
+ if( jobs.length > 0 )
+ {
+ for (int i=0; i<jobs.length; i++) {
+ existingValidateWSDLJob = (ValidateWSDLJob)jobs[i];
+
+ if (existingValidateWSDLJob.getState() != Job.NONE) {
+ if (ignoreWSDLValidation(env)) {
+ // if don't want to wait for validation, cancel existing validation job
+ existingValidateWSDLJob.cancel();
+ return Status.OK_STATUS;
+ } else {
+ // Setting the error string to an empty string so that the command engine would not
+ // pop-up another error message when the user decided to wait for WSDL validation.
+ return StatusUtils.errorStatus( "" );
+ }
+ }
+ }
+ }
+
+ return Status.OK_STATUS;
+
+ }
+
+ private boolean ignoreWSDLValidation(IEnvironment env) {
+ if (!WSPlugin.getInstance().getWaitForWSDLValidationContext().getPersistentWaitForWSDLValidation())
+ return true; // do not want to wait for WSDL validation, i.e. Ignore all
+
+ // give a warning message with the options to stop, ignore this one, or
+ // ignore all coming messages
+ IStatus status_ = StatusUtils.warningStatus( ConsumptionUIMessages.STILL_VALIDATING_WSDL );
+ // adding all messages from WSI Incompliances
+
+ Choice ignoreChoice = new Choice('C', ConsumptionUIMessages.CANCEL_VALIDATION_LABEL,
+ ConsumptionUIMessages.CANCEL_VALIDATION_DESCRIPTION);
+ Choice ignoreAllChoice = new Choice('A', ConsumptionUIMessages.CANCEL_ALL_VALIDATION_LABEL,
+ ConsumptionUIMessages.CANCEL_ALL_VALIDATION_DESCRIPTION);
+ Choice cancelChoice = new Choice('W', ConsumptionUIMessages.WAIT_VALIDATION_LABEL,
+ ConsumptionUIMessages.WAIT_VALIDATION_DESCRIPTION);
+
+ Choice result = env.getStatusHandler().report(status_,
+ new Choice[] { ignoreChoice, ignoreAllChoice, cancelChoice });
+
+ // if the user closes the message box or selects ignore continue
+ if (result == null
+ || (result.getLabel().equals(ignoreChoice.getLabel()))) {
+ return true;
+ // if the user selects ignore all, change the preference
+ } else if (result.getLabel().equals(ignoreAllChoice.getLabel())) {
+ // update ignore WSDL validation preference
+ WSPlugin.getInstance().getWaitForWSDLValidationContext().setWaitForWSDLValidation(false);
+ return true;
+ }
+ // if the user selects to cancel , do not continue with the command
+ else if (result.getLabel().equals(cancelChoice.getLabel())) {
+ return false;
+ }
+ return true;
+ }
+
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientHandlersWidgetDefaultingCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientHandlersWidgetDefaultingCommand.java
new file mode 100644
index 000000000..449c472f4
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientHandlersWidgetDefaultingCommand.java
@@ -0,0 +1,329 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IFile;
+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.emf.ecore.resource.Resource;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.j2ee.applicationclient.componentcore.util.AppClientArtifactEdit;
+import org.eclipse.jst.j2ee.client.ApplicationClient;
+import org.eclipse.jst.j2ee.client.ApplicationClientResource;
+import org.eclipse.jst.j2ee.ejb.EJBJar;
+import org.eclipse.jst.j2ee.ejb.EJBResource;
+import org.eclipse.jst.j2ee.ejb.internal.modulecore.util.EJBArtifactEditUtilities;
+import org.eclipse.jst.j2ee.internal.webservice.WebServiceNavigatorGroupType;
+import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit;
+import org.eclipse.jst.j2ee.webapplication.WebApp;
+import org.eclipse.jst.j2ee.webapplication.WebAppResource;
+import org.eclipse.jst.j2ee.webservice.wsclient.Handler;
+import org.eclipse.jst.j2ee.webservice.wsclient.ServiceRef;
+import org.eclipse.jst.j2ee.webservice.wsclient.WebServicesResource;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.common.HandlerServiceRefHolder;
+import org.eclipse.jst.ws.internal.consumption.ui.helper.WebServicesManager;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.HandlerTableItem;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.environment.IEnvironment;
+
+/**
+ * ClientHandlersWidgetDefaultingCommand
+ *
+ * Initialize and load the handlers data
+ */
+public class ClientHandlersWidgetDefaultingCommand extends AbstractHandlersWidgetDefaultingCmd {
+
+ private WebServicesManager webServicesManager_;
+
+ private IProject project_;
+
+ private String serviceRefName_ = null;
+
+ private List wsServiceRefs_;
+
+ private HandlerServiceRefHolder[] handlerServiceRefHolder_;
+ private String errorStatusMsg_ = null;
+ private boolean isMultipleSelection_;
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+ IStatus status = Status.OK_STATUS;
+
+ webServicesManager_ = WebServicesManager.getInstance();
+
+ IStructuredSelection selection = getInitialSelection();
+ if (selection == null) {
+ status = StatusUtils.errorStatus( ConsumptionUIMessages.MSG_ERROR_TASK_EXCEPTED );
+ env.getStatusHandler().reportError(status);
+ return status;
+ }
+ else if (selection.size()>1){
+ status = processMultipleHandlers();
+ return status;
+ }
+
+ status = processHandlers();
+ return status;
+
+ }
+
+ /**
+ * For processing handlers
+ * @return
+ */
+ public IStatus processHandlers() {
+ try {
+
+ Collection selectedServiceRefs = getWSServiceRefsFromSelection(); // get initial selection values
+ if (selectedServiceRefs==null || selectedServiceRefs.isEmpty()){
+ //report no Web service client is available
+ return StatusUtils.errorStatus(ConsumptionUIMessages.MSG_ERROR_WEB_SERVICE_CLIENTS_NOT_FOUND);
+ }
+ wsServiceRefs_ = webServicesManager_.getAllWorkspaceServiceRefs();
+
+ if (wsServiceRefs_ != null) {
+ int numberOfServiceRefs = wsServiceRefs_.size();
+ handlerServiceRefHolder_ = new HandlerServiceRefHolder[numberOfServiceRefs];
+
+ for (int i = 0; i < numberOfServiceRefs; i++) {
+ ServiceRef wsServiceRef = (ServiceRef) wsServiceRefs_.get(i);
+ Vector handlers = new Vector();
+ List wsHandlers = wsServiceRef.getHandlers();
+
+ for (int k = 0; k < wsHandlers.size(); k++) {
+
+ Handler wsHandler = (Handler) wsHandlers.get(k);
+
+ HandlerTableItem handlerItem = new HandlerTableItem();
+ handlerItem.setHandler(wsHandler);
+ handlerItem.setHandlerName(wsHandler.getHandlerName());
+ handlerItem.setHandlerClassName(wsHandler.getHandlerClass().getQualifiedName());
+ handlerItem.setWsDescRef(wsServiceRef);
+
+ handlers.add(handlerItem);
+ }
+ String wsServiceRefName = wsServiceRef.getServiceRefName();
+ handlerServiceRefHolder_[i] = new HandlerServiceRefHolder();
+ handlerServiceRefHolder_[i].setHandlerList(handlers);
+ handlerServiceRefHolder_[i].setServiceRef(wsServiceRef);
+ handlerServiceRefHolder_[i].setServiceRefName(wsServiceRefName);
+
+ }
+
+ }
+
+ }
+ catch (Exception e) {
+ return StatusUtils.errorStatus( ConsumptionUIMessages.MSG_ERROR_TASK_EXCEPTED, e);
+ }
+ return Status.OK_STATUS;
+ }
+
+ public IStatus processMultipleHandlers(){
+ ServiceRef[] serviceRefs = getServiceRefs();
+ if (errorStatusMsg_ != null){
+ return StatusUtils.errorStatus(errorStatusMsg_);
+ }
+ isMultipleSelection_ = true;
+
+ handlerServiceRefHolder_ = new HandlerServiceRefHolder[serviceRefs.length];
+ Vector handlers = new Vector();
+ for (int i=0;i<serviceRefs.length;i++){
+
+ String refName = serviceRefs[i].getServiceRefName();
+ handlerServiceRefHolder_[i] = new HandlerServiceRefHolder();
+ handlerServiceRefHolder_[i].setHandlerList(handlers);
+ handlerServiceRefHolder_[i].setServiceRefName(refName);
+ handlerServiceRefHolder_[i].setServiceRef(serviceRefs[i]);
+ }
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @return Returns the isGenSkeletonEnabled_.
+ */
+ public boolean getGenSkeletonEnabled() {
+ if (isMultipleSelection_)
+ return false;
+ return true;
+ }
+
+
+ public String getServiceRefName() {
+ return this.serviceRefName_;
+ }
+
+ public IProject getClientProject() {
+ return project_;
+ }
+
+ private ServiceRef[] getServiceRefs(){
+ IStructuredSelection initSel = getInitialSelection();
+ ServiceRef[] serviceRefs = new ServiceRef[initSel.size()];
+ Iterator iter = initSel.iterator();
+ for (int i=0;i<initSel.size();i++) {
+ Object obj = iter.next();
+ if (obj instanceof ServiceRef){
+ serviceRefs[i] = (ServiceRef)obj;
+ }
+ else{
+ errorStatusMsg_ = ConsumptionUIMessages.MSG_ERROR_INVALID_MULTIPLE_SERVICE_SELECT;
+ return null;
+ }
+ }
+ return serviceRefs;
+}
+
+ private Collection getWSServiceRefsFromSelection() {
+
+ IStructuredSelection initSel = getInitialSelection();
+ if (initSel != null && initSel.size() == 1) {
+ Object obj = initSel.getFirstElement();
+ ServiceRef serviceRef = null;
+ if (obj instanceof ServiceRef) {
+ // Client ServiceRef
+ serviceRef = (ServiceRef) obj;
+ serviceRefName_ = serviceRef.getServiceRefName();
+ project_ = ProjectUtilities.getProject(serviceRef);
+ }
+ else if (obj instanceof WebServiceNavigatorGroupType) {
+ WebServiceNavigatorGroupType wsngt = (WebServiceNavigatorGroupType) obj;
+ serviceRef = wsngt.getServiceRef();
+ serviceRefName_ = serviceRef.getServiceRefName();
+ project_ = ProjectUtilities.getProject(serviceRef);
+ }
+ else if (obj instanceof IFile){
+ Resource res = WorkbenchResourceHelperBase.getResource((IFile)obj, true);
+ Collection serviceRefs = null;
+ if (res instanceof WebServicesResource) {
+ // webservicesclient.xml for J2EE 1.3
+ WebServicesResource wsRes = (WebServicesResource)res;
+ serviceRefs = wsRes.getWebServicesClient().getServiceRefs();
+ if (!serviceRefs.isEmpty()) {
+ ServiceRef ref = (ServiceRef)((List)serviceRefs).get(0);
+ serviceRefName_ = ref.getServiceRefName();
+ project_ = ProjectUtilities.getProject(ref);
+ return serviceRefs;
+ }
+ return null;
+ }
+ else {
+ if(res instanceof WebAppResource){
+ // web.xml for J2EE 1.4
+ WebAppResource webAppRes = (WebAppResource)res;
+ serviceRefs = webAppRes.getWebApp().getServiceRefs();
+ }
+ else if (res instanceof EJBResource){
+ EJBResource ejbRes = (EJBResource)res;
+ serviceRefs = webServicesManager_.getServiceRefs(ejbRes.getEJBJar());
+ }
+ else if (res instanceof ApplicationClientResource){
+ ApplicationClientResource appClientRes = (ApplicationClientResource)res;
+ serviceRefs = webServicesManager_.getServiceRefs(appClientRes.getApplicationClient());//appClientRes.getApplicationClient().getServiceRefs();
+ }
+ if (serviceRefs!=null && serviceRefs.size()>0) {
+ ServiceRef ref = (ServiceRef)((List)serviceRefs).get(0);
+ serviceRefName_ = ref.getServiceRefName();
+ project_ = ProjectUtilities.getProject(ref);
+ }
+ return serviceRefs;
+ }
+ }
+
+ // This section is for obtaining all the serviceRefs from the project, given that the initial selection
+ // was from the J2EE view (ServiceRef or WebServiceNavigatorGroupType), it will select the right serviceRef
+ if (project_==null){
+ project_ = getProject();
+ }
+ if (project_==null){
+ return null;
+ }
+
+ if (J2EEUtils.isWebComponent(project_)) {
+ WebArtifactEdit webEdit = null;
+ try {
+ IVirtualComponent vc = ComponentCore.createComponent(project_);
+ webEdit = WebArtifactEdit.getWebArtifactEditForRead(vc);
+ if (webEdit != null)
+ {
+ WebApp webApp = (WebApp) webEdit.getDeploymentDescriptorRoot();
+ if (webApp != null) {
+ return webServicesManager_.getServiceRefs(webApp);
+ }
+ }
+ }
+ finally{
+ if(webEdit!=null)
+ webEdit.dispose();
+ }
+ }
+ else if (J2EEUtils.isEJBComponent(project_)){
+
+ IVirtualComponent vc = ComponentCore.createComponent(project_);
+ EJBJar ejbJar = EJBArtifactEditUtilities.getEJBJar(vc);
+ if (ejbJar!=null) {
+ return webServicesManager_.getServiceRefs(ejbJar);
+ }
+ }
+ else if (J2EEUtils.isAppClientComponent(project_)){
+ IVirtualComponent vc = ComponentCore.createComponent(project_);
+ AppClientArtifactEdit appEdit = null;
+ try {
+ appEdit = AppClientArtifactEdit.getAppClientArtifactEditForRead(vc);
+ if (appEdit!=null){
+ ApplicationClient appClient = appEdit.getApplicationClient();
+ if (appClient !=null){
+ return webServicesManager_.getServiceRefs(appClient);
+ }
+ }
+ }
+ finally{
+ if(appEdit!=null){
+ appEdit.dispose();
+ }
+ }
+ }
+
+
+ }
+ return null;
+ }
+
+ public Collection getWsServiceRefs(){
+ return this.wsServiceRefs_;
+ }
+
+ public boolean getIsMultipleSelection(){
+ return this.isMultipleSelection_;
+ }
+
+ public HandlerServiceRefHolder[] getHandlerServiceRefHolder(){
+ return this.handlerServiceRefHolder_;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientHandlersWidgetOutputCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientHandlersWidgetOutputCommand.java
new file mode 100644
index 000000000..4cee18a13
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientHandlersWidgetOutputCommand.java
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu
+ * 20060517 142339 sengpl@ca.ibm.com - Seng Phung-Lu
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+
+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.java.JavaClass;
+import org.eclipse.jst.j2ee.applicationclient.componentcore.util.AppClientArtifactEdit;
+import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit;
+import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit;
+import org.eclipse.jst.j2ee.webservice.wsclient.Handler;
+import org.eclipse.jst.j2ee.webservice.wsclient.ServiceRef;
+import org.eclipse.jst.j2ee.webservice.wsclient.Webservice_clientFactory;
+import org.eclipse.jst.j2ee.webservice.wsclient.internal.impl.Webservice_clientFactoryImpl;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.common.JavaMOFUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.common.HandlerServiceRefHolder;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.HandlerTableItem;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.common.componentcore.ArtifactEdit;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.internal.emf.utilities.EtoolsCopyUtility;
+
+/*
+ * Provide a way to externalize the edited fields and create new handlers
+ *
+ */
+public class ClientHandlersWidgetOutputCommand extends AbstractDataModelOperation
+{
+
+ private HandlerServiceRefHolder[] handlerServiceRefHolder_;
+ private Hashtable oldWSServiceRefsToHandlersTable_;
+ private Hashtable newWSServiceRefsToHandlersTable_;
+ private IProject project_;
+ private boolean isMultipleSelection_;
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IStatus status = Status.OK_STATUS;
+
+ try {
+
+ if (isMultipleSelection_) {
+ if (handlerServiceRefHolder_ != null) {
+ // add new handler to internal model if it doesn't already exist
+ for (int i = 0; i < handlerServiceRefHolder_.length; i++) {
+ handlerServiceRefHolder_[i].addHandlerToServiceRef();
+ saveEditModel(handlerServiceRefHolder_[i].getProject());
+ }
+
+ }
+
+ }
+ else {
+ oldWSServiceRefsToHandlersTable_ = new Hashtable();
+ newWSServiceRefsToHandlersTable_ = new Hashtable();
+
+ if (handlerServiceRefHolder_ != null) {
+
+ for (int i = 0; i < handlerServiceRefHolder_.length; i++) {
+
+ ServiceRef wsServiceRef =handlerServiceRefHolder_[i].getServiceRef();
+
+ List wsHandlers = wsServiceRef.getHandlers();
+ oldWSServiceRefsToHandlersTable_.put(wsServiceRef, wsHandlers);
+ newWSServiceRefsToHandlersTable_.put(wsServiceRef, new ArrayList());
+ }
+
+ //Enumeration e = handlersTable_.keys();
+ for (int j=0;j<handlerServiceRefHolder_.length;j++) {
+
+ List handlerTableItems_ = handlerServiceRefHolder_[j].getHandlerList();
+ if (handlerTableItems_ != null) {
+ // form Handler tables
+ for (int i = 0; i < handlerTableItems_.size(); i++) {
+
+ HandlerTableItem hti = (HandlerTableItem) handlerTableItems_.get(i);
+ Object wsModelRef = hti.getWsDescRef();
+ if (wsModelRef != null && wsModelRef instanceof ServiceRef) {
+ ServiceRef wsRef = (ServiceRef) wsModelRef;
+
+ Object handler = hti.getHandler();
+ if (handler != null && handler instanceof Handler) {
+ // clone it
+ Handler clonedHandler = (Handler) EtoolsCopyUtility.createCopy((Handler) handler);
+ ((List) newWSServiceRefsToHandlersTable_.get(wsRef)).add(clonedHandler);
+ }
+ else {
+ // create it
+ Webservice_clientFactory wsClientFactory = new Webservice_clientFactoryImpl();
+ Handler newHandler = wsClientFactory.createHandler();
+ newHandler.setHandlerName(hti.getHandlerName());
+
+ JavaClass javaClass = JavaMOFUtils.getJavaClass(hti.getHandlerClassName(), project_);
+ if (javaClass != null) {
+ newHandler.setHandlerClass(javaClass);
+ }
+
+ ((List) newWSServiceRefsToHandlersTable_.get(wsRef)).add(newHandler);
+ }
+
+ }
+
+ }
+ }
+ }
+
+ // add handlers to ports
+ addHandlersToServiceRefs();
+ }
+
+ // save the artifact edit model
+ saveEditModel();
+ }
+
+ }
+ catch (Exception e)
+ {
+ return StatusUtils.errorStatus(ConsumptionUIMessages.MSG_ERROR_TASK_EXCEPTED, e);
+ }
+
+ return status;
+ }
+
+ private void saveEditModel() {
+ ArtifactEdit artifactEdit = null;
+ try {
+ if (J2EEUtils.isWebComponent(project_)) {
+ artifactEdit = WebArtifactEdit.getWebArtifactEditForWrite(project_);
+ }
+ else if (J2EEUtils.isEJBComponent(project_)){
+ artifactEdit = EJBArtifactEdit.getEJBArtifactEditForWrite(project_);
+ }
+ else if (J2EEUtils.isAppClientComponent(project_)){
+ artifactEdit = AppClientArtifactEdit.getAppClientArtifactEditForWrite(project_);
+ }
+ }
+ finally {
+ if (artifactEdit!=null) {
+ artifactEdit.save(null);
+ artifactEdit.dispose();
+ }
+ }
+ }
+
+ private void saveEditModel(IProject project){
+ project_ = project;
+ saveEditModel();
+ }
+
+ private void addHandlersToServiceRefs() {
+ try {
+ Enumeration refsToHandlers = newWSServiceRefsToHandlersTable_.keys();
+ while (refsToHandlers.hasMoreElements()) {
+ ServiceRef serviceRef = (ServiceRef) refsToHandlers.nextElement();
+ if (serviceRef != null) {
+ List handlers = (List) newWSServiceRefsToHandlersTable_.get(serviceRef);
+ List modelHandlers = (List) oldWSServiceRefsToHandlersTable_.get(serviceRef);
+ modelHandlers.clear();
+ modelHandlers.addAll(handlers);
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ public void setClientProject(IProject project) {
+ this.project_ = project;
+ }
+
+ /**
+ * An array of HandlerDescriptionHolders
+ * @return
+ */
+ public void setHandlerServiceRefHolder(HandlerServiceRefHolder[] handlerHolders){
+ this.handlerServiceRefHolder_ = handlerHolders;
+ }
+
+ public void setIsMultipleSelection(boolean isMulitpleSelection) {
+ this.isMultipleSelection_ = isMulitpleSelection;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientWizardWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientWizardWidget.java
new file mode 100644
index 000000000..a49785aa5
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientWizardWidget.java
@@ -0,0 +1,563 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2015 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060407 135415 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060417 136390/136159 joan@ca.ibm.com - Joan Haggarty
+ * 20060413 135581 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060420 135912 joan@ca.ibm.com - Joan Haggarty
+ * 20060424 138052 kathy@ca.ibm.com - Kathy Chan
+ * 20060425 137831 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060509 119296 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060529 141422 kathy@ca.ibm.com - Kathy Chan
+ * 20060612 145081 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060725 149351 makandre@ca.ibm.com - Andrew Mak, Deleted service definition keeps reappearing
+ * 20060803 152486 makandre@ca.ibm.com - Andrew Mak, Typing WSDL in Service definition field is very slow
+ * 20060817 140017 makandre@ca.ibm.com - Andrew Mak, longer project or server/runtime strings do not resize wizard
+ * 20060825 135570 makandre@ca.ibm.com - Andrew Mak, Service implementation URL not displayed properly on first page
+ * 20060829 155441 makandre@ca.ibm.com - Andrew Mak, web service wizard hangs during resize
+ * 20060907 156211 makandre@ca.ibm.com - Andrew Mak, Selecting service definition invalidated project config when creating web service java client
+ * 20061212 159911 makandre@ca.ibm.com - Andrew Mak, changing service definition resets some configuration fields
+ * 20060125 159911 kathy@ca.ibm.com - Kathy Chan, Remove unused method and imports
+ * 20080613 236523 makandre@ca.ibm.com - Andrew Mak, Overwrite setting on Web service wizard is coupled with preference
+ * 20090926 248448 mahutch@ca.ibm.com - Mark Hutchinson, Should not resize WS Wizard for long WSDL file names
+ * 20090302 242462 ericdp@ca.ibm.com - Eric D. Peters, Save Web services wizard settings
+ * 20090313 268567 ericdp@ca.ibm.com - Eric D. Peters, persisted wizard settings gone unless launching on object
+ * 20090326 269097 kchong@ca.ibm.com - Keith Chong, [Accessibility] Web services wizard dialog should be selected after canceling the Browse for class dialog
+ * 20150311 461526 jgwest@ca.ibm.com - Jonathan West, Allow OSGi bundles to be selected in the Wizard
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jst.ws.internal.consumption.common.WSDLParserFactory;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.command.data.EclipseIPath2URLStringTransformer;
+import org.eclipse.jst.ws.internal.consumption.ui.common.ValidationUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.Timer;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.jst.ws.internal.plugin.WebServicePlugin;
+import org.eclipse.jst.ws.internal.ui.common.ComboWithHistory;
+import org.eclipse.jst.ws.internal.ui.common.UIUtils;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.core.context.ResourceContext;
+import org.eclipse.wst.command.internal.env.ui.widgets.PageInfo;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributorFactory;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+
+
+public class ClientWizardWidget extends SimpleWidgetDataContributor implements Runnable
+{
+ private WebServiceClientTypeWidget clientWidget_;
+ private Button overwriteButton_;
+ private Button monitorService_;
+
+ private ComboWithHistory serviceImpl_;
+ private Button browseButton_;
+ private WSDLSelectionDialog wsdlDialog_;
+ private String componentName_;
+ private IProject project_;
+ private String webServiceURI_;
+ private WebServicesParser parser_;
+ private ResourceContext resourceContext_;
+
+ private Listener statusListener_;
+ private ModifyListener objectModifyListener_ ;
+ private int validationState_;
+ private boolean validObjectSelection_ = true;
+ private WSDLSelectionWidgetWrapper wsdlValidatorWidget_;
+
+ private Timer timer_ = null;
+
+ /* CONTEXT_ID WSWSCEN0020 for the Service Implemenation text field of the Scenario Page */
+ private String INFOPOP_WSWSCEN_TEXT_SERVICE_IMPL = "WSWSCEN0020";
+
+
+ /* CONTEXT_ID WSWSCEN0014 for the monitor service checkbox of the Scenario page */
+ private String INFOPOP_WSWSCEN_CHECKBOX_MONITOR_SERVICE = "WSWSCEN0014";
+ /* CONTEXT_ID WSWSCEN0030 for the Overwrite Files checkbox of the Scenario Page */
+ private String INFOPOP_WSWSCEN_CHECKBOX_OVERWRITE = "WSWSCEN0030";
+ /* CONTEXT_ID WSWSCEN0001 for the Scenario Page */
+ private String INFOPOP_WSWSCEN_PAGE = "WSWSCEN0001";
+
+ /**
+ * Run this ClientWizardWidget, which validates the entry field values.
+ */
+ public void run() {
+ validationState_ = ValidationUtils.VALIDATE_ALL;
+ statusListener_.handleEvent(null);
+ if (validObjectSelection_)
+ callObjectTransformation(project_,
+ wsdlValidatorWidget_.getComponentName(),
+ wsdlValidatorWidget_.getWsdlURI());
+ }
+
+ public WidgetDataEvents addControls( Composite parent, Listener statusListener)
+ {
+ String pluginId = "org.eclipse.jst.ws.consumption.ui";
+ UIUtils utils = new UIUtils( pluginId );
+ utils.createInfoPop(parent, INFOPOP_WSWSCEN_PAGE);
+
+ statusListener_ = statusListener;
+ validationState_ = ValidationUtils.VALIDATE_ALL;
+ // Create text field and browse for service selection
+ Composite typeComposite = utils.createComposite(parent, 3);
+ serviceImpl_ = utils.createComboWithHistory(typeComposite, ConsumptionUIMessages.LABEL_WEBSERVICEDEF,
+ ConsumptionUIMessages.TOOLTIP_WSWSCEN_TEXT_IMPL,
+ INFOPOP_WSWSCEN_TEXT_SERVICE_IMPL, SWT.LEFT | SWT.BORDER, WebServiceConsumptionUIPlugin.getInstance().getDialogSettings() );
+
+ Object layoutData = serviceImpl_.getLayoutData();
+ if (layoutData instanceof GridData) {
+ ((GridData)layoutData).widthHint = 225;
+ }
+
+ objectModifyListener_ = new ModifyListener(){
+ public void modifyText(ModifyEvent e) {
+ if (serviceImpl_.getText().indexOf(':') > 0) {
+ timer_ = Timer.newInstance(timer_, Display.getCurrent(), ClientWizardWidget.this);
+ timer_.startTimer();
+ }
+ else
+ run();
+ }
+ };
+
+ serviceImpl_.addModifyListener(objectModifyListener_);
+
+ browseButton_ = utils.createPushButton(typeComposite,
+ ConsumptionUIMessages.BUTTON_BROWSE, ConsumptionUIMessages.TOOLTIP_WSWSCEN_BUTTON_BROWSE_IMPL, null);
+
+ browseButton_.addSelectionListener(new WSDLBrowseListener());
+
+ utils.createHorizontalSeparator(parent, 1);
+
+ Composite clientComposite = utils.createComposite( parent, 1, 0, 0 );
+
+ clientWidget_ = new WebServiceClientTypeWidget(true);
+ clientWidget_.addControls(clientComposite , statusListener );
+
+ // Create test service check box.
+ Composite buttonGroup = utils.createComposite(clientComposite,1);
+
+ // Create monitor service check box.
+ monitorService_ = utils.createCheckbox(buttonGroup , ConsumptionUIMessages.CHECKBOX_MONITOR_WEBSERVICE,
+ ConsumptionUIMessages.TOOLTIP_PWPR_CHECKBOX_MONITOR_SERVICE,
+ INFOPOP_WSWSCEN_CHECKBOX_MONITOR_SERVICE);
+
+ //show overwrite if it is enabled in the preferences
+ if (getResourceContext().isOverwriteFilesEnabled()) {
+ Label prefSeparator = utils.createHorizontalSeparator(parent, 1);
+ prefSeparator.setText("File Options");
+ Composite prefButtonPanel = utils.createComposite(parent, 1);
+ overwriteButton_ = utils.createCheckbox(prefButtonPanel,
+ ConsumptionUIMessages.CHECKBOX_OVERWRITE_FILES,
+ ConsumptionUIMessages.TOOLTIP_WSWSCEN_BUTTON_OVERWRITE_FILES,
+ INFOPOP_WSWSCEN_CHECKBOX_OVERWRITE);
+ overwriteButton_.setSelection(getResourceContext()
+ .isOverwriteFilesEnabled());
+ overwriteButton_.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ getResourceContext().setOverwriteFilesEnabled(overwriteButton_.getSelection());
+ }
+ });
+ }
+ return this;
+ }
+
+ public void setResourceContext( ResourceContext context )
+ {
+ resourceContext_ = context;
+ }
+
+ public ResourceContext getResourceContext()
+ {
+ if (resourceContext_ == null) {
+ resourceContext_ = WebServicePlugin.getInstance()
+ .getResourceContext();
+ }
+ return resourceContext_;
+ }
+
+ public void setClientTypeRuntimeServer( TypeRuntimeServer ids )
+ {
+ clientWidget_.setTypeRuntimeServer( ids );
+ }
+
+ public void setClientProjectName(String name)
+ {
+ clientWidget_.setClientProjectName(name);
+ }
+
+ public void setClientEarProjectName(String name)
+ {
+ clientWidget_.setClientEarProjectName(name);
+ }
+
+ public void setClientComponentType(String name)
+ {
+ clientWidget_.setClientComponentType(name);
+ }
+
+ public void setClientNeedEAR(boolean b)
+ {
+ clientWidget_.setClientNeedEAR(b);
+ }
+
+ public String getClientRuntimeId()
+ {
+ return clientWidget_.getClientRuntimeId();
+ }
+
+
+ public String getClientEarProjectName()
+ {
+ if(clientWidget_.isOSGI()) {
+ return null;
+ } else {
+ return clientWidget_.getClientEarProjectName();
+ }
+ }
+
+ public String getClientOsgiAppProjectName() {
+ if(clientWidget_.isOSGI()) {
+ return clientWidget_.getClientEarProjectName();
+ } else {
+ return null;
+ }
+
+ }
+
+
+ public String getClientProjectName()
+ {
+ return clientWidget_.getClientProjectName();
+ }
+
+ public String getClientComponentType()
+ {
+ return clientWidget_.getClientComponentType();
+ }
+
+ public boolean getClientNeedEAR()
+ {
+ return clientWidget_.getClientNeedEAR();
+ }
+
+ public void setWebServiceURI(String uri)
+ {
+ webServiceURI_ = uri;
+ }
+ public void externalize() {
+ super.externalize();
+ if (getClientTypeRuntimeServer() != null ) {
+ serviceImpl_.storeWidgetHistory(getClientTypeRuntimeServer().getTypeId());
+ }
+ }
+public void internalize() {
+ serviceImpl_.removeModifyListener(objectModifyListener_);
+ if (webServiceURI_ != null && webServiceURI_.length() != 0)
+ serviceImpl_.setText(webServiceURI_);
+ if (getClientTypeRuntimeServer() != null ) {
+ serviceImpl_.restoreWidgetHistory(getClientTypeRuntimeServer().getTypeId());
+ }
+ serviceImpl_.addModifyListener(objectModifyListener_);
+
+ EclipseIPath2URLStringTransformer transformer = new EclipseIPath2URLStringTransformer();
+ webServiceURI_ = (String) transformer.transform(webServiceURI_);
+}
+
+ public void setProject(IProject project)
+ {
+ project_ = project;
+ }
+ public void setComponentName(String name)
+ {
+ componentName_ = name;
+ }
+
+ public String getWebServiceURI()
+ {
+ return webServiceURI_ ;
+ }
+
+ public String getWsdlURI()
+ {
+ return getWebServiceURI();
+ }
+
+ public IProject getProject()
+ {
+ return project_;
+ }
+
+ public String getComponentName()
+ {
+ return componentName_ ;
+ }
+
+ public WebServicesParser getWebServicesParser()
+ {
+ return WSDLParserFactory.getWSDLParser();
+ }
+
+ public void setWebServicesParser(WebServicesParser parser)
+ {
+ parser_ = getWebServicesParser();
+ clientWidget_.setWebServicesParser(parser_);
+ }
+
+ public TypeRuntimeServer getClientTypeRuntimeServer()
+ {
+ return clientWidget_.getTypeRuntimeServer();
+ }
+
+ public void setInstallClient( Boolean install)
+ {
+ clientWidget_.setInstallClient( install );
+ }
+
+ public Boolean getInstallClient()
+ {
+ return clientWidget_.getInstallClient();
+ }
+
+ public Boolean getTestService()
+ {
+ return clientWidget_.getTestClient();
+ }
+
+ public void setTestService( Boolean value )
+ {
+ clientWidget_.setTestClient(value);
+ }
+
+ public int getClientGeneration()
+ {
+ return clientWidget_.getClientGeneration();
+ }
+
+ public void setClientGeneration(int value)
+ {
+ clientWidget_.setClientGeneration(value);
+ }
+
+ public void setDevelopClient(boolean develop) {
+ clientWidget_.setDevelopClient( develop );
+ }
+
+ public boolean getDevelopClient() {
+ return clientWidget_.getDevelopClient();
+ }
+
+ public void setAssembleClient(boolean assemble) {
+ clientWidget_.setAssembleClient( assemble );
+ }
+
+ public boolean getAssembleClient() {
+ return clientWidget_.getAssembleClient();
+ }
+
+ public void setDeployClient(boolean deploy) {
+ clientWidget_.setDeployClient( deploy );
+ }
+
+ public boolean getDeployClient() {
+ return clientWidget_.getDeployClient();
+ }
+
+ public void setStartClient(Boolean start) {
+ clientWidget_.setStartClient( start );
+ }
+
+ public Boolean getStartClient() {
+ return clientWidget_.getStartClient();
+ }
+
+ public Boolean getMonitorService()
+ {
+ return new Boolean(monitorService_.getSelection());
+ }
+
+ public void setMonitorService(Boolean value)
+ {
+ monitorService_.setSelection(value.booleanValue());
+ }
+
+ public IStatus getStatus() {
+
+ validObjectSelection_ = false; // assume false at first
+
+ IStatus missingFieldStatus = checkMissingFieldStatus();
+ if (missingFieldStatus.getSeverity() == IStatus.ERROR) {
+ return missingFieldStatus;
+ }
+
+ IStatus invalidServiceImplStatus = checkServiceImplTextStatus();
+ if (invalidServiceImplStatus.getSeverity() == IStatus.ERROR) {
+ return invalidServiceImplStatus;
+ }
+
+ IStatus possibleErrorStatus = checkErrorStatus();
+ if (possibleErrorStatus.getSeverity() == IStatus.ERROR) {
+ return possibleErrorStatus;
+ }
+
+ IStatus possibleWarningStatus = checkWarningStatus();
+ if (possibleWarningStatus.getSeverity() == IStatus.WARNING) {
+ return possibleWarningStatus;
+ }
+
+ // if no errors or warnings were found, clear the validation state.
+ validationState_ = ValidationUtils.VALIDATE_NONE;
+ clientWidget_.setValidationState(ValidationUtils.VALIDATE_NONE);
+
+ return Status.OK_STATUS;
+ }
+
+ private IStatus checkMissingFieldStatus() {
+
+ if (validationState_ == ValidationUtils.VALIDATE_ALL) {
+ if (serviceImpl_.getText().trim().length() == 0) {
+ return StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_NO_SERVICE_SELECTION, new String[]{ConsumptionUIMessages.LABEL_WEBSERVICEIMPL}));
+ }
+ }
+
+ IStatus clientMissingFieldsStatus = clientWidget_.checkMissingFieldStatus();
+ if (clientMissingFieldsStatus.getSeverity() == IStatus.ERROR) {
+ return clientMissingFieldsStatus;
+ }
+
+ return Status.OK_STATUS;
+
+ }
+
+ private IStatus checkErrorStatus() {
+ IStatus clientSideErrorStatus = clientWidget_.checkErrorStatus();
+ if (clientSideErrorStatus.getSeverity() == IStatus.ERROR) {
+ return clientSideErrorStatus;
+ }
+ return Status.OK_STATUS;
+ }
+
+ private IStatus checkWarningStatus() {
+ IStatus clientWarningStatus = clientWidget_.checkWarningStatus();
+ if (clientWarningStatus.getSeverity() == IStatus.WARNING) {
+ return clientWarningStatus;
+ }
+ return Status.OK_STATUS;
+ }
+
+ /*call validation code in the object selection widget to ensure
+ any modifications to the serviceImpl_ field are valid*/
+ private IStatus checkServiceImplTextStatus() {
+
+ String fieldText = serviceImpl_.getText().trim();
+
+ if (wsdlValidatorWidget_ == null)
+ wsdlValidatorWidget_ = new WSDLSelectionWidgetWrapper();
+
+ validObjectSelection_ = wsdlValidatorWidget_.validate(fieldText);
+
+ if (!validObjectSelection_)
+ {
+ return StatusUtils.errorStatus(ConsumptionUIMessages.MSG_INVALID_SERVICE_DEF);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ private void callObjectTransformation(IProject project, String componentName,
+ String wsdlURI)
+ {
+ WSDLSelectionOutputCommand wsdlOutputCommand = new WSDLSelectionOutputCommand();
+ wsdlOutputCommand.setComponentName(componentName);
+ wsdlOutputCommand.setProject(project);
+ wsdlOutputCommand.setWsdlURI(wsdlURI);
+ wsdlOutputCommand.setTestService(getTestService().booleanValue());
+ wsdlOutputCommand.setWebServicesParser(getWebServicesParser());
+
+ wsdlOutputCommand.execute(null, null);
+
+ setComponentName(wsdlOutputCommand.getComponentName());
+ setProject(wsdlOutputCommand.getProject());
+ setWebServicesParser(wsdlOutputCommand.getWebServicesParser());
+ setWebServiceURI(wsdlOutputCommand.getWsdlURI());
+
+ // bug 159911: our starting point is a wsdl, we should not need to
+ // refresh the runtime everytime the user specify a new wsdl path
+ // refreshClientRuntimeSelection();
+ }
+
+ private class WSDLBrowseListener implements SelectionListener
+ {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ public void widgetSelected(SelectionEvent e) {
+
+ // bug 269097 - Use the Web Service Client's dialog shell, not the platform workbench's shell.
+ wsdlDialog_ = new WSDLSelectionDialog(Display.getCurrent().getActiveShell(),
+ new PageInfo(ConsumptionUIMessages.DIALOG_TITILE_SERVICE_IMPL_SELECTION, "",
+ new WidgetContributorFactory()
+ {
+ public WidgetContributor create()
+ {
+ return new WSDLSelectionWidgetWrapper();
+ }
+ }));
+
+ wsdlDialog_.setComponentName(getComponentName());
+ wsdlDialog_.setProject(getProject());
+ wsdlDialog_.setWebServiceURI( serviceImpl_.getText() );
+
+ int result = wsdlDialog_.open();
+
+ if (result == Dialog.OK)
+ {
+ serviceImpl_.removeModifyListener(objectModifyListener_);
+ serviceImpl_.setText(wsdlDialog_.getDisplayableSelectionString());
+ serviceImpl_.addModifyListener(objectModifyListener_);
+
+ // call WSDLSelectionOutputCommand to carry out any transformation on the objectSelection
+ callObjectTransformation(project_,
+ wsdlDialog_.getComponentName(), wsdlDialog_.getWebServiceURI());
+
+ validationState_ = ValidationUtils.VALIDATE_ALL;
+ clientWidget_.setValidationState(ValidationUtils.VALIDATE_ALL);
+ statusListener_.handleEvent(null); //validate the page
+ }
+ wsdlDialog_ = null;
+ }
+ }
+}
+
+
+
+
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientWizardWidgetDefaultingCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientWizardWidgetDefaultingCommand.java
new file mode 100644
index 000000000..9892c8b3e
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientWizardWidgetDefaultingCommand.java
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060221 119111 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060524 142635 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20060529 141422 kathy@ca.ibm.com - Kathy Chan
+ * 20060728 150560 kathy@ca.ibm.com - Kathy Chan
+ * 20060728 151078 kathy@ca.ibm.com - Kathy Chan
+ * 20080402 225378 makandre@ca.ibm.com - Andrew Mak, Client wizard runtime/server defaulting is not respecting the preference
+ * 20080528 234487 makandre@ca.ibm.com - Andrew Mak, Performance degradation in Web service client gen
+ * 20080613 236523 makandre@ca.ibm.com - Andrew Mak, Overwrite setting on Web service wizard is coupled with preference
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.core.commands.ExecutionException;
+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.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils2;
+import org.eclipse.jst.ws.internal.context.ScenarioContext;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.jst.ws.internal.plugin.WebServicePlugin;
+import org.eclipse.wst.command.internal.env.core.context.ResourceContext;
+import org.eclipse.wst.command.internal.env.eclipse.BaseEclipseEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+
+
+public class ClientWizardWidgetDefaultingCommand extends AbstractDataModelOperation
+{
+ private int clientGeneration_;
+ private boolean developClient_;
+ private boolean assembleClient_;
+ private boolean deployClient_;
+ private boolean installClient_;
+ private boolean startClient_;
+ private boolean testClient_;
+ private boolean clientOnly_ = false;
+ private TypeRuntimeServer clientTypeRuntimeServer_;
+
+ public ClientWizardWidgetDefaultingCommand() {
+ }
+
+
+ /**
+ * @param clientOnly Set to true for if called from ClientWidgetWizard
+ */
+ public ClientWizardWidgetDefaultingCommand(boolean clientOnly) {
+ clientOnly_ = clientOnly;
+ }
+
+ public Boolean getTestService()
+ {
+ return new Boolean( getScenarioContext().getTestWebService() );
+ }
+
+ public Boolean getMonitorService()
+ {
+ return new Boolean( getScenarioContext().getMonitorWebService());
+ }
+
+ public boolean getInstallClient()
+ {
+ return installClient_;
+ }
+
+ public boolean getRunTestClient()
+ {
+ return getScenarioContext().isLaunchSampleEnabled() ;
+ }
+
+ public int getClientGeneration()
+ {
+ return clientGeneration_;
+ }
+
+ public ResourceContext getResourceContext()
+ {
+ return ((BaseEclipseEnvironment) getEnvironment()).getResourceContext();
+ }
+
+ // Current ScenarioContext is used to default the first page of the wizard. The
+ // properties in ScenarioContext are mapped individual. Therefore, ScenarioContext
+ // should not also be mapped.
+ protected ScenarioContext getScenarioContext()
+ {
+ return WebServicePlugin.getInstance().getScenarioContext();
+ }
+
+ // TODO Set client name defaults here.
+ public TypeRuntimeServer getClientTypeRuntimeServer()
+ {
+ if (clientTypeRuntimeServer_ == null) {
+ String type = getScenarioContext().getClientWebServiceType();
+ String runtime = WebServiceRuntimeExtensionUtils2.getDefaultClientRuntimeValueFor(type);
+ String factoryID = WebServiceRuntimeExtensionUtils2.getDefaultClientServerValueFor(type);
+ clientTypeRuntimeServer_ = new TypeRuntimeServer();
+
+ clientTypeRuntimeServer_.setTypeId( type );
+ clientTypeRuntimeServer_.setRuntimeId( runtime );
+ clientTypeRuntimeServer_.setServerId( factoryID );
+ }
+
+ return clientTypeRuntimeServer_;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ defaultClientScale();
+ return Status.OK_STATUS;
+ }
+
+ protected void defaultClientScale() {
+ clientGeneration_ = getScenarioContext().getGenerateClient();
+
+ if (clientOnly_ && clientGeneration_ == ScenarioContext.WS_NONE) {
+ developClient_ = true;
+ assembleClient_ = true;
+ deployClient_ = true;
+ clientGeneration_ = ScenarioContext.WS_DEPLOY;
+ } else {
+ developClient_ = clientGeneration_ <= ScenarioContext.WS_DEVELOP;
+ assembleClient_ = clientGeneration_ <= ScenarioContext.WS_ASSEMBLE;
+ deployClient_ = clientGeneration_ <= ScenarioContext.WS_DEPLOY;
+ }
+ installClient_ = clientGeneration_ <= ScenarioContext.WS_INSTALL;
+ startClient_ = clientGeneration_ <= ScenarioContext.WS_START;
+ testClient_ = clientGeneration_ <= ScenarioContext.WS_TEST;
+ }
+
+ public boolean getDevelopClient() {
+ return developClient_;
+ }
+
+ public boolean getAssembleClient() {
+ return assembleClient_;
+ }
+
+ public boolean getDeployClient() {
+ return deployClient_;
+ }
+
+ public boolean getStartClient() {
+ return startClient_;
+ }
+
+ public boolean getTestClient() {
+ return testClient_;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientWizardWidgetOutputCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientWizardWidgetOutputCommand.java
new file mode 100644
index 000000000..35511e131
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ClientWizardWidgetOutputCommand.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060524 142635 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20060529 141422 kathy@ca.ibm.com - Kathy Chan
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.core.commands.ExecutionException;
+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.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.wst.command.internal.env.core.context.ResourceContext;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+
+
+public class ClientWizardWidgetOutputCommand extends AbstractDataModelOperation
+{
+ private boolean testService_;
+ private boolean monitorService;
+ private ResourceContext resourceContext_;
+ private TypeRuntimeServer clientIds_;
+ private boolean installClient_;
+
+ private String webServiceURI_;
+ private IProject project_;
+ private String componentName_;
+ private boolean runTestClient_;
+ private boolean developClient_;
+ private boolean assembleClient_;
+ private boolean deployClient_;
+ private boolean startClient_;
+ private boolean testClient_;
+
+ public boolean getTestService()
+ {
+ return testService_;
+ }
+
+ public void setTestService( boolean testService )
+ {
+ testService_ = testService;
+ }
+
+ public boolean getRunTestClient()
+ {
+ return runTestClient_;
+ }
+
+ public void setRunTestClient( boolean runTestClient )
+ {
+ runTestClient_ = runTestClient;
+ }
+
+ public void setInstallClient( boolean installClient)
+ {
+ installClient_ = installClient;
+ }
+
+ public boolean getInstallClient()
+ {
+ return installClient_;
+ }
+
+ public boolean getDevelopClient() {
+ return developClient_;
+ }
+
+ public void setDevelopClient(boolean developClient) {
+ this.developClient_ = developClient;
+ }
+
+ public boolean getAssembleClient() {
+ return assembleClient_;
+ }
+
+ public void setAssembleClient(boolean assembleClient) {
+ this.assembleClient_ = assembleClient;
+ }
+
+ public boolean getDeployClient() {
+ return deployClient_;
+ }
+
+ public void setDeployClient(boolean deployClient) {
+ this.deployClient_ = deployClient;
+ }
+
+ public boolean getStartClient() {
+ return startClient_;
+ }
+
+ public void setStartClient(boolean startClient) {
+ this.startClient_ = startClient;
+ }
+
+ public boolean getTestClient() {
+ return testClient_;
+ }
+
+ public void setTestClient(boolean testClient) {
+ this.testClient_ = testClient;
+ }
+ public boolean getMonitorService()
+ {
+ return monitorService;
+ }
+
+ public void setMonitorService(boolean monitorService)
+ {
+ this.monitorService = monitorService;
+ }
+
+ public ResourceContext getResourceContext()
+ {
+
+ return resourceContext_;
+ }
+
+ public void setResourceContext( ResourceContext context )
+ {
+ resourceContext_ = context;
+ }
+
+ public TypeRuntimeServer getClientTypeRuntimeServer()
+ {
+ return clientIds_;
+ }
+
+ public void setClientTypeRuntimeServer( TypeRuntimeServer clientIds )
+ {
+ clientIds_ = clientIds;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ return Status.OK_STATUS;
+ }
+
+ public String getWsdlURI()
+ {
+ return webServiceURI_ ;
+ }
+
+ public void setWsdlURI(String uri)
+ {
+ webServiceURI_ = uri;
+ }
+
+ public void setProject(IProject project)
+ {
+ project_ = project;
+ }
+
+ public IProject getProject()
+ {
+ return project_;
+ }
+
+ public void setComponentName(String name)
+ {
+ componentName_ = name;
+ }
+
+ public String getComponentName()
+ {
+ return componentName_ ;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ConfigClientHandlersTableWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ConfigClientHandlersTableWidget.java
new file mode 100644
index 000000000..c615cce7c
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ConfigClientHandlersTableWidget.java
@@ -0,0 +1,637 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu
+ * 20060426 135614 sengpl@ca.ibm.com - Seng Phung-Lu
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jst.j2ee.webservice.wsclient.ServiceRef;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.common.HandlerServiceRefHelper;
+import org.eclipse.jst.ws.internal.consumption.ui.common.HandlerServiceRefHolder;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.HandlerTableItem;
+import org.eclipse.jst.ws.internal.ui.common.UIUtils;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+
+/**
+ * ConfigClientHandlersTreeWidget
+ *
+ */
+public class ConfigClientHandlersTableWidget extends SimpleWidgetDataContributor {
+
+ private String pluginId_ = "org.eclipse.jst.ws.consumption.ui";
+
+ private Composite parent_;
+ private String outputLocation_;
+ private Composite webServiceRefComp_;
+ private Combo webServiceRefCombo_;
+ private Text webServiceDescText_ = null;
+ private Table handlersTable_;
+ private TableViewer tableViewer_;
+ private Button addButton_;
+ private Button removeButton_;
+ private Button genSkeletonRadioButton_;
+ private Composite sourceLocationComp_;
+ private Combo sourceLocationCombo_;
+
+ private HandlerServiceRefHolder[] handlerServiceRefHolder_;
+ private HandlerServiceRefHolder currentHSRH_;
+ private Hashtable pathsTable_ = new Hashtable();
+ private boolean isMultipleSelection_ = false;
+ private boolean isGenSkeletonEnabled_;
+ private String serviceRefName_;
+ private int DEFAULT_COLUMN_WIDTH = 150;
+
+ // ----TOOLTIPS Section----
+ /* CONTEXT_ID HDLR0001 for the Handler Config Page */
+ private final String INFOPOP_HDLR_WS_HANDLERS = "HDLR0001"; //$NON-NLS-1$
+
+ /* CONTEXT_ID HDLR0002 for the Handler Config Page */
+ private final String INFOPOP_HDLR_GEN_SKELETON = "HDLR0002"; //$NON-NLS-1$
+
+ /* CONTEXT_ID HDLR0003 for the Handler Config Page */
+ private final String INFOPOP_COMBO_SOURCE_LOC = "HDLR0003"; //$NON-NLS-1$
+
+ /* CONTEXT_ID HDLR0004 for the Handler Config Page */
+ private final String INFOPOP_WS_CLIENT_REF = "HDLR0004"; //$NON-NLS-1$
+
+ // ------------------------
+
+ public ConfigClientHandlersTableWidget() {
+ super();
+ }
+
+ public WidgetDataEvents addControls(Composite parent, Listener statusListener) {
+
+ UIUtils uiUtils = new UIUtils(pluginId_);
+
+ parent_ = parent;
+
+ // Web service reference combo
+ webServiceRefComp_ = uiUtils.createComposite(parent_, 2);
+
+ Composite displayComp = new Composite(parent_, SWT.NONE);
+ GridLayout gridlayout = new GridLayout(2, false);
+ displayComp.setLayout(gridlayout);
+ displayComp.setLayoutData(uiUtils.createFillAll());
+
+ final Composite handlersComp = uiUtils.createComposite(displayComp, 1);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL |GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING
+ | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL | GridData.FILL_VERTICAL);
+ handlersComp.setLayoutData(griddata);
+ handlersComp.setSize(130, 600);
+
+ Composite buttonsComp = uiUtils.createComposite(displayComp, 1);
+ griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+ buttonsComp.setLayoutData(griddata);
+
+ Text handlersText = new Text(handlersComp, SWT.READ_ONLY);
+ handlersText.setText(ConsumptionUIMessages.LABEL_HANDLERS_CONFIG);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ handlersText.setLayoutData(gd);
+
+ handlersTable_ = uiUtils.createTable(handlersComp, ConsumptionUIMessages.TOOLTIP_EDIT_WS_HANDLERS, INFOPOP_HDLR_WS_HANDLERS, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
+ handlersTable_.setHeaderVisible(true);
+ handlersTable_.setLinesVisible(true);
+
+ // empty space
+ Label wsLabel = new Label(buttonsComp, SWT.NONE);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ wsLabel.setLayoutData(gd);
+
+ Button moveUpButton = uiUtils.createPushButton(buttonsComp, ConsumptionUIMessages.LABEL_BUTTON_MOVE_UP, null, null);
+ GridData muGriddata = new GridData();
+ Point musize = moveUpButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ moveUpButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleMoveUpButtonSelected(event);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+
+ Button moveDownButton = uiUtils.createPushButton(buttonsComp, ConsumptionUIMessages.LABEL_BUTTON_MOVE_DOWN, null, null);
+ GridData mdGriddata = new GridData();
+ Point mdsize = moveDownButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ moveDownButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleMoveDownButtonSelected(event);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+
+ // empty space
+ wsLabel = new Label(buttonsComp, SWT.NONE);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ wsLabel.setLayoutData(gd);
+
+ addButton_ = uiUtils.createPushButton(buttonsComp, ConsumptionUIMessages.LABEL_BUTTON_ADD, null, null);
+ GridData addGriddata = new GridData();
+ Point addSize = addButton_.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ addButton_.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleAddButtonSelected(event);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+
+ removeButton_ = uiUtils.createPushButton(buttonsComp, ConsumptionUIMessages.LABEL_BUTTON_REMOVE, null, null);
+ GridData remGriddata = new GridData();
+ Point remSize = removeButton_.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ removeButton_.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleRemoveButtonSelected(event);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+ enableRemove(false);
+
+ // set the width to the max of the button labels
+ int widthHint = 0;
+ int[] sizes = new int[]{musize.x, mdsize.x, addSize.x, remSize.x, 100};
+ for(int j = 0; j < sizes.length; j++) {
+ if (sizes[j] > widthHint)
+ widthHint = sizes[j];
+ }
+ muGriddata.widthHint = widthHint;
+ mdGriddata.widthHint = widthHint;
+ addGriddata.widthHint = widthHint;
+ remGriddata.widthHint = widthHint;
+
+ moveUpButton.setLayoutData(muGriddata);
+ moveDownButton.setLayoutData(mdGriddata);
+ addButton_.setLayoutData(addGriddata);
+ removeButton_.setLayoutData(remGriddata);
+
+ // table stuff
+ String[] columns_ = new String[] { ConsumptionUIMessages.LABEL_HANDLER_NAME, ConsumptionUIMessages.LABLE_HANDLER_CLASS};
+
+ final TableColumn[] tableCols = new TableColumn[columns_.length];
+ for (int i = 0; i < columns_.length; i++) {
+ TableColumn tableColumn = new TableColumn(handlersTable_, i);
+ tableColumn.setText(columns_[i]);
+ tableColumn.setAlignment(SWT.LEFT);
+ tableColumn.setWidth(DEFAULT_COLUMN_WIDTH);
+ tableColumn.setResizable(true);
+ tableCols[i] = tableColumn;
+ }
+
+ handlersComp.addControlListener(new ControlAdapter() {
+ public void controlResized(ControlEvent e) {
+ Rectangle area = handlersComp.getClientArea();
+ Point preferredSize = handlersTable_.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ int width = area.width - 2*handlersTable_.getBorderWidth()-10;
+ if (preferredSize.y > area.height + handlersTable_.getHeaderHeight()) {
+ // Subtract the scrollbar width from the total column width
+ // if a vertical scrollbar will be required
+ Point vBarSize = handlersTable_.getVerticalBar().getSize();
+ width -= vBarSize.x;
+ }
+ Point oldSize = handlersTable_.getSize();
+ if (oldSize.x > area.width) {
+ // table is getting smaller so make the columns
+ // smaller first and then resize the table to
+ // match the client area width
+ tableCols[0].setWidth(width/2);
+ tableCols[1].setWidth(width - tableCols[0].getWidth());
+ handlersTable_.setSize(area.width, area.height);
+ } else {
+ // table is getting bigger so make the table
+ // bigger first and then make the columns wider
+ // to match the client area width
+ handlersTable_.setSize(area.width, area.height);
+ tableCols[0].setWidth(width/2);
+ tableCols[1].setWidth(width - tableCols[0].getWidth());
+ }
+ }
+ });
+
+ tableViewer_ = new TableViewer(handlersTable_);
+ Control control = tableViewer_.getControl();
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ data.verticalAlignment = GridData.FILL;
+ data.grabExcessVerticalSpace = true;
+ control.setLayoutData(data);
+
+ tableViewer_.setColumnProperties(columns_);
+ tableViewer_.setContentProvider(new ListContentProvider());
+ tableViewer_.setLabelProvider(new ListLabelProvider());
+ tableViewer_.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ enableRemove(true);
+ }
+ });
+
+ // gen skeleton check box
+ genSkeletonRadioButton_ = uiUtils.createCheckbox(parent_, ConsumptionUIMessages.LABEL_BUTTON_GEN_SKELETON, ConsumptionUIMessages.TOOLTIP_BUTTON_GEN_SKELETON, INFOPOP_HDLR_GEN_SKELETON);
+ genSkeletonRadioButton_.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ handleGenSkeletonRadioButton();
+ }
+ });
+
+ // source location combo
+ sourceLocationComp_ = uiUtils.createComposite(parent_, 2);
+ sourceLocationCombo_ = uiUtils.createCombo(sourceLocationComp_, ConsumptionUIMessages.LABEL_COMBO_SOURCE_LOC, ConsumptionUIMessages.TOOLTIP_COMBO_SOURCE_LOC, INFOPOP_COMBO_SOURCE_LOC,
+ SWT.READ_ONLY);
+ sourceLocationCombo_.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ handleSourceLocationCombo(evt);
+ }
+ });
+
+ return this;
+ }
+
+ // Called at start
+ private void populateHandlersTable() {
+ try {
+ UIUtils uiUtils = new UIUtils(pluginId_);
+
+ // process for multiple service selection
+ if (isMultipleSelection_) {
+ webServiceDescText_ = uiUtils.createText(webServiceRefComp_, ConsumptionUIMessages.LABEL_COMBO_WS_CLIENT_REF,
+ ConsumptionUIMessages.TOOLTIP_WS_CLIENT_REF, INFOPOP_WS_CLIENT_REF, SWT.READ_ONLY);
+ if (handlerServiceRefHolder_!=null){
+ currentHSRH_ = handlerServiceRefHolder_[0];
+ String text = NLS.bind(ConsumptionUIMessages.MSG_TEXT_NUM_OF_CLIENTS, Integer.toString(handlerServiceRefHolder_.length));
+ webServiceDescText_.setText(text);
+ }
+
+ genSkeletonRadioButton_.setSelection(false);
+ genSkeletonRadioButton_.setEnabled(false);
+ genSkeletonRadioButton_.setVisible(false);
+
+ sourceLocationComp_.setVisible(false);
+ sourceLocationCombo_.setEnabled(false);
+ sourceLocationCombo_.setVisible(false);
+
+ refresh();
+
+ }
+ else {
+
+ webServiceRefCombo_ = uiUtils.createCombo(webServiceRefComp_, ConsumptionUIMessages.LABEL_COMBO_WS_CLIENT_REF,
+ ConsumptionUIMessages.TOOLTIP_WS_CLIENT_REF, INFOPOP_WS_CLIENT_REF, SWT.READ_ONLY);
+ webServiceRefCombo_.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleWebServiceRefCombo(evt);
+ }
+ });
+
+ String[] wsRefNames = HandlerServiceRefHelper.getAllServiceRefNames(handlerServiceRefHolder_);
+ webServiceRefCombo_.setItems(wsRefNames);
+
+ if (handlerServiceRefHolder_.length < 1) {
+ webServiceRefCombo_.select(0);
+ webServiceRefCombo_.setEnabled(false);
+ }
+ else {
+ if (serviceRefName_ != null) {
+ int index = webServiceRefCombo_.indexOf(serviceRefName_);
+ if (index != -1) webServiceRefCombo_.select(index);
+ }
+ else
+ webServiceRefCombo_.select(0);
+ }
+
+ // set handler table
+ HandlerServiceRefHolder hsrh = HandlerServiceRefHelper.getForServiceRefName(handlerServiceRefHolder_, webServiceRefCombo_.getText());
+ if (hsrh != null) {
+ currentHSRH_ = hsrh;
+ List handlers = hsrh.getHandlerList();
+ tableViewer_.setInput(handlers);
+ tableViewer_.refresh();
+ }
+
+ // set output folder
+ setSourceOutputLocation();
+ }
+ parent_.getShell().setSize(530, 650);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.env.ui.widgets.WidgetContributor#getStatus()
+ */
+ public IStatus getStatus() {
+ IStatus finalStatus = Status.OK_STATUS;
+ if (isMultipleSelection_)
+ return StatusUtils.infoStatus(ConsumptionUIMessages.PAGE_DESC_MULTIPLE_CLIENTS_CONFIG);
+ return finalStatus;
+ }
+
+ protected void handleAddButtonSelected(SelectionEvent event) {
+
+ AddHandlerDialog dialog = new AddHandlerDialog(parent_.getShell(), true);
+ dialog.create();
+ dialog.getShell().setSize( 500, 200 );
+
+ int result = dialog.open();
+
+ if (result == Window.OK) {
+ String name = dialog.getName();
+ String className = dialog.getClassName();
+
+ HandlerTableItem hi = new HandlerTableItem();
+ hi.setHandlerName(name);
+ hi.setHandlerClassName(className);
+
+ ServiceRef serviceRef = currentHSRH_.getServiceRef();
+ hi.setWsDescRef(serviceRef);
+ currentHSRH_.getHandlerList().add(hi);
+ }
+
+ refresh();
+ }
+
+ protected void handleRemoveButtonSelected(SelectionEvent event) {
+ handleDeleteKeyPressed();
+ }
+
+ protected void handleMoveUpButtonSelected(SelectionEvent event) {
+
+ int index = tableViewer_.getTable().getSelectionIndex();
+ if (index != -1) {
+ if (index > 0) {
+ if (currentHSRH_!=null) {
+ List handlers = currentHSRH_.getHandlerList();
+ Object object = handlers.remove(index);
+ handlers.add( index - 1, object);
+ tableViewer_.refresh();
+ }
+ }
+ }
+
+ }
+
+ protected void handleMoveDownButtonSelected(SelectionEvent event) {
+
+ int index = tableViewer_.getTable().getSelectionIndex();
+ if (index != -1) {
+ if (currentHSRH_!=null){
+ List handlers = currentHSRH_.getHandlerList();
+ if (index < handlers.size() - 1) {
+ Object object = handlers.remove(index);
+ handlers.add(index + 1, object);
+ tableViewer_.refresh();
+ }
+ }
+ }
+
+ }
+
+ protected void handleSourceLocationCombo(SelectionEvent event) {
+ outputLocation_ = sourceLocationCombo_.getText();
+ IPath outputPath = (IPath) pathsTable_.get(outputLocation_);
+ currentHSRH_.setSourceOutputPath(outputPath);
+ }
+
+ protected void handleGenSkeletonRadioButton() {
+ if (genSkeletonRadioButton_.isEnabled()) {
+ if (genSkeletonRadioButton_.getSelection()) {
+ this.isGenSkeletonEnabled_ = true;
+ sourceLocationCombo_.setEnabled(true);
+ }
+ else {
+ this.isGenSkeletonEnabled_ = false;
+ sourceLocationCombo_.setEnabled(false);
+ }
+ }
+ }
+
+ protected void handleWebServiceRefCombo(SelectionEvent event) {
+
+ if (webServiceRefCombo_!=null && webServiceRefCombo_.isEnabled()) {
+ HandlerServiceRefHolder hsrh = HandlerServiceRefHelper.getForServiceRefName(handlerServiceRefHolder_, webServiceRefCombo_.getText());
+ currentHSRH_ = hsrh;
+ refresh();
+ }
+
+ if (isGenSkeletonEnabled_){
+ setSourceOutputLocation();
+ }
+
+ }
+
+ /**
+ * @return Returns the isGenSkeletonEnabled_.
+ */
+ public boolean isGenSkeletonEnabled_() {
+ return isGenSkeletonEnabled_;
+ }
+
+ protected class ListLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object object, int columnIndex) {
+
+ if (object instanceof HandlerTableItem) {
+ HandlerTableItem hti = (HandlerTableItem) object;
+ if (columnIndex == 0) {
+
+ return hti.getHandlerName() != null ? hti.getHandlerName() : "";
+ }
+ else if (columnIndex == 1) { return hti.getHandlerClassName() != null ? hti.getHandlerClassName() : ""; }
+ }
+ return null;
+ }
+
+ }
+
+ private void enableRemove(boolean enabled) {
+ removeButton_.setEnabled(enabled && !tableViewer_.getSelection().isEmpty());
+ }
+
+ protected class ListContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object element) {
+ if (element instanceof Vector) { return ((Vector) element).toArray(); }
+ return null;
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object old, Object newobj) {
+ }
+
+ public boolean isDeleted(Object object) {
+ return false;
+ }
+ }
+
+ protected void handleDeleteKeyPressed() {
+ ISelection selection = tableViewer_.getSelection();
+ if (selection != null && !selection.isEmpty() && (selection instanceof IStructuredSelection)) {
+ int selectionIndex = handlersTable_.getSelectionIndex();
+ if (currentHSRH_!=null){
+ currentHSRH_.getHandlerList().remove(selectionIndex);
+ }
+ refresh();
+ }
+ }
+
+ public void refresh() {
+
+ try {
+ tableViewer_.setInput(null);
+ if (currentHSRH_!=null){
+ List handlers = currentHSRH_.getHandlerList();
+ tableViewer_.setInput(handlers);
+ tableViewer_.refresh();
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public void setGenSkeletonEnabled(boolean isGenSkeletonEnabled) {
+ this.isGenSkeletonEnabled_ = isGenSkeletonEnabled;
+ genSkeletonRadioButton_.setSelection(isGenSkeletonEnabled);
+
+ }
+
+ public boolean getGenSkeletonEnabled() {
+ return this.isGenSkeletonEnabled_;
+ }
+
+ private void setSourceOutputLocation(){
+ if (currentHSRH_!=null){
+ IProject project = currentHSRH_.getProject();
+ if (project!=null){
+ IPath[]locations = ResourceUtils.getAllJavaSourceLocations(project);
+ String[] paths = new String[locations.length];
+ for (int i = 0; i < locations.length; i++) {
+ paths[i] = locations[i].toString();
+ pathsTable_.put(paths[i], locations[i]);
+ }
+ sourceLocationCombo_.setItems(paths);
+ sourceLocationCombo_.select(0);
+ }
+
+ // set in model
+ outputLocation_ = sourceLocationCombo_.getText();
+ IPath outputPath = (IPath) pathsTable_.get(outputLocation_);
+ currentHSRH_.setSourceOutputPath(outputPath);
+ }
+ }
+
+ /**
+ * Called at the beginning
+ */
+ public void internalize(){
+ populateHandlersTable();
+ }
+
+ /**
+ * Initial selection
+ * @param wsRefName
+ */
+ public void setServiceRefName(String wsRefName) {
+ serviceRefName_ = wsRefName;
+ }
+
+ /**
+ * true if multiple clients are selected
+ * @param isMulitpleSelection
+ */
+ public void setIsMultipleSelection(boolean isMulitpleSelection) {
+ this.isMultipleSelection_ = isMulitpleSelection;
+ }
+
+ /**
+ * An array of HandlerDescriptionHolders
+ * @return
+ */
+ public void setHandlerServiceRefHolder(HandlerServiceRefHolder[] handlerHolders){
+ this.handlerServiceRefHolder_ = handlerHolders;
+ }
+
+ public HandlerServiceRefHolder[] getHandlerServiceRefHolder(){
+ return this.handlerServiceRefHolder_;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ConfigServiceHandlersTableWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ConfigServiceHandlersTableWidget.java
new file mode 100644
index 000000000..37b15ead0
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ConfigServiceHandlersTableWidget.java
@@ -0,0 +1,685 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu
+ * 20060426 135614 sengpl@ca.ibm.com - Seng Phung-Lu
+ * 20060529 143518 sengpl@ca.ibm.com - Seng Phung-Lu
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jst.j2ee.webservice.wsdd.PortComponent;
+import org.eclipse.jst.j2ee.webservice.wsdd.WebServiceDescription;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.common.HandlerDescriptionHelper;
+import org.eclipse.jst.ws.internal.consumption.ui.common.HandlerDescriptionHolder;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.HandlerTableItem;
+import org.eclipse.jst.ws.internal.ui.common.UIUtils;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+
+/**
+ * ConfigServiceHandlersTreeWidget
+ *
+ */
+public class ConfigServiceHandlersTableWidget extends SimpleWidgetDataContributor {
+
+ private String pluginId_ = "org.eclipse.jst.ws.consumption.ui";
+
+ private Composite parent_;
+ private Table handlersTable_;
+ private TableViewer tableViewer_;
+ private Composite webServiceDescComp_;
+ private Combo webServiceDescCombo_ = null;
+ private Text webServiceDescText_ = null;
+ private Button addButton_;
+ private Button removeButton_;
+ private Button genSkeletonRadioButton_;
+ private Composite sourceLocationComp_;
+ private Combo sourceLocationCombo_;
+
+ private HandlerDescriptionHolder[] handlerDescriptionHolder_;
+ private HandlerDescriptionHolder currentHDH_;
+ private Hashtable pathsTable_ = new Hashtable(); // available paths for combo
+ private String outputLocation_; // selected path from combo
+ private String descriptionName_ = null;
+ private boolean isMultipleSelection_ = false;
+ private boolean isGenSkeletonEnabled_;
+
+ private int DEFAULT_COLUMN_WIDTH = 100;
+
+ // ----TOOLTIPS Section----
+ /* CONTEXT_ID SHLD0001 for the Handler Config Page */
+ private final String INFOPOP_HDLR_WS_HANDLERS = "SHDL0001"; //$NON-NLS-1$
+
+ /* CONTEXT_ID SHDL0002 for the Handler Config Page */
+ private final String INFOPOP_HDLR_GEN_SKELETON = "SHDL0002"; //$NON-NLS-1$
+
+ /* CONTEXT_ID SHDL0003 for the Handler Config Page */
+ private final String INFOPOP_COMBO_SOURCE_LOC = "SHDL0003"; //$NON-NLS-1$
+
+ /* CONTEXT_ID SHDL0004 for the Handler Config Page */
+ private final String INFOPOP_WS_SERVICE_DESC = "SHDL0004"; //$NON-NLS-1$
+
+ // ------------------------
+
+ public ConfigServiceHandlersTableWidget() {
+ super();
+ }
+
+ public WidgetDataEvents addControls(Composite parent, Listener statusListener) {
+ UIUtils uiUtils = new UIUtils(pluginId_);
+
+ parent_ = parent;
+
+ // Web service description composite (combo/text to be created later)
+ webServiceDescComp_ = uiUtils.createComposite(parent_, 2);
+
+ Composite displayComp = new Composite(parent_, SWT.NONE);
+
+ GridLayout gridlayout = new GridLayout(2, false);
+ displayComp.setLayout(gridlayout);
+ displayComp.setLayoutData(uiUtils.createFillAll());
+
+ final Composite handlersComp = uiUtils.createComposite(displayComp, 1);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING
+ | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL | GridData.FILL_VERTICAL);
+ handlersComp.setLayoutData(griddata);
+ handlersComp.setSize(130, 600);
+
+ Composite buttonsComp = uiUtils.createComposite(displayComp, 1);
+ griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+ buttonsComp.setLayoutData(griddata);
+
+ Text handlersText = new Text(handlersComp, SWT.READ_ONLY);
+ handlersText.setText(ConsumptionUIMessages.LABEL_HANDLERS_CONFIG);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ handlersText.setLayoutData(gd);
+
+ handlersTable_ = uiUtils.createTable(handlersComp, ConsumptionUIMessages.TOOLTIP_EDIT_WS_HANDLERS, INFOPOP_HDLR_WS_HANDLERS, SWT.MULTI
+ | SWT.FULL_SELECTION | SWT.BORDER);
+ handlersTable_.setHeaderVisible(true);
+ handlersTable_.setLinesVisible(true);
+
+ // empty space
+ Label wsLabel = new Label(buttonsComp, SWT.NONE);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ wsLabel.setLayoutData(gd);
+
+ Button moveUpButton = uiUtils.createPushButton(buttonsComp, ConsumptionUIMessages.LABEL_BUTTON_MOVE_UP, null, null);
+ GridData muGriddata = new GridData();
+ Point musize = moveUpButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ moveUpButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleMoveUpButtonSelected(event);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+
+ Button moveDownButton = uiUtils.createPushButton(buttonsComp, ConsumptionUIMessages.LABEL_BUTTON_MOVE_DOWN, null, null);
+ GridData mdGriddata = new GridData();
+ Point mdsize = moveDownButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ moveDownButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleMoveDownButtonSelected(event);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+
+ // empty space
+ wsLabel = new Label(buttonsComp, SWT.NONE);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ wsLabel.setLayoutData(gd);
+
+ addButton_ = uiUtils.createPushButton(buttonsComp, ConsumptionUIMessages.LABEL_BUTTON_ADD, null, null);
+ GridData addGriddata = new GridData();
+ Point addSize = addButton_.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ addButton_.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleAddButtonSelected(event);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+
+ removeButton_ = uiUtils.createPushButton(buttonsComp, ConsumptionUIMessages.LABEL_BUTTON_REMOVE, null, null);
+ GridData remGriddata = new GridData();
+ Point remSize = removeButton_.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ removeButton_.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleRemoveButtonSelected(event);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+ enableRemove(false);
+
+ int widthHint = 0;
+ int[] sizes = new int[]{musize.x, mdsize.x, addSize.x, remSize.x, 100};
+ for(int j = 0; j < sizes.length; j++) {
+ if (sizes[j] > widthHint)
+ widthHint = sizes[j];
+ }
+ muGriddata.widthHint = widthHint;
+ mdGriddata.widthHint = widthHint;
+ addGriddata.widthHint = widthHint;
+ remGriddata.widthHint = widthHint;
+
+ moveUpButton.setLayoutData(muGriddata);
+ moveDownButton.setLayoutData(mdGriddata);
+ addButton_.setLayoutData(addGriddata);
+ removeButton_.setLayoutData(remGriddata);
+
+ // table stuff here
+ String[] columns_ = new String[] { ConsumptionUIMessages.LABEL_HANDLER_NAME, ConsumptionUIMessages.LABLE_HANDLER_CLASS,
+ ConsumptionUIMessages.LABEL_HANDLER_PORT};
+
+ final TableColumn[] tableCols = new TableColumn[columns_.length];
+ for (int i = 0; i < columns_.length; i++) {
+ TableColumn tableColumn = new TableColumn(handlersTable_, SWT.LEFT);
+ tableColumn.setText(columns_[i]);
+ tableColumn.setAlignment(SWT.LEFT);
+ tableColumn.setWidth(DEFAULT_COLUMN_WIDTH);
+ tableColumn.setResizable(true);
+ tableCols[i] = tableColumn;
+ }
+ handlersComp.addControlListener(new ControlAdapter() {
+
+ public void controlResized(ControlEvent e) {
+ Rectangle area = handlersComp.getClientArea();
+ Point preferredSize = handlersTable_.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ int width = area.width - 2 * handlersTable_.getBorderWidth() - 10;
+ if (preferredSize.y > area.height + handlersTable_.getHeaderHeight()) {
+ // Subtract the scrollbar width from the total column width
+ // if a vertical scrollbar will be required
+ Point vBarSize = handlersTable_.getVerticalBar().getSize();
+ width -= vBarSize.x;
+ }
+ Point oldSize = handlersTable_.getSize();
+ if (oldSize.x > area.width) {
+ // table is getting smaller so make the columns
+ // smaller first and then resize the table to
+ // match the client area width
+ tableCols[0].setWidth(width / 3);
+ tableCols[1].setWidth(width / 3);
+ tableCols[2].setWidth(width - (tableCols[0].getWidth() + tableCols[1].getWidth()));
+ handlersTable_.setSize(area.width, area.height);
+ }
+ else {
+ // table is getting bigger so make the table
+ // bigger first and then make the columns wider
+ // to match the client area width
+ handlersTable_.setSize(area.width, area.height);
+ tableCols[0].setWidth(width / 3);
+ tableCols[1].setWidth(width / 3);
+ tableCols[2].setWidth(width - (tableCols[0].getWidth() + tableCols[1].getWidth()));
+ }
+ }
+ });
+
+ tableViewer_ = new TableViewer(handlersTable_);
+ Control control = tableViewer_.getControl();
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ data.verticalAlignment = GridData.FILL;
+ data.grabExcessVerticalSpace = true;
+ control.setLayoutData(data);
+
+ tableViewer_.setColumnProperties(columns_);
+ tableViewer_.setContentProvider(new ListContentProvider());
+ tableViewer_.setLabelProvider(new ListLabelProvider());
+ tableViewer_.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ enableRemove(true);
+ }
+ });
+
+ genSkeletonRadioButton_ = uiUtils.createCheckbox(parent_, ConsumptionUIMessages.LABEL_BUTTON_GEN_SKELETON,
+ ConsumptionUIMessages.TOOLTIP_BUTTON_GEN_SKELETON, INFOPOP_HDLR_GEN_SKELETON);
+ griddata = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
+ genSkeletonRadioButton_.setLayoutData(griddata);
+ genSkeletonRadioButton_.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ handleGenSkeletonRadioButton();
+ }
+ });
+
+ sourceLocationComp_ = uiUtils.createComposite(parent_, 2);
+ sourceLocationCombo_ = uiUtils.createCombo(sourceLocationComp_, ConsumptionUIMessages.LABEL_COMBO_SOURCE_LOC,
+ ConsumptionUIMessages.TOOLTIP_COMBO_SOURCE_LOC, INFOPOP_COMBO_SOURCE_LOC, SWT.READ_ONLY);
+ sourceLocationCombo_.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ handleSourceLocationCombo(evt);
+ }
+ });
+
+ return this;
+ }
+
+ // Called at start and only for single service selection
+ private void populateHandlersTable() {
+ try {
+ UIUtils uiUtils = new UIUtils(pluginId_);
+
+ // process for multiple service selection
+ if (isMultipleSelection_) {
+ parent_.getShell().setText(ConsumptionUIMessages.PAGE_DESC_MULTIPLE_SERVICES_CONFIG);
+
+ webServiceDescText_ = uiUtils.createText(webServiceDescComp_, ConsumptionUIMessages.LABEL_COMBO_WS_SERVICE_DESC,
+ ConsumptionUIMessages.TOOLTIP_WS_SERVICE_DESC, INFOPOP_WS_SERVICE_DESC, SWT.READ_ONLY);
+ if (handlerDescriptionHolder_!=null){
+ currentHDH_ = handlerDescriptionHolder_[0];
+ String text = NLS.bind(ConsumptionUIMessages.MSG_TEXT_NUM_OF_SERVICES, Integer.toString(handlerDescriptionHolder_.length));
+ webServiceDescText_.setText(text);
+ }
+
+ genSkeletonRadioButton_.setSelection(false);
+ genSkeletonRadioButton_.setEnabled(false);
+ genSkeletonRadioButton_.setVisible(false);
+
+ sourceLocationComp_.setVisible(false);
+ sourceLocationCombo_.setEnabled(false);
+ sourceLocationCombo_.setVisible(false);
+
+ refresh();
+
+ }
+ else {
+ // populate the table for a single service selection
+
+ webServiceDescCombo_ = uiUtils.createCombo(webServiceDescComp_, ConsumptionUIMessages.LABEL_COMBO_WS_SERVICE_DESC,
+ ConsumptionUIMessages.TOOLTIP_WS_SERVICE_DESC, INFOPOP_WS_SERVICE_DESC, SWT.READ_ONLY);
+ webServiceDescCombo_.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ handleWebServiceDescCombo(evt);
+ }
+ });
+
+ String[] wsDescNames = HandlerDescriptionHelper.getAllDescriptionNames(handlerDescriptionHolder_);
+ webServiceDescCombo_.setItems(wsDescNames);
+
+ if (handlerDescriptionHolder_.length < 1) {
+ webServiceDescCombo_.select(0);
+ webServiceDescCombo_.setEnabled(false);
+ }
+ else {
+ if (descriptionName_ != null) {
+ int index = webServiceDescCombo_.indexOf(descriptionName_);
+ if (index != -1) webServiceDescCombo_.select(index);
+ }
+ else
+ webServiceDescCombo_.select(0);
+ }
+
+ // set Descriptions
+ HandlerDescriptionHolder hdh = HandlerDescriptionHelper.getForDescriptionName(handlerDescriptionHolder_, webServiceDescCombo_.getText());
+ if (hdh!=null){
+ currentHDH_ = hdh;
+ List handlers = hdh.getHandlerList();
+ tableViewer_.setInput(handlers);
+ tableViewer_.refresh();
+ }
+ // set output folder
+ setSourceOutputLocation();
+ }
+ parent_.getShell().setSize(530, 650);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.env.ui.widgets.WidgetContributor#getStatus()
+ */
+ public IStatus getStatus() {
+ IStatus finalStatus = Status.OK_STATUS;
+ if (isMultipleSelection_)
+ return StatusUtils.infoStatus(ConsumptionUIMessages.PAGE_DESC_MULTIPLE_SERVICES_CONFIG);
+ return finalStatus;
+ }
+
+ protected void handleAddButtonSelected(SelectionEvent event) {
+ AddHandlerDialog dialog = new AddHandlerDialog(parent_.getShell(), false);
+ dialog.setIsMultipleServices(isMultipleSelection_);
+ dialog.create();
+
+ WebServiceDescription serviceDesc = null;
+ if (!isMultipleSelection_ ){
+ if (currentHDH_!=null) {
+ serviceDesc = currentHDH_.getDescriptionObject();
+ String[] portNames = getPortComponentNames(serviceDesc);
+ dialog.setPortNames(portNames);
+ }
+ }
+
+ dialog.getShell().setSize(500, 230);
+
+ int result = dialog.open();
+
+ if (result == Window.OK) {
+ String name = dialog.getName();
+ String className = dialog.getClassName();
+ String port = dialog.getPortName();
+ if (port == null)
+ port = "*";
+
+ HandlerTableItem hi = new HandlerTableItem();
+ hi.setHandlerName(name);
+ hi.setHandlerClassName(className);
+ hi.setPortName(port);
+
+ if (serviceDesc!=null){
+ hi.setWsDescRef(serviceDesc);
+ }
+
+ if (currentHDH_!=null){
+ List handlers = currentHDH_.getHandlerList();
+ handlers.add(hi);
+ }
+
+ }
+
+ refresh();
+ }
+
+ private String[] getPortComponentNames(WebServiceDescription webServiceDesc) {
+
+ List ports = webServiceDesc.getPortComponents();
+ if (ports != null) {
+ String[] portNames = new String[ports.size()];
+ for (int i = 0; i < ports.size(); i++) {
+ PortComponent pc = (PortComponent) ports.get(i);
+ String pcName = pc.getPortComponentName();
+ portNames[i] = pcName;
+ }
+ return portNames;
+ }
+ return new String[0];
+ }
+
+ protected void handleRemoveButtonSelected(SelectionEvent event) {
+ handleDeleteKeyPressed();
+ }
+
+ protected void handleMoveUpButtonSelected(SelectionEvent event) {
+
+ int index = tableViewer_.getTable().getSelectionIndex();
+ if (index != -1) {
+ if (index > 0) {
+ if (currentHDH_!=null){
+ List handlers = currentHDH_.getHandlerList();
+ Object object = handlers.remove(index);
+ handlers.add(index - 1, object);
+ }
+ tableViewer_.refresh();
+ }
+ }
+
+ }
+
+ protected void handleMoveDownButtonSelected(SelectionEvent event) {
+
+ int index = tableViewer_.getTable().getSelectionIndex();
+ if (index != -1) {
+ if (currentHDH_!=null){
+ List handlers = currentHDH_.getHandlerList();
+ if (index < handlers.size() - 1) {
+ Object object = handlers.remove(index);
+ handlers.add(index+1, object);
+ }
+ tableViewer_.refresh();
+ }
+ }
+
+ }
+
+ protected void handleSourceLocationCombo(SelectionEvent event) {
+ outputLocation_ = sourceLocationCombo_.getText();
+ IPath outputPath = (IPath) pathsTable_.get(outputLocation_);
+ currentHDH_.setSourceOutputPath(outputPath);
+ }
+
+ protected void handleGenSkeletonRadioButton() {
+ if (genSkeletonRadioButton_.isEnabled()) {
+ if (genSkeletonRadioButton_.getSelection()) {
+ this.isGenSkeletonEnabled_ = true;
+ sourceLocationCombo_.setEnabled(true);
+ }
+ else {
+ this.isGenSkeletonEnabled_ = false;
+ sourceLocationCombo_.setEnabled(false);
+ }
+ }
+ }
+
+ protected void handleWebServiceDescCombo(SelectionEvent event) {
+
+ if (webServiceDescCombo_!=null && webServiceDescCombo_.isEnabled()) {
+ HandlerDescriptionHolder hdh = HandlerDescriptionHelper.getForDescriptionName(handlerDescriptionHolder_, webServiceDescCombo_.getText());
+ currentHDH_ = hdh;
+ refresh();
+ }
+
+ if (isGenSkeletonEnabled_){
+ setSourceOutputLocation();
+ }
+
+ }
+
+ /**
+ * @return Returns the isGenSkeletonEnabled_.
+ */
+ public boolean isGenSkeletonEnabled_() {
+ return isGenSkeletonEnabled_;
+ }
+
+ protected class ListLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object object, int columnIndex) {
+
+ if (object instanceof HandlerTableItem) {
+ HandlerTableItem hti = (HandlerTableItem) object;
+ if (columnIndex == 0) {
+ return hti.getHandlerName() != null ? hti.getHandlerName() : "";
+ }
+ else if (columnIndex == 1) {
+ return hti.getHandlerClassName() != null ? hti.getHandlerClassName() : "";
+ }
+ else {
+ return hti.getPortName() != null ? hti.getPortName() : "";
+ }
+ }
+ return null;
+ }
+
+ }
+
+ private void enableRemove(boolean enabled) {
+ removeButton_.setEnabled(enabled && !tableViewer_.getSelection().isEmpty());
+ }
+
+ protected class ListContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object element) {
+ if (element instanceof Vector) { return ((Vector) element).toArray(); }
+ return null;
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object old, Object newobj) {
+ }
+
+ public boolean isDeleted(Object object) {
+ return false;
+ }
+ }
+
+ protected void handleDeleteKeyPressed() {
+ // internalDispose();
+ ISelection selection = tableViewer_.getSelection();
+ if (selection != null && !selection.isEmpty() && (selection instanceof IStructuredSelection)) {
+ int selectionIndex = handlersTable_.getSelectionIndex();
+ if (currentHDH_!=null){
+ currentHDH_.getHandlerList().remove(selectionIndex);
+ }
+ refresh();
+ }
+ }
+
+ public void refresh() {
+ try {
+ tableViewer_.setInput(null);
+ if (currentHDH_!=null){
+ List handlers = currentHDH_.getHandlerList();
+ tableViewer_.setInput(handlers);
+ tableViewer_.refresh();
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void setGenSkeletonEnabled(boolean isGenSkeletonEnabled) {
+ this.isGenSkeletonEnabled_ = isGenSkeletonEnabled;
+ genSkeletonRadioButton_.setSelection(isGenSkeletonEnabled);
+
+ }
+
+ public boolean getGenSkeletonEnabled() {
+ return this.isGenSkeletonEnabled_;
+ }
+
+ private void setSourceOutputLocation(){
+ IProject project = currentHDH_.getProject();
+ if (project!=null){
+ IPath[] locations = ResourceUtils.getAllJavaSourceLocations(project);
+
+ String[] paths = new String[locations.length];
+ for (int i = 0; i < locations.length; i++) {
+ paths[i] = locations[i].toString();
+ pathsTable_.put(paths[i], locations[i]);
+ }
+ sourceLocationCombo_.setItems(paths);
+ sourceLocationCombo_.select(0);
+ }
+
+ // set in model
+ outputLocation_ = sourceLocationCombo_.getText();
+ IPath outputPath = (IPath) pathsTable_.get(outputLocation_);
+ currentHDH_.setSourceOutputPath(outputPath);
+
+ }
+
+ /**
+ * An array of HandlerDescriptionHolders
+ * @return
+ */
+ public void setHandlerDescriptionHolders(HandlerDescriptionHolder[] handlerHolders){
+ this.handlerDescriptionHolder_ = handlerHolders;
+ }
+
+ public HandlerDescriptionHolder[] getHandlerDescriptionHolders(){
+ return this.handlerDescriptionHolder_;
+ }
+
+ /**
+ * For getting the handlers to apply for multiple services
+ * @return
+ */
+ public List getHandlersList(){
+ if (handlerDescriptionHolder_[0]!=null)
+ return handlerDescriptionHolder_[0].getHandlerList();
+ return null;
+ }
+
+ public void setDescriptionName(String wsDescName) {
+ descriptionName_ = wsDescName;
+ }
+
+ public void setIsMultipleSelection(boolean isMulitpleSelection) {
+ this.isMultipleSelection_ = isMulitpleSelection;
+ }
+
+ public void internalize(){
+ populateHandlersTable();
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/HandlersDefaultingCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/HandlersDefaultingCommand.java
new file mode 100644
index 000000000..44a212910
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/HandlersDefaultingCommand.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+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.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.j2ee.internal.webservice.WebServiceNavigatorGroupType;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.common.environment.IEnvironment;
+
+
+/**
+ * HandlersDefaultingCommand
+ *
+ * Determine if Handlers belongs to service or client side
+ */
+public class HandlersDefaultingCommand extends AbstractHandlersWidgetDefaultingCmd
+{
+ private boolean isClientHandler_ = false;
+ private boolean isServiceHandler_ = false;
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+ IStatus status = Status.OK_STATUS;
+
+ IStructuredSelection selection = getInitialSelection();
+ if (selection != null && selection.size() == 1) {
+ Object obj = selection.getFirstElement();
+
+ if (obj instanceof WebServiceNavigatorGroupType) {
+ WebServiceNavigatorGroupType wsngt = (WebServiceNavigatorGroupType) obj;
+ if (wsngt.getWsdlService()!=null){
+ isServiceHandler_ = true;
+ }
+
+ if (wsngt.getServiceRef()!=null){
+ isClientHandler_ = true;
+ }
+
+ }
+ }
+ else {
+ status = StatusUtils.errorStatus( ConsumptionUIMessages.MSG_ERROR_TASK_EXCEPTED );
+ env.getStatusHandler().reportError(status);
+ return status;
+ }
+
+ return status;
+
+ }
+
+
+/**
+ * @return Returns the isClientHandler_.
+ */
+public boolean getIsClientHandler() {
+ return isClientHandler_;
+}
+/**
+ * @return Returns the isServiceHandler_.
+ */
+public boolean getIsServiceHandler() {
+ return isServiceHandler_;
+}
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/IObjectSelectionLaunchable.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/IObjectSelectionLaunchable.java
new file mode 100644
index 000000000..c59ad6df6
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/IObjectSelectionLaunchable.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
+ * -------- -------- -----------------------------------------------------------
+ * 20060420 135912 joan@ca.ibm.com - Joan Haggarty
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+
+public interface IObjectSelectionLaunchable {
+ /**
+ * The framework will call this method to set the initial selection
+ * value that the user has specified.
+ *
+ * @param initialSelection the initial selection the user specified.
+ */
+ public void setInitialSelection(IStructuredSelection initialSelection);
+
+ /**
+ * The intent of the Object Selection Widget is that the user has
+ * the opportunity change/find the object that they want to turn into
+ * a Web service.
+ *
+ * @return returns the an IStructuredSelection object that the user
+ * want to turn into a Web service. This object may be different than
+ * the initialSelection passed in by the setInitialSelection method.
+ */
+ public IStructuredSelection getObjectSelection();
+
+ /**
+ * Validates whether the objectSelection parameter is valid for
+ * this Object selection widget. An error status should be returned
+ * if this object is not value. Otherwise, and ok status should be
+ * returned
+ *
+ * @param objectSelection the object to be validated.
+ * @return the status of the validation.
+ */
+ public IStatus validateSelection(IStructuredSelection objectSelection);
+
+ /**
+ *
+ * @return returns the IProject that contains the selection
+ * object that the user has chosen with this widget. The value can be
+ * null if there is no IProject for this object.
+ */
+ public IProject getProject();
+
+ /**
+ *
+ * @return returns the name of the IVirtualComponent that contains the selection
+ * object that the user has chosen with this widget. The value can be
+ * null if there is no IVirtualComponent for this object
+ */
+ public String getComponentName();
+
+ /**
+ * Called to launch a dialog which allows the user to make an object selection.
+ * This is an alternative to implementing IObjectSelectionWidget which can be used by the dialog framework.
+ * The implementation of this method should call the necessary getters on the dialog to update the
+ * object selection.
+ *
+ * @return the status of completing the dialog launch
+ */
+ public int launch(Shell shell);
+
+ /**
+ *
+ * @return returns the string to displayed in the UI for the selected object
+ */
+ public String getObjectSelectionDisplayableString();
+
+ /**
+ *
+ * @param s A string representation of the object selection
+ * @return true if the string represents a valid object selection.
+ * The implementation of this method should set the widget object selection
+ * according to the input string so that a subsequent call to getObjectSelection
+ * will retrieve the correct object.
+ */
+ public boolean validate(String s);
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/IPackable.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/IPackable.java
new file mode 100644
index 000000000..5600bd90a
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/IPackable.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060829 155441 makandre@ca.ibm.com - Andrew Mak, web service wizard hangs during resize
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+/**
+ * An interface that marks an UI element as having some custom packing code.
+ */
+public interface IPackable {
+
+ /**
+ * Calling this method should cause the UI element to pack itself. Note that
+ * this does not necessarily have the same behavior as the pack() method in SWT.
+ */
+ void packIt();
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ImportWSILWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ImportWSILWidget.java
new file mode 100644
index 000000000..6c7b19d39
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ImportWSILWidget.java
@@ -0,0 +1,234 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 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
+ * -------- -------- -----------------------------------------------------------
+ * 20080501 229728 makandre@ca.ibm.com - Andrew Mak, uppercase .WSDL cannot be found by the Web Service Client wizard
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.j2ee.webservice.wsclient.ServiceRef;
+import org.eclipse.jst.ws.internal.common.J2EEActionAdapterFactory;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
+import org.eclipse.jst.ws.internal.consumption.ui.wsil.Arguments;
+import org.eclipse.jst.ws.internal.consumption.ui.wsil.TableViewerEditor;
+import org.eclipse.jst.ws.internal.ui.common.DialogResourceBrowser;
+import org.eclipse.jst.ws.internal.ui.common.FileExtensionFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.help.IWorkbenchHelpSystem;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.ws.internal.wsil.AddWSDLToWSILCommand;
+import org.eclipse.wst.wsdl.internal.impl.ServiceImpl;
+import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
+
+/**
+* Page for importing WSDL references into a WSIL in the workbench.
+*/
+public class ImportWSILWidget extends SimpleWidgetDataContributor
+{
+ /*CONTEXT_ID WSIL0001 for the WSIL Import Page*/
+ private final String INFOPOP_WSIL_IMPORT_PAGE = WebServiceConsumptionUIPlugin.ID + ".WSIL0001";
+
+ /*CONTEXT_ID WSIL0002 for the WSIL text field*/
+ private final String INFOPOP_WSIL_TEXT_WSIL = WebServiceConsumptionUIPlugin.ID + ".WSIL0002";
+
+ /*CONTEXT_ID WSIL0003 for the WSIL browse button*/
+ private final String INFOPOP_WSIL_BUTTON_BROWSE_WSIL = WebServiceConsumptionUIPlugin.ID + ".WSIL0003";
+
+ /*CONTEXT_ID WSIL0004 for the WSDL table*/
+ private final String INFOPOP_WSIL_TABLE_WSDL = WebServiceConsumptionUIPlugin.ID + ".WSIL0004";
+
+ private final String INSPECTION_WSIL = "inspection.wsil";
+
+ private Text wsil_;
+ private Button browse_;
+ private TableViewerEditor wsdls_;
+
+ /**
+ * Constructs a new page.
+ */
+ public ImportWSILWidget()
+ {
+ }
+
+ public WidgetDataEvents addControls(Composite parent, Listener statusListener)
+ {
+ IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+
+ parent.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSIL_IMPORT_PAGE);
+ helpSystem.setHelp(parent, INFOPOP_WSIL_IMPORT_PAGE);
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 3;
+ composite.setLayout(gl);
+ GridData gd = new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ gd.grabExcessVerticalSpace = true;
+ gd.grabExcessHorizontalSpace = true;
+ composite.setLayoutData(gd);
+
+ Label label = new Label(composite, SWT.WRAP);
+ label.setText(ConsumptionUIMessages.LABEL_WSIL_URI);
+ label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ wsil_ = new Text(composite, SWT.WRAP | SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+ gd.widthHint = 256;
+ wsil_.setLayoutData(gd);
+ wsil_.addListener(SWT.Modify, statusListener);
+ wsil_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSIL_TEXT_WSIL);
+ helpSystem.setHelp(wsil_, INFOPOP_WSIL_TEXT_WSIL);
+
+ browse_ = new Button(composite, SWT.PUSH);
+ browse_.setText(ConsumptionUIMessages.LABEL_BROWSE);
+ browse_.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ browse_.addListener(SWT.Selection,
+ new Listener()
+ {
+ public void handleEvent(Event event)
+ {
+ handleBrowseEvent(event);
+ }
+ }
+ );
+ browse_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSIL_BUTTON_BROWSE_WSIL);
+ helpSystem.setHelp(browse_, INFOPOP_WSIL_BUTTON_BROWSE_WSIL);
+
+ Composite wsdlComposite = new Composite(composite, SWT.NONE);
+ wsdlComposite.setLayout(new GridLayout());
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 3;
+ wsdlComposite.setLayoutData(gd);
+ label = new Label(wsdlComposite, SWT.WRAP);
+ label.setText(ConsumptionUIMessages.LABEL_WSDL);
+ label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ String[] columns = {ConsumptionUIMessages.LABEL_WSDL_URI};
+ wsdls_ = new TableViewerEditor(wsdlComposite, columns, new ArrayList(), "http://");
+ wsdls_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSIL_TABLE_WSDL);
+ wsdls_.setInfopop(INFOPOP_WSIL_TABLE_WSDL);
+ return this;
+ }
+
+ public void handleBrowseEvent(Event event)
+ {
+ DialogResourceBrowser dialog = new DialogResourceBrowser(browse_.getShell(), null, new FileExtensionFilter(new String[] {"wsil"}));
+ dialog.open();
+ IResource res = dialog.getFirstSelection();
+ if (res != null)
+ {
+ if (res instanceof IFile)
+ wsil_.setText(res.getFullPath().toString());
+ else
+ wsil_.setText(res.getFullPath().addTrailingSeparator().append(INSPECTION_WSIL).toString());
+ }
+ }
+
+ public IStatus getStatus()
+ {
+ if (!wsil_.getText().toLowerCase().endsWith(".wsil"))
+ return StatusUtils.errorStatus( ConsumptionUIMessages.PAGE_MSG_INVALID_WSIL_FILE_NAME );
+ else
+ return Status.OK_STATUS;
+ }
+
+ public void setInitialSelection(IStructuredSelection selection)
+ {
+ ArrayList list = new ArrayList();
+ if (selection != null && !selection.isEmpty())
+ {
+ for (Iterator it = selection.iterator(); it.hasNext();)
+ {
+ Object object = it.next();
+ if (object instanceof IFile) {
+ IFile file = (IFile) object;
+ String ext = file.getFileExtension();
+ if (ext != null) {
+ if (ext.equalsIgnoreCase("wsdl"))
+ list.add(file.getFullPath().toString());
+ else if (ext.equalsIgnoreCase("wsil"))
+ wsil_.setText(file.getFullPath().toString());
+ }
+ }
+ if (object instanceof ServiceImpl)
+ list.add(J2EEActionAdapterFactory.getWSILPath(((ServiceImpl)(object))));
+ if (object instanceof ServiceRef)
+ list.add(J2EEActionAdapterFactory.getWSILPath(((ServiceRef)(object))));
+ if (object instanceof WSDLResourceImpl)
+ list.add(J2EEActionAdapterFactory.getWSILPath(((WSDLResourceImpl)(object))));
+ }
+ }
+ wsdls_.setInput(list);
+ wsdls_.refresh();
+ if (list.size() > 0)
+ {
+ StringBuffer path = new StringBuffer(list.get(0).toString());
+ // change extension from .wsdl to .wsil
+ int length = path.length();
+ path = path.replace(length-4, length, "wsil");
+ wsil_.setText(path.toString());
+ }
+ }
+
+ public Arguments getGenWSILArguments()
+ {
+ Arguments args = new Arguments();
+ String wsilPath = wsil_.getText();
+ if (wsilPath.indexOf(':') < 0)
+ args.add(AddWSDLToWSILCommand.ARG_WSIL, URI.createPlatformResourceURI(wsil_.getText()).toString());
+ else
+ args.add(AddWSDLToWSILCommand.ARG_WSIL, wsilPath);
+ TableItem[] items = wsdls_.getItems();
+ for (int i = 0; i < items.length; i++)
+ {
+ String uri = items[i].getText(0);
+ if (uri.indexOf(':') < 0)
+ {
+ IResource res = ResourceUtils.findResource(uri);
+ if (res != null)
+ {
+ try
+ {
+ uri = res.getLocation().toFile().toURL().toString();
+ }
+ catch (MalformedURLException murle)
+ {
+ murle.getMessage();
+ }
+ }
+ }
+ args.add(AddWSDLToWSILCommand.ARG_WSDL, uri);
+ }
+ args.add(AddWSDLToWSILCommand.ARG_RESOLVE_WSDL, null);
+ return args;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/JavaBeanSelectionLaunchable.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/JavaBeanSelectionLaunchable.java
new file mode 100644
index 000000000..8b36f4d62
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/JavaBeanSelectionLaunchable.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060420 135912 joan@ca.ibm.com - Joan Haggarty
+ * 20060719 149352 mahutch@ca.ibm.com - Mark Hutchinson
+ * 20060826 135570 makandre@ca.ibm.com - Andrew Mak, Service implementation URL not displayed properly on first page
+ * 20070313 170126 makandre@ca.ibm.com - Andrew Mak, BUJava scenario doesn't catch improper service definition
+ * 20080310 222075 makandre@ca.ibm.com - Andrew Mak, Cannot launch Web Service wizard on an IType
+ * 20080318 213330 trungha@ca.ibm.com - Trung, Non-conventional Java naming prevents creating Web Services (client)
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaConventions;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jst.j2ee.webservice.wsdd.BeanLink;
+import org.eclipse.jst.j2ee.webservice.wsdd.internal.impl.PortComponentImpl;
+import org.eclipse.jst.j2ee.webservice.wsdd.internal.impl.ServiceImplBeanImpl;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.ui.dialog.DialogUtils;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+
+public class JavaBeanSelectionLaunchable extends AbstractObjectSelectionLaunchable {
+
+ private IProject serverProject_ = null;
+ private String serverComponentName_ = null;
+ private String beanClassString_="";
+ private IStatus validationStatus;
+
+ public void setInitialSelection(IStructuredSelection initialSelection)
+ {
+ if (initialSelection != null && !initialSelection.isEmpty())
+ {
+ Object object = initialSelection.getFirstElement();
+ if (object instanceof IFile)
+ {
+ IFile iFile = (IFile)object;
+ String fileExt = iFile.getFileExtension().toLowerCase();
+ if (fileExt.equals("java") || fileExt.equals("class"))
+ setBeanClass(iFile);
+ }
+ else if (object instanceof IType)
+ setBeanClass((IType) object);
+ else if (object instanceof ICompilationUnit)
+ setBeanClass(((ICompilationUnit)object).getResource());
+ else if (object instanceof ServiceImplBeanImpl)
+ setBeanClass((ServiceImplBeanImpl)object);
+ else if(object instanceof BeanLink)
+ setBeanClass((BeanLink)object);
+ else if (object instanceof String)
+ beanClassString_ = (String) object; // use for displayable string
+ }
+ }
+
+ public IStructuredSelection getObjectSelection()
+ {
+ return new StructuredSelection(beanClassString_);
+ }
+
+ public IProject getProject()
+ {
+ return serverProject_;
+ }
+
+ public String getComponentName()
+ {
+ return serverComponentName_;
+ }
+
+ public int launch(Shell shell) {
+
+ IType itype = DialogUtils.browseClassesAsIType(shell, ResourcesPlugin.getWorkspace().getRoot().getProjects(), new ProgressMonitorDialog(shell));
+ return setBeanClass(itype);
+ }
+
+ private int setBeanClass(IType itype) {
+ if (itype != null)
+ {
+ beanClassString_ = itype.getFullyQualifiedName();
+ try
+ {
+ IResource res = itype.getUnderlyingResource();
+ if (res != null)
+ {
+ serverProject_ = res.getProject();
+ IVirtualComponent comp = ResourceUtils.getComponentOf(res);
+ if (comp!=null)
+ {
+ serverComponentName_ = comp.getName();
+ }
+ }
+ else
+ {
+ serverProject_ = null;
+ serverComponentName_ = null;
+ }
+ return Status.OK;
+ }
+ catch (JavaModelException jme)
+ {
+ serverProject_ = null;
+ serverComponentName_ = null;
+ return Status.ERROR;
+ }
+ }
+ return Status.CANCEL;
+ }
+
+ private void setBeanClass(IResource resource)
+ {
+ if( resource != null && resource instanceof IFile )
+ {
+ IPath path = resource.getFullPath();
+ String basename = path.lastSegment();
+
+ if( basename != null && basename.length() > 0 )
+ {
+ String beanPackage = org.eclipse.jst.ws.internal.common.ResourceUtils.getJavaResourcePackageName(path);
+ String beanClass = (beanPackage == null || beanPackage.length() == 0 ? basename : (beanPackage + "." + basename));
+
+ if( beanClass.toLowerCase().endsWith(".java") || beanClass.toLowerCase().endsWith(".class" ) )
+ {
+ beanClass = beanClass.substring( 0, beanClass.lastIndexOf('.') );
+ }
+
+ beanClassString_ = beanClass;
+ serverProject_ = ResourceUtils.getProjectOf(path);
+ IVirtualComponent comp = ResourceUtils.getComponentOf(resource);
+
+ if (comp!=null)
+ {
+ serverComponentName_ = comp.getName();
+ }
+
+ }
+ }
+ }
+
+ private void setBeanClass(ServiceImplBeanImpl serviceImpl)
+ {
+ if( serviceImpl != null )
+ {
+ EObject eObject = serviceImpl.eContainer();
+ if(eObject instanceof PortComponentImpl){
+ PortComponentImpl pci = (PortComponentImpl)eObject;
+ beanClassString_ = pci.getServiceEndpointInterface();
+ }
+ }
+ }
+
+ private void setBeanClass(BeanLink serviceImpl)
+ {
+ if( serviceImpl != null )
+ {
+ EObject eObject = serviceImpl.eContainer();
+ if(eObject instanceof ServiceImplBeanImpl){
+ setBeanClass((ServiceImplBeanImpl)eObject);
+ }
+ }
+ }
+
+ public IStatus getStatus()
+ {
+ if (beanClassString_.length() <= 0)
+ {
+ return StatusUtils.errorStatus(ConsumptionUIMessages.PAGE_MSG_BEAN_CANNOT_BE_EMPTY);
+ }
+ return Status.OK_STATUS;
+ }
+
+ public IStatus validateSelection(IStructuredSelection objectSelection)
+ {
+ if (validationStatus == null)
+ return Status.OK_STATUS;
+
+ return validationStatus;
+ }
+
+ public String getObjectSelectionDisplayableString() {
+ return beanClassString_;
+ }
+
+ public boolean validate(String s) {
+ beanClassString_ = s;
+ String sourceLevel = JavaCore.getOption(JavaCore.COMPILER_SOURCE);
+ String complianceLevel = JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE);
+ validationStatus = JavaConventions.validateJavaTypeName(s, sourceLevel, complianceLevel);
+ return validationStatus.isOK();
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/PreferencesSelectionWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/PreferencesSelectionWidget.java
new file mode 100644
index 000000000..82c464941
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/PreferencesSelectionWidget.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.jst.ws.internal.ui.WSUIPluginMessages;
+import org.eclipse.jst.ws.internal.ui.common.UIUtils;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.wst.command.internal.env.core.context.ResourceContext;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+
+
+public class PreferencesSelectionWidget extends SimpleWidgetDataContributor
+{
+ private ResourceContext context_;
+
+ /*CONTEXT_ID PWPR0003 for the Overwrite Files check box of the Project Page*/
+ private String INFOPOP_PWPR_CHECKBOX_OVERWRITE_FILES = "PWPR0003";
+ private Button overwriteFilesCheckbox_;
+
+ /*CONTEXT_ID PWPR0004 for the Create Folders check box of the Project Page*/
+ private String INFOPOP_PWPR_CHECKBOX_CREATE_FOLDERS = "PWPR0004";
+ private Button createFoldersCheckbox_;
+
+ /*CONTEXT_ID PWPR0015 for the Check Out Files check box of the Project Page*/
+ private String INFOPOP_PWPR_CHECKBOX_CHECKOUT_FILES = "PWPR0015";
+ private Button checkoutFilesCheckbox_;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.WidgetContributor#addControls(org.eclipse.swt.widgets.Composite, org.eclipse.swt.widgets.Listener)
+ */
+ public WidgetDataEvents addControls( Composite parent, Listener statusListener)
+ {
+ String conPluginId = "org.eclipse.jst.ws.consumption.ui";
+ UIUtils utils = new UIUtils( conPluginId );
+
+ Composite resourcesGroup = utils.createComposite( parent, 1 );
+
+ overwriteFilesCheckbox_ = utils.createCheckbox( resourcesGroup, WSUIPluginMessages.BUTTON_OVERWRITE_FILES,
+ WSUIPluginMessages.TOOLTIP_PPRM_CHECKBOX_OVERWRITE_FILES,
+ INFOPOP_PWPR_CHECKBOX_OVERWRITE_FILES );
+
+ createFoldersCheckbox_ = utils.createCheckbox( resourcesGroup, WSUIPluginMessages.BUTTON_CREATE_FOLDERS,
+ WSUIPluginMessages.TOOLTIP_PPRM_CHECKBOX_CREATE_FOLDERS ,
+ INFOPOP_PWPR_CHECKBOX_CREATE_FOLDERS );
+
+ checkoutFilesCheckbox_ = utils.createCheckbox( resourcesGroup, WSUIPluginMessages.BUTTON_CHECKOUT_FILES,
+ WSUIPluginMessages.TOOLTIP_PPRM_CHECKBOX_CHECK_OUT,
+ INFOPOP_PWPR_CHECKBOX_CHECKOUT_FILES );
+
+ return this;
+ }
+
+ public void setResourceContext( ResourceContext context )
+ {
+ overwriteFilesCheckbox_.setSelection( context.isOverwriteFilesEnabled() );
+ createFoldersCheckbox_.setSelection( context.isCreateFoldersEnabled() );
+ checkoutFilesCheckbox_.setSelection( context.isCheckoutFilesEnabled() );
+
+ context_ = context;
+ }
+
+ public ResourceContext getResourceContext()
+ {
+ context_.setOverwriteFilesEnabled( overwriteFilesCheckbox_.getSelection() );
+ context_.setCreateFoldersEnabled( createFoldersCheckbox_.getSelection() );
+ context_.setCheckoutFilesEnabled( checkoutFilesCheckbox_.getSelection() );
+
+ return context_;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ProjectSelectionDialog.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ProjectSelectionDialog.java
new file mode 100644
index 000000000..bb43ca1ec
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ProjectSelectionDialog.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060413 135581 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060802 148731 mahutch@ca.ibm.com - Mark Hutchinson
+ * 20080603 234251 pmoogk@ca.ibm.com - Peter Moogk, Updated the size of project selection dialog
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.runtime.ProjectSelectionWidget;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.command.internal.env.ui.widgets.PageInfo;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleDialog;
+
+public class ProjectSelectionDialog extends SimpleDialog {
+
+ String titleText_="";
+ String projectName_="";
+ String earProjectName_="";
+ String componentType_="";
+ TypeRuntimeServer trs_;
+ boolean needEAR_;
+
+ public ProjectSelectionDialog(Shell shell, PageInfo pageInfo)
+ {
+ super(shell, pageInfo);
+ titleText_ = pageInfo.getPageName();
+ }
+
+ protected void callSetters() {
+ // TODO Auto-generated method stub
+ ProjectSelectionWidget projWidget = (ProjectSelectionWidget)getWidget();
+ projWidget.setEarProjectName(earProjectName_);
+ projWidget.setProjectName(projectName_);
+ projWidget.setComponentType(componentType_);
+ projWidget.setNeedEAR(needEAR_);
+ projWidget.setTypeRuntimeServer(trs_);
+
+ projWidget.refreshProjectItems();
+ }
+
+ protected Point getInitialSize()
+ {
+ return this.getShell().computeSize(325, SWT.DEFAULT, true);
+ }
+
+
+ protected void setShellStyle(int newShellStyle)
+ {
+ super.setShellStyle( newShellStyle | SWT.RESIZE );
+ }
+
+ protected void configureShell(Shell newShell)
+ {
+ newShell.setText(titleText_);
+ super.configureShell(newShell);
+ }
+
+ public void setProjectName(String name)
+ {
+ projectName_ = name;
+ }
+
+ public String getProjectName()
+ {
+ return projectName_;
+ }
+
+ public void setEarProjectName(String name)
+ {
+ earProjectName_ = name;
+ }
+
+ public String getEarProjectName()
+ {
+ return earProjectName_;
+ }
+
+ public void setProjectComponentType( String type )
+ {
+ componentType_ = type;
+ }
+
+ public String getProjectComponentType()
+ {
+ return componentType_;
+ }
+
+ public void setNeedEAR(boolean b)
+ {
+ needEAR_ = b;
+ }
+
+ public boolean getNeedEAR()
+ {
+ return needEAR_;
+ }
+
+ public void setTypeRuntimeServer(TypeRuntimeServer trs)
+ {
+ trs_ = trs;
+ }
+
+ public boolean close() {
+
+ projectName_ = ((ProjectSelectionWidget)getWidget()).getProjectName();
+ earProjectName_ = ((ProjectSelectionWidget)getWidget()).getEarProjectName();
+ needEAR_ = ((ProjectSelectionWidget)getWidget()).getNeedEAR();
+ componentType_ = ((ProjectSelectionWidget)getWidget()).getComponentType();
+ return super.close();
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/PublishToPrivateUDDICommandFragment.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/PublishToPrivateUDDICommandFragment.java
new file mode 100644
index 000000000..f81138eb4
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/PublishToPrivateUDDICommandFragment.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.jst.ws.internal.consumption.ui.wizard.PrivateUDDIRegistryTypeRegistry;
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+import org.eclipse.wst.command.internal.env.core.fragment.AbstractCommandFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.ui.widgets.CanFinishRegistry;
+import org.eclipse.wst.command.internal.env.ui.widgets.CommandWidgetBinding;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetRegistry;
+
+
+public class PublishToPrivateUDDICommandFragment extends AbstractCommandFragment
+{
+ private DataMappingRegistry dataMappingRegistry;
+ private CanFinishRegistry canFinishRegistry;
+ private WidgetRegistry widgetRegistry;
+ private boolean publishToPrivateUDDI;
+ private CommandWidgetBinding privateUDDIBinding;
+
+ public PublishToPrivateUDDICommandFragment()
+ {
+ super(null, "");
+ privateUDDIBinding = PrivateUDDIRegistryTypeRegistry.getInstance().getPrivateUDDIRegistryType().getBinding();
+ }
+
+ /**
+ * Gets the first child fragment for this fragment.
+ *
+ * @return returns the first child fragment for this fragment. Returns
+ * null when there is no first child.
+ **/
+ public CommandFragment getFirstSubFragment()
+ {
+ if (privateUDDIBinding != null && publishToPrivateUDDI && !PrivateUDDIRegistryTypeRegistry.getInstance().getPrivateUDDIRegistryType().isPrivateUDDIRegistryInstalled())
+ {
+ privateUDDIBinding.registerCanFinish(canFinishRegistry);
+ privateUDDIBinding.registerDataMappings(dataMappingRegistry);
+ privateUDDIBinding.registerWidgetMappings(widgetRegistry);
+ return privateUDDIBinding.create().create();
+ }
+ else
+ return null;
+ }
+
+ /**
+ * Gets the next child fragment for this fragment.
+ *
+ * @return returns the next child fragment for this fragment. Returns null
+ * when there is no next child.
+ **/
+ public CommandFragment getNextSubFragment(CommandFragment fragment)
+ {
+ return null;
+ }
+
+ /*
+ * This method is called to retrieve the data mappings for this command fragment.
+ */
+ public void registerDataMappings(DataMappingRegistry registry)
+ {
+ dataMappingRegistry = registry;
+ }
+
+ public void registerCanFinish(CanFinishRegistry canFinishRegistry)
+ {
+ this.canFinishRegistry = canFinishRegistry;
+ }
+
+ public void registerWidgetMappings(WidgetRegistry widgetRegistry)
+ {
+ this.widgetRegistry = widgetRegistry;
+ }
+
+ /**
+ * All wizard fragments need to be cloneable.
+ **/
+ public Object clone()
+ {
+ PublishToPrivateUDDICommandFragment fragment = new PublishToPrivateUDDICommandFragment();
+ fragment.registerDataMappings(dataMappingRegistry);
+ fragment.registerCanFinish(canFinishRegistry);
+ fragment.registerWidgetMappings(widgetRegistry);
+ fragment.setPublishToPrivateUDDI(publishToPrivateUDDI);
+ return fragment;
+ }
+
+ public void setPublishToPrivateUDDI(boolean publish)
+ {
+ publishToPrivateUDDI = publish;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/PublishWSWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/PublishWSWidget.java
new file mode 100644
index 000000000..5b74d45b3
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/PublishWSWidget.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 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
+ * -------- -------- -----------------------------------------------------------
+ * 20080430 214624 makandre@ca.ibm.com - Andrew Mak, Remove favourite UDDI registries from Web Service Publish page
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import java.util.Vector;
+
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
+import org.eclipse.jst.ws.internal.consumption.ui.wizard.PrivateUDDIRegistryTypeRegistry;
+import org.eclipse.jst.ws.internal.ui.uddi.PrivateUDDIRegistryType;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.help.IWorkbenchHelpSystem;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.ws.internal.explorer.LaunchOption;
+import org.eclipse.wst.ws.internal.explorer.LaunchOptions;
+
+
+public class PublishWSWidget extends SimpleWidgetDataContributor
+{
+ /* CONTEXT_ID PWPB0001 for the UDDI Publish Page */
+ private String INFOPOP_PWPB_PAGE = WebServiceConsumptionUIPlugin.ID + ".PWPB0001";
+ /* CONTEXT_ID PWPB0002 for the UDDI Launch check box of the UDDI Publish Page */
+ private String INFOPOP_PWPB_CHECKBOX_WS_LAUNCH = WebServiceConsumptionUIPlugin.ID + ".PWPB0002";
+ private Button launchUDDICheckbox_;
+ private Button launchPrivateUDDICheckbox_;
+ private Listener statusListener;
+ private Boolean publish;
+
+ public PublishWSWidget(boolean publish)
+ {
+ this.publish = new Boolean(publish);
+ }
+
+ public WidgetDataEvents addControls(Composite parent, Listener statusListener)
+ {
+ this.statusListener = statusListener;
+ Listener selListener = new Listener()
+ {
+ public void handleEvent(Event event)
+ {
+ handleSelectionEvent(event);
+ }
+ };
+ parent.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWPB_PAGE);
+ IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+ helpSystem.setHelp(parent, INFOPOP_PWPB_PAGE);
+ launchPrivateUDDICheckbox_ = new Button(parent, SWT.CHECK);
+ if (publish.booleanValue())
+ launchPrivateUDDICheckbox_.setText(ConsumptionUIMessages.BUTTON_WS_PUBLISH_PRIVATE_UDDI);
+ else
+ launchPrivateUDDICheckbox_.setText(ConsumptionUIMessages.BUTTON_WS_FIND_PRIVATE_UDDI);
+ launchPrivateUDDICheckbox_.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWPB_CHECKBOX_WS_LAUNCH);
+ launchPrivateUDDICheckbox_.addListener(SWT.Selection, selListener);
+ helpSystem.setHelp(launchPrivateUDDICheckbox_, INFOPOP_PWPB_CHECKBOX_WS_LAUNCH);
+ launchUDDICheckbox_ = new Button(parent, SWT.CHECK);
+ if (publish.booleanValue())
+ launchUDDICheckbox_.setText(ConsumptionUIMessages.BUTTON_WS_PUBLISH);
+ else
+ launchUDDICheckbox_.setText(ConsumptionUIMessages.BUTTON_WS_FIND);
+ launchUDDICheckbox_.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWPB_CHECKBOX_WS_LAUNCH);
+ launchUDDICheckbox_.addListener(SWT.Selection, selListener);
+ helpSystem.setHelp(launchUDDICheckbox_, INFOPOP_PWPB_CHECKBOX_WS_LAUNCH);
+ initPrivateUDDI();
+ return this;
+ }
+
+ private void initPrivateUDDI()
+ {
+ if (!publish.booleanValue() && !PrivateUDDIRegistryTypeRegistry.getInstance().getPrivateUDDIRegistryType().isPrivateUDDIRegistryInstalled())
+ launchPrivateUDDICheckbox_.setEnabled(false);
+ }
+
+ private void handleSelectionEvent(Event event)
+ {
+ statusListener.handleEvent(event);
+ }
+
+ public void setPublishToPublicUDDI(boolean publish)
+ {
+ launchUDDICheckbox_.setSelection(publish);
+ }
+
+ public void setPublishToPublicUDDI(Boolean publish)
+ {
+ setPublishToPublicUDDI(publish.booleanValue());
+ }
+
+ public void setPublishToPrivateUDDI(boolean publish)
+ {
+ launchPrivateUDDICheckbox_.setSelection(publish);
+ }
+
+ public void setPublishToPrivateUDDI(Boolean publish)
+ {
+ setPublishToPrivateUDDI(publish.booleanValue());
+ }
+
+ public boolean getPublishToPublicUDDI()
+ {
+ return launchUDDICheckbox_.getSelection();
+ }
+
+ public boolean getPublishToPrivateUDDI()
+ {
+ return launchPrivateUDDICheckbox_.getSelection();
+ }
+
+ public boolean getForceLaunchOutsideIDE()
+ {
+ return false;
+ }
+
+ public LaunchOption[] getLaunchOptions()
+ {
+ Vector launchOptionVector = new Vector();
+ if (launchUDDICheckbox_.getSelection())
+ {
+ launchOptionVector.add(new LaunchOption(LaunchOptions.INQUIRY_URL, ""));
+ launchOptionVector.add(new LaunchOption(LaunchOptions.PUBLISH_URL, ""));
+ }
+ if (launchPrivateUDDICheckbox_.getSelection())
+ {
+ PrivateUDDIRegistryTypeRegistry privateReg = PrivateUDDIRegistryTypeRegistry.getInstance();
+ PrivateUDDIRegistryType privateType = privateReg.getPrivateUDDIRegistryType();
+ String[] privateInquiryURL = privateType.getPrivateUDDIRegistryInquiryAPI();
+ String[] privatePublishURL = privateType.getPrivateUDDIRegistryPublishAPI();
+ for (int i = 0; i < privateInquiryURL.length; i++)
+ {
+ launchOptionVector.add(new LaunchOption(LaunchOptions.INQUIRY_URL, privateInquiryURL[i]));
+ launchOptionVector.add(new LaunchOption(LaunchOptions.PUBLISH_URL, privatePublishURL[i]));
+ }
+ }
+ return (LaunchOption[]) launchOptionVector.toArray(new LaunchOption[0]);
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ServiceHandlersWidgetDefaultingCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ServiceHandlersWidgetDefaultingCommand.java
new file mode 100644
index 000000000..7d8020a47
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ServiceHandlersWidgetDefaultingCommand.java
@@ -0,0 +1,376 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu
+ * 20060517 142027 sengpl@ca.ibm.com - Seng Phung-Lu
+ * 20060518 142554 sengpl@ca.ibm.com - Seng Phung-Lu
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+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.Status;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.j2ee.internal.webservice.WebServiceNavigatorGroupType;
+import org.eclipse.jst.j2ee.webservice.wsdd.Handler;
+import org.eclipse.jst.j2ee.webservice.wsdd.PortComponent;
+import org.eclipse.jst.j2ee.webservice.wsdd.WebServiceDescription;
+import org.eclipse.jst.j2ee.webservice.wsdd.WebServices;
+import org.eclipse.jst.j2ee.webservice.wsdd.WsddResource;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.common.HandlerDescriptionHolder;
+import org.eclipse.jst.ws.internal.consumption.ui.helper.WebServicesManager;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.HandlerTableItem;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.wsdl.Service;
+import org.eclipse.wst.wsdl.internal.impl.ServiceImpl;
+import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
+
+/**
+ * ServiceHandlersWidgetDefaultingCommand
+ *
+ * Initialize and load the handlers data
+ */
+public class ServiceHandlersWidgetDefaultingCommand extends AbstractHandlersWidgetDefaultingCmd {
+
+ private WsddResource[] wsddResource_ = null;
+ private IProject project_;
+ private String descriptionName_ = null;
+ private String errorStatusMsg_ = null;
+ private boolean isMultipleSelection_;
+ private HandlerDescriptionHolder[] handlerDescriptionHolder_;
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+ IStatus status = Status.OK_STATUS;
+
+ IStructuredSelection selection = getInitialSelection();
+ if (selection == null) {
+ status = StatusUtils.errorStatus( ConsumptionUIMessages.MSG_ERROR_TASK_EXCEPTED );
+ env.getStatusHandler().reportError(status);
+ return status;
+ }
+ else if (selection.size()>1){
+ status = processMultipleHandlers(env);
+ return status;
+ }
+
+ status = processHandlers(env);
+ return status;
+
+ }
+
+ public IStatus processHandlers(IEnvironment env) {
+ try {
+ WebServicesManager webServicesManager = new WebServicesManager();
+ List allWSDLServices = webServicesManager.getAllWSDLServices();
+ int servicesSize = allWSDLServices.size();
+
+ wsddResource_= new WsddResource[servicesSize];
+ wsddResource_[0] = getWsddResourceFromSelection();
+ if (wsddResource_[0] == null) {
+ return StatusUtils.errorStatus(ConsumptionUIMessages.MSG_ERROR_WSDD_NOT_FOUND);
+ }
+
+ // check for another wsddResource of another J2EE level
+ int x = 0;
+ while (x<servicesSize) {
+ Service service = (Service )allWSDLServices.get(x);
+ WsddResource wsddRes = webServicesManager.getWsddResource(service);
+ boolean isUniqueWsdd = true;
+ for (int w=0;w<wsddResource_.length;w++){
+ if (wsddRes.equals(wsddResource_[w])){
+ isUniqueWsdd = false;
+ break;
+ }
+ }
+
+ if (isUniqueWsdd) {
+ wsddResource_[x] = wsddRes;
+ }
+ x++;
+ }
+
+ // determine total # for descriptions
+ handlerDescriptionHolder_ = new HandlerDescriptionHolder[getNumberofServices(wsddResource_)];
+
+ int descCounter = 0;
+ for (int y=0;y<wsddResource_.length;y++) {
+ if (wsddResource_[y] !=null) {
+ WebServices webServices = wsddResource_[y].getWebServices();
+ if (webServices != null) {
+ List wsDescriptions = webServices.getWebServiceDescriptions();
+ for (int i = 0; i < wsDescriptions.size() ; i++) {
+
+ WebServiceDescription wsDescription = (WebServiceDescription) wsDescriptions.get(i);
+ Vector handlers = new Vector();
+ List wsPortComponents = wsDescription.getPortComponents();
+ for (int j = 0; j < wsPortComponents.size(); j++) {
+ PortComponent wsPort = (PortComponent) wsPortComponents.get(j);
+ String portName = wsPort.getPortComponentName();
+ List wsHandlers = wsPort.getHandlers();
+
+ for (int k = 0; k < wsHandlers.size(); k++) {
+
+ Handler wsHandler = (Handler) wsHandlers.get(k);
+
+ HandlerTableItem handlerItem = new HandlerTableItem();
+ handlerItem.setHandler(wsHandler);
+ handlerItem.setHandlerName(wsHandler.getHandlerName());
+ handlerItem.setHandlerClassName(wsHandler.getHandlerClass());
+ handlerItem.setPort(wsPort);
+ handlerItem.setPortName(portName);
+ handlerItem.setWsDescRef(wsDescription);
+
+ handlers.add(handlerItem);
+ }
+ }
+ String wsDescName = wsDescription.getWebServiceDescriptionName();
+ handlerDescriptionHolder_[descCounter] = new HandlerDescriptionHolder();
+ handlerDescriptionHolder_[descCounter].setHandlerList(handlers);
+ handlerDescriptionHolder_[descCounter].setDescriptionObject(wsDescription);
+ handlerDescriptionHolder_[descCounter].setDescriptionName(wsDescName);
+ descCounter++;
+ }
+ }
+ }
+ }
+
+ if (handlerDescriptionHolder_ == null){
+ //report no Web service is available
+ return StatusUtils.errorStatus(ConsumptionUIMessages.MSG_ERROR_WEB_SERVICES_NOT_FOUND);
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ return StatusUtils.errorStatus( ConsumptionUIMessages.MSG_ERROR_TASK_EXCEPTED, e);
+ }
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * For processing multiple service selection; only prepare table of service description names
+ * description objects will be processed later by the output command
+ * @param env
+ * @return
+ */
+ private IStatus processMultipleHandlers(IEnvironment env){
+
+ Service[] services = getSelectedServices();
+ if (errorStatusMsg_ != null){
+ return StatusUtils.errorStatus(errorStatusMsg_);
+ }
+ isMultipleSelection_ = true;
+
+ handlerDescriptionHolder_ = new HandlerDescriptionHolder[services.length];
+ Vector handlers = new Vector();
+ for (int i=0;i<services.length;i++){
+
+ String descName = services[i].getQName().getLocalPart();
+ WebServiceDescription wsDescription = getServiceDescription(services[i], descName);
+ handlerDescriptionHolder_[i] = new HandlerDescriptionHolder();
+ handlerDescriptionHolder_[i].setHandlerList(handlers);
+ handlerDescriptionHolder_[i].setDescriptionName(descName);
+ handlerDescriptionHolder_[i].setDescriptionObject(wsDescription);
+ }
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * Matches the serviceName with the ServiceDescriptionName to get the WebServiceDescription
+ * @param service
+ * @param serviceName
+ * @return
+ */
+ private WebServiceDescription getServiceDescription(Service service, String serviceName){
+ WebServicesManager webServicesManager = new WebServicesManager();
+ WsddResource wsddResource = webServicesManager.getWsddResource(service);
+ if (wsddResource!=null) {
+ WebServices services = wsddResource.getWebServices();
+ if (services!=null) {
+ List descriptions = services.getWebServiceDescriptions();
+ for (int i=0;i<descriptions.size();i++){
+ WebServiceDescription wsd = (WebServiceDescription)descriptions.get(i);
+ if (wsd!=null && wsd.getWebServiceDescriptionName().equals(serviceName)){
+ return wsd;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean getIsMultipleSelection(){
+ return this.isMultipleSelection_;
+ }
+
+ /**
+ * @return Returns the isGenSkeletonEnabled_.
+ */
+ public boolean getGenSkeletonEnabled() {
+ if (isMultipleSelection_)
+ return false;
+ return true;
+ }
+
+ /**
+ * @return Returns the sourceOutputLocation_.
+ */
+ public IPath[] getSourceOutputLocation() {
+ IPath[] locations = null;
+ IProject project = getProject();
+
+ if (project != null) {
+ locations = ResourceUtils.getAllJavaSourceLocations(project);
+ }
+ else {
+ project = project_;
+ if (project != null) {
+ locations = ResourceUtils.getAllJavaSourceLocations(project);
+ }
+ }
+ return locations;
+ }
+
+ /**
+ * Gets the WsddResource
+ * @return
+ */
+ public WsddResource[] getWsddResource() {
+ return wsddResource_;
+ }
+
+ private WsddResource getWsddResourceFromSelection() {
+ WebServicesManager webServicesManager = new WebServicesManager();
+
+ IStructuredSelection initSel = getInitialSelection();
+ if (initSel != null && initSel.size() == 1) {
+ Object obj = initSel.getFirstElement();
+ if (obj instanceof ServiceImpl) {
+ // Service object
+ Service service = (Service) obj;
+ descriptionName_ = service.getQName().getLocalPart();
+ project_ = ProjectUtilities.getProject(service);
+ return webServicesManager.getWsddResource(service);
+ }
+ else if (obj instanceof WSDLResourceImpl) {
+ // WSDL resource
+ WSDLResourceImpl res = (WSDLResourceImpl) obj;
+ project_ = ProjectUtilities.getProject(res);
+ List wsdlResources = webServicesManager.getWSDLServices(res);
+ return webServicesManager.getWsddResource((Service) wsdlResources.get(0));
+ }
+ else if (obj instanceof WebServiceNavigatorGroupType) {
+ WebServiceNavigatorGroupType wsngt = (WebServiceNavigatorGroupType) obj;
+ Service service = (Service)wsngt.getWsdlService();
+ descriptionName_ = service.getQName().getLocalPart();
+ project_ = ProjectUtilities.getProject(service);
+ return webServicesManager.getWsddResource(service);
+ }
+ else if (obj instanceof IFile){
+ // webservices.xml file
+ Resource res = WorkbenchResourceHelperBase.getResource((IFile)obj, true);
+ WsddResource wsddRes = (WsddResource)res;
+ WebServices webServices = wsddRes.getWebServices();
+ if (webServices != null) {
+ List wsDescriptions = webServices.getWebServiceDescriptions();
+ if (wsDescriptions!=null) {
+ WebServiceDescription wsd = (WebServiceDescription)wsDescriptions.get(0);
+ descriptionName_ = wsd.getWebServiceDescriptionName();
+ }
+ }
+ project_ = ProjectUtilities.getProject(res);
+ return wsddRes;
+ }
+ }
+
+ return null;
+
+ }
+
+ /**
+ * Get total number of ServiceDescriptions given 14 and 13 services
+ * @param wsddRes
+ * @return
+ */
+ private int getNumberofServices(WsddResource[] wsddRes){
+ int num= 0;
+ for (int i=0;i<wsddRes.length;i++){
+ if (wsddRes[i]!=null) {
+ WebServices ws = wsddRes[i].getWebServices();
+ if (ws!=null){
+ num += ws.getWebServiceDescriptions().size();
+ }
+ }
+ }
+ return num;
+
+ }
+
+ /**
+ * For multiple selection of Services
+ * @return
+ */
+ private Service[] getSelectedServices(){
+ WebServicesManager wsManager = new WebServicesManager();
+ IStructuredSelection initSel = getInitialSelection();
+ Service[] services = new Service[initSel.size()];
+ wsddResource_ = new WsddResource[initSel.size()];
+ Iterator iter = initSel.iterator();
+ for (int i=0;i<initSel.size();i++) {
+ Object obj = iter.next();
+ if (obj instanceof Service){
+ services[i] = (Service)obj;
+ wsddResource_[i] = wsManager.getWsddResource(services[i]);
+ }
+ else{
+ errorStatusMsg_ = ConsumptionUIMessages.MSG_ERROR_INVALID_MULTIPLE_SERVICE_SELECT;
+ return null;
+ }
+ }
+ return services;
+ }
+
+
+
+ /**
+ * Get Description Name for single Web services selected
+ * null if mulitple services are selected
+ * @return
+ */
+ public String getDescriptionName(){
+ return descriptionName_;
+ }
+
+ /**
+ * An array of HandlerDescriptionHolders
+ * @return
+ */
+ public HandlerDescriptionHolder[] getHandlerDescriptionHolders(){
+ return handlerDescriptionHolder_;
+ }
+
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ServiceHandlersWidgetOutputCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ServiceHandlersWidgetOutputCommand.java
new file mode 100644
index 000000000..9ef8c607b
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/ServiceHandlersWidgetOutputCommand.java
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * Copyright (c) 2004,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
+ * -------- -------- -----------------------------------------------------------
+ * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu
+ * 20060517 142027 sengpl@ca.ibm.com - Seng Phung-Lu
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+
+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.jst.j2ee.webservice.wsdd.Handler;
+import org.eclipse.jst.j2ee.webservice.wsdd.PortComponent;
+import org.eclipse.jst.j2ee.webservice.wsdd.WebServiceDescription;
+import org.eclipse.jst.j2ee.webservice.wsdd.WsddFactory;
+import org.eclipse.jst.j2ee.webservice.wsdd.WsddResource;
+import org.eclipse.jst.j2ee.webservice.wsdd.internal.impl.WsddFactoryImpl;
+import org.eclipse.jst.ws.internal.consumption.ui.common.HandlerDescriptionHelper;
+import org.eclipse.jst.ws.internal.consumption.ui.common.HandlerDescriptionHolder;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.HandlerTableItem;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.internal.emf.utilities.EtoolsCopyUtility;
+
+/*
+ * Provide a way to externalize the edited fields and create new handlers
+ *
+ */
+public class ServiceHandlersWidgetOutputCommand extends AbstractDataModelOperation
+{
+
+ private WsddResource[] wsddResource_;
+ private boolean isMultipleSelection_;
+ private HandlerDescriptionHolder[] handlerDescriptionHolder_;
+
+ /**
+ * For each HandlerDescriptionHolder, the user selected Handlers are
+ * sync'd up with the internal model
+ * For multiple services, handlers are added (not removed) to each port.
+ *
+ */
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IStatus status = Status.OK_STATUS;
+ try {
+ if (isMultipleSelection_){
+ for (int i=0; i<handlerDescriptionHolder_.length;i++){
+
+ handlerDescriptionHolder_[i].addHandlerToAllPorts();
+ }
+ }
+ else {
+ // add handler(s) for single service selected
+ for (int h=0;h<handlerDescriptionHolder_.length;h++){
+
+ Hashtable wsPortsTable = new Hashtable();
+ Hashtable wsPortToHandlerTable = new Hashtable();
+
+ String serviceDescName = handlerDescriptionHolder_[h].getDescriptionName();
+ // load PortName -> PortComponent table
+ HandlerDescriptionHolder hdh = HandlerDescriptionHelper.getForDescriptionName(handlerDescriptionHolder_, serviceDescName);
+ if (hdh!=null) {
+
+ WebServiceDescription wsDescription_ = hdh.getDescriptionObject();
+ if (wsDescription_ != null) {
+ List wsPorts = wsDescription_.getPortComponents();
+ for (int k = 0; k < wsPorts.size(); k++) {
+ PortComponent port = (PortComponent) wsPorts.get(k);
+ wsPortsTable.put(port.getPortComponentName(), port);
+ wsPortToHandlerTable.put(port.getPortComponentName(), new ArrayList());
+ }
+ }
+
+ List handlerTableItems = hdh.getHandlerList();
+ if (handlerTableItems != null) {
+
+ WsddFactory wsddFactory = new WsddFactoryImpl();
+
+ //form port components tables first
+ for (int i = 0; i < handlerTableItems.size(); i++) {
+
+ HandlerTableItem hti = (HandlerTableItem) handlerTableItems.get(i);
+ PortComponent wsPort = (PortComponent) hti.getPort();
+ if (wsPort == null) {
+ //find it
+ if (wsPortsTable.get(hti.getPortName()) != null)
+ wsPort = (PortComponent) wsPortsTable.get(hti.getPortName());
+ else {
+ // create it; should not get into here
+ wsPort = wsddFactory.createPortComponent();
+ wsPort.setPortComponentName(hti.getPortName());
+ wsPortsTable.put(wsPort.getPortComponentName(), wsPort);
+ }
+ }
+ wsPortToHandlerTable.put(wsPort.getPortComponentName(), new ArrayList());
+ }
+
+ // form Handler and ports table
+ for (int i = 0; i < handlerTableItems.size(); i++) {
+
+ HandlerTableItem hti = (HandlerTableItem) handlerTableItems.get(i);
+ String portName = hti.getPortName();
+
+ PortComponent port = (PortComponent) wsPortsTable.get(portName);
+ if (port == null) return status;
+
+ List existingHandlers = port.getHandlers();
+
+ Object handler = hti.getHandler();
+ if (!existingHandlers.contains(handler)) {
+ // create it
+ Handler newHandler = wsddFactory.createHandler();
+ newHandler.setHandlerName(hti.getHandlerName());
+ newHandler.setHandlerClass(hti.getHandlerClassName());
+ ((List) wsPortToHandlerTable.get(portName)).add(newHandler);
+
+ }
+ else if (handler instanceof Handler) {
+ // clone it
+ EtoolsCopyUtility copyUtil = new EtoolsCopyUtility();
+ copyUtil.setCopyAdapters(true);
+ Handler clonedHandler = (Handler) copyUtil.copy((Handler) handler);
+ ((List) wsPortToHandlerTable.get(portName)).add(clonedHandler);
+ }
+ }
+ }
+
+ // remove existing handlers from ports
+ removeExistingHandlers(wsPortsTable, wsPortToHandlerTable);
+
+ // add ports to wsDescription
+ addPortsToDescriptions(wsPortsTable, wsDescription_);
+
+ // add handlers to ports
+ addHandlersToPorts(wsPortsTable, wsPortToHandlerTable);
+ }
+ }
+ }
+
+ // save
+ if (wsddResource_ != null) {
+ for (int i=0;i<wsddResource_.length;i++) {
+ if (wsddResource_[i]!=null)
+ wsddResource_[i].save(new HashMap());
+ }
+ }
+
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return status;
+ }
+
+ private void removeExistingHandlers(Hashtable portsTable, Hashtable portsToHandlersTable) {
+ try {
+ Enumeration ports = portsToHandlersTable.keys();
+ while (ports.hasMoreElements()) {
+ String portName = (String) ports.nextElement();
+ Object port = portsTable.get(portName);
+ if (port != null && port instanceof PortComponent) {
+ List handlers = ((PortComponent) port).getHandlers();
+ handlers.clear();
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void addPortsToDescriptions(Hashtable portsTable, WebServiceDescription wsDescription_) {
+ try {
+ Enumeration ports = portsTable.keys();
+ while (ports.hasMoreElements()) {
+ String portName = (String) ports.nextElement();
+ // newly edited port
+ Object port = portsTable.get(portName);
+
+ // existing port
+ List emfPorts = wsDescription_.getPortComponents();
+ if (!emfPorts.contains(port) && port != null && port instanceof PortComponent) {
+ emfPorts.add((PortComponent) port);
+ }
+ }
+ }
+
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void addHandlersToPorts(Hashtable portsTable, Hashtable portsToHandlersTable) {
+ try {
+ Enumeration ports = portsToHandlersTable.keys();
+ while (ports.hasMoreElements()) {
+ String portName = (String) ports.nextElement();
+ Object port = portsTable.get(portName);
+ if (port != null && port instanceof PortComponent) {
+ List handlers = (List) portsToHandlersTable.get(portName);
+
+ List modelHandlers = ((PortComponent) port).getHandlers();
+ modelHandlers.addAll(handlers);
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * HandlerDescriptionHolder
+ * @param hdhs
+ */
+ public void setHandlerDescriptionHolders(HandlerDescriptionHolder[] hdhs){
+ this.handlerDescriptionHolder_ = hdhs;
+ }
+
+ public void setIsMultipleSelection(boolean isMulitpleSelection) {
+ this.isMultipleSelection_ = isMulitpleSelection;
+ }
+
+
+ public void setWsddResource(WsddResource[] wsddRes) {
+ this.wsddResource_ = wsddRes;
+ }
+
+} \ No newline at end of file
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/TableViewerWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/TableViewerWidget.java
new file mode 100644
index 000000000..21e88e532
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/TableViewerWidget.java
@@ -0,0 +1,639 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060505 139918 pmoogk@ca.ibm.com - Peter Moogk
+ * 20110824 355591 kchong@ca.ibm.com - Keith Chong, [Usability] Package to mapping table doesn't handle 'enter' key properly
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.consumption.common.PropertiesResourceFilter;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.ui.dialog.DialogUtils;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+
+
+public class TableViewerWidget extends SimpleWidgetDataContributor
+{
+ private int DEFAULT_TABLE_HEIGHT_HINT = 100;
+ private int DEFAULT_COLUMN_WIDTH = 80;
+
+ public static byte MAP_ONE_TO_ONE = 3;
+ public static byte MAP_MANY_TO_ONE = 1;
+ public static byte MAP_MANY_TO_MANY = 0;
+
+ private String[] columns_;
+ private TableViewer tableViewer_;
+ private Table table_;
+ private TableEditor editor_;
+ private TableEditorListener tableEditorListener_;
+ private Text text_;
+ private Button import_;
+ private Button add_;
+ private Button remove_;
+
+ private Composite parent_;
+ private Listener statusListener_;
+
+ private String message = null;
+ private byte rescriction = MAP_MANY_TO_MANY;
+
+ private List values_;
+ private Object defaultValue_;
+
+ private PropertiesResourceFilter filter_ = new PropertiesResourceFilter();
+
+ public TableViewerWidget(String[] columns, List initValues, Object defaultValue, byte rescriction)
+ {
+ columns_ = columns;
+ values_ = new ArrayList();
+ if (initValues != null && initValues.size() > 0)
+ values_.addAll(initValues);
+ defaultValue_ = (defaultValue != null) ? defaultValue : new String("");
+ this.rescriction = rescriction;
+ }
+
+ public WidgetDataEvents addControls( Composite parent, Listener statusListener )
+ {
+ parent_ = parent;
+ statusListener_ = statusListener;
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout();
+
+ gl.marginHeight = 0;
+ gl.marginWidth = 0;
+ composite.setLayout(gl);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ table_ = new Table(composite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = DEFAULT_TABLE_HEIGHT_HINT;
+ table_.setLayoutData(gd);
+ table_.setHeaderVisible(true);
+ table_.setLinesVisible(true);
+ TableLayout tableLayout = new TableLayout();
+ int maxWidth = DEFAULT_COLUMN_WIDTH;
+ for (int i = 0; i < columns_.length; i++)
+ {
+ TableColumn tableColumn = new TableColumn(table_, SWT.NONE);
+ tableColumn.setText(columns_[i]);
+ tableColumn.pack();
+ int tableColumnWidth = Math.max(DEFAULT_COLUMN_WIDTH, tableColumn.getWidth());
+ maxWidth = Math.max(maxWidth, tableColumnWidth);
+ ColumnWeightData columnData = new ColumnWeightData(tableColumnWidth, tableColumnWidth, true);
+ tableLayout.addColumnData(columnData);
+ }
+ table_.setLayout(tableLayout);
+ // initialize the table editor
+ editor_ = new TableEditor(table_);
+ // The editor must have the same size as the cell and must
+ // not be any smaller than 50 pixels.
+ editor_.horizontalAlignment = SWT.LEFT;
+ editor_.grabHorizontal = true;
+ editor_.minimumWidth = maxWidth;
+ tableEditorListener_ = new TableEditorListener();
+ table_.addMouseListener(tableEditorListener_);
+ tableViewer_ = new TableViewer(table_);
+ tableViewer_.getControl().addKeyListener(
+ new KeyListener()
+ {
+ public void keyPressed(KeyEvent e)
+ {
+ int asciiDel = (int)e.character;
+ // Del
+ if (asciiDel == 127)
+ handleDeleteKeyPressed();
+ // Enter or space
+ if (((int)e.character) == 13 || ((int)e.character) == 32)
+ tableEditorListener_.editSelection();
+ }
+ public void keyReleased(KeyEvent e)
+ {
+ }
+ }
+ );
+ tableViewer_.setContentProvider(new ListContentProvider());
+ tableViewer_.setLabelProvider(new ListLabelProvider());
+ tableViewer_.setInput(values_);
+ tableViewer_.addSelectionChangedListener(
+ new ISelectionChangedListener()
+ {
+ public void selectionChanged(SelectionChangedEvent event)
+ {
+ enableRemove(true);
+ }
+ }
+ );
+
+ Composite buttonComposite = new Composite(composite, SWT.NONE);
+ gl = new GridLayout();
+ gl.numColumns = 3;
+ gl.makeColumnsEqualWidth = true;
+ buttonComposite.setLayout(gl);
+ buttonComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+ import_ = new Button(buttonComposite, SWT.PUSH);
+ import_.setText(ConsumptionUIMessages.LABEL_IMPORT);
+ import_.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ import_.addSelectionListener(
+ new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+ handleImportButtonSelected(event);
+ }
+ public void widgetDefaultSelected(SelectionEvent event)
+ {
+ }
+ }
+ );
+
+ add_ = new Button(buttonComposite, SWT.PUSH);
+ add_.setText(ConsumptionUIMessages.LABEL_ADD);
+ add_.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ add_.addSelectionListener(
+ new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+ handleAddButtonSelected(event);
+ }
+ public void widgetDefaultSelected(SelectionEvent event)
+ {
+ }
+ }
+ );
+
+
+ remove_ = new Button(buttonComposite, SWT.PUSH);
+ remove_.setText(ConsumptionUIMessages.LABEL_REMOVE);
+ remove_.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ remove_.addSelectionListener(
+ new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+ handleRemoveButtonSelected(event);
+ }
+ public void widgetDefaultSelected(SelectionEvent event)
+ {
+ }
+ }
+ );
+ enableRemove(false);
+
+ return this;
+ }
+
+ private void enableRemove(boolean enabled)
+ {
+ remove_.setEnabled(enabled && !tableViewer_.getSelection().isEmpty());
+ }
+
+ private void handleImportButtonSelected(SelectionEvent event)
+ {
+ IResource resource = DialogUtils.browseResources(
+ parent_.getShell(),
+ ResourceUtils.getWorkspaceRoot(),
+ null,
+ filter_
+ );
+ if (resource != null && resource instanceof IFile)
+ {
+ try
+ {
+ Properties props = new Properties();
+ props.load(((IFile)resource).getContents());
+ Set set = props.entrySet();
+ java.util.List list = new LinkedList();
+ Iterator i = set.iterator();
+ while (i.hasNext())
+ {
+ Map.Entry me = (Map.Entry)i.next();
+ String key = (String)me.getKey();
+ String val = (String)me.getValue();
+ list.add(new String[] {key,val});
+ }
+ values_.addAll(list);
+ }
+ catch (Exception e)
+ {
+ // TODO Report some error here.
+ }
+ }
+ refresh();
+ }
+
+ private void handleAddButtonSelected(SelectionEvent event)
+ {
+ values_.add(defaultValue_);
+ refresh();
+ setSelectionAsObject(values_.get(table_.getItemCount()-1));
+ tableEditorListener_.editSelection();
+ }
+
+ private void handleRemoveButtonSelected(SelectionEvent event)
+ {
+ handleDeleteKeyPressed();
+ }
+
+ private void handleDeleteKeyPressed()
+ {
+ internalDispose();
+ ISelection selection = tableViewer_.getSelection();
+ if (selection != null && !selection.isEmpty() && (selection instanceof IStructuredSelection))
+ {
+ int selectionIndex = table_.getSelectionIndex();
+ int selectionCount = table_.getItemCount();
+ values_.remove(selectionIndex);
+ if (selectionIndex < selectionCount-1)
+ setSelectionAsObject(values_.get(selectionIndex));
+ else if (selectionCount -2 >= 0)
+ setSelectionAsObject(values_.get(selectionCount-2));
+ refresh();
+ }
+ }
+
+ private void internalRefresh()
+ {
+ // synchronize text field, previously selected table cell and model (inputObject)
+ if (text_ != null)
+ {
+ TableItem oldTableItem = editor_.getItem();
+ int oldColumnIndex = editor_.getColumn();
+ if (oldTableItem != null && oldColumnIndex >= 0 && oldColumnIndex < columns_.length)
+ {
+ String oldText = text_.getText();
+ oldTableItem.setText(oldColumnIndex, oldText);
+ int oldRowIndex = table_.indexOf(oldTableItem);
+ values_.set(oldRowIndex, new String[] {oldTableItem.getText(0), oldTableItem.getText(1)});
+ }
+ }
+ checkMappingConstraints();
+ statusListener_.handleEvent( null );
+ }
+
+ private void checkMappingConstraints() {
+
+ HashMap map = new HashMap();
+
+ for(int cnt=0; cnt<values_.size(); cnt++){
+ String[] value = (String[])values_.get(cnt);
+ if(map.containsKey(value[0]) && ((rescriction & 1)!=0)){
+ message =NLS.bind(ConsumptionUIMessages.MSG_MAPPING_DUPLICATE_ENTRIES, new String[]{columns_[0],columns_[1]});
+ return;
+ }
+ if(map.containsValue(value[1]) && ((rescriction & 2)!=0)){
+ message =NLS.bind(ConsumptionUIMessages.MSG_MAPPING_DUPLICATE_ENTRIES, new String[]{columns_[1],columns_[0]});
+ return;
+ }
+ map.put(value[0],value[1]);
+
+ }
+ message = null;
+
+ }
+
+ public IStatus getStatus()
+ {
+ return message == null ? Status.OK_STATUS :
+ StatusUtils.errorStatus( message );
+ }
+
+ private void setSelectionAsObject(Object object)
+ {
+ tableViewer_.setSelection(new StructuredSelection(object), true);
+ }
+
+ public void refresh()
+ {
+ internalRefresh();
+ tableViewer_.refresh();
+ }
+
+ public TableItem[] getItems()
+ {
+ //internalRefresh();
+ return table_.getItems();
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ add_.setEnabled(enabled);
+ enableRemove(enabled);
+ }
+
+ public void dispose()
+ {
+ internalDispose();
+ if (editor_ != null)
+ editor_.dispose();
+ if (table_ != null)
+ table_.dispose();
+ if (add_ != null)
+ add_.dispose();
+ if (remove_ != null)
+ remove_.dispose();
+ }
+
+ private void internalDispose()
+ {
+ if (text_ != null)
+ text_.dispose();
+ text_ = null;
+ }
+
+ protected class TableEditorListener implements MouseListener
+ {
+ private int currSelectionIndex_;
+ private int editRow_;
+ private int editColumn_;
+
+ public TableEditorListener()
+ {
+ super();
+ currSelectionIndex_ = -1;
+ editRow_ = -1;
+ editColumn_ = -1;
+ }
+
+ public void mouseDoubleClick(MouseEvent e)
+ {
+ mouseDown(e);
+ }
+
+ public void mouseDown(MouseEvent e)
+ {
+ // refresh table
+ internalRefresh();
+ // Clean up previous text editor control
+ internalDispose();
+ // update table
+ if (table_.isFocusControl())
+ {
+ int selectedRowIndex = getSelectedRow(table_, e.y);
+ if (currSelectionIndex_ != -1 && selectedRowIndex != -1 && currSelectionIndex_ == selectedRowIndex)
+ {
+ TableItem tableItem = table_.getItem(selectedRowIndex);
+ int selectedColumnIndex = getSelectedColumn(tableItem, e.x, e.y);
+ if (selectedColumnIndex != -1 && (text_ == null || text_.isDisposed() || selectedColumnIndex != editor_.getColumn()))
+ editSelection(selectedRowIndex, selectedColumnIndex);
+ }
+ currSelectionIndex_ = selectedRowIndex;
+ }
+ }
+
+ public void mouseUp(MouseEvent e)
+ {
+ }
+
+ private int getSelectedRow(Table table, int y)
+ {
+ TableItem[] tableItems = table.getItems();
+ for (int i = 0; i < tableItems.length; i++)
+ {
+ Rectangle rectangle = tableItems[i].getBounds(0);
+ if (rectangle != null && y >= rectangle.y && y < (rectangle.y + rectangle.height))
+ return i;
+ }
+ return -1;
+ }
+
+ private int getSelectedColumn(TableItem tableItem, int x, int y)
+ {
+ for (int i = 0; i < columns_.length; i++)
+ {
+ if (tableItem.getBounds(i).contains(x, y))
+ return i;
+ }
+ return -1;
+ }
+
+ private void editSelection(int row, int column)
+ {
+ editRow_ = row;
+ editColumn_ = column;
+ TableItem tableItem = table_.getItem(row);
+ // Setup adapter for the new selection
+ text_ = new Text(table_, SWT.NONE);
+ String text = tableItem.getText(column);
+ text_.setText((text != null) ? text : "");
+ text_.addKeyListener(new KeyListener()
+ {
+ public void keyPressed(KeyEvent e)
+ {
+ // Esc
+ if (((int)e.character) == 27)
+ cancelSelection();
+ if (e.character == SWT.CR)
+ {
+ // Handle the carriage return and set the value
+ internalRefresh();
+ internalDispose();
+ }
+ }
+ public void keyReleased(KeyEvent e)
+ {
+ }
+ }
+ );
+ text_.addTraverseListener(new TraverseListener()
+ {
+ public void keyTraversed(TraverseEvent e)
+ {
+ if (e.detail == SWT.TRAVERSE_TAB_NEXT)
+ traverseTabNext();
+ else if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)
+ traverseTabPrevious();
+ else if (e.detail == SWT.TRAVERSE_RETURN)
+ e.doit = false;
+ }
+ }
+ );
+
+ text_.addFocusListener( new FocusAdapter()
+ {
+ public void focusLost(FocusEvent e)
+ {
+ internalRefresh();
+ }
+ } );
+
+ editor_.setEditor(text_, tableItem, column);
+ text_.setFocus();
+ text_.selectAll();
+ }
+
+ protected void traverseTabNext()
+ {
+ internalRefresh();
+ internalDispose();
+ if (!(editRow_ == table_.getItems().length-1 && editColumn_ == columns_.length-1))
+ {
+ if (editColumn_ < columns_.length-1)
+ editColumn_++;
+ else
+ {
+ editColumn_ = 0;
+ editRow_++;
+ table_.select(editRow_);
+ }
+ editSelection(editRow_, editColumn_);
+ }
+ }
+
+ protected void traverseTabPrevious()
+ {
+ internalRefresh();
+ internalDispose();
+ if (!(editRow_ == 0 && editColumn_ == 0))
+ {
+ if (editColumn_ > 0)
+ editColumn_--;
+ else
+ {
+ editColumn_ = columns_.length-1;
+ editRow_--;
+ table_.select(editRow_);
+ }
+ editSelection(editRow_, editColumn_);
+ }
+ }
+
+ public void cancelSelection()
+ {
+ internalDispose();
+ internalRefresh();
+ }
+
+ public void editSelection()
+ {
+ int selectedRowIndex = table_.getSelectionIndex();
+ if (selectedRowIndex != -1 && columns_.length > 0)
+ {
+ // refresh table
+ internalRefresh();
+ // Clean up any previous editor control
+ internalDispose();
+ editSelection(selectedRowIndex, 0);
+ }
+ currSelectionIndex_ = selectedRowIndex;
+ }
+ }
+
+ protected class ListContentProvider implements IStructuredContentProvider
+ {
+ public void dispose()
+ {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ tableViewer_.add(getElements(newInput));
+ }
+
+ public Object[] getElements(Object inputElement)
+ {
+ if (inputElement instanceof List)
+ {
+ List list = (List)inputElement;
+ Object[] objects = new Object[list.size()];
+ for (int i = 0; i < objects.length; i++)
+ objects[i] = list.get(i);
+ return objects;
+ }
+ else
+ return new Object[0];
+ }
+ }
+
+ protected class ListLabelProvider implements ITableLabelProvider
+ {
+ public Image getColumnImage(Object element, int columnIndex)
+ {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex)
+ {
+ return ((String[])element)[columnIndex];
+ }
+
+ public void addListener(ILabelProviderListener listener)
+ {
+ }
+
+ public void removeListener(ILabelProviderListener listener)
+ {
+ }
+
+ public boolean isLabelProperty(Object element, String property)
+ {
+ return true;
+ }
+
+ public void dispose()
+ {
+ }
+ }
+ }
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/TimedWSDLSelectionConditionCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/TimedWSDLSelectionConditionCommand.java
new file mode 100644
index 000000000..de42995db
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/TimedWSDLSelectionConditionCommand.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2015 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060504 119296 pmoogk@ca.ibm.com - Peter Moogk
+ * 20150113 457332 jgwest@ca.ibm.com - Jonathan West, TimedWSDLSelectionConditionCommand/TimedOperation classes blocks automated tests with confirmation dialog box
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
+import org.eclipse.wst.command.internal.env.core.common.Condition;
+import org.eclipse.wst.command.internal.env.ui.common.TimedOperation;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+
+
+public class TimedWSDLSelectionConditionCommand extends AbstractDataModelOperation implements Condition
+{
+ private final String TIMEOUT_PREFERENCE = "wsdlTimeOut";
+ private WSDLSelectionConditionCommand selectionCommand;
+ private int timeOutValue;
+ private boolean headless = false;
+
+ public TimedWSDLSelectionConditionCommand()
+ {
+ selectionCommand = new WSDLSelectionConditionCommand();
+
+ IPreferenceStore prefStore = WebServiceConsumptionUIPlugin.getInstance().getPreferenceStore();
+
+ timeOutValue = prefStore.getDefaultString(TIMEOUT_PREFERENCE).equals("") ? 10000 : prefStore.getInt( TIMEOUT_PREFERENCE );
+ }
+
+ public void setWebServicesParser(WebServicesParser webServicesParser)
+ {
+ selectionCommand.setWebServicesParser( webServicesParser );
+ }
+
+ public WebServicesParser getWebServicesParser()
+ {
+ return selectionCommand.getWebServicesParser();
+ }
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ String timeOutMessage = ConsumptionUIMessages.bind( ConsumptionUIMessages.MSG_INFO_WSDL_OPERATION_TIMED_OUT, getWebServiceURI() );
+
+ TimedOperation timedOperation = new TimedOperation( selectionCommand, timeOutValue, timeOutMessage );
+ timedOperation.setHeadless(headless);
+
+ return timedOperation.execute(monitor, adaptable);
+ }
+
+ public boolean evaluate()
+ {
+ return selectionCommand.evaluate();
+ }
+
+ public String getWebServiceURI()
+ {
+ return selectionCommand.getWebServiceURI();
+ }
+
+ public void setWebServiceURI(String webServiceURI)
+ {
+ selectionCommand.setWebServiceURI(webServiceURI);
+ }
+
+ public String getWsdlURI()
+ {
+ return getWebServiceURI();
+ }
+/**
+ * @return Returns the httpBasicAuthPassword.
+ */
+public String getHttpBasicAuthPassword() {
+ return selectionCommand.getHttpBasicAuthPassword();
+}
+/**
+ * @return Returns the httpBasicAuthUsername.
+ */
+public String getHttpBasicAuthUsername() {
+ return selectionCommand.getHttpBasicAuthUsername();
+}
+
+public void setHeadless(boolean headless) {
+ this.headless = headless;
+}
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionConditionCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionConditionCommand.java
new file mode 100644
index 000000000..bb6049aa9
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionConditionCommand.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+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.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.wsil.DialogWWWAuthentication;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.core.common.Condition;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.parser.discovery.WebServicesParserExt;
+import org.eclipse.wst.ws.internal.parser.wsil.WWWAuthenticationException;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServiceEntity;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+
+
+public class WSDLSelectionConditionCommand extends AbstractDataModelOperation implements Condition
+{
+ private WebServicesParser webServicesParser;
+ private String webServiceURI;
+ private String httpBasicAuthUsername;
+ private String httpBasicAuthPassword;
+ private boolean needWSDLSelectionTreeWidget;
+
+ public WSDLSelectionConditionCommand()
+ {
+ }
+
+ public void setWebServicesParser(WebServicesParser webServicesParser)
+ {
+ this.webServicesParser = webServicesParser;
+ }
+
+ public WebServicesParser getWebServicesParser()
+ {
+ if (webServicesParser == null)
+ webServicesParser = new WebServicesParserExt();
+ return webServicesParser;
+ }
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ needWSDLSelectionTreeWidget = false;
+ WebServicesParser parser = getWebServicesParser();
+ parser.setURI(webServiceURI);
+ try
+ {
+ parser.parse(WebServicesParser.PARSE_WSIL | WebServicesParser.PARSE_DISCO | WebServicesParser.PARSE_LINKS);
+ }
+ catch (WWWAuthenticationException wwwae)
+ {
+ DialogWWWAuthentication dialog = new DialogWWWAuthentication(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ dialog.handleWWWAuthentication(wwwae);
+ String username = dialog.getUsername();
+ String password = dialog.getPassword();
+ httpBasicAuthUsername = username;
+ httpBasicAuthPassword = password;
+ if (username != null && password != null)
+ {
+ parser.setHTTPBasicAuthUsername(username);
+ parser.setHTTPBasicAuthPassword(password);
+ try
+ {
+ parser.parse(WebServicesParser.PARSE_WSIL | WebServicesParser.PARSE_DISCO | WebServicesParser.PARSE_LINKS);
+ }
+ catch (Throwable t)
+ {
+ return StatusUtils.errorStatus( NLS.bind(ConsumptionUIMessages.MSG_ERROR_URI_NOT_RESOLVABLE, new Object[] {webServiceURI}), t);
+ }
+ finally
+ {
+ parser.setHTTPBasicAuthUsername(null);
+ parser.setHTTPBasicAuthPassword(null);
+ }
+ }
+ }
+ catch (Throwable t)
+ {
+ return StatusUtils.errorStatus( NLS.bind(ConsumptionUIMessages.MSG_ERROR_URI_NOT_RESOLVABLE, new Object[] {webServiceURI}), t);
+ }
+ WebServiceEntity wsEntity = parser.getWebServiceEntityByURI(webServiceURI);
+ if (wsEntity != null)
+ {
+ int type = wsEntity.getType();
+ if (type != WebServiceEntity.TYPE_WSDL)
+ needWSDLSelectionTreeWidget = true;
+ }
+ return Status.OK_STATUS;
+ }
+
+ public boolean evaluate()
+ {
+ return needWSDLSelectionTreeWidget;
+ }
+
+ public String getWebServiceURI()
+ {
+ return webServiceURI;
+ }
+
+ public void setWebServiceURI(String webServiceURI)
+ {
+ this.webServiceURI = webServiceURI;
+ }
+
+ public String getWsdlURI()
+ {
+ return getWebServiceURI();
+ }
+/**
+ * @return Returns the httpBasicAuthPassword.
+ */
+public String getHttpBasicAuthPassword() {
+ return httpBasicAuthPassword;
+}
+/**
+ * @return Returns the httpBasicAuthUsername.
+ */
+public String getHttpBasicAuthUsername() {
+ return httpBasicAuthUsername;
+}
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionDialog.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionDialog.java
new file mode 100644
index 000000000..a24276ecf
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionDialog.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060525 142281 joan@ca.ibm.com - Joan Haggarty
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.command.internal.env.ui.widgets.AbstractSelectionDialog;
+import org.eclipse.wst.command.internal.env.ui.widgets.PageInfo;
+
+public class WSDLSelectionDialog extends AbstractSelectionDialog {
+
+ private String titleText_;
+ private String wsUri_;
+ private String componentName_;
+ private IProject project_;
+
+ public WSDLSelectionDialog(Shell parent, PageInfo pageInfo) {
+ super(parent, pageInfo);
+ titleText_ = pageInfo.getPageName();
+ }
+
+ protected void callSetters()
+ {
+ ((WSDLSelectionWidgetWrapper)getWidget()).setComponentName(componentName_);
+ ((WSDLSelectionWidgetWrapper)getWidget()).setProject(project_);
+ ((WSDLSelectionWidgetWrapper)getWidget()).setWebServiceURI(wsUri_);
+ }
+
+ public void setComponentName(String componentName)
+ {
+ componentName_ = componentName;
+ }
+
+ public String getComponentName()
+ {
+ return componentName_ ;
+ }
+
+ public void setProject(IProject project)
+ {
+ project_ = project;
+ }
+
+ public void setWebServiceURI(String wsUri)
+ {
+ wsUri_ = wsUri;
+ }
+
+ protected void setShellStyle(int newShellStyle)
+ {
+ super.setShellStyle( newShellStyle | SWT.RESIZE );
+ }
+
+ protected void configureShell(Shell newShell)
+ {
+ newShell.setText(titleText_);
+ super.configureShell(newShell);
+ }
+
+ public String getDisplayableSelectionString() {
+
+ return ((WSDLSelectionWidgetWrapper)getWidget()).getObjectSelectionDisplayableString();
+ }
+
+ public IStructuredSelection getObjectSelection() {
+ return ((WSDLSelectionWidgetWrapper)getWidget()).getObjectSelection();
+ }
+
+ public String getWebServiceURI()
+ {
+ return wsUri_;
+ }
+
+ public IProject getProject(){
+ return project_;
+ }
+
+ public boolean close() {
+ setComponentName(((WSDLSelectionWidgetWrapper)getWidget()).getComponentName());
+ setProject(((WSDLSelectionWidgetWrapper)getWidget()).getProject());
+ setWebServiceURI(((WSDLSelectionWidgetWrapper)getWidget()).getWebServiceURI());
+ return super.close();
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionOutputCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionOutputCommand.java
new file mode 100644
index 000000000..861311e67
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionOutputCommand.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060413 135581 rsinha@ca.ibm.com - Rupam Kuehner
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import java.util.Map;
+
+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.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.parser.discovery.WebServicesParserExt;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+
+
+public class WSDLSelectionOutputCommand extends AbstractDataModelOperation
+{
+ private WebServicesParser webServicesParser;
+ private String wsdlURI;
+ private IProject project;
+ private String componentName;
+
+ private boolean testService;
+
+
+ public boolean getTestService() {
+ return testService;
+ }
+
+
+ public void setTestService(boolean testService) {
+ this.testService = testService;
+ }
+
+ /**
+ * @return Returns the project.
+ */
+ public IProject getProject()
+ {
+ return project;
+ }
+
+ /**
+ * @param project
+ * The project to set.
+ */
+ public void setProject(IProject project)
+ {
+ this.project = project;
+ }
+
+
+
+ public String getComponentName()
+ {
+ return componentName;
+ }
+
+ public void setComponentName(String componentName)
+ {
+ this.componentName = componentName;
+ }
+
+ public String getWsdlURI()
+ {
+ return wsdlURI;
+ }
+
+ public void setWsdlURI(String wsdlURI)
+ {
+ this.wsdlURI = wsdlURI;
+ }
+
+ /**
+ * @return Returns the webServicesParser.
+ */
+ public WebServicesParser getWebServicesParser()
+ {
+ if (webServicesParser != null)
+ return webServicesParser;
+ else
+ return new WebServicesParserExt();
+ }
+
+ /**
+ * @param webServicesParser to set.
+ */
+ public void setWebServicesParser(WebServicesParser webServicesParser)
+ {
+ this.webServicesParser = webServicesParser;
+ }
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+
+ if (wsdlURI != null && getWebServicesParser().getWSDLDefinition(wsdlURI) != null) {
+ IStatus status = Status.OK_STATUS;
+ Map services = getWebServicesParser().getWSDLDefinition(wsdlURI).getServices();
+ if (services.isEmpty()){
+ if (testService==true){
+ testService = false;
+ status = StatusUtils.warningStatus( ConsumptionUIMessages.MSG_WARNING_NO_SERVICE_ELEMENT );
+ try{
+ env.getStatusHandler().report(status);
+ }catch(Exception e){
+ status = StatusUtils.errorStatus( ConsumptionUIMessages.MSG_WARNING_NO_SERVICE_ELEMENT );
+ }
+ }
+ }
+ return status;
+ }
+ else
+ {
+ IStatus status = StatusUtils.errorStatus( ConsumptionUIMessages.PAGE_MSG_SELECTION_MUST_BE_WSDL );
+ if (env != null)
+ {
+ env.getStatusHandler().reportError(status);
+ }
+ return status;
+ }
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionTreeWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionTreeWidget.java
new file mode 100644
index 000000000..28cc163fe
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionTreeWidget.java
@@ -0,0 +1,291 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060418 136712 joan@ca.ibm.com - Joan Haggarty
+ * 20070131 168786 makandre@ca.ibm.com - Andrew Mak, wsdl url on web service wizard page 1 is not reflected in browse dialog
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServiceEntity;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+
+
+/**
+* This wizard page allows the user to select the WSDL URI for consumption
+*/
+public class WSDLSelectionTreeWidget extends SimpleWidgetDataContributor
+{
+ private String pluginId_ = "org.eclipse.jst.ws.consumption.ui";
+
+ /*CONTEXT_ID PWWS0001 for the WSDL Selection Page*/
+ private final String INFOPOP_PWWS_PAGE = ".PWWS0001";
+
+ private WebServicesParser webServicesParser;
+ private String webServiceURI;
+
+ private Listener statusListener;
+ private TreeViewer treeViewer_;
+ private TreeContentProvider treeContentProvider;
+ private Tree tree_;
+ private int pageWidth_;
+ private WebServiceEntity entity_;
+
+ /**
+ * Default constructor.
+ */
+ public WSDLSelectionTreeWidget()
+ {
+ }
+
+ public WidgetDataEvents addControls( Composite parent, Listener statusListener )
+ {
+ this.statusListener = statusListener;
+ parent.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWWS_PAGE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, pluginId_ + INFOPOP_PWWS_PAGE);
+
+ Label wsdlLabel = new Label(parent, SWT.WRAP);
+ wsdlLabel.setText(ConsumptionUIMessages.LABEL_SELECT_WSDL);
+ wsdlLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ tree_ = new Tree(parent, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 200;
+ tree_.setLayoutData(gd);
+ pageWidth_ = tree_.getShell().getSize().x;
+ treeViewer_ = new TreeViewer(tree_);
+ treeContentProvider = new TreeContentProvider();
+ treeViewer_.setContentProvider(treeContentProvider);
+ treeViewer_.setLabelProvider(new TreeLabelProvider());
+ treeViewer_.addSelectionChangedListener(
+ new ISelectionChangedListener()
+ {
+ public void selectionChanged(SelectionChangedEvent event)
+ {
+ handleTreeSelectionChangedEvent(event);
+ }
+ }
+ );
+ return this;
+ }
+
+ private void handleTreeSelectionChangedEvent(SelectionChangedEvent event)
+ {
+ statusListener.handleEvent(new Event());
+ }
+
+ /**
+ * @return Returns the webServicesParser.
+ */
+ public WebServicesParser getWebServicesParser()
+ {
+ return webServicesParser;
+ }
+ /**
+ * @param webServicesParser The webServicesParser to set.
+ */
+ public void setWebServicesParser(WebServicesParser webServicesParser)
+ {
+ this.webServicesParser = webServicesParser;
+ treeViewer_.setInput(this.webServicesParser);
+ refreshTreeViewer();
+ }
+
+ public void setWebServiceURI(String wsURI)
+ {
+ webServiceURI = wsURI;
+ if (!tree_.isDisposed()) {
+ treeContentProvider.setWebServiceURI(webServiceURI);
+ refreshTreeViewer();
+ }
+ }
+
+ public void refreshTreeViewer()
+ {
+ if (webServicesParser != null && webServiceURI != null)
+ {
+ treeViewer_.refresh();
+ Control shell = tree_.getShell();
+ if (tree_.getSize().x > pageWidth_ || shell.getSize().x > pageWidth_)
+ {
+ tree_.setSize(pageWidth_, tree_.getSize().y);
+ shell.setSize(pageWidth_, shell.getSize().y);
+ shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ shell.redraw();
+ }
+ }
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ tree_.setEnabled(enabled);
+ }
+
+ public boolean isEnabled()
+ {
+ return tree_.isEnabled();
+ }
+
+ public String getWsdlURI()
+ {
+ if (entity_ != null)
+ return entity_.getURI();
+ else
+ return webServiceURI;
+ }
+
+ private WebServiceEntity getSelectionAsWebServiceEntity()
+ {
+ if (treeViewer_ != null)
+ {
+ ISelection sel = treeViewer_.getSelection();
+ if (!sel.isEmpty() && (sel instanceof IStructuredSelection))
+ {
+ IStructuredSelection ssel = (IStructuredSelection)sel;
+ Object object = ssel.getFirstElement();
+ if (object instanceof WebServiceEntity)
+ return (WebServiceEntity)object;
+ }
+ }
+ return null;
+ }
+
+ public IStatus getStatus()
+ {
+ entity_ = getSelectionAsWebServiceEntity();
+ if (entity_ == null || entity_.getType() != WebServiceEntity.TYPE_WSDL)
+ return StatusUtils.errorStatus( ConsumptionUIMessages.PAGE_MSG_SELECTION_MUST_BE_WSDL );
+ else
+ return Status.OK_STATUS;
+ }
+
+ private class TreeContentProvider implements ITreeContentProvider
+ {
+ private String webServiceURI;
+
+ public void dispose()
+ {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ }
+
+ public Object[] getElements(Object inputElement)
+ {
+ if (inputElement instanceof WebServicesParser)
+ {
+ WebServicesParser parser = (WebServicesParser)inputElement;
+ Object wsEntity = parser.getWebServiceEntityByURI(webServiceURI);
+ if (wsEntity != null)
+ return new Object[] {wsEntity};
+ }
+ return new Object[0];
+ }
+
+ public Object[] getChildren(Object parentElement)
+ {
+ if (parentElement instanceof WebServiceEntity)
+ {
+ List list = ((WebServiceEntity)parentElement).getChildren();
+ Object[] objects = new Object[list.size()];
+ for (int i = 0; i < objects.length; i++)
+ objects[i] = list.get(i);
+ return objects;
+ }
+ return new Object[0];
+ }
+
+ public Object getParent(Object element)
+ {
+ if (element instanceof WebServiceEntity)
+ return ((WebServiceEntity)element).getParent();
+ return new Object[0];
+ }
+
+ public boolean hasChildren(Object element)
+ {
+ return (getChildren(element).length > 0);
+ }
+
+ public void setWebServiceURI(String wsURI)
+ {
+ webServiceURI = wsURI;
+ }
+ }
+
+ private class TreeLabelProvider implements ILabelProvider
+ {
+ public Image getImage(Object element)
+ {
+ switch (((WebServiceEntity)element).getType())
+ {
+ case WebServiceEntity.TYPE_HTML:
+ return WebServiceConsumptionUIPlugin.getImageDescriptor("icons/wsil/html.gif").createImage();
+ case WebServiceEntity.TYPE_WSIL:
+ return WebServiceConsumptionUIPlugin.getImageDescriptor("icons/wsil/wsil.gif").createImage();
+ case WebServiceEntity.TYPE_WSDL:
+ return WebServiceConsumptionUIPlugin.getImageDescriptor("icons/wsil/wsdl.gif").createImage();
+ default:
+ return null;
+ }
+ }
+
+ public String getText(Object element)
+ {
+ return ((WebServiceEntity)element).getURI();
+ }
+
+ public void addListener(ILabelProviderListener listener)
+ {
+ }
+
+ public void removeListener(ILabelProviderListener listener)
+ {
+ }
+
+ public boolean isLabelProperty(Object element, String property)
+ {
+ return true;
+ }
+
+ public void dispose()
+ {
+ }
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionWidgetDefaultingCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionWidgetDefaultingCommand.java
new file mode 100644
index 000000000..738e58033
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionWidgetDefaultingCommand.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 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
+ * -------- -------- -----------------------------------------------------------
+ * 20070116 159618 makandre@ca.ibm.com - Andrew Mak, Project and EAR not defaulted properly when wizard launched from JSR-109 Web services branch in J2EE Project Explorer
+ * 20070327 172339 kathy@ca.ibm.com - Kathy Chan
+ * 20070125 171071 makandre@ca.ibm.com - Andrew Mak, Create public utility method for copying WSDL files
+ * 20070410 181827 kathy@ca.ibm.com - Kathy Chan
+ * 20080220 219537 makandre@ca.ibm.com - Andrew Mak
+ * 20080501 229728 makandre@ca.ibm.com - Andrew Mak, uppercase .WSDL cannot be found by the Web Service Client wizard
+ * 20081208 257618 mahutch@ca.ibm.com - Mark Hutchinson, Add Mechanism for Adopters to map Services to WSDL URLs
+ * 20090310 242440 yenlu@ca.ibm.com - Yen Lu, Pluggable IFile to URI Converter
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.j2ee.webservice.wsclient.ServiceRef;
+import org.eclipse.jst.ws.internal.common.J2EEActionAdapterFactory;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.converter.IIFile2UriConverter;
+import org.eclipse.wst.ws.internal.plugin.WSPlugin;
+import org.eclipse.wst.ws.internal.ui.utils.AdapterUtils;
+import org.eclipse.wst.ws.internal.util.UniversalPathTransformer;
+import org.eclipse.wst.ws.internal.wsfinder.WSDLURLStringWrapper;
+import org.eclipse.wst.wsdl.internal.impl.ServiceImpl;
+import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
+
+public class WSDLSelectionWidgetDefaultingCommand extends AbstractDataModelOperation
+{
+ private IStructuredSelection selection_;
+ private String uri_;
+
+ public String getWebServiceURI()
+ {
+ if (uri_ != null)
+ return uri_;
+
+ uri_ = "";
+
+ if (selection_ != null && !selection_.isEmpty())
+ {
+ Object firstSel = selection_.getFirstElement();
+ if (firstSel instanceof IFile)
+ {
+ IFile ifile = (IFile)firstSel;
+ String ext = ifile.getFileExtension();
+ if (ext != null && (ext.equalsIgnoreCase("wsdl") || ext.equalsIgnoreCase("wsil") || ext.equalsIgnoreCase("html")))
+ {
+ IIFile2UriConverter converter = WSPlugin.getInstance().getIFile2UriConverter();
+ boolean allowBaseConversionOnFailure = true;
+ if (converter != null)
+ {
+ uri_ = converter.convert(ifile);
+ if (uri_ == null)
+ allowBaseConversionOnFailure = converter.allowBaseConversionOnFailure();
+
+ }
+ if ((uri_ == null || uri_.length() == 0) && allowBaseConversionOnFailure)
+ uri_ = ifile.getFullPath().toString();
+ }
+ }
+ else if (Platform.getAdapterManager().hasAdapter(firstSel, WSDLURLStringWrapper.class.getName())) {
+ Object adaptedObject = Platform.getAdapterManager().loadAdapter(firstSel, WSDLURLStringWrapper.class.getName());
+ WSDLURLStringWrapper wrapper = (WSDLURLStringWrapper)adaptedObject;
+ uri_ = wrapper.getWSDLURLString();
+ }
+ else if (firstSel instanceof ServiceImpl)
+ {
+ ServiceImpl serviceImpl = (ServiceImpl)firstSel;
+ uri_ = J2EEActionAdapterFactory.getWSDLURI(serviceImpl);
+ } else if (firstSel instanceof ServiceRef)
+ {
+ ServiceRef serviceRef = (ServiceRef)firstSel;
+ uri_ = J2EEActionAdapterFactory.getWSDLURI(serviceRef);
+ } else if (firstSel instanceof WSDLResourceImpl)
+ {
+ WSDLResourceImpl wsdlRI = (WSDLResourceImpl)firstSel;
+ uri_ = J2EEActionAdapterFactory.getWSDLURI(wsdlRI);
+ } else if (firstSel instanceof String)
+ {
+ uri_ = (String)firstSel;
+ } else {
+ String adaptedUri = AdapterUtils.getAdaptedWSDL(firstSel);
+ if (adaptedUri != null) {
+ uri_ = adaptedUri;
+ }
+ }
+
+ uri_ = UniversalPathTransformer.toPath(uri_);
+ }
+ return uri_;
+ }
+
+ public void setInitialSelection( IStructuredSelection selection )
+ {
+ selection_ = selection;
+ uri_ = null;
+ }
+
+ public boolean getGenWSIL()
+ {
+ return false;
+ }
+
+ public String getWsilURI()
+ {
+ String wsURI = getWebServiceURI();
+ if (wsURI != null && wsURI.length() > 0 && wsURI.toLowerCase().endsWith("wsdl"))
+ {
+ StringBuffer sb = new StringBuffer(wsURI.substring(0, wsURI.length()-4));
+ sb.append("wsil");
+ return sb.toString();
+ }
+ return "";
+ }
+
+ public IProject getProject()
+ {
+ IProject p = getProjectFromInitialSelection(selection_);
+ return p;
+ }
+
+ public String getComponentName()
+ {
+ String cname = getComponentNameFromInitialSelection(selection_);
+ return cname;
+ }
+
+ private boolean hasProtocol(String url) {
+ return url.indexOf(":") != -1;
+ }
+
+ private IProject getProjectFromInitialSelection(IStructuredSelection selection)
+ {
+ if (selection != null && selection.size() == 1)
+ {
+ Object obj = selection.getFirstElement();
+ if (obj != null)
+ {
+ try
+ {
+ IResource resource = ResourceUtils.getResourceFromSelection(obj);
+ if (resource==null) {
+ String uri = getWebServiceURI();
+ if (hasProtocol(uri)) return null;
+ return ResourceUtils.getProjectOf(new Path(uri));
+ }
+ else
+ return ResourceUtils.getProjectOf(resource.getFullPath());
+ } catch(CoreException e)
+ {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getComponentNameFromInitialSelection(IStructuredSelection selection)
+ {
+ if (selection != null && selection.size() == 1)
+ {
+ Object obj = selection.getFirstElement();
+ if (obj != null)
+ {
+ try
+ {
+ IResource resource = ResourceUtils.getResourceFromSelection(obj);
+ IVirtualComponent comp;
+ if (resource==null) {
+ String uri = getWebServiceURI();
+ if (hasProtocol(uri)) return null;
+ comp = ResourceUtils.getComponentOf(new Path(uri)) ;
+ }
+ else
+ comp = ResourceUtils.getComponentOf(resource);
+ if (comp!=null)
+ {
+ return comp.getName();
+ }
+ } catch(CoreException e)
+ {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ return Status.OK_STATUS;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionWidgetWrapper.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionWidgetWrapper.java
new file mode 100644
index 000000000..56a9a6abe
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WSDLSelectionWidgetWrapper.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060420 135912 joan@ca.ibm.com - Joan Haggarty
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.WSDLSelectionWidget;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.WSDLSelectionWrapper;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+
+public class WSDLSelectionWidgetWrapper extends SimpleWidgetDataContributor
+{
+ private WSDLSelectionWidget wsdlSelectionWidget;
+ private IProject project;
+ private String componentName;
+
+ public WSDLSelectionWidgetWrapper()
+ {
+ wsdlSelectionWidget = new WSDLSelectionWidget();
+ }
+
+ public WidgetDataEvents addControls(Composite parent, Listener statusListener)
+ {
+ wsdlSelectionWidget.addControls(parent, statusListener);
+ return this;
+ }
+
+ public IStatus getStatus()
+ {
+ return wsdlSelectionWidget.getStatus();
+ }
+
+ public void setWebServiceURI(String wsUri)
+ {
+ IStructuredSelection sel;
+ if (wsUri != null)
+ sel = new StructuredSelection(wsUri);
+ else
+ sel = new StructuredSelection();
+ wsdlSelectionWidget.setInitialSelection(sel);
+ }
+
+ public String getWebServiceURI()
+ {
+ IStructuredSelection sel = wsdlSelectionWidget.getObjectSelection();
+ Object object = sel.getFirstElement();
+ String result = null;
+
+ if (object != null )
+ {
+ if( object instanceof WSDLSelectionWrapper )
+ {
+ // Get at the inner structured selection object.
+ WSDLSelectionWrapper wrapper = (WSDLSelectionWrapper)object;
+ IStructuredSelection innerSelection = wrapper.wsdlSelection;
+ Object innerObject = innerSelection.getFirstElement();
+
+ result = innerObject == null ? null : innerObject.toString();
+ }
+ else
+ {
+ result = object.toString();
+ }
+ }
+
+ return result;
+ }
+
+ public String getWsdlURI()
+ {
+ return getWebServiceURI();
+ }
+
+ public WebServicesParser getWebServicesParser()
+ {
+ return wsdlSelectionWidget.getWebServicesParser();
+ }
+
+ public void setProject(IProject project)
+ {
+ this.project = project;
+ }
+
+ public IProject getProject()
+ {
+ IProject p = wsdlSelectionWidget.getProject();
+ if (p==null)
+ {
+ return project;
+ }
+ else
+ return p;
+ }
+
+ public String getComponentName()
+ {
+ String cname = wsdlSelectionWidget.getComponentName();
+ if (cname==null)
+ {
+ return componentName;
+ }
+ else
+ return cname;
+ }
+
+ public void setComponentName(String componentName)
+ {
+ this.componentName = componentName;
+ }
+
+ public String getObjectSelectionDisplayableString() {
+ if (wsdlSelectionWidget != null)
+ {
+ return wsdlSelectionWidget.getObjectSelectionDisplayableString();
+ }
+ else return "";
+ }
+
+ public IStructuredSelection getObjectSelection() {
+ return wsdlSelectionWidget.getObjectSelection();
+ }
+
+ public boolean validate(String s)
+ {
+ return wsdlSelectionWidget.validate(s);
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WebServiceClientTypeWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WebServiceClientTypeWidget.java
new file mode 100644
index 000000000..aabc3b1ed
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/WebServiceClientTypeWidget.java
@@ -0,0 +1,1080 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2015 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060407 135443 joan@ca.ibm.com - Joan Haggarty
+ * 20060410 135441 joan@ca.ibm.com - Joan Haggarty
+ * 20060410 136030 kathy@ca.ibm.com - Kathy Chan
+ * 20060411 136167 kathy@ca.ibm.com - Kathy Chan
+ * 20060417 136390 joan@ca.ibm.com - Joan Haggarty
+ * 20060413 135581 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060420 136158 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060420 136705 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060421 136761 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060424 138052 kathy@ca.ibm.com - Kathy Chan
+ * 20060425 137831 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060426 137622 joan@ca.ibm.com - Joan Haggarty
+ * 20060427 138058 joan@ca.ibm.com - Joan Haggarty
+ * 20060504 138035 joan@ca.ibm.com - Joan Haggarty
+ * 20060529 141422 kathy@ca.ibm.com - Kathy Chan
+ * 20060607 144826 joan@ca.ibm.com - Joan Haggarty
+ * 20060607 144049 joan@ca.ibm.com - Joan Haggarty
+ * 20060614 146270 joan@ca.ibm.com - Joan Haggarty
+ * 20060717 150577 makandre@ca.ibm.com - Andrew Mak
+ * 20060726 150865 sengpl@ca.ibm.com - Seng Phung-Lu
+ * 20060817 140017 makandre@ca.ibm.com - Andrew Mak, longer project or server/runtime strings do not resize wizard
+ * 20060829 155441 makandre@ca.ibm.com - Andrew Mak, web service wizard hangs during resize
+ * 20070126 138484 kathy@ca.ibm.com - Kathy Chan
+ * 20071130 203826 kathy@ca.ibm.com - Kathy Chan
+ * 20080205 170141 kathy@ca.ibm.com - Kathy Chan
+ * 20080312 147442 trungha@ca.ibm.com - Trung Ha
+ * 20080311 222103 trungha@ca.ibm.com - Trung, Changing service scale doesn't update completely non-UI part of client scale
+ * 20080327 224452 trungha@ca.ibm.com - Trung Ha
+ * 20080416 215084 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20090121 261730 zhang@ca.ibm.com - Allan Zhang, WebService client runtime id return null
+ * 20150311 461526 jgwest@ca.ibm.com - Jonathan West, Allow OSGi bundles to be selected in the Wizard
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets;
+
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.common.DefaultingUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.common.ValidationUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.runtime.ClientRuntimeSelectionWidgetDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.runtime.ProjectSelectionWidget;
+import org.eclipse.jst.ws.internal.consumption.ui.wizard.RuntimeServerSelectionDialog;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils2;
+import org.eclipse.jst.ws.internal.context.ScenarioContext;
+import org.eclipse.jst.ws.internal.data.LabelsAndIds;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.jst.ws.internal.ui.common.UIUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.Accessible;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleControlAdapter;
+import org.eclipse.swt.accessibility.AccessibleControlEvent;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Scale;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.HyperlinkGroup;
+import org.eclipse.ui.forms.HyperlinkSettings;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.wst.command.internal.env.ui.widgets.PageInfo;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributorFactory;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+
+
+public class WebServiceClientTypeWidget extends SimpleWidgetDataContributor implements IPackable
+{
+ // INFOPOPS
+ /* CONTEXT_ID WSWSCEN0022 for the Server hyperlink of the Scenario Page */
+ private String INFOPOP_WSWSCEN_HYPERLINK_SERVER = "WSWSCEN0022";
+ /* CONTEXT_ID WSWSCEN0023 for the Runtime hyperlink of the Scenario Page */
+ private String INFOPOP_WSWSCEN_HYPERLINK_RUNTIME = "WSWSCEN0023";
+ /* CONTEXT_ID WSWSCEN0024 for theProjects hyperlink of the Scenario Page */
+ private String INFOPOP_WSWSCEN_HYPERLINK_PROJECTS = "WSWSCEN0024";
+ /* CONTEXT_ID WSWSCEN0025 for theClient Type combo box of the Scenario Page */
+ private String INFOPOP_WSWSCEN_COMBO_CLIENTTYPE = "WSWSCEN0025";
+ /* CONTEXT_ID WSWSCEN0026 for theClient Slider of the Scenario Page */
+ private String INFOPOP_WSWSCEN_SCALE_CLIENT = "WSWSCEN0026";
+
+ private String GRAPHIC_CLIENT_0="icons/client_test.jpg"; //$NON-NLS-N$
+ private String GRAPHIC_CLIENT_1="icons/client_run.jpg"; //$NON-NLS-N$
+ private String GRAPHIC_CLIENT_2="icons/client_install.jpg"; //$NON-NLS-N$
+ private String GRAPHIC_CLIENT_3="icons/client_deploy.jpg"; //$NON-NLS-N$
+ private String GRAPHIC_CLIENT_4="icons/client_assemble.jpg"; //$NON-NLS-N$
+ private String GRAPHIC_CLIENT_5="icons/client_develop.jpg"; //$NON-NLS-N$
+ private String GRAPHIC_CLIENT_6="icons/client_none.jpg"; //$NON-NLS-N$
+
+ private String ICON_SCALE_BG_0="icons/scale0_bground.jpg"; //$NON-NLS-N$
+ private String ICON_SCALE_BG_1="icons/scale1_bground.jpg"; //$NON-NLS-N$
+ private String ICON_SCALE_BG_2="icons/scale2_bground.jpg"; //$NON-NLS-N$
+ private String ICON_SCALE_BG_3="icons/scale3_bground.jpg"; //$NON-NLS-N$
+ private String ICON_SCALE_BG_4="icons/scale4_bground.jpg"; //$NON-NLS-N$
+ private String ICON_SCALE_BG_5="icons/scale5_bground.jpg"; //$NON-NLS-N$
+ private String ICON_SCALE_BG_6="icons/scale6_bground.jpg"; //$NON-NLS-N$
+
+ private Composite clientComposite_;
+ private Composite hCompClient_;
+ private Shell shell_;
+ private Combo clientTypeCombo_;
+ private Scale clientScale_;
+ private Label topologySpot_;
+ private Label clientDetailsLabel_;
+ private Hyperlink hLinkClientRuntime_;
+ private Hyperlink hLinkClientServer_;
+ private Hyperlink hLinkClientProject_;
+ private Hyperlink hLinkClientEAR_;
+ private ProjectSelectionDialog projectDialog_;
+
+ private boolean developClient_;
+ private boolean assembleClient_;
+ private boolean deployClient_;
+
+ private Boolean testClient_;
+ private Boolean installClient_;
+ private Boolean startClient_;
+
+ private TypeRuntimeServer ids_;
+ private IStructuredSelection objectSelection_;
+ private boolean enableProxy_; //service scale is set to a level that the client scale can be enabled
+ private boolean clientOnly_=false;
+ private int clientScaleSetting_;
+ private ImageRegistry imageReg_;
+ private IProject project_;
+ private WebServicesParser parser_;
+ private String earProjectName_;
+ private String projectName_;
+ private boolean needEar_;
+ private String clientComponentType_;
+
+ private Listener statusListener_;
+ private int validationState_;
+
+ private ScaleSelectionListener scaleSelectionListener = new ScaleSelectionListener();
+
+ private String CLIENT_RUNTIME_PREFIX = ConsumptionUIMessages.LABEL_RUNTIMES_LIST ;
+ private String CLIENT_SERVER_PREFIX = ConsumptionUIMessages.LABEL_SERVERS_LIST;
+ private String CLIENT_PROJECT_PREFIX = ConsumptionUIMessages.LABEL_CLIENT_PROJECT;
+ private String CLIENT_EAR_PREFIX = ConsumptionUIMessages.LABEL_CLIENT_EAR_PROJECT;
+
+ private Composite clientGroupComposite_ ;
+
+ private UIUtils utils_ = new UIUtils("org.eclipse.jst.ws.consumption.ui");
+ private IPackable packable_ = null;
+ private LabelsAndIds labelIds_;
+
+ public WebServiceClientTypeWidget(boolean clientOnly) {
+ clientOnly_ = clientOnly;
+ initImageRegistry();
+ validationState_ = ValidationUtils.VALIDATE_ALL;
+ }
+
+ /**
+ * Give this widget a handle to an IPackable instance, which will also be
+ * packed when this widget's packIt() is called.
+ *
+ * @param packable The IPackable instance.
+ */
+ public void setPackable(IPackable packable) {
+ packable_ = packable;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jst.ws.internal.consumption.ui.widgets.IPackable#packIt()
+ */
+ public void packIt() {
+ clientGroupComposite_.pack(true);
+ utils_.horizontalResize(clientGroupComposite_.getShell(), clientGroupComposite_, UIUtils.DEFAULT_PADDING);
+ if (!clientOnly_ && packable_ != null)
+ packable_.packIt();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.WidgetContributor#addControls(org.eclipse.swt.widgets.Composite, org.eclipse.swt.widgets.Listener)
+ */
+ public WidgetDataEvents addControls( Composite parent, Listener statusListener)
+ {
+ statusListener_ = statusListener;
+ Composite clientTypeComposite = new Composite(parent, SWT.NONE);
+ GridLayout cclayout = new GridLayout();
+ cclayout.numColumns = 2;
+ cclayout.marginTop=3;
+ clientTypeComposite.setLayout( cclayout );
+ GridData ccGridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+ clientTypeComposite.setLayoutData(ccGridData);
+
+ int comboStyle = SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY;
+ clientTypeCombo_ = utils_.createCombo( clientTypeComposite,
+ ConsumptionUIMessages.LABEL_WEBSERVICECLIENTTYPE,
+ ConsumptionUIMessages.TOOLTIP_PWPR_COMBO_CLIENTTYPE,
+ INFOPOP_WSWSCEN_COMBO_CLIENTTYPE,
+ comboStyle );
+ GridData comboGridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+ clientTypeCombo_.setLayoutData(comboGridData);
+ clientTypeCombo_.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ String oldTypeId = ids_.getTypeId();
+ int currentSelectionIdx = clientTypeCombo_.getSelectionIndex();
+ String currentTypeId = labelIds_.getIds_()[currentSelectionIdx];
+ if (!oldTypeId.equals(currentTypeId)) {
+ // handle changing client type
+ ids_.setTypeId(currentTypeId);
+ refreshServerRuntimeSelection();
+ }
+ validationState_ = ValidationUtils.VALIDATE_ALL;
+ statusListener_.handleEvent(null);
+ }
+
+ });
+
+ clientGroupComposite_ = new Composite(parent, SWT.NONE);
+ GridLayout gclayout = new GridLayout();
+ gclayout.numColumns = 2;
+ gclayout.horizontalSpacing=0;
+ gclayout.marginHeight=0;
+ gclayout.marginBottom=5;
+ clientGroupComposite_.setLayout( gclayout );
+ GridData gcGridData = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
+ clientGroupComposite_.setLayoutData(gcGridData);
+
+ clientGroupComposite_.addControlListener(new ControlListener()
+ {
+ public void controlMoved(ControlEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ public void controlResized(ControlEvent e) {
+ clientGroupComposite_.pack(true);
+ }
+ });
+
+
+ clientComposite_ = new Composite(clientGroupComposite_, SWT.NONE);
+ GridLayout gridlayout = new GridLayout();
+ gridlayout.numColumns = 2;
+ gridlayout.horizontalSpacing=0;
+ gridlayout.marginHeight=0;
+ clientComposite_.setLayout( gridlayout );
+ GridData scGridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ clientComposite_.setLayoutData(scGridData);
+
+ clientScale_ = new Scale(clientComposite_ , SWT.VERTICAL | SWT.BORDER);
+ utils_.createInfoPop(clientScale_, INFOPOP_WSWSCEN_SCALE_CLIENT);
+ clientScale_.setMinimum(0);
+ clientScale_.setMaximum(6);
+ clientScale_.setIncrement(1);
+ clientScale_.setPageIncrement(1);
+ clientScale_.addSelectionListener(scaleSelectionListener);
+ setClientScale(getClientGeneration());
+ clientScale_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_CLIENT);
+
+ Accessible accessibleScale = clientScale_.getAccessible();
+ accessibleScale.addAccessibleListener(new AccessibleAdapter(){
+ // return a string that describes what to do with the slider
+ // this is read by the screen reader when the slider first gets focus
+ public void getName(AccessibleEvent e) {
+ e.result = ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_CLIENT;
+ }
+ });
+ accessibleScale.addAccessibleControlListener(new AccessibleControlAdapter(){
+ // return a meaningful string when the screen reader
+ // attempts to get the value from the service scale
+ public void getValue(AccessibleControlEvent e) {
+ int selection = clientScale_.getSelection();
+ switch (selection) {
+ case 0:
+ e.result = ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_TEST;
+ break;
+ case 1:
+ e.result = ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_RUN;
+ break;
+ case 2:
+ e.result = ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_INSTALL;
+ break;
+ case 3:
+ e.result = ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_DEPLOY;
+ break;
+ case 4:
+ e.result = ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_ASSEMBLE;
+ break;
+ case 5:
+ e.result = ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_DEVELOP;
+ break;
+ case 6:
+ if (clientOnly_)
+ e.result = ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_CLIENT_ONLY;
+ else
+ e.result = ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_CLIENT;
+ break;
+ default:
+ break;
+ }
+ }
+ });
+
+ GridData layoutData1 = new GridData();
+ layoutData1.horizontalAlignment=SWT.CENTER;
+ layoutData1.verticalAlignment = SWT.BEGINNING;
+ Rectangle scaleR = (imageReg_.get(ICON_SCALE_BG_0)).getBounds();
+ layoutData1.heightHint=scaleR.height;
+ layoutData1.widthHint=scaleR.width+1;
+ clientScale_.setLayoutData(layoutData1);
+
+ topologySpot_ = new Label(clientComposite_ , SWT.CENTER | SWT.BORDER );
+ topologySpot_.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+ if (clientOnly_)
+ topologySpot_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_CLIENT_ONLY);
+ else
+ topologySpot_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_CLIENT);
+
+ GridData layoutData = new GridData();
+ layoutData.verticalAlignment=SWT.BEGINNING;
+ layoutData.horizontalAlignment=SWT.BEGINNING;
+ Rectangle topR = (imageReg_.get(GRAPHIC_CLIENT_6)).getBounds();
+ layoutData.widthHint=topR.width;
+ layoutData.heightHint=topR.height;
+ topologySpot_.setLayoutData(layoutData);
+
+ setGraphics(getClientGeneration());
+
+ hCompClient_ = utils_.createComposite(clientGroupComposite_, 1);
+
+ clientDetailsLabel_ = new Label(hCompClient_, SWT.NONE);
+ clientDetailsLabel_.setText(ConsumptionUIMessages.LABEL_SUMMARY);
+
+ hLinkClientServer_= new Hyperlink(hCompClient_, SWT.NULL);
+ utils_.createInfoPop(hLinkClientServer_, INFOPOP_WSWSCEN_HYPERLINK_SERVER);
+ hLinkClientServer_.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWRS_TEXT_SERVER);
+ hLinkClientServer_.addHyperlinkListener(new IHyperlinkListener(){
+ public void linkActivated(HyperlinkEvent e){
+ launchRuntimeSelectionDialog(true, true);
+ }
+ public void linkEntered(HyperlinkEvent e){}
+ public void linkExited(HyperlinkEvent e){}
+ });
+
+ hLinkClientRuntime_ = new Hyperlink(hCompClient_, SWT.NULL);
+ utils_.createInfoPop(hLinkClientRuntime_, INFOPOP_WSWSCEN_HYPERLINK_RUNTIME);
+ hLinkClientRuntime_.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWRS_TEXT_RUNTIME);
+ hLinkClientRuntime_.addHyperlinkListener(new IHyperlinkListener(){
+ public void linkActivated(HyperlinkEvent e){
+ launchRuntimeSelectionDialog(true);
+ }
+ public void linkEntered(HyperlinkEvent e){}
+ public void linkExited(HyperlinkEvent e){}
+ });
+
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ projectDialog_ = new ProjectSelectionDialog(workbench.getActiveWorkbenchWindow().getShell(),
+ new PageInfo(ConsumptionUIMessages.DIALOG_TITILE_CLIENT_PROJECT_SETTINGS, "",
+ new WidgetContributorFactory()
+ {
+ public WidgetContributor create()
+ {
+ return new ProjectSelectionWidget(true);
+ }
+ }));
+
+ hLinkClientProject_ = new Hyperlink(hCompClient_, SWT.NULL);
+ utils_.createInfoPop(hLinkClientRuntime_, INFOPOP_WSWSCEN_HYPERLINK_PROJECTS);
+ hLinkClientProject_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_CLIENTPROJECT_LINK);
+ hLinkClientProject_.addHyperlinkListener(new IHyperlinkListener(){
+ public void linkActivated(HyperlinkEvent e){
+ launchProjectDialog();
+ }
+ public void linkEntered(HyperlinkEvent e){}
+ public void linkExited(HyperlinkEvent e){}
+ });
+
+ hLinkClientEAR_ = new Hyperlink(hCompClient_, SWT.NULL);
+ utils_.createInfoPop(hLinkClientRuntime_, INFOPOP_WSWSCEN_HYPERLINK_PROJECTS);
+ hLinkClientEAR_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_CLIENTPROJECT_LINK);
+ hLinkClientEAR_.addHyperlinkListener(new IHyperlinkListener(){
+ public void linkActivated(HyperlinkEvent e){
+ launchProjectDialog();
+ }
+ public void linkEntered(HyperlinkEvent e){}
+ public void linkExited(HyperlinkEvent e){}
+ });
+
+ hLinkClientServer_.setText(CLIENT_SERVER_PREFIX);
+ hLinkClientRuntime_.setText(CLIENT_RUNTIME_PREFIX);
+ hLinkClientProject_.setText(CLIENT_PROJECT_PREFIX);
+ hLinkClientEAR_.setText(CLIENT_EAR_PREFIX);
+
+ HyperlinkGroup serverRuntimeGroup = new HyperlinkGroup(Display.getCurrent());
+ serverRuntimeGroup.add(hLinkClientServer_);
+ serverRuntimeGroup.add(hLinkClientRuntime_);
+ serverRuntimeGroup.add(hLinkClientProject_);
+ serverRuntimeGroup.add(hLinkClientEAR_);
+ serverRuntimeGroup.setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_ALWAYS);
+
+ enableClientSlider(getGenerateProxy());
+
+ return this;
+ }
+
+ public void enableClientSlider( boolean enable )
+ {
+ enableProxy_ = enable;
+ clientScale_.setEnabled(enable);
+ int selection = getClientGeneration();
+ if (enable)
+ {
+ setGraphics(selection);
+ }
+ else
+ {
+ setClientScale(ScenarioContext.WS_NONE);
+ updateFields(ScenarioContext.WS_NONE);
+ setGraphics(ScenarioContext.WS_NONE);
+ clientScale_.setBackgroundImage(null); //override background for disable to grey
+ }
+ showSummary(enable && (selection <= ScenarioContext.WS_DEVELOP));
+ }
+
+ private void updateFields(int selection) {
+ setDevelopClient(selection <= ScenarioContext.WS_DEVELOP);
+ setAssembleClient(selection <= ScenarioContext.WS_ASSEMBLE);
+ setDeployClient(selection <= ScenarioContext.WS_DEPLOY);
+ setTestClient(new Boolean(selection <= ScenarioContext.WS_TEST));
+ setInstallClient(new Boolean(selection <= ScenarioContext.WS_INSTALL));
+ setStartClient(new Boolean(selection <= ScenarioContext.WS_START));
+ }
+
+ private void showSummary(boolean show)
+ {
+ if (clientOnly_)
+ show = true; //short circuit to eliminate flicker...
+
+ hLinkClientEAR_.setVisible(show && needEar_);
+ hLinkClientProject_.setVisible(show);
+ hLinkClientRuntime_.setVisible(show);
+ hLinkClientServer_.setVisible(show);
+
+ if (show)
+ {
+ clientDetailsLabel_.setText(ConsumptionUIMessages.LABEL_SUMMARY);
+ }
+ else
+ {
+ if (clientOnly_)
+ hCompClient_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_CLIENT_ONLY);
+ else
+ hCompClient_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_CLIENT);
+ clientDetailsLabel_.setText(ConsumptionUIMessages.LABEL_SUMMARY_NO_CLIENT);
+ }
+ clientDetailsLabel_.pack(true);
+ hLinkClientProject_.pack(true);
+ hLinkClientEAR_.pack(true);
+ packIt();
+ }
+
+ public void setTypeRuntimeServer( TypeRuntimeServer ids )
+ {
+ LabelsAndIds labelIds = WebServiceRuntimeExtensionUtils2.getClientTypeLabels();
+ int selection = 0;
+ String[] clientIds = labelIds.getIds_();
+ String selectedId = ids.getTypeId();
+
+ labelIds_ = labelIds;
+ // rskreg
+ clientTypeCombo_.setItems( labelIds.getLabels_() );
+
+ // Now find the selected one.
+ for( int index = 0; index < clientIds.length; index++ )
+ {
+ if( selectedId.equals( clientIds[index ]) )
+ {
+ selection = index;
+ break;
+ }
+ }
+
+ clientTypeCombo_.select( selection );
+ ids_ = ids;
+
+ if (ids_ != null)
+ {
+ String clientServerText = "";
+ String serverId = ids_.getServerId();
+ if (serverId != null && serverId.length()>0)
+ {
+ clientServerText = WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId);
+ }
+ String clientRuntimeText = WebServiceRuntimeExtensionUtils2.getRuntimeLabelById(ids_.getRuntimeId());
+
+ String currentServerText = hLinkClientServer_.getText();
+ String currentRuntimeText = hLinkClientRuntime_.getText();
+ String newServerText = CLIENT_SERVER_PREFIX + " " + clientServerText;
+ String newRuntimeText = CLIENT_RUNTIME_PREFIX + " " + clientRuntimeText;
+ hLinkClientServer_.setText(newServerText);
+ hLinkClientRuntime_.setText(newRuntimeText);
+
+ /*check to see if text has changed for server or runtime
+ if so, repaint links */
+ if (!newServerText.equals(currentServerText))
+ {
+ hLinkClientServer_.pack(true);
+ packIt();
+ }
+
+ if (!newRuntimeText.equals(currentRuntimeText))
+ {
+ hLinkClientRuntime_.pack(true);
+ packIt();
+ }
+ }
+
+ if (projectDialog_ != null)
+ projectDialog_.setTypeRuntimeServer(ids_);
+
+ //When the server changes, the state of needEar could change.
+ //If the the server change results in a change in the state of needEar,
+ //update needEar and clientEarProjectName.
+
+ ValidationUtils vu = new ValidationUtils();
+ boolean oldNeedEar = getClientNeedEAR();
+ boolean clientProjectOrProjectTypeNeedsEar;
+
+ if (!oldNeedEar) {
+ // If an EAR was not needed previously it could have been because of
+ // the project/project type or the server.
+ // If it was because of the project/project type, changing the
+ // server should have no impact
+ // on the state of needEar.
+ clientProjectOrProjectTypeNeedsEar = vu.projectOrProjectTypeNeedsEar(getClientProjectName(),
+ getClientComponentType());
+ } else {
+ clientProjectOrProjectTypeNeedsEar = true;
+ }
+
+ // boolean clientProjectOrProjectTypeNeedsEar =
+ // vu.projectOrProjectTypeNeedsEar(getClientProjectName(),
+ // getClientComponentType());
+ if (clientProjectOrProjectTypeNeedsEar) {
+ // Could not rule out need for an Ear from the project/project type
+ // so changing the server
+ // may impact the need for an Ear.
+ boolean currentServerNeedsEar = vu.serverNeedsEAR(getTypeRuntimeServer().getServerId());
+ if (oldNeedEar != currentServerNeedsEar) {
+ // Update needEar and serviceEarProjectName.
+ if (currentServerNeedsEar) {
+ // Calculate a reasonable default for the Ear project name
+ String earProjectName = DefaultingUtils.getDefaultEARProjectName(getClientProjectName());
+ setClientNeedEAR(currentServerNeedsEar);
+ setClientEarProjectName(earProjectName);
+ } else {
+ setClientNeedEAR(currentServerNeedsEar);
+ setClientEarProjectName("");
+ }
+
+ }
+ }
+ }
+
+ public TypeRuntimeServer getTypeRuntimeServer()
+ {
+ return ids_;
+ }
+
+ public boolean getGenerateProxy()
+ {
+ return getClientGeneration() <= ScenarioContext.WS_DEVELOP;
+ }
+
+ public boolean getDevelopClient() {
+ return developClient_;
+ }
+
+ public void setDevelopClient(boolean developClient) {
+ this.developClient_ = developClient;
+ }
+
+ public boolean getAssembleClient() {
+ return assembleClient_;
+ }
+
+ public void setAssembleClient(boolean assembleClient) {
+ this.assembleClient_ = assembleClient;
+ }
+
+ public boolean getDeployClient() {
+ return deployClient_;
+ }
+
+ public void setDeployClient(boolean deployClient) {
+ this.deployClient_ = deployClient;
+ }
+
+ public void setTestClient(Boolean value)
+ {
+ testClient_ = value;
+ }
+
+ public Boolean getTestClient()
+ {
+ return testClient_;
+ }
+
+ public Boolean getInstallClient()
+ {
+ return installClient_;
+ }
+
+ public Boolean getStartClient()
+ {
+ return startClient_;
+ }
+
+ public void setInstallClient( Boolean value )
+ {
+ installClient_ = value;
+ }
+
+ public void setStartClient( Boolean value )
+ {
+ startClient_ = value;
+ }
+
+
+ private void launchProjectDialog()
+ {
+ String currentProjectName = getClientProjectName();
+ String currentEarProjectName = getClientEarProjectName();
+ String currentProjectType = getClientComponentType();
+ boolean currentNeedEar = getClientNeedEAR();
+
+ projectDialog_.setProjectName(currentProjectName);
+ projectDialog_.setEarProjectName(currentEarProjectName);
+ projectDialog_.setNeedEAR(currentNeedEar);
+ projectDialog_.setProjectComponentType(currentProjectType);
+
+ int status = projectDialog_.open();
+
+ if (status == Window.OK)
+ {
+ String newProjectName = projectDialog_.getProjectName();
+ String newEarProjectName = projectDialog_.getEarProjectName();
+ String newProjectType = projectDialog_.getProjectComponentType();
+ boolean newNeedEar = projectDialog_.getNeedEAR();
+
+ //Update project settings and validate page if selections changed.
+ if (!newProjectName.equals(currentProjectName)
+ || !newEarProjectName.equals(currentEarProjectName)
+ || !newProjectType.equals(currentProjectType)
+ || newNeedEar != currentNeedEar) {
+ setClientProjectName(newProjectName);
+ setClientEarProjectName(newEarProjectName);
+ setClientNeedEAR(newNeedEar);
+ setClientComponentType(newProjectType);
+ validationState_ = (new ValidationUtils()).getNewValidationState(validationState_, ValidationUtils.VALIDATE_PROJECT_CHANGES);
+ statusListener_.handleEvent(null);
+ }
+
+ /*check to see if text has changed for project or EAR
+ if so, repaint links */
+ if (!newProjectName.equals(currentProjectName))
+ {
+ hLinkClientProject_.pack(true);
+ packIt();
+ }
+ refreshEARLink();
+ }
+ }
+
+ private void launchRuntimeSelectionDialog(boolean clientContext) {
+ launchRuntimeSelectionDialog(clientContext, false);
+ }
+
+ private void launchRuntimeSelectionDialog(boolean clientContext, boolean selectServerFirst)
+ {
+ TypeRuntimeServer currentClientTRS = getTypeRuntimeServer();
+ RuntimeServerSelectionDialog rssd = new RuntimeServerSelectionDialog(shell_, (byte)1, getTypeRuntimeServer(), "14");
+ rssd.setSelectServerFirst(selectServerFirst);
+ int status = rssd.open();
+ if (status == Window.OK)
+ {
+ TypeRuntimeServer newClientTRS = rssd.getTypeRuntimeServer();
+ if (!currentClientTRS.equals(newClientTRS))
+ {
+ setTypeRuntimeServer(rssd.getTypeRuntimeServer());
+ validationState_ = (new ValidationUtils()).getNewValidationState(validationState_, ValidationUtils.VALIDATE_SERVER_RUNTIME_CHANGES);
+ statusListener_.handleEvent(null); //validate the page
+ }
+ }
+ }
+
+ //Private method should be used whenever clientScale_ setting is changed
+ //instead of calling clientScale_.setSelection directly.
+ private void setClientScale(int setting)
+ {
+ clientScale_.setSelection(setting);
+ clientScaleSetting_ = setting;
+ }
+
+ protected void initImageRegistry()
+ {
+ imageReg_ = new ImageRegistry(Display.getCurrent());
+
+ imageReg_.put(ICON_SCALE_BG_0, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(ICON_SCALE_BG_0));
+ imageReg_.put(ICON_SCALE_BG_1, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(ICON_SCALE_BG_1));
+ imageReg_.put(ICON_SCALE_BG_2, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(ICON_SCALE_BG_2));
+ imageReg_.put(ICON_SCALE_BG_3, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(ICON_SCALE_BG_3));
+ imageReg_.put(ICON_SCALE_BG_4, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(ICON_SCALE_BG_4));
+ imageReg_.put(ICON_SCALE_BG_5, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(ICON_SCALE_BG_5));
+ imageReg_.put(ICON_SCALE_BG_6, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(ICON_SCALE_BG_6));
+
+ imageReg_.put(GRAPHIC_CLIENT_0, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(GRAPHIC_CLIENT_0));
+ imageReg_.put(GRAPHIC_CLIENT_1, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(GRAPHIC_CLIENT_1));
+ imageReg_.put(GRAPHIC_CLIENT_2, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(GRAPHIC_CLIENT_2));
+ imageReg_.put(GRAPHIC_CLIENT_3, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(GRAPHIC_CLIENT_3));
+ imageReg_.put(GRAPHIC_CLIENT_4, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(GRAPHIC_CLIENT_4));
+ imageReg_.put(GRAPHIC_CLIENT_5, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(GRAPHIC_CLIENT_5));
+ imageReg_.put(GRAPHIC_CLIENT_6, WebServiceConsumptionUIPlugin
+ .getImageDescriptor(GRAPHIC_CLIENT_6));
+ }
+
+ private void setGraphics(int selection)
+ {
+ String iconImage = "";
+ String topologyImage = "";
+
+ switch (selection) {
+ case ScenarioContext.WS_TEST:
+ iconImage=ICON_SCALE_BG_0;
+ topologyImage=GRAPHIC_CLIENT_0;
+ clientScale_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_TEST);
+ break;
+ case ScenarioContext.WS_START:
+ iconImage=ICON_SCALE_BG_1;
+ topologyImage=GRAPHIC_CLIENT_1;
+ clientScale_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_RUN);
+ break;
+ case ScenarioContext.WS_INSTALL:
+ iconImage=ICON_SCALE_BG_2;
+ topologyImage=GRAPHIC_CLIENT_2;
+ clientScale_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_INSTALL);
+ break;
+ case ScenarioContext.WS_DEPLOY:
+ iconImage=ICON_SCALE_BG_3;
+ topologyImage=GRAPHIC_CLIENT_3;
+ clientScale_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_DEPLOY);
+ break;
+ case ScenarioContext.WS_ASSEMBLE:
+ iconImage=ICON_SCALE_BG_4;
+ topologyImage=GRAPHIC_CLIENT_4;
+ clientScale_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_ASSEMBLE);
+ break;
+ case ScenarioContext.WS_DEVELOP:
+ iconImage=ICON_SCALE_BG_5;
+ topologyImage=GRAPHIC_CLIENT_5;
+ clientScale_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_DEVELOP);
+ break;
+ case ScenarioContext.WS_NONE:
+ if (!clientOnly_)
+ {
+ if (enableProxy_) //if service is start or test...
+ iconImage=ICON_SCALE_BG_6;
+ else
+ iconImage=null;
+ topologyImage=GRAPHIC_CLIENT_6;
+ clientScale_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_CLIENT);
+ }
+ else
+ {
+ setClientScale(ScenarioContext.WS_DEVELOP); //"no selection" is not allowed...must develop client @ minimum
+ iconImage=ICON_SCALE_BG_5;
+ topologyImage=GRAPHIC_CLIENT_5;
+ clientScale_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_SCALE_DEVELOP);
+ }
+ break;
+ default:
+ break;
+ }
+ clientScale_.setBackgroundImage(imageReg_.get(iconImage));
+ topologySpot_.setImage(imageReg_.get(topologyImage));
+ }
+
+ public IStructuredSelection getObjectSelection()
+ {
+ return objectSelection_;
+ }
+
+ public void setObjectSelection(IStructuredSelection selection)
+ {
+ objectSelection_ = selection;
+ }
+
+ public int getClientGeneration()
+ {
+ return clientScaleSetting_;
+ }
+
+ public void setClientGeneration(int value)
+ {
+ if (clientOnly_ && value == ScenarioContext.WS_NONE) {
+ value = ScenarioContext.WS_DEVELOP;
+ setDevelopClient(true);
+ }
+
+ setClientScale(value);
+
+ setGraphics(value);
+ showSummary(value < ScenarioContext.WS_NONE);
+ updateFields(value);
+ }
+
+ public void setProject(IProject project)
+ {
+ project_ = project;
+ }
+
+ public IProject getProject()
+ {
+ return project_;
+ }
+
+ public String getClientRuntimeId()
+ {
+ // calculate the most appropriate clientRuntimeId based on current settings.
+ return WebServiceRuntimeExtensionUtils2.getClientRuntimeId(getTypeRuntimeServer(), getClientProjectName(), getClientComponentType());
+
+ }
+
+ public void setClientComponentType(String type)
+ {
+ clientComponentType_= type;
+ }
+
+ public String getClientComponentType()
+ {
+ return clientComponentType_;
+ }
+
+ public void setClientProjectName(String name)
+ {
+ projectName_ = name;
+ hLinkClientProject_.setText(CLIENT_PROJECT_PREFIX + " " + projectName_);
+ hLinkClientProject_.pack(true);
+ packIt();
+ }
+
+ public String getClientProjectName()
+ {
+ if (projectName_ == null)
+ return "";
+ return projectName_;
+ }
+
+ public void setClientEarProjectName(String name)
+ {
+ earProjectName_ = name;
+ refreshEARLink();
+
+ }
+
+
+ public boolean isOSGI()
+ {
+
+ if(DefaultingUtils.isOSGIProject(projectName_))
+ {
+ return true;
+ }
+
+ if(clientComponentType_ != null && DefaultingUtils.isOSGITemplate(clientComponentType_))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+
+ public void refreshEARLink()
+ {
+ hLinkClientEAR_.setVisible(needEar_ && getGenerateProxy());
+ if (needEar_)
+ {
+ if(isOSGI()) {
+ hLinkClientEAR_.setText(ConsumptionUIMessages.LABEL_CLIENT_OSGI_PROJECT + " " + earProjectName_);
+ hLinkClientEAR_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_CLIENTPROJECT_LINK_OSGI);
+
+ hLinkClientProject_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_CLIENTPROJECT_LINK_OSGI);
+
+ } else {
+ hLinkClientEAR_.setText(CLIENT_EAR_PREFIX + " " + earProjectName_);
+ hLinkClientEAR_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_CLIENTPROJECT_LINK);
+ hLinkClientProject_.setToolTipText(ConsumptionUIMessages.TOOLTIP_WSWSCEN_CLIENTPROJECT_LINK);
+ }
+
+ hLinkClientEAR_.pack(true);
+ packIt();
+ }
+ }
+
+ public String getClientEarProjectName()
+ {
+ if (earProjectName_ == null)
+ return "";
+ return earProjectName_;
+ }
+
+ public void setClientNeedEAR(boolean b)
+ {
+ needEar_ = b;
+ refreshEARLink();
+ }
+
+ public boolean getClientNeedEAR()
+ {
+ return needEar_;
+ }
+
+ public WebServicesParser getWebServicesParser()
+ {
+ return parser_;
+ }
+
+ public void setWebServicesParser(WebServicesParser parser)
+ {
+ parser_ = parser;
+ }
+
+ //for the purposes of disabling the service implementation controls from the preferences dialog
+ public void disableNonPreferenceWidgets()
+ {
+ if (hCompClient_ != null)
+ {
+ hCompClient_.setVisible(false);
+ }
+ }
+
+ public int getValidationState()
+ {
+ return validationState_;
+ }
+
+ public void setValidationState(int state)
+ {
+ validationState_ = state;
+ }
+
+ public IStatus checkMissingFieldStatus() {
+
+ ValidationUtils valUtils = new ValidationUtils();
+ String runtimeId = getTypeRuntimeServer().getRuntimeId();
+ String serverId = getTypeRuntimeServer().getServerId();
+ String projectName = getClientProjectName();
+ boolean needEar = getClientNeedEAR();
+ String earProjectName = getClientEarProjectName();
+ String projectTypeId = getClientComponentType();
+ IStatus missingFieldStatus = valUtils.checkMissingFieldStatus(validationState_, null, null, runtimeId, serverId,
+ projectName, needEar, earProjectName, projectTypeId, true);
+ return missingFieldStatus;
+ }
+
+ public IStatus checkErrorStatus() {
+
+ ValidationUtils valUtils = new ValidationUtils();
+ String projectName = getClientProjectName();
+ boolean needEar = getClientNeedEAR();
+ String earProjectName = getClientEarProjectName();
+ String projectTypeId = getClientComponentType();
+ // Defect 215084 - no need to pass initial project for client scenario
+ IStatus possibleErrorStatus = valUtils.checkErrorStatus(validationState_, getTypeRuntimeServer(), projectName,"", needEar, earProjectName, projectTypeId, true);
+ return possibleErrorStatus;
+ }
+
+ public IStatus checkWarningStatus() {
+ ValidationUtils valUtils = new ValidationUtils();
+
+ int scaleSetting = getClientGeneration();
+ String serverId = getTypeRuntimeServer().getServerId();
+ IStatus warningStatus = valUtils.checkWarningStatus(validationState_, scaleSetting, serverId, getTypeRuntimeServer().getServerInstanceId(), true);
+ return warningStatus;
+ }
+
+
+ private class ScaleSelectionListener implements SelectionListener
+ {
+ public void widgetSelected(SelectionEvent e) {
+ int oldClientScaleSetting = clientScaleSetting_;
+
+ int selection = clientScale_.getSelection();
+
+ //WARNING: No scale change should be done after the line below, 'selection' might not have the correct value
+ setClientGeneration(selection);
+
+ //When client slider moves out of the "WS_NONE" state, VALIDATE_ALL should be done.
+ //Otherwise, VALIDATE_SCALE_CHANGES is sufficient.
+ if (oldClientScaleSetting==ScenarioContext.WS_NONE && clientScaleSetting_!=ScenarioContext.WS_NONE)
+ {
+ validationState_ = ValidationUtils.VALIDATE_ALL;
+ }
+ else
+ {
+ validationState_ = (new ValidationUtils()).getNewValidationState(validationState_, ValidationUtils.VALIDATE_SCALE_CHANGES);
+ }
+ statusListener_.handleEvent(null); //validate the page
+ }
+
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ }
+
+ private void refreshServerRuntimeSelection()
+ {
+ //new up ServerRuntimeSelectionWidgetDefaultingCommand
+ ClientRuntimeSelectionWidgetDefaultingCommand clientRTDefaultCmd = new ClientRuntimeSelectionWidgetDefaultingCommand();
+
+ //call setters of new defaulting command:
+ clientRTDefaultCmd.setClientInitialSelection(getObjectSelection());
+ clientRTDefaultCmd.setClientInitialProject(getProject());
+ clientRTDefaultCmd.setClientTypeRuntimeServer(getTypeRuntimeServer());
+ clientRTDefaultCmd.setWebServicesParser(getWebServicesParser());
+ clientRTDefaultCmd.setClientEarProjectName(getClientEarProjectName());
+
+ clientRTDefaultCmd.execute(null, null);
+
+ //perform mappings from the defaulting command to the project settings...
+ setClientProjectName(clientRTDefaultCmd.getClientProjectName());
+ setClientEarProjectName(clientRTDefaultCmd.getClientEarProjectName());
+ setClientComponentType(clientRTDefaultCmd.getClientComponentType());
+ setTypeRuntimeServer(clientRTDefaultCmd.getClientTypeRuntimeServer());
+ setClientNeedEAR(clientRTDefaultCmd.getClientNeedEAR());
+ }
+}
+
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ClientWidgetBinding.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ClientWidgetBinding.java
new file mode 100644
index 000000000..61c70bb35
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ClientWidgetBinding.java
@@ -0,0 +1,486 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2015 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060204 124408 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060204 121605 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060221 119111 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060223 129020 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060406 135350 kathy@ca.ibm.com - Kathy Chan
+ * 20060407 135415 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060425 138052 kathy@ca.ibm.com - Kathy Chan
+ * 20060517 141880 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060524 142635 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20060529 141422 kathy@ca.ibm.com - Kathy Chan
+ * 20060530 144358 kathy@ca.ibm.com - Kathy Chan
+ * 20060530 141422 kathy@ca.ibm.com - Kathy Chan
+ * 20060717 146332 makandre@ca.ibm.com - Andrew Mak
+ * 20060728 145426 kathy@ca.ibm.com - Kathy Chan
+ * 20060821 153833 makandre@ca.ibm.com - Andrew Mak, Allow the Web Service Test extension point to specify the supported client runtime
+ * 20060825 155114 pmoogk@ca.ibm.com - Peter Moogk
+ * 20070502 180304 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20071031 140518 joan@ca.ibm.com - Joan Haggarty
+ * 20080325 184761 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080506 227848 makandre@ca.ibm.com - Andrew Mak, Disabled "Run on Server" checkbox is in checked state
+ * 20080715 240722 makandre@ca.ibm.com - Andrew Mak, Cannot setup TCP/IP Monitor for soap12 endpoints
+ * 20080722 240231 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20150311 461526 jgwest@ca.ibm.com - Jonathan West, Allow OSGi bundles to be selected in the Wizard
+ *
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.binding;
+
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.command.CheckForServiceProjectCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.command.data.EclipseIPath2URLStringTransformer;
+import org.eclipse.jst.ws.internal.consumption.ui.common.FinishFragment;
+import org.eclipse.jst.ws.internal.consumption.ui.common.ScenarioCleanupCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.extension.ClientRootFragment;
+import org.eclipse.jst.ws.internal.consumption.ui.extension.PreClientDevelopCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.extension.PreClientInstallCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ClientWizardWidget;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ClientWizardWidgetDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ClientWizardWidgetOutputCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.WSDLSelectionWidgetDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.extensions.ClientExtensionDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.extensions.ClientExtensionFragment;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.extensions.ClientExtensionOutputCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.runtime.ClientRuntimeSelectionWidgetDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.ClientTestDelegateCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.ClientTestFragment;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.ClientTestWidget;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.FinishDefaultCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.FinishTestFragment;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.TestDefaultingFragment;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.WebServiceClientTestArrivalCommand;
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactory;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
+import org.eclipse.wst.command.internal.env.ui.widgets.CanFinishRegistry;
+import org.eclipse.wst.command.internal.env.ui.widgets.CommandWidgetBinding;
+import org.eclipse.wst.command.internal.env.ui.widgets.SelectionCommand;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributorFactory;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetRegistry;
+import org.eclipse.wst.ws.internal.extensions.AssembleClientFragment;
+import org.eclipse.wst.ws.internal.extensions.DeployClientFragment;
+import org.eclipse.wst.ws.internal.extensions.DevelopClientFragment;
+import org.eclipse.wst.ws.internal.extensions.InstallClientFragment;
+import org.eclipse.wst.ws.internal.extensions.RunClientFragment;
+import org.eclipse.wst.ws.internal.monitor.GetMonitorCommand;
+
+
+public class ClientWidgetBinding implements CommandWidgetBinding
+{
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#create()
+ */
+ public CommandFragmentFactory create()
+ {
+ return new CommandFragmentFactory()
+ {
+ public CommandFragment create()
+ {
+ return new ClientRootCommandFragment();
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerCanFinish(org.eclipse.wst.command.env.ui.widgets.CanFinishRegistry)
+ */
+ public void registerCanFinish(CanFinishRegistry canFinishRegistry)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry)
+ {
+ //jvh mapping for initialselection????
+
+ // Before ClientWizardWidget
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "ClientTypeRuntimeServer", ClientWizardWidget.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "InstallClient", ClientWizardWidget.class );
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "TestService", ClientWizardWidget.class );
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "MonitorService", ClientWizardWidget.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "ClientGeneration", ClientWizardWidget.class );
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "ResourceContext", ClientWizardWidget.class );
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "DevelopClient", ClientWizardWidget.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "AssembleClient", ClientWizardWidget.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "DeployClient", ClientWizardWidget.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "StartClient", ClientWizardWidget.class);
+
+ // After ClientWizardWidget
+ dataRegistry.addMapping(ClientWizardWidget.class, "ClientTypeRuntimeServer", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "InstallClient", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "TestService", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "MonitorService", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "ResourceContext", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "ClientProjectName", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "DevelopClient", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "AssembleClient", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "DeployClient", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "StartClient", ClientWizardWidgetOutputCommand.class);
+
+ //jvh added..
+ dataRegistry.addMapping(ClientWizardWidget.class, "Project", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "WebServicesParser", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "WsdlURI", ClientWizardWidgetOutputCommand.class);
+
+ //jvh - rerouted the defaulting command to the ClientWizardWidget
+ // Before ClientRuntimeSelectionWidget
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientTypeRuntimeServer", ClientWizardWidget.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", ClientWizardWidget.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", ClientWizardWidget.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientComponentType", ClientWizardWidget.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientNeedEAR", ClientWizardWidget.class);
+
+ //jvh - rerouted from ClientWizardWidget instead of runtimeserverwidget- add getters to ClientWizardWidget for them
+ // After ClientRuntimeSelectionWidget
+ dataRegistry.addMapping(ClientWizardWidget.class, "ClientTypeRuntimeServer", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "ClientRuntimeId", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "ClientProjectName", ClientExtensionDefaultingCommand.class);
+
+ dataRegistry.addMapping(ClientWizardWidget.class, "ClientEarProjectName", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "ClientOsgiAppProjectName", ClientExtensionDefaultingCommand.class);
+
+ dataRegistry.addMapping(ClientWizardWidget.class, "ClientComponentType", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidget.class, "ClientNeedEAR", ClientExtensionDefaultingCommand.class);
+
+ // Before WSDLSelectionWidgetWrapper
+ // jvh - rerouted these to ClientWizardWidget
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "WebServiceURI", ClientWizardWidget.class );
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "Project", ClientWizardWidget.class );
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "ComponentName", ClientWizardWidget.class );
+
+/* // After WSDLSelectionWidgetWrapper
+ //jvh - reroute these from the dialog to ClientWizardWidget - call setters on the other dialogs...
+ dataRegistry.addMapping(WSDLSelectionWidgetWrapper.class, "WsdlURI", WSDLSelectionOutputCommand.class);
+ dataRegistry.addMapping(WSDLSelectionWidgetWrapper.class, "WebServicesParser", WSDLSelectionOutputCommand.class);
+ dataRegistry.addMapping(WSDLSelectionWidgetWrapper.class, "Project", WSDLSelectionOutputCommand.class);
+ dataRegistry.addMapping(WSDLSelectionWidgetWrapper.class, "ComponentName", WSDLSelectionOutputCommand.class);
+*/
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "GenerateProxy",TestDefaultingFragment.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientRuntimeId",TestDefaultingFragment.class);
+
+ // Before Client Test widget.
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "TestService",FinishTestFragment.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "TestService", ClientTestWidget.class );
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "RunTestClient", ClientTestWidget.class );
+ dataRegistry.addMapping(PreClientInstallCommand.class, "CanRunTestClient", ClientTestWidget.class );
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ClientTestWidget.class );
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "SampleProject", ClientTestWidget.class );
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "SampleProjectEAR", ClientTestWidget.class );
+ dataRegistry.addMapping(TestDefaultingFragment.class, "TestFacility",ClientTestWidget.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "Folder",ClientTestWidget.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "JspFolder",ClientTestWidget.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "RunTestClient",ClientTestWidget.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "Methods",ClientTestWidget.class);
+
+ // After the client test widget
+ dataRegistry.addMapping(ClientTestWidget.class, "SampleProjectEAR",FinishDefaultCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "SampleProject",FinishDefaultCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "TestFacility",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "Folder",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "JspFolder",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "RunTestClient",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "CanRunTestClient",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "Methods",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "TestService",FinishTestFragment.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "TestID",FinishTestFragment.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "IsTestWidget",FinishTestFragment.class);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerWidgetMappings(org.eclipse.wst.command.env.ui.widgets.WidgetRegistry)
+ */
+ public void registerWidgetMappings(WidgetRegistry widgetRegistry)
+ {
+
+ widgetRegistry.add( "ClientWizardWidget",
+ ConsumptionUIMessages.PAGE_TITLE_WS_PROJECT,
+ ConsumptionUIMessages.PAGE_DESC_WS_CLIENT,
+ new WidgetContributorFactory()
+ {
+ public WidgetContributor create()
+ {
+ return new ClientWizardWidget();
+ }
+ } );
+
+ //jvh
+ /*widgetRegistry.add( "ClientRuntimeSelectionWidget",
+ ConsumptionUIMessages.PAGE_TITLE_WS_CLIENT_RUNTIME_SELECTION,
+ ConsumptionUIMessages.PAGE_DESC_WS_CLIENT_RUNTIME_SELECTION,
+ new WidgetContributorFactory()
+ {
+ public WidgetContributor create()
+ {
+ return new ClientRuntimeSelectionWidget();
+ }
+ } );*/
+
+ //jvh
+ /*widgetRegistry.add( "WSDLSelectionWidgetWrapper",
+ ConsumptionUIMessages.PAGE_TITLE_WS_SELECTION,
+ ConsumptionUIMessages.PAGE_DESC_WS_SELECTION,
+ new WidgetContributorFactory()
+ {
+ public WidgetContributor create()
+ {
+ return new WSDLSelectionWidgetWrapper();
+ }
+ } );*/
+
+ widgetRegistry.add( "ClientTestWidget",
+ ConsumptionUIMessages.PAGE_TITLE_WS_SAMPLE,
+ ConsumptionUIMessages.PAGE_DESC_WS_SAMPLE,
+ new WidgetContributorFactory()
+ {
+ public WidgetContributor create()
+ {
+ return new ClientTestWidget();
+ }
+ });
+ }
+
+ private class ClientRootCommandFragment extends SequenceFragment
+ {
+ public ClientRootCommandFragment()
+ {
+ add( new SimpleFragment( new ScenarioCleanupCommand(), "" ));
+
+ //add( new SimpleFragment( new CheckForMissingFiles(), "" ) );
+ add( new SimpleFragment( new ClientWizardWidgetDefaultingCommand(true), "" ) );
+ add( new SimpleFragment( new WSDLSelectionWidgetDefaultingCommand(), "")); //jvh moved this up
+ add( new SimpleFragment( new ClientRuntimeSelectionWidgetDefaultingCommand(), "")); //jvh moved this up
+ add( new SimpleFragment( "ClientWizardWidget" ) );
+ //add( new TestCommandFactoryFragment() );
+ add( new SimpleFragment( new ClientWizardWidgetOutputCommand(), "" ));
+
+ //add( new TestCommandFactoryFragment2() );
+ //add( new SimpleFragment( new CheckForServiceProjectCommand(), ""));
+ add( new SimpleFragment( new ClientExtensionDefaultingCommand( true ), ""));
+ //add(new SimpleFragment(new ClientServerDeployableConfigCommand(false), "")); //Note: added here for client
+ //add( new ClientExtensionFragment() );
+ add( new ClientRootFragment() );
+ add( new SimpleFragment( new ClientExtensionOutputCommand(), "" ) );
+ add( new SimpleFragment(new GetMonitorCommand(), ""));
+ add( new SimpleFragment(new TestDefaultingFragment(),""));
+ add( new ClientTestFragment( "ClientTestWidget") );
+ add(new FinishFragment());
+
+ add( new SimpleFragment( new ScenarioCleanupCommand(), "" ));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragment#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry)
+ {
+ //Map SelectionCommand
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ClientRuntimeSelectionWidgetDefaultingCommand.class, "InitialInitialSelection", null);
+
+ // Map ClientWizardWidgetDefaultingCommand command.
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "ClientTypeRuntimeServer", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "InstallClient", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "TestService", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "RunTestClient", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "MonitorService", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "ResourceContext", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "DevelopClient", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "AssembleClient", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "DeployClient", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "StartClient", ClientWizardWidgetOutputCommand.class);
+
+
+ // Map ClientWizardWidgetOutputCommand command.
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "ResourceContext", ClientRuntimeSelectionWidgetDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "ClientTypeRuntimeServer", ClientRuntimeSelectionWidgetDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "InstallClient", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "RunTestClient", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "TestService", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "TestService", ClientRuntimeSelectionWidgetDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "StartClient", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "DevelopClient", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "AssembleClient", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "DeployClient", ClientExtensionDefaultingCommand.class);
+
+
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "ResourceContext", ClientRuntimeSelectionWidgetDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "ResourceContext", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "MonitorService", GetMonitorCommand.class);
+
+ // Map ClientRuntimeSelectionWidgetDefaultingCommand command
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientTypeRuntimeServer", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientRuntimeId", ClientExtensionDefaultingCommand.class);
+ //dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "Runtime2ClientTypes", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", ClientExtensionDefaultingCommand.class);
+ //dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarComponentName", ClientExtensionDefaultingCommand.class);
+ //dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientComponentName", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientComponentType", ClientExtensionDefaultingCommand.class);
+ //dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientJ2EEVersion", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientNeedEAR", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", CheckForServiceProjectCommand.class);
+
+ // Map WSDLSelectionWidgetDefaultingCommand command.
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", WSDLSelectionWidgetDefaultingCommand.class );
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "Project", ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientInitialProject", null);
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "WebServiceURI", ClientRuntimeSelectionWidgetDefaultingCommand.class, "WsdlURI", new EclipseIPath2URLStringTransformer());
+
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "GenWSIL", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "WsilURI", ClientExtensionDefaultingCommand.class);
+ //jvh - rerouted these to the ClientWizardWidgetOutputCommand
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "WebServiceURI", ClientWizardWidgetOutputCommand.class, "WsdlURI", new EclipseIPath2URLStringTransformer());
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "Project", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "ComponentName", ClientWizardWidgetOutputCommand.class);
+
+ // WSDLSelectionOutputCommand
+ //jvh - rerouted these from ClientWizardWidgetOutputCommand
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "WsdlURI", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "WebServicesParser", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "WsdlURI", GetMonitorCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "WebServicesParser", GetMonitorCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "WsdlURI", CheckForServiceProjectCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "WebServicesParser", CheckForServiceProjectCommand.class);
+
+
+ //jvh - add code to widget so that the appropriate sets happen and defaulting occurs again after object selection
+ /*dataRegistry.addMapping(WSDLSelectionOutputCommand.class, "Project", ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientInitialProject", null);
+ dataRegistry.addMapping(WSDLSelectionOutputCommand.class, "WsdlURI", ClientRuntimeSelectionWidgetDefaultingCommand.class);
+ dataRegistry.addMapping(WSDLSelectionOutputCommand.class, "WebServicesParser", ClientRuntimeSelectionWidgetDefaultingCommand.class);*/
+
+ // Setup the PreClientDevelopCommand.
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "DeployClient", PreClientDevelopCommand.class);
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "InstallClient", PreClientDevelopCommand.class);
+
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "DevelopClient", PreClientDevelopCommand.class);
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "AssembleClient", PreClientDevelopCommand.class);
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "StartClient", PreClientDevelopCommand.class, "StartService", null);
+
+
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "TestService", PreClientDevelopCommand.class);
+ dataRegistry.addMapping( ClientWizardWidgetOutputCommand.class, "ResourceContext", PreClientDevelopCommand.class);
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "ClientTypeRuntimeServer", PreClientDevelopCommand.class );
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "ClientJ2EEVersion", PreClientDevelopCommand.class);
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "ClientProject", PreClientDevelopCommand.class, "Module", null );
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "ClientProjectType", PreClientDevelopCommand.class, "ModuleType", null);
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "ClientProjectEAR", PreClientDevelopCommand.class, "Ear", null );
+ dataRegistry.addMapping( ClientWizardWidgetOutputCommand.class, "ResourceContext", PreClientDevelopCommand.class);
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "WsdlURI", PreClientDevelopCommand.class );
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "ClientRuntimeId", PreClientDevelopCommand.class );
+
+ dataRegistry.addMapping( PreClientDevelopCommand.class, "WebService", ClientExtensionOutputCommand.class, "WebServiceClient", null );
+
+ // Map ClientExtensionDefaultingCommand command.
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientTypeRuntimeServer", ClientExtensionFragment.class);
+
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientProjectEAR", WebServiceClientTestArrivalCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientProject", WebServiceClientTestArrivalCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientOsgiAppProjectName", WebServiceClientTestArrivalCommand.class, "ClientProjectOSGI", null);
+
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientOsgiAppProjectName", ClientTestDelegateCommand.class, "ClientOsgiAppProjectName", null);
+
+
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "GenerateProxy", ClientTestFragment.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "TestService", ClientTestFragment.class );
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ProxyBean", ClientTestFragment.class );
+
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientNeedEAR", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientEarProjectName", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientEarProjectName", ClientTestDelegateCommand.class,"ClientEarComponentName", null);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientProject",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "RunTestClient",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientTypeRuntimeServer", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientServer", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "WsdlURI", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "CanRunTestClient", ClientTestDelegateCommand.class );
+
+ // Map ClientExtensionOutputCommand command.
+ dataRegistry.addMapping(ClientExtensionOutputCommand.class, "ProxyBean", WebServiceClientTestArrivalCommand.class);
+ dataRegistry.addMapping(ClientExtensionOutputCommand.class, "ProxyBean", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionOutputCommand.class, "ProxyEndpoint", GetMonitorCommand.class);
+ dataRegistry.addMapping(ClientExtensionOutputCommand.class, "CanGenerateProxy", ClientTestFragment.class);
+ dataRegistry.addMapping(ClientExtensionOutputCommand.class, "CanGenerateProxy", FinishTestFragment.class);
+ dataRegistry.addMapping(ClientExtensionOutputCommand.class, "SetEndpointMethod", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionOutputCommand.class, "ServerInstanceId", FinishDefaultCommand.class);
+
+ dataRegistry.addMapping(PreClientInstallCommand.class, "CanRunTestClient", ClientTestDelegateCommand.class );
+
+ // GetMonitorCommand
+ dataRegistry.addMapping(GetMonitorCommand.class, "Endpoints", ClientTestDelegateCommand.class);
+
+ // MAP post server config call
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientProjectEAR", ClientExtensionOutputCommand.class, "EarProjectName", null);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientServerInstance", ClientExtensionOutputCommand.class, "ExistingServerId", null);
+
+ // Map WebServiceClientTestArrivalCommand command.
+ dataRegistry.addMapping(TestDefaultingFragment.class, "TestFacility",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "TestFacility",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "Folder",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "JspFolder",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "RunClientTest",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "Methods",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "SampleProject",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "SampleProjectEAR",ClientTestDelegateCommand.class);
+
+
+ //Mappings to enable peek-ahead for Page 3 of the client wizard
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "WebService", DevelopClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Environment", DevelopClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Context", DevelopClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Selection", DevelopClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", DevelopClientFragment.class, "Project", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", DevelopClientFragment.class, "Module", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", DevelopClientFragment.class, "EarProject", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", DevelopClientFragment.class, "Ear", null );
+
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "WebService", AssembleClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Environment", AssembleClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Context", AssembleClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Selection", AssembleClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", AssembleClientFragment.class, "Project", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", AssembleClientFragment.class, "Module", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", AssembleClientFragment.class, "EarProject", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", AssembleClientFragment.class, "Ear", null );
+
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "WebService", DeployClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Environment", DeployClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Context", DeployClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Selection", DeployClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", DeployClientFragment.class, "Project", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", DeployClientFragment.class, "Module", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", DeployClientFragment.class, "EarProject", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", DeployClientFragment.class, "Ear", null );
+
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "WebService", InstallClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Environment", InstallClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Context", InstallClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Selection", InstallClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", InstallClientFragment.class, "Project", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", InstallClientFragment.class, "Module", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", InstallClientFragment.class, "EarProject", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", InstallClientFragment.class, "Ear", null );
+
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "WebService", RunClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Environment", RunClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Context", RunClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "Selection", RunClientFragment.class );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", RunClientFragment.class, "Project", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", RunClientFragment.class, "Module", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", RunClientFragment.class, "EarProject", null );
+ dataRegistry.addMapping( ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", RunClientFragment.class, "Ear", null );
+ }
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ConfigClientHandlersWidgetBinding.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ConfigClientHandlersWidgetBinding.java
new file mode 100644
index 000000000..16b3fa8a0
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ConfigClientHandlersWidgetBinding.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu
+ * 20060517 142339 sengpl@ca.ibm.com - Seng Phung-Lu
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.binding;
+
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.command.GenerateHandlerSkeletonCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.command.OpenJavaEditorCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ClientHandlersWidgetDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ClientHandlersWidgetOutputCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ConfigClientHandlersTableWidget;
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactory;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
+import org.eclipse.wst.command.internal.env.ui.widgets.CanFinishRegistry;
+import org.eclipse.wst.command.internal.env.ui.widgets.CommandWidgetBinding;
+import org.eclipse.wst.command.internal.env.ui.widgets.SelectionCommand;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributorFactory;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetRegistry;
+
+
+/**
+ *
+ * Handler Configuration Window - Preferences - Java - Code Generation - Code
+ * and Comments
+ */
+public class ConfigClientHandlersWidgetBinding implements CommandWidgetBinding
+{
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerWidgetMappings(org.eclipse.wst.command.env.ui.widgets.WidgetRegistry)
+ */
+ public void registerWidgetMappings(WidgetRegistry widgetRegistry) {
+
+ widgetRegistry.add("ConfigClientHandlersTableWidget",
+ ConsumptionUIMessages.PAGE_TITLE_CLIENT_HDLR_CONFIG,
+ ConsumptionUIMessages.PAGE_DESC_CLIENT_HDLR_CONFIG,
+ new WidgetContributorFactory() {
+
+ public WidgetContributor create() {
+ return new ConfigClientHandlersTableWidget();
+ }
+ });
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry) {
+
+ // widget
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"HandlerServiceRefHolder", ConfigClientHandlersTableWidget.class);
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"IsMultipleSelection", ConfigClientHandlersTableWidget.class);
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"GenSkeletonEnabled", ConfigClientHandlersTableWidget.class);
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"ServiceRefName", ConfigClientHandlersTableWidget.class);
+
+ // output
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"IsMultipleSelection", ClientHandlersWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"ClientProject", ClientHandlersWidgetOutputCommand.class);
+ dataRegistry.addMapping(ConfigClientHandlersTableWidget.class,"HandlerServiceRefHolder", ClientHandlersWidgetOutputCommand.class);
+
+ // gen skeleton
+ dataRegistry.addMapping(ConfigClientHandlersTableWidget.class,"HandlerServiceRefHolder", GenerateHandlerSkeletonCommand.class);
+ dataRegistry.addMapping(ConfigClientHandlersTableWidget.class,"GenSkeletonEnabled", GenerateHandlerSkeletonCommand.class);
+
+ // open in editor
+ dataRegistry.addMapping(GenerateHandlerSkeletonCommand.class,"Project", OpenJavaEditorCommand.class);
+ dataRegistry.addMapping(GenerateHandlerSkeletonCommand.class,"ClassNames", OpenJavaEditorCommand.class);
+ dataRegistry.addMapping(ConfigClientHandlersTableWidget.class,"GenSkeletonEnabled", OpenJavaEditorCommand.class,"IsEnabled", null);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerCanFinish(org.eclipse.wst.command.env.ui.widgets.CanFinishRegistry)
+ */
+ public void registerCanFinish(CanFinishRegistry canFinishRegistry) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactoryFactory#create()
+ */
+ public CommandFragmentFactory create() {
+ return new CommandFragmentFactory() {
+
+ public CommandFragment create() {
+
+ return new ClientHandlersConfigCommandFragment();
+ }
+ };
+ }
+
+ private class ClientHandlersConfigCommandFragment extends SequenceFragment{
+
+ public ClientHandlersConfigCommandFragment()
+ {
+ add( new SimpleFragment( new ClientHandlersWidgetDefaultingCommand(), "" ));
+ add( new SimpleFragment( "ConfigClientHandlersTableWidget" ) );
+ add( new SimpleFragment( new ClientHandlersWidgetOutputCommand(), "" ));
+ add( new SimpleFragment( new GenerateHandlerSkeletonCommand(), ""));
+ add( new SimpleFragment( new OpenJavaEditorCommand(), ""));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragment#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry)
+ {
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ClientHandlersWidgetDefaultingCommand.class);
+
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"WsServiceRefs", ClientHandlersWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"ClientProject", ClientHandlersWidgetOutputCommand.class);
+ }
+
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ConfigServiceHandlersWidgetBinding.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ConfigServiceHandlersWidgetBinding.java
new file mode 100644
index 000000000..c7b7c7a90
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ConfigServiceHandlersWidgetBinding.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.binding;
+
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.command.GenerateHandlerSkeletonCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.command.OpenJavaEditorCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ConfigServiceHandlersTableWidget;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ServiceHandlersWidgetDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ServiceHandlersWidgetOutputCommand;
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactory;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
+import org.eclipse.wst.command.internal.env.ui.widgets.CanFinishRegistry;
+import org.eclipse.wst.command.internal.env.ui.widgets.CommandWidgetBinding;
+import org.eclipse.wst.command.internal.env.ui.widgets.SelectionCommand;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributorFactory;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetRegistry;
+
+
+/**
+ *
+ * Handler Configuration Window - Preferences - Java - Code Generation - Code
+ * and Comments
+ */
+public class ConfigServiceHandlersWidgetBinding implements CommandWidgetBinding {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerWidgetMappings(org.eclipse.wst.command.env.ui.widgets.WidgetRegistry)
+ */
+ public void registerWidgetMappings(WidgetRegistry widgetRegistry) {
+
+ widgetRegistry.add("ConfigServiceHandlersTableWidget",
+ ConsumptionUIMessages.PAGE_TITLE_SERVICE_HDLR_CONFIG,
+ ConsumptionUIMessages.PAGE_DESC_SERVICE_HDLR_CONFIG,
+ new WidgetContributorFactory() {
+
+ public WidgetContributor create() {
+ return new ConfigServiceHandlersTableWidget();
+ }
+ });
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry) {
+
+ // widget
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class,"HandlerDescriptionHolders", ConfigServiceHandlersTableWidget.class);
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "IsMultipleSelection", ConfigServiceHandlersTableWidget.class);
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class,"GenSkeletonEnabled", ConfigServiceHandlersTableWidget.class);
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class,"DescriptionName", ConfigServiceHandlersTableWidget.class);
+
+ // output command (adds/removes from model)
+ dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class,"HandlerDescriptionHolders", ServiceHandlersWidgetOutputCommand.class);
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "IsMultipleSelection", ServiceHandlersWidgetOutputCommand.class);
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class,"WsddResource", ServiceHandlersWidgetOutputCommand.class);
+
+ // gen skeleton command
+ dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class,"HandlerDescriptionHolders", GenerateHandlerSkeletonCommand.class);
+ dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class,"GenSkeletonEnabled", GenerateHandlerSkeletonCommand.class);
+
+ // open Java editor
+ dataRegistry.addMapping(GenerateHandlerSkeletonCommand.class,"Project", OpenJavaEditorCommand.class);
+ dataRegistry.addMapping(GenerateHandlerSkeletonCommand.class,"ClassNames", OpenJavaEditorCommand.class);
+ dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class,"GenSkeletonEnabled", OpenJavaEditorCommand.class,"IsEnabled", null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerCanFinish(org.eclipse.wst.command.env.ui.widgets.CanFinishRegistry)
+ */
+ public void registerCanFinish(CanFinishRegistry canFinishRegistry) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactoryFactory#create()
+ */
+ public CommandFragmentFactory create() {
+ return new CommandFragmentFactory() {
+
+ public CommandFragment create() {
+
+ return new ServiceHandlersConfigCommandFragment();
+ }
+ };
+ }
+
+ private class ServiceHandlersConfigCommandFragment extends SequenceFragment{
+
+ public ServiceHandlersConfigCommandFragment()
+ {
+ add( new SimpleFragment( new ServiceHandlersWidgetDefaultingCommand(), "" ));
+ add( new SimpleFragment( "ConfigServiceHandlersTableWidget" ) );
+ add( new SimpleFragment( new ServiceHandlersWidgetOutputCommand(), "" ));
+ add( new SimpleFragment( new GenerateHandlerSkeletonCommand(), ""));
+ add( new SimpleFragment( new OpenJavaEditorCommand(), ""));
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragment#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry)
+ {
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ServiceHandlersWidgetDefaultingCommand.class);
+
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "WsddResource", ServiceHandlersWidgetOutputCommand.class);
+
+
+ }
+
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ConfigureHandlersWidgetBinding.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ConfigureHandlersWidgetBinding.java
new file mode 100644
index 000000000..53969b4b9
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ConfigureHandlersWidgetBinding.java
@@ -0,0 +1,256 @@
+/*******************************************************************************
+ * Copyright (c) 2004,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
+ * -------- -------- -----------------------------------------------------------
+ * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.binding;
+
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.command.GenerateHandlerSkeletonCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.command.OpenJavaEditorCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ClientHandlersWidgetDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ClientHandlersWidgetOutputCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ConfigClientHandlersTableWidget;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ConfigServiceHandlersTableWidget;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.HandlersDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ServiceHandlersWidgetDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ServiceHandlersWidgetOutputCommand;
+import org.eclipse.wst.command.internal.env.core.common.Condition;
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+import org.eclipse.wst.command.internal.env.core.fragment.BooleanFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactory;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
+import org.eclipse.wst.command.internal.env.ui.widgets.CanFinishRegistry;
+import org.eclipse.wst.command.internal.env.ui.widgets.CommandWidgetBinding;
+import org.eclipse.wst.command.internal.env.ui.widgets.SelectionCommand;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributorFactory;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetRegistry;
+
+
+public class ConfigureHandlersWidgetBinding implements CommandWidgetBinding {
+
+
+ public ConfigureHandlersWidgetBinding() {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#create()
+ */
+ public CommandFragmentFactory create() {
+ return new CommandFragmentFactory() {
+
+ public CommandFragment create() {
+ return new HandlersCommandFragment();
+ }
+ };
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerCanFinish(org.eclipse.wst.command.env.ui.widgets.CanFinishRegistry)
+ */
+ public void registerCanFinish(CanFinishRegistry canFinishRegistry) {
+ }
+
+ /*
+ * (non-Javadoc),
+ *
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry) {
+
+ // Map client-side widgets to commands
+ // widget
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"HandlerServiceRefHolder", ConfigClientHandlersTableWidget.class);
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"IsMultipleSelection", ConfigClientHandlersTableWidget.class);
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"GenSkeletonEnabled", ConfigClientHandlersTableWidget.class);
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"ServiceRefName", ConfigClientHandlersTableWidget.class);
+
+ // output
+
+ dataRegistry.addMapping(ConfigClientHandlersTableWidget.class,"HandlerServiceRefHolder", ClientHandlersWidgetOutputCommand.class);
+
+ // gen skeleton
+ dataRegistry.addMapping(ConfigClientHandlersTableWidget.class,"HandlerServiceRefHolder", GenerateHandlerSkeletonCommand.class);
+ dataRegistry.addMapping(ConfigClientHandlersTableWidget.class,"GenSkeletonEnabled", GenerateHandlerSkeletonCommand.class);
+
+ // open in editor
+ dataRegistry.addMapping(ConfigClientHandlersTableWidget.class,"GenSkeletonEnabled", OpenJavaEditorCommand.class,"IsEnabled", null);
+
+
+ // Map service-side widgets to commands
+ // widget
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class,"HandlerDescriptionHolders", ConfigServiceHandlersTableWidget.class);
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "IsMultipleSelection", ConfigServiceHandlersTableWidget.class);
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class,"GenSkeletonEnabled", ConfigServiceHandlersTableWidget.class);
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class,"DescriptionName", ConfigServiceHandlersTableWidget.class);
+
+ // output command (adds/removes from model)
+ dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class,"HandlerDescriptionHolders", ServiceHandlersWidgetOutputCommand.class);
+
+
+ // gen skeleton command
+ dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class,"HandlerDescriptionHolders", GenerateHandlerSkeletonCommand.class);
+ dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class,"GenSkeletonEnabled", GenerateHandlerSkeletonCommand.class);
+
+ // open Java editor
+ dataRegistry.addMapping(ConfigServiceHandlersTableWidget.class,"GenSkeletonEnabled", OpenJavaEditorCommand.class,"IsEnabled", null);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerWidgetMappings(org.eclipse.wst.command.env.ui.widgets.WidgetRegistry)
+ */
+ public void registerWidgetMappings(WidgetRegistry widgetRegistry) {
+
+ widgetRegistry.add("ConfigServiceHandlersTableWidget", ConsumptionUIMessages.PAGE_TITLE_SERVICE_HDLR_CONFIG,
+ ConsumptionUIMessages.PAGE_DESC_SERVICE_HDLR_CONFIG, new WidgetContributorFactory() {
+
+ public WidgetContributor create() {
+ return new ConfigServiceHandlersTableWidget();
+ }
+ });
+
+ widgetRegistry.add("ConfigClientHandlersTableWidget", ConsumptionUIMessages.PAGE_TITLE_CLIENT_HDLR_CONFIG,
+ ConsumptionUIMessages.PAGE_DESC_CLIENT_HDLR_CONFIG, new WidgetContributorFactory() {
+
+ public WidgetContributor create() {
+ return new ConfigClientHandlersTableWidget();
+ }
+ });
+
+ }
+
+ private class HandlersCommandFragment extends SequenceFragment {
+
+ public HandlersCommandFragment() {
+
+ add(new SimpleFragment(new HandlersDefaultingCommand(), ""));
+
+ add(new ServiceHandlersFragment());
+ add(new ClientHandlersFragment());
+ }
+
+ public void registerDataMappings(DataMappingRegistry dataRegistry) {
+
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", HandlersDefaultingCommand.class);
+
+ dataRegistry.addMapping(HandlersDefaultingCommand.class, "IsClientHandler", ClientHandlersFragment.class, "ClientHandlersEnabled", null);
+ dataRegistry.addMapping(HandlersDefaultingCommand.class, "IsServiceHandler", ServiceHandlersFragment.class, "ServiceHandlersEnabled", null);
+
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class,"IsMultipleSelection", ClientHandlersWidgetOutputCommand.class);
+ dataRegistry.addMapping(GenerateHandlerSkeletonCommand.class,"Project", OpenJavaEditorCommand.class);
+ dataRegistry.addMapping(GenerateHandlerSkeletonCommand.class,"ClassNames", OpenJavaEditorCommand.class);
+
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "IsMultipleSelection", ServiceHandlersWidgetOutputCommand.class);
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class,"WsddResource", ServiceHandlersWidgetOutputCommand.class);
+ dataRegistry.addMapping(GenerateHandlerSkeletonCommand.class,"Project", OpenJavaEditorCommand.class);
+ dataRegistry.addMapping(GenerateHandlerSkeletonCommand.class,"ClassNames", OpenJavaEditorCommand.class);
+
+ }
+
+ public void registerCanFinish(CanFinishRegistry canFinishRegistry) {
+ }
+ }
+
+ private class ClientHandlersFragment extends BooleanFragment {
+
+ boolean isClient_ = false;
+
+ public ClientHandlersFragment() {
+ setCondition(new Condition() {
+
+ public boolean evaluate() {
+ return isClient_;
+ }
+ });
+
+ SequenceFragment clientHandlersRootFragment = new SequenceFragment();
+
+ clientHandlersRootFragment.add(new SimpleFragment(new ClientHandlersWidgetDefaultingCommand(), ""));
+
+ clientHandlersRootFragment.add(new SimpleFragment("ConfigClientHandlersTableWidget"));
+ clientHandlersRootFragment.add(new SimpleFragment(new ClientHandlersWidgetOutputCommand(), ""));
+ clientHandlersRootFragment.add(new SimpleFragment(new GenerateHandlerSkeletonCommand(), ""));
+
+ setTrueFragment(clientHandlersRootFragment);
+ }
+
+ public void setClientHandlersEnabled(boolean isClient) {
+ isClient_ = isClient;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragment#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry) {
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ClientHandlersWidgetDefaultingCommand.class);
+
+ dataRegistry.addMapping(ClientHandlersWidgetDefaultingCommand.class, "ClientProject", ClientHandlersWidgetOutputCommand.class);
+
+ }
+
+ }
+
+ private class ServiceHandlersFragment extends BooleanFragment {
+
+ boolean isService_ = false;
+
+ public ServiceHandlersFragment() {
+ setCondition(new Condition() {
+
+ public boolean evaluate() {
+ return isService_;
+ }
+ });
+
+ SequenceFragment serviceHandlersRootFragment = new SequenceFragment();
+ serviceHandlersRootFragment.add(new SimpleFragment(new ServiceHandlersWidgetDefaultingCommand(), ""));
+
+ SequenceFragment serviceHandlersFragment = new SequenceFragment();
+ serviceHandlersFragment.add(new SimpleFragment("ConfigServiceHandlersTableWidget"));
+ serviceHandlersFragment.add(new SimpleFragment(new ServiceHandlersWidgetOutputCommand(), ""));
+ serviceHandlersFragment.add(new SimpleFragment(new GenerateHandlerSkeletonCommand(), ""));
+
+ serviceHandlersRootFragment.add(serviceHandlersFragment);
+
+ setTrueFragment(serviceHandlersRootFragment);
+ }
+
+ public void setServiceHandlersEnabled(boolean isService) {
+ isService_ = isService;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragment#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry) {
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ServiceHandlersWidgetDefaultingCommand.class);
+
+ dataRegistry.addMapping(ServiceHandlersWidgetDefaultingCommand.class, "WsddResource", ServiceHandlersWidgetOutputCommand.class);
+
+ }
+
+ }
+} \ No newline at end of file
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/GenSampleWidgetBinding.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/GenSampleWidgetBinding.java
new file mode 100644
index 000000000..ed9a14e83
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/GenSampleWidgetBinding.java
@@ -0,0 +1,493 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060524 142635 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20060529 141422 kathy@ca.ibm.com - Kathy Chan
+ * 20060608 145529 kathy@ca.ibm.com - Kathy Chan
+ * 20060717 146332 makandre@ca.ibm.com - Andrew Mak
+ * 20070516 186233 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20070815 199626 kathy@ca.ibm.com - Kathy Chan
+ * 20080325 184761 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080331 224953 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080415 227237 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080425 221232 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080616 237298 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080619 237797 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20090324 247535 mahutch@ca.ibm.com - Mark Hutchinson, Wrong server instance(s) is chosen during JAX-RPC sample generation
+ * 20100528 314934 mahutch@ca.ibm.com - Mark Hutchinson, Pressing "Launch" on service test page causes test client not to launch on "Client test" page
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+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.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.common.StringToIProjectTransformer;
+import org.eclipse.jst.ws.internal.consumption.command.common.AddModuleToServerCommand;
+import org.eclipse.jst.ws.internal.consumption.command.common.CreateServerCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.command.data.EclipseIPath2URLStringTransformer;
+import org.eclipse.jst.ws.internal.consumption.ui.common.FinishFragment;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ClientWizardWidgetDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ClientWizardWidgetOutputCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.WSDLSelectionWidgetDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.extensions.ClientExtensionDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.extensions.ClientExtensionFragment;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.extensions.ClientExtensionOutputCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.runtime.ClientRuntimeSelectionWidgetDefaultingCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.ClientTestDelegateCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.ClientTestFragment;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.ClientTestWidget;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.FinishDefaultCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.FinishTestFragment;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.TestDefaultingFragment;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.TestWebServiceClient;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.WebServiceClientTestArrivalCommand;
+import org.eclipse.jst.ws.internal.context.ScenarioContext;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.jst.ws.internal.ext.test.WebServiceTestExtension;
+import org.eclipse.jst.ws.internal.ext.test.WebServiceTestRegistry;
+import org.eclipse.jst.ws.internal.plugin.WebServicePlugin;
+import org.eclipse.wst.command.internal.env.core.context.ResourceContext;
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+import org.eclipse.wst.command.internal.env.core.data.Transformer;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactory;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
+import org.eclipse.wst.command.internal.env.core.selection.SelectionList;
+import org.eclipse.wst.command.internal.env.ui.widgets.CanFinishRegistry;
+import org.eclipse.wst.command.internal.env.ui.widgets.CommandWidgetBinding;
+import org.eclipse.wst.command.internal.env.ui.widgets.SelectionCommand;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributorFactory;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetRegistry;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.wsrt.IWebServiceClient;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceClientInfo;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceState;
+
+
+public class GenSampleWidgetBinding implements CommandWidgetBinding
+{
+
+
+
+/* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#create()
+ */
+ public CommandFragmentFactory create()
+ {
+ return new CommandFragmentFactory()
+ {
+ public CommandFragment create()
+ {
+ return new GenSampleRootCommandFragment();
+ }
+ };
+ }
+
+ public SelectionList getLegitTestFacility()
+ {
+ ScenarioContext scenarioContext = WebServicePlugin.getInstance().getScenarioContext().copy();
+ String[] testTypes = scenarioContext.getWebServiceTestTypes();
+ List newTestTypes = new ArrayList();
+
+ for(int i = 0;i<testTypes.length;i++){
+ WebServiceTestExtension extension =
+ (WebServiceTestExtension) WebServiceTestRegistry.getInstance()
+ .getWebServiceExtensionsByName(testTypes[i]);
+
+ if(extension.testJavaProxy()){
+ boolean defaultJaxrpc = extension.isDefaultJAXRPC();
+ if(defaultJaxrpc){
+ newTestTypes.add(testTypes[i]);
+ }
+ }
+ }
+ String[] tempArray = new String[newTestTypes.size()];
+ return new SelectionList((String[]) newTestTypes.toArray(tempArray), 0);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerCanFinish(org.eclipse.wst.command.env.ui.widgets.CanFinishRegistry)
+ */
+ public void registerCanFinish(CanFinishRegistry canFinishRegistry)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry)
+ {
+ // Before Client Test widget.
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "TestService",FinishTestFragment.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "TestService", ClientTestWidget.class );
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "RunTestClient", ClientTestWidget.class );
+ dataRegistry.addMapping(InitializeProxyCommand.class, "CanRunTestClient", ClientTestWidget.class );
+ dataRegistry.addMapping(InitializeProxyCommand.class, "IsWebProject", ClientTestWidget.class );
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ClientTestWidget.class );
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "SampleProject", ClientTestWidget.class );
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "SampleProjectEAR", ClientTestWidget.class );
+ dataRegistry.addMapping(InitializeProxyCommand.class, "TestFacility",ClientTestWidget.class);
+ dataRegistry.addMapping(InitializeProxyCommand.class, "Popup",ClientTestWidget.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "Folder",ClientTestWidget.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "JspFolder",ClientTestWidget.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "Methods",ClientTestWidget.class);
+
+ // After the client test widget
+ dataRegistry.addMapping(ClientTestWidget.class, "SampleProjectEAR",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "SampleProject",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "TestFacility",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "Folder",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "JspFolder",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "RunTestClient",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "Methods",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "TestService",FinishTestFragment.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "TestID",FinishTestFragment.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "IsTestWidget",FinishTestFragment.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "ServerInstanceId", FinishDefaultCommand.class);
+ dataRegistry.addMapping(ClientTestWidget.class, "ExistingServerId", FinishDefaultCommand.class);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerWidgetMappings(org.eclipse.wst.command.env.ui.widgets.WidgetRegistry)
+ */
+ public void registerWidgetMappings(WidgetRegistry widgetRegistry)
+ {
+
+ widgetRegistry.add( "ClientTestWidget",
+ ConsumptionUIMessages.PAGE_TITLE_WS_SAMPLE,
+ ConsumptionUIMessages.PAGE_DESC_WS_SAMPLE,
+ new WidgetContributorFactory()
+ {
+ public WidgetContributor create()
+ {
+ return new ClientTestWidget();
+ }
+ });
+ }
+
+ private class InitializeProxyCommand extends AbstractDataModelOperation
+ {
+ private IStructuredSelection selection_;
+ private TypeRuntimeServer typeRuntimeServer_;
+ private String project_;
+ private String module_;
+// private String earProject_;
+ private String ear_;
+ private IWebServiceClient webServiceClient_;
+ private String wsdlURI_;
+ private boolean canRunTestClient_;
+ private boolean isWebProject = false;
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+ IStatus status = Status.OK_STATUS;
+
+ // Split up the project and module
+ int index = module_.indexOf("/");
+ if (index!=-1){
+ project_ = module_.substring(0,index);
+ module_ = module_.substring(index+1);
+ }
+
+
+ if (ear_!=null && ear_.length()>0)
+ {
+ int earIndex = ear_.indexOf("/");
+ if (earIndex!=-1) {
+// earProject_ = ear_.substring(0,earIndex);
+ ear_ = ear_.substring(earIndex+1);
+ }
+ }
+
+ IProject project = ProjectUtilities.getProject(project_);
+ WebServiceClientInfo clientInfo = new WebServiceClientInfo();
+ clientInfo.setImplURL(getProxyBean());
+ //clientInfo.setJ2eeLevel(j2eeLevel_);
+ clientInfo.setServerFactoryId(typeRuntimeServer_.getServerId());
+ clientInfo.setServerInstanceId(typeRuntimeServer_.getServerInstanceId());
+ clientInfo.setState(WebServiceState.UNKNOWN_LITERAL);
+ clientInfo.setWebServiceRuntimeId(typeRuntimeServer_.getRuntimeId());
+ clientInfo.setWsdlURL(wsdlURI_);
+ /*
+ if (clientInfo.getServerInstanceId()==null)
+ {
+ CreateServerCommand createServerCommand = new CreateServerCommand();
+ createServerCommand.setServerFactoryid(clientInfo.getServerFactoryId());
+ createServerCommand.setEnvironment( env );
+ IStatus createServerStatus = createServerCommand.execute( null, null );
+ if (createServerStatus.getSeverity()==Status.OK){
+ clientInfo.setServerInstanceId(createServerCommand.getServerInstanceId());
+ clientInfo.setServerCreated(true);
+ canRunTestClient_ = true;
+ }
+ else if (createServerStatus.getSeverity()==Status.ERROR){
+ if(J2EEUtils.isWebComponent(project))
+ canRunTestClient_ = false;
+ else
+ canRunTestClient_ = true;
+ }
+ }
+ else {
+ canRunTestClient_ = true;
+ }*/
+
+ canRunTestClient_ = true;
+ IProject[] earproject = J2EEProjectUtilities.getReferencingEARProjects(project);
+ boolean earNull = false;
+ if (earproject.length<1) earNull = true;
+
+ boolean j2eeProject = J2EEProjectUtilities.isJEEProject(project);
+ if(J2EEUtils.isWebComponent(project))
+ isWebProject = true;
+
+ if (j2eeProject && earNull)
+ canRunTestClient_ = false;
+ /*
+ if (!earNull && clientInfo.getServerInstanceId() != null){
+
+ AddModuleToServerCommand command = new AddModuleToServerCommand();
+ command.setServerInstanceId(clientInfo.getServerInstanceId());
+ command.setProject(project_);
+ command.setModule(module_);
+ command.setEnvironment( env );
+ status = command.execute( monitor, null );
+ if (status.getSeverity()==Status.ERROR)
+ {
+ env.getStatusHandler().reportError(status);
+ }
+ }*/
+ webServiceClient_ = new TestWebServiceClient(clientInfo);
+ return status;
+ }
+
+ public boolean getPopup(){
+ return true;
+ }
+
+ public String getProxyBean()
+ {
+ String proxyBean = "";
+ try
+ {
+ IResource resource = ResourceUtils.getResourceFromSelection( selection_.getFirstElement() );
+ String beanPackage = ResourceUtils.getJavaResourcePackageName( resource.getFullPath() );
+
+ if( beanPackage==null )
+ beanPackage = "";
+ else
+ beanPackage = beanPackage + ".";
+
+ proxyBean = beanPackage + resource.getName();
+
+ if( proxyBean.toLowerCase().endsWith(".java") || proxyBean.toLowerCase().endsWith(".class"))
+ {
+ proxyBean = proxyBean.substring(0,proxyBean.lastIndexOf('.'));
+ }
+ }
+ catch( CoreException exc )
+ {
+ }
+
+ return proxyBean;
+ }
+
+ public IWebServiceClient getWebServiceClient()
+ {
+ return webServiceClient_;
+ }
+
+ public boolean getCanRunTestClient(){
+ return canRunTestClient_;
+ }
+
+ public boolean getGenerateProxy()
+ {
+ return true;
+ }
+
+ public boolean getCanGenerateProxy()
+ {
+ return true;
+ }
+
+ public SelectionList getTestFacility()
+ {
+ return getLegitTestFacility();
+ }
+
+ public boolean getIsWebProject()
+ {
+ return isWebProject;
+ }
+
+ public void setClientTypeRuntimeServer( TypeRuntimeServer typeRuntimeServer )
+ {
+ typeRuntimeServer_ = typeRuntimeServer;
+ }
+
+ public void setModule( String module )
+ {
+ module_ = module;
+ }
+
+ public void setModuleType( String moduleType)
+ {
+ }
+
+ public void setResourceContext( ResourceContext resourceContext )
+ {
+ }
+
+ public void setInitialSelection( IStructuredSelection selection )
+ {
+ selection_ = selection;
+ }
+ }
+
+ private class GenSampleRootCommandFragment extends SequenceFragment
+ {
+ public GenSampleRootCommandFragment()
+ {
+ add( new SimpleFragment( new ClientWizardWidgetDefaultingCommand(true), "" ) );
+ add( new SimpleFragment( new ClientWizardWidgetOutputCommand(), "" ));
+ add( new SimpleFragment( new WSDLSelectionWidgetDefaultingCommand(), ""));
+ add( new SimpleFragment( new ClientRuntimeSelectionWidgetDefaultingCommand(), ""));
+ add( new SimpleFragment( new ClientExtensionDefaultingCommand( true ), ""));
+ add( new SimpleFragment( new InitializeProxyCommand(), "" ));
+ add( new SimpleFragment( new ClientExtensionOutputCommand(), "" ) );
+ add( new SimpleFragment( new TestDefaultingFragment(),""));
+ add( new ClientTestFragment( "ClientTestWidget") );
+ add( new FinishFragment() );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragment#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry)
+ {
+ //Map SelectionCommand
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientInitialSelection", null);
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", InitializeProxyCommand.class );
+
+ // Map ClientWizardWidgetDefaultingCommand command.
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "ClientTypeRuntimeServer", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "TestService", ClientWizardWidgetOutputCommand.class, "TestService", new ForceTrue() );
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "ResourceContext", ClientWizardWidgetOutputCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetDefaultingCommand.class, "RunTestClient", ClientWizardWidgetOutputCommand.class);
+
+ // Map ClientWizardWidgetOutputCommand command.
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "ClientTypeRuntimeServer", ClientRuntimeSelectionWidgetDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "TestService", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "RunTestClient", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientWizardWidgetOutputCommand.class, "ResourceContext", ClientExtensionDefaultingCommand.class);
+
+ // Map ClientRuntimeSelectionWidgetDefaultingCommand command
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientTypeRuntimeServer", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientProjectName", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientEarProjectName", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(ClientRuntimeSelectionWidgetDefaultingCommand.class, "ClientComponentType", ClientExtensionDefaultingCommand.class);
+
+
+ // Map WSDLSelectionWidgetDefaultingCommand command.
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", WSDLSelectionWidgetDefaultingCommand.class );
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "GenWSIL", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "WsilURI", ClientExtensionDefaultingCommand.class);
+ dataRegistry.addMapping(WSDLSelectionWidgetDefaultingCommand.class, "WebServiceURI", ClientExtensionDefaultingCommand.class, "WsdlURI", new EclipseIPath2URLStringTransformer());
+
+ // Map ClientExtensionDefaultingCommand command.
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientTypeRuntimeServer", ClientExtensionFragment.class);
+
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientProject", WebServiceClientTestArrivalCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientProjectEAR", WebServiceClientTestArrivalCommand.class);
+
+
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "GenerateProxy", ClientTestFragment.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "TestService", ClientTestFragment.class );
+
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientNeedEAR", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientEarProjectName", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientEarProjectName", ClientTestDelegateCommand.class,"ClientEarComponentName",null);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientProject",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientTypeRuntimeServer", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ServiceServerInstanceId", FinishDefaultCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientServer", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "WsdlURI", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "RunTestClient", ClientTestDelegateCommand.class);
+
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "ClientTypeRuntimeServer", InitializeProxyCommand.class );
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "ClientJ2EEVersion", InitializeProxyCommand.class);
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "ClientProject", InitializeProxyCommand.class, "Module", null );
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "ClientProjectType", InitializeProxyCommand.class, "ModuleType", null);
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "ClientProjectEAR", InitializeProxyCommand.class, "Ear", null );
+ dataRegistry.addMapping( ClientWizardWidgetOutputCommand.class, "ResourceContext", InitializeProxyCommand.class);
+ dataRegistry.addMapping( ClientExtensionDefaultingCommand.class, "WsdlURI", InitializeProxyCommand.class );
+
+
+
+
+ // Map InitializeProxyCommand command.
+ dataRegistry.addMapping(InitializeProxyCommand.class, "WebServiceClient", ClientExtensionOutputCommand.class);
+ dataRegistry.addMapping(InitializeProxyCommand.class, "GenerateProxy", ClientExtensionDefaultingCommand.class);
+
+ // Map ClientExtensionOutputCommand command.
+ dataRegistry.addMapping(ClientExtensionOutputCommand.class, "ProxyBean", WebServiceClientTestArrivalCommand.class);
+ dataRegistry.addMapping(ClientExtensionOutputCommand.class, "ProxyBean", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "GenerateProxy", TestDefaultingFragment.class);
+ dataRegistry.addMapping(InitializeProxyCommand.class, "CanGenerateProxy", ClientTestFragment.class);
+ dataRegistry.addMapping(InitializeProxyCommand.class, "CanRunTestClient", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "GenerateProxy", FinishTestFragment.class, "CanGenerateProxy", null);
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "GenerateProxy", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionOutputCommand.class, "RunTestClient", ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(ClientExtensionOutputCommand.class, "ServerInstanceId", FinishDefaultCommand.class);
+
+ // MAP post server config call
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientProjectEAR", ClientExtensionOutputCommand.class, "EARProjectName", new StringToIProjectTransformer());
+ dataRegistry.addMapping(ClientExtensionDefaultingCommand.class, "ClientServerInstance", ClientExtensionOutputCommand.class, "ExistingServerId", null);
+
+
+ // Map WebServiceClientTestArrivalCommand command.
+ dataRegistry.addMapping(TestDefaultingFragment.class, "TestFacility",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "TestFacility",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "Folder",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "JspFolder",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "Methods",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "SampleProject",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(WebServiceClientTestArrivalCommand.class, "SampleProjectEAR",ClientTestDelegateCommand.class);
+
+
+ }
+ }
+
+ private class ForceTrue implements Transformer
+ {
+ public Object transform(Object value)
+ {
+ return new Boolean(true);
+ }
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ImportWSILWidgetBinding.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ImportWSILWidgetBinding.java
new file mode 100644
index 000000000..bd7ef3929
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ImportWSILWidgetBinding.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.binding;
+
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.ImportWSILWidget;
+import org.eclipse.jst.ws.internal.consumption.ui.wsil.AddWSDLToWSILWrapperCommand;
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactory;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
+import org.eclipse.wst.command.internal.env.ui.widgets.CanFinishRegistry;
+import org.eclipse.wst.command.internal.env.ui.widgets.CommandWidgetBinding;
+import org.eclipse.wst.command.internal.env.ui.widgets.SelectionCommand;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributorFactory;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetRegistry;
+
+
+public class ImportWSILWidgetBinding implements CommandWidgetBinding
+{
+ public ImportWSILWidgetBinding()
+ {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#create()
+ */
+ public CommandFragmentFactory create()
+ {
+ return new CommandFragmentFactory()
+ {
+ public CommandFragment create()
+ {
+ SequenceFragment root = new SequenceFragment();
+ root.add(new SimpleFragment("ImportWSILWidget"));
+ root.add(new SimpleFragment(new AddWSDLToWSILWrapperCommand(), ""));
+ return root;
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerCanFinish(org.eclipse.wst.command.env.ui.widgets.CanFinishRegistry)
+ */
+ public void registerCanFinish(CanFinishRegistry canFinishRegistry)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry)
+ {
+ // ImportWSILWidget
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ImportWSILWidget.class);
+
+ // AddWSDLToWSILWrapperCommand
+ dataRegistry.addMapping(ImportWSILWidget.class, "GenWSILArguments", AddWSDLToWSILWrapperCommand.class, "Args", null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerWidgetMappings(org.eclipse.wst.command.env.ui.widgets.WidgetRegistry)
+ */
+ public void registerWidgetMappings(WidgetRegistry widgetRegistry)
+ {
+
+ widgetRegistry.add("ImportWSILWidget",
+ ConsumptionUIMessages.TITLE_WSIL_IMPORT,
+ ConsumptionUIMessages.DESC_WSIL_IMPORT,
+ new WidgetContributorFactory()
+ {
+ public WidgetContributor create()
+ {
+ return new ImportWSILWidget();
+ }
+ }
+ );
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ImportWSWidgetBinding.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ImportWSWidgetBinding.java
new file mode 100644
index 000000000..e95cd41f8
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/binding/ImportWSWidgetBinding.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.binding;
+
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.PublishToPrivateUDDICommandFragment;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.PublishWSWidget;
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactory;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
+import org.eclipse.wst.command.internal.env.ui.widgets.CanFinishRegistry;
+import org.eclipse.wst.command.internal.env.ui.widgets.CommandWidgetBinding;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributorFactory;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetRegistry;
+import org.eclipse.wst.ws.internal.explorer.WSExplorerLauncherCommand;
+
+
+public class ImportWSWidgetBinding implements CommandWidgetBinding
+{
+ private CanFinishRegistry canFinishRegistry;
+ private WidgetRegistry widgetRegistry;
+ private DataMappingRegistry dataMappingRegistry;
+ private PublishToPrivateUDDICommandFragment publishToPrivateUDDICmdFrag;
+
+ public ImportWSWidgetBinding()
+ {
+ publishToPrivateUDDICmdFrag = new PublishToPrivateUDDICommandFragment();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#create()
+ */
+ public CommandFragmentFactory create()
+ {
+ return new CommandFragmentFactory()
+ {
+ public CommandFragment create()
+ {
+ SequenceFragment root = new SequenceFragment();
+ root.add(new SimpleFragment("WSImport"));
+ root.add(publishToPrivateUDDICmdFrag);
+ root.add(new SimpleFragment(new WSExplorerLauncherCommand(), ""));
+ return root;
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerCanFinish(org.eclipse.wst.command.env.ui.widgets.CanFinishRegistry)
+ */
+ public void registerCanFinish(CanFinishRegistry canFinishRegistry)
+ {
+ this.canFinishRegistry = canFinishRegistry;
+ publishToPrivateUDDICmdFrag.registerCanFinish(this.canFinishRegistry);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry)
+ {
+ this.dataMappingRegistry = dataRegistry;
+ publishToPrivateUDDICmdFrag.registerDataMappings(this.dataMappingRegistry);
+
+ // PublishToPrivateUDDICommandFragment
+ dataMappingRegistry.addMapping(PublishWSWidget.class, "PublishToPrivateUDDI", PublishToPrivateUDDICommandFragment.class);
+
+ // LaunchWebServicesExplorerCommand
+ dataMappingRegistry.addMapping(PublishWSWidget.class, "ForceLaunchOutsideIDE", WSExplorerLauncherCommand.class);
+ dataMappingRegistry.addMapping(PublishWSWidget.class, "LaunchOptions", WSExplorerLauncherCommand.class);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerWidgetMappings(org.eclipse.wst.command.env.ui.widgets.WidgetRegistry)
+ */
+ public void registerWidgetMappings(WidgetRegistry widgetRegistry)
+ {
+ this.widgetRegistry = widgetRegistry;
+ publishToPrivateUDDICmdFrag.registerWidgetMappings(this.widgetRegistry);
+
+ widgetRegistry.add("WSImport",
+ ConsumptionUIMessages.PAGE_TITLE_WS_FIND,
+ ConsumptionUIMessages.PAGE_DESC_WS_FIND,
+ new WidgetContributorFactory()
+ {
+ public WidgetContributor create()
+ {
+ return new PublishWSWidget(false);
+ }
+ }
+ );
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionDefaultingCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionDefaultingCommand.java
new file mode 100644
index 000000000..89f76f2e6
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionDefaultingCommand.java
@@ -0,0 +1,691 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2015 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060204 124408 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060221 119111 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060524 142635 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20060529 141422 kathy@ca.ibm.com - Kathy Chan
+ * 20060818 154402 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060830 151091 kathy@ca.ibm.com - Kathy Chan, Client side still enabled when there's only stub server
+ * 20080205 170141 kathy@ca.ibm.com - Kathy Chan
+ * 20080325 184761 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080506 227848 makandre@ca.ibm.com - Andrew Mak, Disabled "Run on Server" checkbox is in checked state
+ * 20080729 241275 ericdp@ca.ibm.com - Eric D. Peters, No Validation error generating Web Service client if dialog hidden
+ * 20090803 283312 ericdp@ca.ibm.com - Eric D. Peters, ANT Client gen- message missing server name subst. variable
+ * 20150311 461526 jgwest@ca.ibm.com - Jonathan West, Allow OSGi bundles to be selected in the Wizard
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.extensions;
+
+import org.eclipse.core.commands.ExecutionException;
+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.ws.internal.common.ServerUtils;
+import org.eclipse.jst.ws.internal.consumption.common.FacetUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.common.ValidationUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.RuntimeDescriptor;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils2;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.osgi.util.NLS;
+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.server.core.IRuntime;
+import org.eclipse.wst.ws.internal.parser.discovery.WebServicesParserExt;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+
+
+public class ClientExtensionDefaultingCommand extends AbstractDataModelOperation
+{
+ // ClientWizardWidget
+
+ private boolean developClient_;
+ private boolean assembleClient_;
+ private boolean deployClient_;
+
+ private TypeRuntimeServer clientIds_;
+ private String clientRuntimeId_;
+ private boolean testService;
+ private Boolean installClient;
+ private boolean startClient;
+ private boolean runTestClient;
+ private ResourceContext resourceContext;
+
+ // ClientRuntimeSelectionWidget
+ //private SelectionListChoices clientChoices_;
+ private String clientProjectName_;
+ private String clientEarProjectName_;
+ //private String clientComponentName_;
+ //private String clientEarComponentName_;
+ private String clientComponentType_;
+ //private String j2eeVersion;
+ private boolean clientNeedEAR_;
+
+ private String serviceServerFactoryId_;
+ private String serviceServerInstanceId_;
+
+ // WSDLSelectionWidget
+ private boolean genWSIL;
+ private String wsilURI;
+
+ // WSDLSelectionConditionCommand
+ private WebServicesParser webServicesParser;
+
+ // WSDLSelectionTreeWidget
+ private String wsdlURI;
+
+ private boolean isClientScenario_;
+ private boolean genProxy_ = true;
+ private String launchedServiceTestName;
+
+ //ServerDeployableConfigurationCommand
+ private String serverInstId_;
+
+
+ private String clientOsgiAppProjectName;
+
+ public ClientExtensionDefaultingCommand( boolean isClientScenario )
+ {
+ isClientScenario_ = isClientScenario;
+ }
+
+ /**
+ *
+ * @return returns true if this command is running in the client wizard and
+ * false if this command is running in the create web service wizard.
+ */
+ public boolean getIsClientScenario()
+ {
+ return isClientScenario_;
+ }
+
+ /*
+ public void setRuntime2ClientTypes( SelectionListChoices choices )
+ {
+ clientChoices_ = choices;
+ }
+
+
+ public SelectionListChoices getRuntime2ClientTypes()
+ {
+ return clientChoices_;
+ }
+ */
+
+ public void setClientTypeRuntimeServer(TypeRuntimeServer ids)
+ {
+ clientIds_ = ids;
+ }
+
+ public TypeRuntimeServer getClientTypeRuntimeServer()
+ {
+ if (clientIds_.getServerInstanceId()==null || clientIds_.getServerInstanceId().length()==0)
+ {
+ //Set the instance id from the service side if the factory ids match
+ if (serviceServerInstanceId_!=null && serviceServerInstanceId_.length()>0)
+ {
+ if (serviceServerFactoryId_!=null && serviceServerFactoryId_.length()>0)
+ {
+ if (serviceServerFactoryId_.equals(clientIds_.getServerId()))
+ {
+ clientIds_.setServerInstanceId(serviceServerInstanceId_);
+ }
+ }
+ }
+ }
+ return clientIds_;
+ }
+
+ public void setClientRuntimeId(String id)
+ {
+ clientRuntimeId_ = id;
+ }
+
+ public String getClientRuntimeId()
+ {
+ return clientRuntimeId_;
+ }
+
+ public void setServiceExistingServerInstId(String serverInstId) {
+ this.serverInstId_ = serverInstId;
+ }
+
+ public String getServiceExistingServerInstId(){
+ return this.serverInstId_;
+ }
+
+ /**
+ * @return Returns the clientIsExistingServer.
+ */
+ public boolean isClientIsExistingServer()
+ {
+ return clientIds_.getServerInstanceId() != null;
+ }
+
+ /**
+ * @return Returns the clientProject.
+ */
+ public String getClientProject()
+ {
+ //return clientProjectName_ + "/" + clientComponentName_;
+ return clientProjectName_ + "/" + clientProjectName_;
+ }
+
+ /**
+ * @return Returns the clientProjectEAR.
+ */
+ public String getClientProjectEAR()
+ {
+ if (clientEarProjectName_!=null && clientEarProjectName_.length()>0)
+ {
+ //return clientEarProjectName_ + "/" + clientEarComponentName_;
+ return clientEarProjectName_ + "/" + clientEarProjectName_;
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ /*
+ private String getModuleProjectName( String projectName )
+ {
+ String result = "";
+
+ if( projectName != null && !projectName.equals("") )
+ {
+ IPath projectPath = new Path( projectName );
+ IProject project = (IProject)ResourceUtils.findResource( projectPath );
+ String moduleName = J2EEUtils.getFirstWebModuleName( project );
+
+ result = projectName + "/" + moduleName;
+ }
+
+ return result;
+ }
+ */
+ /**
+ * @return Returns the clientProjectType.
+ */
+
+ public String getClientProjectType()
+ {
+ //return clientChoices_.getChoice().getList().getSelection();
+ return clientComponentType_;
+ }
+
+ /**
+ * @return Returns the clientRuntime.
+ */
+ public String getClientRuntime()
+ {
+ return clientIds_.getRuntimeId();
+ }
+
+ /**
+ * @return Returns the clientServer.
+ */
+ public String getClientServer()
+ {
+ return clientIds_.getServerId();
+ }
+
+ public String getClientServerInstance()
+ {
+ return clientIds_.getServerInstanceId();
+ }
+
+ public void setClientExistingServerInstanceId(String serverInstId){
+
+ if (clientIds_.getServerInstanceId()==null)
+ clientIds_.setServerInstanceId(serverInstId);
+ }
+
+ /**
+ * @return Returns the genWSIL.
+ */
+ public boolean isGenWSIL()
+ {
+ return genWSIL;
+ }
+
+ /**
+ * @param genWSIL
+ * The genWSIL to set.
+ */
+ public void setGenWSIL(boolean genWSIL)
+ {
+ this.genWSIL = genWSIL;
+ }
+
+ /**
+ * @return Returns the resourceContext.
+ */
+ public ResourceContext getResourceContext()
+ {
+ return resourceContext;
+ }
+
+ /**
+ * @param resourceContext
+ * The resourceContext to set.
+ */
+ public void setResourceContext(ResourceContext resourceContext)
+ {
+ this.resourceContext = resourceContext;
+ }
+
+ /**
+ * @return Returns the testProxySelected.
+ */
+ public boolean getTestService()
+ {
+ return testService;
+ }
+
+ /**
+ * @param testProxySelected
+ * The testProxySelected to set.
+ */
+ public void setTestService(boolean testService)
+ {
+ this.testService = testService;
+ }
+
+ /**
+ * @return Returns the testProxySelected.
+ */
+ public boolean getRunTestClient()
+ {
+ return runTestClient;
+ }
+
+ /**
+ * @param testProxySelected
+ * The testProxySelected to set.
+ */
+ public void setRunTestClient(boolean runTestClient)
+ {
+ this.runTestClient = runTestClient;
+ }
+
+ public boolean getDevelopClient() {
+ return developClient_;
+ }
+
+ public void setDevelopClient(boolean developClient) {
+ this.developClient_ = developClient;
+ }
+
+ public boolean getAssembleClient() {
+ return assembleClient_;
+ }
+
+ public void setAssembleClient(boolean assembleClient) {
+ this.assembleClient_ = assembleClient;
+ }
+
+ public boolean getDeployClient() {
+ return deployClient_;
+ }
+
+ public void setDeployClient(boolean deployClient) {
+ this.deployClient_ = deployClient;
+ }
+
+ /**
+ * @return Returns the installClient.
+ */
+ public Boolean getInstallClient()
+ {
+ return installClient;
+ }
+
+ /**
+ * @param installClient
+ * The installClient to set.
+ */
+ public void setInstallClient(Boolean installClient)
+ {
+ this.installClient = installClient;
+ }
+
+ /**
+ * @return Returns the startClient.
+ */
+ public boolean getStartClient()
+ {
+ return startClient;
+ }
+
+ /**
+ * @param startClient
+ * The startClient to set.
+ */
+ public void setStartClient(boolean startClient)
+ {
+ this.startClient = startClient;
+ }
+
+ /**
+ * @return Returns the wsdlURI.
+ */
+ public String getWsdlURI()
+ {
+ return wsdlURI;
+ }
+
+ /**
+ * @param wsdlURI
+ * The wsdlURI to set.
+ */
+ public void setWsdlURI(String wsdlURI)
+ {
+ this.wsdlURI = wsdlURI;
+ }
+
+ /**
+ * @return Returns the wsilURI.
+ */
+ public String getWsilURI()
+ {
+ return wsilURI;
+ }
+
+ /**
+ * @param wsilURI
+ * The wsilURI to set.
+ */
+ public void setWsilURI(String wsilURI)
+ {
+ this.wsilURI = wsilURI;
+ }
+
+ /**
+ * @return Returns the webServicesParser.
+ */
+ public WebServicesParser getWebServicesParser()
+ {
+ if (webServicesParser != null)
+ return webServicesParser;
+ else
+ return new WebServicesParserExt();
+ }
+
+ /**
+ * @param webServicesParser
+ * The webServicesParser to set.
+ */
+ public void setWebServicesParser(WebServicesParser webServicesParser)
+ {
+ this.webServicesParser = webServicesParser;
+ }
+
+ /**
+ * @return Returns the j2eeVersion.
+ */
+ public String getClientJ2EEVersion()
+ {
+ return "14"; //rm j2ee
+ }
+
+ /**
+ * @param version The j2eeVersion to set.
+ */
+ /*
+ public void setClientJ2EEVersion(String version)
+ {
+ j2eeVersion = version;
+ }
+ */
+ /**
+ *
+ * @return returns true if a proxy should be generated and false otherwise.
+ */
+ public boolean getGenerateProxy()
+ {
+ return genProxy_;
+ }
+
+ public void setGenerateProxy( boolean genProxy )
+ {
+ genProxy_ = genProxy;
+ }
+
+ public void setLaunchedServiceTestName(String launchedServiceTestName)
+ {
+ this.launchedServiceTestName = launchedServiceTestName;
+ }
+
+ /**
+ *
+ * @return returns the name of the test facility to launch.
+ */
+ public String getLaunchedServiceTestName()
+ {
+ return launchedServiceTestName;
+ }
+
+ /**
+ *
+ * @return returns true if the client project needs an EAR project.
+ */
+ public boolean getClientNeedEAR()
+ {
+ return clientNeedEAR_;
+ }
+
+ public void setClientNeedEAR(boolean clientNeedEAR)
+ {
+ clientNeedEAR_ = clientNeedEAR;
+ }
+
+
+ public void setClientComponentType(String clientComponentType)
+ {
+ this.clientComponentType_ = clientComponentType;
+ }
+
+ public void setClientProjectName(String clientProjectName)
+ {
+ this.clientProjectName_ = clientProjectName;
+ }
+
+ /*
+ public void setClientComponentName(String clientComponentName)
+ {
+ this.clientComponentName_ = clientComponentName;
+ }
+ */
+
+ public void setClientEarProjectName(String clientEarProjectName)
+ {
+ this.clientEarProjectName_ = clientEarProjectName;
+ }
+
+ /*
+ public void setClientEarComponentName(String clientEarComponentName)
+ {
+ this.clientEarComponentName_ = clientEarComponentName;
+ }
+ */
+
+ public String getClientEarProjectName()
+ {
+ return clientEarProjectName_;
+ }
+
+ /*
+ public String getClientEarComponentName()
+ {
+ return clientEarComponentName_;
+ }
+ */
+
+ public void setServiceServerFactoryId(String id)
+ {
+ serviceServerFactoryId_ = id;
+ }
+
+ public void setServiceServerInstanceId(String id)
+ {
+ serviceServerInstanceId_ = id;
+ }
+
+ public boolean getCanRunTestClient(){
+ if(clientIds_.getServerInstanceId() != null) return true;
+
+ return false;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ IEnvironment env = getEnvironment();
+ //Do some basic validation to ensure the server/runtime/type combination is supported.
+ //This is needed to catch problems in the defaulting
+ //when the user clicks Finish prior to page 3 of the wizard.
+
+ IStatus status = Status.OK_STATUS;
+
+ String scenario = ConsumptionUIMessages.MSG_CLIENT_SUB;
+
+ //Ensure server and runtime are non-null
+ String runtimeId = clientIds_.getRuntimeId();
+ String serverId = clientIds_.getServerId();
+ String typeId = clientIds_.getTypeId();
+
+ if( runtimeId == null || runtimeId.length()==0)
+ {
+ status = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_NO_RUNTIME, new String[]{ scenario } ) );
+ env.getStatusHandler().reportError(status);
+ }
+
+ if( serverId == null || serverId.length()==0)
+ {
+ //Popup and error if the selected client project does not exist.
+ IProject clientProject = ProjectUtilities.getProject(clientProjectName_);
+ if (!clientProject.exists())
+ {
+ String runtimeLabel = WebServiceRuntimeExtensionUtils2.getRuntimeLabelById(runtimeId);
+ status = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_PROJECT_MUST_EXIST, new String[]{clientProjectName_, runtimeLabel } ) );
+ env.getStatusHandler().reportError(status);
+ }
+ else
+ {
+ RuntimeDescriptor desc = WebServiceRuntimeExtensionUtils2.getRuntimeById(runtimeId);
+
+ if (desc.getServerRequired())
+ {
+ status = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_NO_SERVER, new String[] { scenario }));
+ env.getStatusHandler().reportError(status);
+ }
+ else
+ {
+ // No server has been selected and the selected Web service runtime
+ // does not
+ // require a server. Set deploy, install, run, and test to false.
+ deployClient_ = false;
+ installClient = Boolean.FALSE;
+ startClient = false;
+ //testService = Boolean.FALSE;
+ }
+ }
+ }
+
+ // If the server is non-null, ensure there is an installed server with ID the same as 'serverID' registered in Eclipse
+ boolean noRuntimeInstalled = true;
+ if (serverId != null) {
+ // If the server is non-null, ensure there is an installed server with ID the same as 'serverID' registered in Eclipse
+ String[] runtimes = WebServiceRuntimeExtensionUtils2.getAllServerFactoryIdsWithRuntimes();
+ for (int i = 0; i < runtimes.length; i++) {
+ if (runtimes[i].equals(serverId)){
+ noRuntimeInstalled = false;
+ break;
+ }
+ }
+ if (noRuntimeInstalled){
+ String serverLabel = WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId);
+ if (serverLabel == null) // Cannot translate from id to label, so let's just use the id
+ serverLabel = serverId;
+ status = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_ERROR_NO_SERVER_RUNTIME_INSTALLED, new String[] {serverLabel}));
+ env.getStatusHandler().reportError(status);
+ }
+ }
+
+ //If the server is non-null and is installed in Eclipse, ensure the server, runtime, and type are compatible
+ if (!noRuntimeInstalled && serverId != null && serverId.length() > 0)
+ {
+ if (!WebServiceRuntimeExtensionUtils2.isServerClientRuntimeTypeSupported(serverId, runtimeId, typeId))
+ {
+ String serverLabel = WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId);
+ String runtimeLabel = WebServiceRuntimeExtensionUtils2.getRuntimeLabelById(runtimeId);
+ status = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_INVALID_SRT_SELECTIONS, new String[] { serverLabel,
+ runtimeLabel }));
+ env.getStatusHandler().reportError(status);
+ }
+
+ IProject clientProject = ProjectUtilities.getProject(clientProjectName_);
+
+ //If the project exists, ensure it supports the Web service type, Web service runtime, and server.
+ if (clientProjectName_ != null && clientProject.exists()) {
+ ValidationUtils vUtil = new ValidationUtils();
+
+ if (!vUtil.doesServerSupportProject(serverId,clientProjectName_)) {
+
+ // If this error is due to differing Java facet versions, display a specific error message
+ boolean isJavaUtilProject = clientProject != null ? FacetUtils.isJavaProject(clientProject) : false ;
+ if(isJavaUtilProject && vUtil.doesServerSupportClientProject(serverId, clientProjectName_, true)) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ ConsumptionUIMessages.MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT_JAVA_UTIL_VERSION,
+ new String[] { WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId),clientProjectName_ }));
+
+ } else {
+ // otherwise display a general error message
+ status = StatusUtils.errorStatus(NLS.bind(
+ ConsumptionUIMessages.MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT,
+ new String[] { WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId),clientProjectName_ }));
+ }
+
+ // Show error
+ env.getStatusHandler().reportError(status);
+ }
+ }
+ // Determine if the selected server type has only stub runtimes associated
+ // with it and if a server instance is not selected.
+ // If so, set install and test to false in the context.
+ IRuntime nonStubRuntime = ServerUtils.getNonStubRuntime(serverId);
+ if (nonStubRuntime == null && clientIds_.getServerInstanceId() == null)
+ {
+ installClient = Boolean.FALSE;
+ startClient = false;
+ //testService = Boolean.FALSE;
+ }
+ }
+
+ // calculate the most appropriate clientRuntimeId based on current settings.
+ clientRuntimeId_ = WebServiceRuntimeExtensionUtils2.getClientRuntimeId(clientIds_, clientProjectName_, clientComponentType_);
+
+ return status;
+ }
+
+ public String getClientOsgiAppProjectName() {
+ return clientOsgiAppProjectName;
+ }
+
+ public void setClientOsgiAppProjectName(String clientOsgiAppProjectName) {
+ this.clientOsgiAppProjectName = clientOsgiAppProjectName;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionFragment.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionFragment.java
new file mode 100644
index 000000000..fa05d0520
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionFragment.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.extensions;
+
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.wst.command.internal.env.core.fragment.ExtensionFragment;
+
+
+public class ClientExtensionFragment extends ExtensionFragment
+{
+ public ClientExtensionFragment()
+ {
+ }
+
+ protected ClientExtensionFragment( ClientExtensionFragment fragment )
+ {
+ super( fragment );
+ }
+
+ public void setClientTypeRuntimeServer( TypeRuntimeServer ids )
+ {
+ setExtensionIds( new String[]{ ids.getTypeId(), ids.getRuntimeId(), ids.getServerId() } );
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ {
+ return new ClientExtensionFragment( this );
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionOutputCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionOutputCommand.java
new file mode 100644
index 000000000..50631d4cf
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionOutputCommand.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060728 145426 kathy@ca.ibm.com - Kathy Chan
+ * 20070502 180304 gilberta@ca.ibm.com - Gilbert Andrews
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.extensions;
+
+import org.eclipse.core.commands.ExecutionException;
+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.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.wsrt.IWebServiceClient;
+
+public class ClientExtensionOutputCommand extends AbstractDataModelOperation
+{
+ private IWebServiceClient webServiceClient_;
+
+ /**
+ * @return Returns the proxyBean.
+ */
+
+ public String getProxyBean()
+ {
+ return webServiceClient_.getWebServiceClientInfo().getImplURL();
+ }
+
+ public boolean getCanGenerateProxy()
+ {
+ return !(webServiceClient_.getWebServiceClientInfo().getImplURL() == null);
+ }
+
+ /**
+ * @return Returns the setEndpointMethod.
+ */
+ public String getSetEndpointMethod()
+ {
+ return "setEndpoint";
+ }
+
+ public void setWebServiceClient(IWebServiceClient wsc)
+ {
+ webServiceClient_ = wsc;
+ }
+
+ public String getServerInstanceId()
+ {
+ return webServiceClient_.getWebServiceClientInfo().getServerInstanceId();
+ }
+
+ public String getServerFactoryId()
+ {
+ return webServiceClient_.getWebServiceClientInfo().getServerFactoryId();
+ }
+
+ /**
+ * @return Returns the proxyEndpoint.
+ */
+ public String getProxyEndpoint() {
+ return webServiceClient_.getWebServiceClientInfo().getProxyEndpoint();
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ return Status.OK_STATUS;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ServerExtensionDefaultingCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ServerExtensionDefaultingCommand.java
new file mode 100644
index 000000000..8ad4080fb
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ServerExtensionDefaultingCommand.java
@@ -0,0 +1,475 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2015 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060204 124408 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060221 119111 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060529 141422 kathy@ca.ibm.com - Kathy Chan
+ * 20060823 154938 pmoogk@ca.ibm.com - Peter Moogk
+ * 20080205 170141 kathy@ca.ibm.com - Kathy Chan
+ * 20080326 171705 trungha@ca.ibm.com - Trung, improve AntTask errors report
+ * 20080409 219121 trungha@ca.ibm.com - Trung Ha
+ * 20080729 241275 ericdp@ca.ibm.com - Eric D. Peters, No Validation error generating Web Service client if dialog hidden
+ * 20081028 248625 ericdp@ca.ibm.com - Eric D. Peters, Exceptions running ANT tasks using inappropriate projects
+ * 20150311 461526 jgwest@ca.ibm.com - Jonathan West, Allow OSGi bundles to be selected in the Wizard
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.extensions;
+
+import org.eclipse.core.commands.ExecutionException;
+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.ws.internal.common.ServerUtils;
+import org.eclipse.jst.ws.internal.consumption.common.FacetUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.common.ValidationUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.RuntimeDescriptor;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils2;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.ws.internal.parser.discovery.WebServicesParserExt;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
+
+
+public class ServerExtensionDefaultingCommand extends AbstractDataModelOperation
+{
+ private boolean developService_;
+ private boolean assembleService_;
+ private boolean deployService_;
+
+ private Boolean installService;
+ private IProject initialProject_;
+ private Boolean startService;
+ private Boolean testService;
+ private Boolean publishService;
+ private TypeRuntimeServer serviceIds_;
+ private String serviceRuntimeId_;
+ //private SelectionListChoices serviceChoices_;
+ private String serviceProjectName_;
+ private String serviceEarProjectName_;
+ private String serviceComponentType_;
+ //private String serviceComponentName_;
+ //private String serviceEarComponentName_;
+ //private String j2eeVersion;
+ private boolean serviceNeedEAR_;
+ private WebServicesParser wsdlParser_;
+
+ private String serviceOsgiAppProjectName_;
+
+
+ public void setServiceTypeRuntimeServer(TypeRuntimeServer ids)
+ {
+ serviceIds_ = ids;
+ }
+
+ public void setServiceExistingServerInstanceId(String serverInstId){
+
+ if (serviceIds_.getServerInstanceId()==null)
+ serviceIds_.setServerInstanceId(serverInstId);
+ }
+
+ /**
+ *
+ * @return returns the TypeRuntimeService object that the user has selected on
+ * page 3 of the wizard.
+ */
+ public TypeRuntimeServer getServiceTypeRuntimeServer()
+ {
+ return serviceIds_;
+ }
+
+ public void setServiceRuntimeId(String id)
+ {
+ serviceRuntimeId_ = id;
+ }
+
+ public String getServiceRuntimeId()
+ {
+ return serviceRuntimeId_;
+ }
+
+ /*
+ public void setServiceProject2EARProject(SelectionListChoices choices)
+ {
+ serviceChoices_ = choices;
+ }
+ */
+
+ /**
+ * @return Returns the publishService.
+ */
+ public Boolean getPublishService()
+ {
+ return publishService;
+ }
+
+ /**
+ * @param publishService
+ * The publishService to set.
+ */
+ public void setPublishService(Boolean publishService)
+ {
+ this.publishService = publishService;
+ }
+
+ /**
+ * @return Returns the serverIsExistingServer.
+ */
+ public boolean getServerIsExistingServer()
+ {
+ return serviceIds_.getServerInstanceId() != null;
+ }
+
+ /**
+
+ * @return Returns the serverInstanceId
+ */
+ public String getServiceServerInstanceId()
+ {
+ return serviceIds_.getServerInstanceId();
+ }
+
+ /**
+ * @return Returns the serverProject.
+ */
+ public String getServerProject()
+ {
+ return serviceProjectName_ + "/" + serviceProjectName_;
+ }
+
+ /**
+ * @return Returns the serverProjectEAR.
+ */
+ public String getServerProjectEAR()
+ {
+ if (serviceEarProjectName_!=null && serviceEarProjectName_.length()>0)
+ {
+ return serviceEarProjectName_ + "/" + serviceEarProjectName_;
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ /**
+ * @return Returns the serverRuntime.
+ */
+ public String getServerRuntime()
+ {
+ return serviceIds_.getRuntimeId();
+ }
+
+ /**
+ * @return Returns the serverServer.
+ */
+ public String getServerServer()
+ {
+ return serviceIds_.getServerId();
+ }
+
+ /**
+ * @return Returns the serviceScenarioId.
+ */
+ public String getServiceScenarioId()
+ {
+ return serviceIds_.getTypeId();
+ }
+
+ public boolean getDevelopService() {
+ return developService_;
+ }
+
+ public void setDevelopService(boolean developService) {
+ this.developService_ = developService;
+ }
+
+ public boolean getAssembleService() {
+ return assembleService_;
+ }
+
+ public void setAssembleService(boolean assembleService) {
+ this.assembleService_ = assembleService;
+ }
+
+ public boolean getDeployService() {
+ return deployService_;
+ }
+
+ public void setDeployService(boolean deployService) {
+ this.deployService_ = deployService;
+ }
+
+ /**
+ * @return Returns the installService.
+ */
+ public Boolean getInstallService()
+ {
+ return installService;
+ }
+ /**
+ * @param installService
+ * Specifies if service should be installed.
+ */
+ public void setInstallService(Boolean installService)
+ {
+ this.installService = installService;
+ }
+
+ /**
+ * @return Returns the startService.
+ */
+ public Boolean getStartService()
+ {
+ return startService;
+ }
+ public void setInitialProject(IProject initialProject)
+ {
+ initialProject_ = initialProject;
+ }
+
+ public IProject getInitialProject()
+ {
+ return initialProject_;
+ }
+ /**
+ * @param startService
+ * The startService to set.
+ */
+ public void setStartService(Boolean startService)
+ {
+ this.startService = startService;
+ }
+
+ /**
+ * @return Returns the testService.
+ */
+ public Boolean getTestService()
+ {
+ return testService;
+ }
+
+ /**
+ * @param testService
+ * The testService to set.
+ */
+ public void setTestService(Boolean testService)
+ {
+ this.testService = testService;
+ }
+
+ public Boolean getPublish()
+ {
+ return new Boolean(true);
+ }
+
+ /**
+ * @return Returns the j2eeVersion.
+ */
+ public String getServiceJ2EEVersion()
+ {
+ return "14"; //rm j2ee
+ }
+
+ /**
+ *
+ * @return returns true if the web service project needs to be in an EAR project.
+ */
+ public boolean getServiceNeedEAR()
+ {
+ return serviceNeedEAR_;
+ }
+
+ public void setServiceNeedEAR(boolean serviceNeedEAR)
+ {
+ serviceNeedEAR_ = serviceNeedEAR;
+ }
+
+ /**
+ * @return Returns the wsdlParser_.
+ */
+ public WebServicesParser getWebServicesParser()
+ {
+ if( wsdlParser_ == null )
+ {
+ wsdlParser_ = new WebServicesParserExt();
+ }
+
+ return wsdlParser_;
+ }
+ /**
+ * @param wsdlParser_ The wsdlParser_ to set.
+ */
+ public void setWebServicesParser(WebServicesParser wsdlParser )
+ {
+ wsdlParser_ = wsdlParser;
+ }
+
+
+ public void setServiceProjectName(String serviceProjectName)
+ {
+ this.serviceProjectName_ = serviceProjectName;
+ }
+
+ public void setServiceEarProjectName(String serviceEarProjectName)
+ {
+ this.serviceEarProjectName_ = serviceEarProjectName;
+ }
+
+ public void setServiceComponentType(String type)
+ {
+ this.serviceComponentType_ = type;
+ }
+
+ public String getServiceComponentType()
+ {
+ return serviceComponentType_;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ IEnvironment env = getEnvironment();
+ //Do some basic validation to ensure the server/runtime/type combination is supported.
+ //This is needed to catch problems in the defaulting
+ //when the user clicks Finish prior to page 3 of the wizard.
+
+ IStatus status = Status.OK_STATUS;
+
+ String scenario = ConsumptionUIMessages.MSG_SERVICE_SUB;
+
+ //Ensure server and runtime are non-null
+ String runtimeId = serviceIds_.getRuntimeId();
+ String serverId = serviceIds_.getServerId();
+ String typeId = serviceIds_.getTypeId();
+
+ if( runtimeId == null || runtimeId.length()==0)
+ {
+ status = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_NO_RUNTIME, new String[]{ scenario } ) );
+ env.getStatusHandler().reportError(status);
+ }
+
+ if( serverId == null || serverId.length()==0)
+ {
+ //Popup and error if the selected service project does not exist.
+ IProject serviceProject = ProjectUtilities.getProject(serviceProjectName_);
+ if (!serviceProject.exists())
+ {
+ String runtimeLabel = WebServiceRuntimeExtensionUtils2.getRuntimeLabelById(runtimeId);
+ status = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_PROJECT_MUST_EXIST, new String[]{ serviceProjectName_, runtimeLabel } ) );
+ env.getStatusHandler().reportError(status);
+ }
+ else
+ {
+
+ RuntimeDescriptor desc = WebServiceRuntimeExtensionUtils2.getRuntimeById(runtimeId);
+ if (desc.getServerRequired())
+ {
+ status = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_NO_SERVER, new String[] { scenario }));
+ env.getStatusHandler().reportError(status);
+ }
+ else
+ {
+ // No server has been selected and the selected Web service runtime
+ // does not require a server. Set deploy, install, run, and test to false.
+ deployService_ = false;
+ installService = Boolean.FALSE;
+ startService = Boolean.FALSE;
+ testService = Boolean.FALSE;
+ }
+ }
+ }
+
+ // If the server is non-null, ensure there is an installed server with ID the same as 'serverID' registered in Eclipse
+ boolean noRuntimeInstalled = true;
+ if (serverId != null) {
+ String[] runtimes = WebServiceRuntimeExtensionUtils2.getAllServerFactoryIdsWithRuntimes();
+
+ for (int i = 0; i < runtimes.length; i++) {
+ if (runtimes[i].equals(serverId)){
+ noRuntimeInstalled = false;
+ break;
+ }
+ }
+ if (noRuntimeInstalled){
+ String serverLabel = WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId);
+ if (serverLabel == null) // Cannot translate from id to label, so let's just use the id
+ serverLabel = serverId;
+ status = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_ERROR_NO_SERVER_RUNTIME_INSTALLED, new String[] {serverLabel}));
+ env.getStatusHandler().reportError(status);
+ }
+ }
+
+ //If the server is non-null and is installed in Eclipse, ensure the server, runtime, and type are compatible
+ if (!noRuntimeInstalled && serverId != null && serverId.length() > 0)
+ {
+ if (!WebServiceRuntimeExtensionUtils2.isServerRuntimeTypeSupported(serverId, runtimeId, typeId))
+ {
+ String serverLabel = WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId);
+ String runtimeLabel = WebServiceRuntimeExtensionUtils2.getRuntimeLabelById(runtimeId);
+ status = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_INVALID_SRT_SELECTIONS, new String[] { serverLabel,
+ runtimeLabel }));
+ env.getStatusHandler().reportError(status);
+ }
+ //If the project exists, ensure it supports the Web service type, Web service runtime, and server.
+ if (getInitialProject() != null && getInitialProject().getName() != null && ProjectUtilities.getProject(getInitialProject().getName()).exists()) {
+ ValidationUtils valUtils = new ValidationUtils();
+
+ if (WebServiceRuntimeExtensionUtils2.getScenarioFromTypeId(typeId) == WebServiceScenario.BOTTOMUP &&
+ FacetUtils.isJavaProject(getInitialProject())){
+ if(!valUtils.doesServerSupportProject(serverId,getInitialProject().getName())){
+ status = StatusUtils.errorStatus(NLS.bind(
+ ConsumptionUIMessages.MSG_SERVICE_SERVER_DOES_NOT_SUPPORT_JAVAPROJECT,
+ new String[] { WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId), getInitialProject().getName() }));
+ env.getStatusHandler().reportError(status);
+ }
+ }
+ if (!valUtils.doesServerSupportProject(serverId, serviceProjectName_)) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ ConsumptionUIMessages.MSG_SERVICE_SERVER_DOES_NOT_SUPPORT_PROJECT,
+ new String[] { WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId),
+ serviceProjectName_ }));
+ env.getStatusHandler().reportError(status);
+ }
+ }
+ // Determine if the selected server type has only stub runtimes associated
+ // with it and if a server instance is not selected.
+ // If so, set install, run, and test to false in the context.
+ IRuntime nonStubRuntime = ServerUtils.getNonStubRuntime(serverId);
+ if (nonStubRuntime == null && serviceIds_.getServerInstanceId() == null)
+ {
+ installService = Boolean.FALSE;
+ startService = Boolean.FALSE;
+ testService = Boolean.FALSE;
+ }
+ }
+
+ // calculate the most appropriate clientRuntimeId based on current settings.
+ serviceRuntimeId_ = WebServiceRuntimeExtensionUtils2.getServiceRuntimeId( serviceIds_, serviceProjectName_, serviceComponentType_);
+
+ return status;
+ }
+
+ public String getServiceOsgiAppProjectName() {
+ return serviceOsgiAppProjectName_;
+ }
+
+ public void setServiceOsgiAppProjectName(String serviceOsgiAppProjectName) {
+ this.serviceOsgiAppProjectName_ = serviceOsgiAppProjectName;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ServerExtensionFragment.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ServerExtensionFragment.java
new file mode 100644
index 000000000..500a49525
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ServerExtensionFragment.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.extensions;
+
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.wst.command.internal.env.core.fragment.ExtensionFragment;
+
+
+public class ServerExtensionFragment extends ExtensionFragment
+{
+ public ServerExtensionFragment()
+ {
+
+ }
+
+ protected ServerExtensionFragment( ServerExtensionFragment fragment )
+ {
+ super( fragment );
+ }
+
+ public void setServiceTypeRuntimeServer( TypeRuntimeServer ids )
+ {
+ setExtensionIds( new String[]{ ids.getTypeId(), ids.getRuntimeId(), ids.getServerId() } );
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ {
+ return new ServerExtensionFragment( this );
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ServerExtensionOutputCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ServerExtensionOutputCommand.java
new file mode 100644
index 000000000..b183cd26e
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ServerExtensionOutputCommand.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.extensions;
+
+import org.eclipse.core.commands.ExecutionException;
+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.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.parser.discovery.WebServicesParserExt;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+import org.eclipse.wst.ws.internal.wsrt.IWebService;
+
+public class ServerExtensionOutputCommand extends AbstractDataModelOperation
+{
+ //private String wsdlURI_;
+ private WebServicesParser wsdlParser_;
+ private IWebService webService_;
+
+ private boolean isWebProjectStartupRequested_ = false;
+
+
+ /**
+ * @return Returns the wsdlURI.
+ */
+ public String getWsdlURI()
+ {
+ return webService_.getWebServiceInfo().getWsdlURL();
+ }
+
+ /**
+ * @param wsdlURI
+ * The wsdlURI to set.
+ */
+ /*
+ public void setWsdlURI(String wsdlURI)
+ {
+ wsdlURI_ = wsdlURI;
+ }
+ */
+
+ public void setWebService(IWebService ws)
+ {
+ webService_ = ws;
+ }
+
+ /**
+ * @return Returns the wsdlParser_.
+ */
+ public WebServicesParser getWebServicesParser()
+ {
+ if( wsdlParser_ == null )
+ {
+ wsdlParser_ = new WebServicesParserExt();
+ }
+
+ return wsdlParser_;
+ }
+ /**
+ * @param wsdlParser_ The wsdlParser_ to set.
+ */
+ public void setWebServicesParser(WebServicesParser wsdlParser_)
+ {
+ this.wsdlParser_ = wsdlParser_;
+ }
+/**
+ * @param earProjectName The earProjectName to set.
+ */
+public void setEarProjectName(String earProjectName) {
+}
+/**
+ * @param existingServerId The existingServerId to set.
+ */
+public void setExistingServerId(String existingServerId) {
+}
+
+/**
+ * @return Returns the isRestartProjectNeeded.
+ */
+public boolean getIsWebProjectStartupRequested() {
+ return isWebProjectStartupRequested_;
+}
+/**
+ * @param isRestartProjectNeeded The isRestartProjectNeeded to set.
+ */
+public void setIsWebProjectStartupRequested(boolean isRestartProjectNeeded) {
+ this.isWebProjectStartupRequested_ = isRestartProjectNeeded;
+}
+
+public String getServiceServerFactoryId()
+{
+ return webService_.getWebServiceInfo().getServerFactoryId();
+}
+
+public String getServiceServerInstanceId()
+{
+ return webService_.getWebServiceInfo().getServerInstanceId();
+}
+
+public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+{
+ return Status.OK_STATUS;
+}
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/AbstractObjectSelectionWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/AbstractObjectSelectionWidget.java
new file mode 100644
index 000000000..805c970f9
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/AbstractObjectSelectionWidget.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060410 135441 joan@ca.ibm.com - Joan Haggarty
+ * 20060420 135912 joan@ca.ibm.com - Joan Haggarty
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+
+
+public abstract class AbstractObjectSelectionWidget extends SimpleWidgetDataContributor implements IObjectSelectionWidget
+{
+ public void setInitialSelection(IStructuredSelection initialSelection)
+ {
+ // subclass should override this method
+ }
+
+ public IStructuredSelection getObjectSelection()
+ {
+ // subclass should override this method
+ return new StructuredSelection();
+ }
+
+ public IStatus validateSelection(IStructuredSelection objectSelection)
+ {
+ // subclass should override this method
+ return Status.OK_STATUS;
+ }
+
+ public IProject getProject()
+ {
+ // subclass should override this method
+ return null;
+ }
+
+ public String getObjectSelectionDisplayableString()
+ {
+ // subclass should override this method
+ return "";
+ }
+
+ public Point getWidgetSize()
+ {
+ // subclasses should override with an appropriate default dialog size for this widget
+ return null;
+ }
+
+ public boolean validate(String s) {
+ // subclass should override this method
+ return true;
+ }
+ }
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/EJBSelectionTransformer.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/EJBSelectionTransformer.java
new file mode 100644
index 000000000..ebd83f142
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/EJBSelectionTransformer.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 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
+ * -------- -------- -----------------------------------------------------------
+ * 20070116 159618 makandre@ca.ibm.com - Andrew Mak, Project and EAR not defaulted properly when wizard launched from JSR-109 Web services branch in J2EE Project Explorer
+ * 20080212 208795 ericdp@ca.ibm.com - Eric D. Peters, WS wizard framework should support EJB 3.0
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
+import org.eclipse.jst.j2ee.webservice.wsdd.EJBLink;
+import org.eclipse.jst.j2ee.webservice.wsdd.PortComponent;
+import org.eclipse.jst.j2ee.webservice.wsdd.ServiceImplBean;
+import org.eclipse.jst.javaee.ejb.SessionBean;
+import org.eclipse.wst.command.internal.env.core.data.Transformer;
+
+public class EJBSelectionTransformer implements Transformer
+{
+
+ public Object transform(Object value)
+ {
+ if (value instanceof IStructuredSelection)
+ {
+ Object sel = ((IStructuredSelection)value).getFirstElement();
+ if (sel instanceof EnterpriseBean)
+ {
+ return new StructuredSelection(((EnterpriseBean)sel).getName());
+ }
+ else if (sel instanceof SessionBean)
+ {
+ return new StructuredSelection(((SessionBean)sel).getEjbName());
+ }
+ else if (sel instanceof ServiceImplBean)
+ {
+ return new StructuredSelection(getBeanName((ServiceImplBean) sel));
+ }
+ else if (sel instanceof EJBLink)
+ {
+ return new StructuredSelection(getBeanName((EJBLink) sel));
+ }
+ }
+ return value;
+ }
+
+ private String getBeanName(ServiceImplBean bean) {
+ EObject eObject = bean.eContainer();
+ if (eObject instanceof PortComponent) {
+ PortComponent pc = (PortComponent) eObject;
+ return pc.getPortComponentName();
+ }
+ return "";
+ }
+
+ private String getBeanName(EJBLink link) {
+ EObject eObject = link.eContainer();
+ if (eObject instanceof ServiceImplBean)
+ return getBeanName((ServiceImplBean) eObject);
+ return "";
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/EJBSelectionWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/EJBSelectionWidget.java
new file mode 100644
index 000000000..ee4c83114
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/EJBSelectionWidget.java
@@ -0,0 +1,392 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060329 128069 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060418 136180 kathy@ca.ibm.com - Kathy Chan
+ * 20060524 141194 joan@ca.ibm.com - Joan Haggarty
+ * 20060825 135570 makandre@ca.ibm.com - Andrew Mak, Service implementation URL not displayed properly on first page
+ * 20080212 208795 ericdp@ca.ibm.com - Eric Peters, WS wizard framework should support EJB 3.0
+ * 20080229 218696 ericdp@ca.ibm.com - Eric D. Peters, APIs using EJBArtifactEdit not able to deal with some EJB 3.0 beans properly
+ * 20080428 224726 pmoogk@ca.ibm.com - Peter Moogk
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jst.j2ee.ejb.EJBJar;
+import org.eclipse.jst.j2ee.ejb.EJBResource;
+import org.eclipse.jst.j2ee.ejb.Session;
+import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.jst.j2ee.model.IModelProvider;
+import org.eclipse.jst.j2ee.model.ModelProviderManager;
+import org.eclipse.jst.javaee.ejb.EnterpriseBeans;
+import org.eclipse.jst.javaee.ejb.SessionBean;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
+import org.eclipse.jst.ws.internal.ui.common.UIUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+
+public class EJBSelectionWidget extends AbstractObjectSelectionWidget implements IObjectSelectionWidget
+{
+
+ private Combo earList;
+ private EJBTableViewer beanList;
+ private IVirtualComponent[] earComponents;
+ private Integer selectedBeanIndex = null;
+ private Vector ejbBeanNames;
+ private Vector ejbComponentNames;
+ private Vector ejbComponentProjectNames;
+ private Hashtable ejbValuesByEARSelectionCache;
+ private Listener statusListener_;
+ private String displayString_ = "";
+ /* CONTEXT_ID PEBD0001 for the EAR Projects drop-down box */
+ private String INFOPOP_PEBD_EAR_PROJECTS = "PEBD0001";
+ /* CONTEXT_ID PEBD0002 for the table containing all of the bean names */
+ private String INFOPOP_PEBD_TABLE_BEAN_NAMES = "PEBD0002";
+
+ public EJBSelectionWidget()
+ {
+ earComponents = J2EEUtils.getAllEARComponents();
+ ejbValuesByEARSelectionCache = new Hashtable();
+ }
+
+ public String getSelectedBean()
+ {
+ if (selectedBeanIndex != null)
+ {
+ return (String) (ejbBeanNames.elementAt(selectedBeanIndex.intValue()));
+ }
+ return null;
+ }
+
+ public String getSelectedProject()
+ {
+ if (selectedBeanIndex != null)
+ {
+ return (String) (ejbComponentProjectNames.elementAt(selectedBeanIndex.intValue()));
+ }
+ return null;
+ }
+
+ public WidgetDataEvents addControls(Composite parent, Listener statusListener)
+ {
+ statusListener_ = statusListener;
+ UIUtils utils = new UIUtils( WebServiceConsumptionUIPlugin.ID );
+
+ Composite composite = utils.createComposite(parent, 1, 0, 0);
+
+ Composite projectComposite = utils.createComposite(composite, 2);
+ new Label(projectComposite, SWT.NULL).setText(ConsumptionUIMessages.LABEL_EAR_PROJECTS);
+ earList = new Combo(projectComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
+ earList.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ earList.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent evt)
+ {
+ Combo widget = (Combo) (evt.widget);
+ int earListSelectionIndex = widget.getSelectionIndex();
+ if (earListSelectionIndex > 0)
+ {
+ setBeanList(earComponents[earListSelectionIndex-1]);
+ }
+ else
+ {
+ setBeanList(null);
+ }
+ selectedBeanIndex = null;
+ statusListener_.handleEvent(null);
+ }
+ });
+ addEARNamesToList();
+ earList.setToolTipText(ConsumptionUIMessages.TOOLTIP_EAR_PROJECTS);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(earList, INFOPOP_PEBD_EAR_PROJECTS);
+
+ Group beanComposite = utils.createGroup(composite, ConsumptionUIMessages.LABEL_EJB_BEAN_NAME, "", "");
+ beanList = new EJBTableViewer(beanComposite);
+ Table beanTable = beanList.getTable();
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
+ gd.heightHint = 100;
+ beanTable.setLayoutData(gd);
+ beanTable.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent evt)
+ {
+ Table table = (Table) (evt.widget);
+ selectedBeanIndex = new Integer(table.getSelectionIndex());
+ statusListener_.handleEvent(null);
+ }
+ });
+ beanTable.setToolTipText(ConsumptionUIMessages.TOOLTIP_TABLE_BEAN_NAMES);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(beanTable, INFOPOP_PEBD_TABLE_BEAN_NAMES);
+
+ if (earComponents != null && earComponents.length > 0)
+ {
+ setBeanList(earComponents[0]);
+ }
+ else
+ {
+ setBeanList(null);
+ }
+
+ // This is a dummy label that forces the status label into the second
+ // column.
+ new Label(composite, SWT.NULL).setText("");
+
+ return this;
+ }
+
+
+
+ private void addEARNamesToList()
+ {
+ earList.add(ConsumptionUIMessages.LABEL_SHOW_ALL_STATELESS_SESSION_EJBS);
+ if (earComponents != null && earComponents.length > 0)
+ {
+ for (int index = 0; index < earComponents.length; index++)
+ {
+ earList.add(earComponents[index].getName());
+ }
+ earList.setText(earList.getItem(1));
+ }
+ }
+
+ private void setBeanList(IVirtualComponent earComponent)
+ {
+ String cacheKey = (earComponent == null)? earList.getItem(0): earComponent.getName();
+
+ //Check if we've already cached results for this case. If so, use the
+ //cached values and return. If not, continue.
+ EJBTableValues cachedValues = (EJBTableValues)ejbValuesByEARSelectionCache.get(cacheKey);
+ if (cachedValues != null)
+ {
+ ejbBeanNames = cachedValues.cachedEjbBeanNames;
+ ejbComponentNames = cachedValues.cachedEjbComponentNames;
+ ejbComponentProjectNames = cachedValues.cachdedEjbComponentProjectNames;
+ beanList.setData(ejbBeanNames, ejbComponentNames);
+ beanList.setInput(ejbBeanNames);
+ return;
+ }
+
+ IVirtualComponent[] ejbComponentsArray = null;
+ if (earComponent == null)
+ {
+ ejbComponentsArray = J2EEUtils.getAllEJBComponents();
+ }
+ else
+ {
+ ejbComponentsArray = J2EEUtils.getReferencingEJBComponentsFromEAR(earComponent.getProject());
+ }
+
+ Table beanTable = beanList.getTable();
+ beanTable.removeAll();
+ ejbBeanNames = new Vector();
+ ejbComponentNames = new Vector();
+ ejbComponentProjectNames = new Vector();
+ for (int index = 0; index < ejbComponentsArray.length; index++)
+ {
+ IProject project = ejbComponentsArray[index].getProject();
+ Vector beans = J2EEUtils.getBeanNames(project);
+ String componentName = ejbComponentsArray[index].getName();
+ String projectName = ejbComponentsArray[index].getProject().getName();
+ ejbBeanNames.addAll(beans);
+ ejbComponentNames.addAll(Collections.nCopies(beans.size(), componentName));
+ ejbComponentProjectNames.addAll(Collections.nCopies(beans.size(), projectName));
+
+ }
+ beanList.setData(ejbBeanNames, ejbComponentNames);
+ beanList.setInput(ejbBeanNames);
+
+ //Cache the results for next time
+ EJBTableValues ejbTableValues = new EJBTableValues();
+ ejbTableValues.cachedEjbBeanNames = ejbBeanNames;
+ ejbTableValues.cachedEjbComponentNames = ejbComponentNames;
+ ejbTableValues.cachdedEjbComponentProjectNames = ejbComponentProjectNames;
+ ejbValuesByEARSelectionCache.put(cacheKey, ejbTableValues);
+ }
+
+ public void setInitialSelection(IStructuredSelection initialSelection)
+ {
+ if (initialSelection != null && !initialSelection.isEmpty())
+ {
+ Object object = initialSelection.getFirstElement();
+ if (object instanceof Session)
+ {
+ Session session = (Session) object;
+ EJBJar jar = session.getEjbJar();
+ if (jar != null)
+ {
+ for (int i = 0; i < earComponents.length; i++)
+ {
+ IVirtualComponent[] ejbComponents = J2EEUtils.getReferencingEJBComponentsFromEAR(earComponents[i].getProject());
+ for (int j=0; j <ejbComponents.length; j++)
+ {
+ EJBArtifactEdit ejbEdit = null;
+ try {
+ ejbEdit = EJBArtifactEdit.getEJBArtifactEditForRead(ejbComponents[j]);
+ EJBResource ejbRes = ejbEdit.getEJBJarXmiResource();
+ if (ejbRes.getEJBJar() == jar)
+ {
+ earList.setText(earComponents[i].getName());
+ setBeanList(earComponents[i]);
+ beanList.setSelection(new StructuredSelection(new Integer[]{new Integer(ejbBeanNames.indexOf(session.getName()))}));
+ selectedBeanIndex = new Integer(ejbBeanNames.indexOf(session.getName()));
+ return;
+ }
+
+ }
+ finally {
+ if (ejbEdit!=null)
+ ejbEdit.dispose();
+ }
+
+ }
+ }
+
+ //Haven't returned yet so we did not find an EAR that contains this EJB. Initialize the page accordingly.
+ earList.setText(earList.getItem(0));
+ setBeanList(null);
+ beanList.setSelection(new StructuredSelection(new Integer[]{new Integer(ejbBeanNames.indexOf(session.getName()))}));
+ selectedBeanIndex = new Integer(ejbBeanNames.indexOf(session.getName()));
+ }
+ }
+ else if (object instanceof String)
+ displayString_ = (String) object; // save for display use
+ }
+ }
+
+ public IStructuredSelection getObjectSelection()
+ {
+ String selEJBName = (String) ejbBeanNames.get(selectedBeanIndex
+ .intValue());
+ if (selEJBName != null) {
+ // Get the project containing the bean to get the corresponding
+ // Session object.
+ // Then return the Session object in an IStructuredSelection.
+ String ejbComponentName = (String) ejbComponentNames
+ .get(selectedBeanIndex.intValue());
+ IVirtualComponent ejbComponent = ComponentUtilities
+ .getComponent(ejbComponentName);
+ IProject project = ejbComponent.getProject();
+ IModelProvider provider = ModelProviderManager
+ .getModelProvider(project);
+ Object modelObject = provider.getModelObject();
+ List sessions = new Vector();
+ boolean isJ2EE5 = J2EEProjectUtilities.isJEEProject(project);
+ if (isJ2EE5) {
+ //a JEE5 project
+ EnterpriseBeans eBeans = ((org.eclipse.jst.javaee.ejb.EJBJar)modelObject).getEnterpriseBeans();
+ if (eBeans !=null)
+ sessions = eBeans.getSessionBeans();
+ } else {
+ sessions = ((EJBJar) modelObject).getSessionBeans();
+ }
+ for (Iterator it2 = sessions.iterator(); it2.hasNext();) {
+ Object next = (it2.next());
+ if (isJ2EE5) {
+ SessionBean session = (SessionBean) next;
+ if (selEJBName.equals(session.getEjbName()))
+ return new StructuredSelection(
+ new SessionBean[] { session });
+
+ } else {
+ Session session = (Session) next;
+ if (selEJBName.equals(session.getName()))
+ return new StructuredSelection(
+ new Session[] { session });
+ }
+
+ }
+ }
+ return new StructuredSelection(new Object[0]);
+ }
+
+ public IProject getProject()
+ {
+ String projectName = getSelectedProject();
+ if (projectName != null && projectName.length() > 0)
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ else
+ return null;
+ }
+
+ public String getComponentName()
+ {
+ if (selectedBeanIndex != null)
+ {
+ return (String) (ejbComponentNames.elementAt(selectedBeanIndex.intValue()));
+ }
+ return null;
+ }
+
+ public String getObjectSelectionDisplayableString() {
+
+ if (ejbBeanNames == null)
+ return displayString_;
+
+ int index = selectedBeanIndex == null ? 0 : selectedBeanIndex.intValue();
+ String bean = (String) ejbBeanNames.get(index);
+ return bean == null ? displayString_ : bean;
+ }
+
+ public IStatus validateSelection(IStructuredSelection objectSelection)
+ {
+ return Status.OK_STATUS;
+ }
+
+ public IStatus getStatus()
+ {
+ if (selectedBeanIndex == null)
+ {
+ return StatusUtils.errorStatus( "" );
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ public Point getWidgetSize() {
+ return new Point(450, 350);
+ }
+
+ private class EJBTableValues
+ {
+ Vector cachedEjbBeanNames;
+ Vector cachedEjbComponentNames;
+ Vector cachdedEjbComponentProjectNames;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/EJBTableViewer.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/EJBTableViewer.java
new file mode 100644
index 000000000..155b4f04e
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/EJBTableViewer.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060524 141194 joan@ca.ibm.com - Joan Haggarty
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import java.util.Vector;
+
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class EJBTableViewer extends TableViewer
+{
+ private Vector beanNames;
+ private Vector projectNames;
+
+ public EJBTableViewer(Composite parent)
+ {
+ super(parent, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
+
+ String columnProperties[] = {ConsumptionUIMessages.TABLE_TITLE_EJB_BEAN_NAMES, ConsumptionUIMessages.TABLE_TITLE_EJB_PROJECT_NAME};
+ int columnsWidth[] = {60, 20};
+ int columnMins[] = {175, 125};
+
+ Table table = getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ TableLayout layout = new TableLayout();
+ for (int i = 0; i < columnProperties.length; i++)
+ {
+ TableColumn column = new TableColumn(table, SWT.NONE, i);
+ column.setText(columnProperties[i]);
+ column.pack();
+ layout.addColumnData(new ColumnWeightData(columnsWidth[i], columnMins[i], true));
+ }
+ table.setLayout(layout);
+ setColumnProperties(columnProperties);
+ setContentProvider(new EJBContentProvider());
+ setLabelProvider(new EJBLabelProvider());
+ }
+
+ public void setData(Vector beanNames, Vector projectNames)
+ {
+ this.beanNames = beanNames;
+ this.projectNames = projectNames;
+ }
+ private class EJBLabelProvider extends LabelProvider implements ITableLabelProvider
+ {
+ public String getColumnText(Object object, int columnIndex)
+ {
+ String result = null;
+ if (object instanceof Integer)
+ {
+ int index = ((Integer) object).intValue();
+ if (columnIndex == 0)
+ {
+ return (String) (beanNames.elementAt(index));
+ }
+ else if (columnIndex == 1)
+ {
+ return (String) (projectNames.elementAt(index));
+ }
+ }
+ return result;
+ }
+
+ public Image getColumnImage(Object object, int columnIndex)
+ {
+ return null;
+ }
+ }
+ public class EJBContentProvider implements IStructuredContentProvider
+ {
+ public Object[] getElements(Object element)
+ {
+ if (beanNames != null)
+ {
+ int size = beanNames.size();
+ Object[] result = new Object[size];
+ for (int index = 0; index < size; index++)
+ {
+ result[index] = new Integer(index);
+ }
+ return result;
+ }
+ return null;
+ }
+
+ public void dispose()
+ {
+ }
+
+ public void inputChanged(Viewer viewer, Object old, Object newobj)
+ {
+ }
+
+ public boolean isDeleted(Object object)
+ {
+ return false;
+ }
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/HandlerTableItem.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/HandlerTableItem.java
new file mode 100644
index 000000000..a7be6f437
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/HandlerTableItem.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2004 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
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import org.eclipse.jst.j2ee.webservice.wsdd.PortComponent;
+
+
+
+public class HandlerTableItem {
+
+ private String handlerClassName;
+ private String handlerName;
+ private String portName;
+ private int index;
+
+ private PortComponent port;
+ private Object handler;
+ private Object wsDescRef;
+
+ /**
+ * @return Returns the handlerClassName.
+ */
+ public String getHandlerClassName() {
+ return handlerClassName;
+ }
+ /**
+ * @param handlerClassName The handlerClassName to set.
+ */
+ public void setHandlerClassName(String handlerClassName) {
+ this.handlerClassName = handlerClassName;
+ }
+ /**
+ * @return Returns the handlerName.
+ */
+ public String getHandlerName() {
+ return handlerName;
+ }
+ /**
+ * @param handlerName The handlerName to set.
+ */
+ public void setHandlerName(String handlerName) {
+ this.handlerName = handlerName;
+ }
+ /**
+ * @return Returns the port.
+ */
+ public PortComponent getPort() {
+ return port;
+ }
+ /**
+ * @param port The port to set.
+ */
+ public void setPort(PortComponent port) {
+ this.port = port;
+ }
+ /**
+ * @return Returns the handler.
+ */
+ public Object getHandler() {
+ return handler;
+ }
+ /**
+ * @param handler The handler to set.
+ */
+ public void setHandler(Object handler) {
+ this.handler = handler;
+ }
+ /**
+ * @return Returns the portName.
+ */
+ public String getPortName() {
+ return portName;
+ }
+ /**
+ * @param portName The portName to set.
+ */
+ public void setPortName(String portName) {
+ this.portName = portName;
+ }
+
+ /**
+ * @return Returns the index.
+ */
+ public int getIndex() {
+ return index;
+ }
+ /**
+ * @param index The index to set.
+ */
+ public void setIndex(int index) {
+ this.index = index;
+ }
+ /**
+ * @return Returns the wsDescRef.
+ */
+ public Object getWsDescRef() {
+ return wsDescRef;
+ }
+ /**
+ * @param wsDescRef The wsDescRef to set.
+ */
+ public void setWsDescRef(Object wsDescRef) {
+ this.wsDescRef = wsDescRef;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/IObjectSelectionWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/IObjectSelectionWidget.java
new file mode 100644
index 000000000..ab80c3818
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/IObjectSelectionWidget.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060410 135441 joan@ca.ibm.com - Joan Haggarty
+ * 20060420 135912 joan@ca.ibm.com - Joan Haggarty
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataContributor;
+
+/**
+ * This interface defines extra methods that Object Selection Widgets
+ * need to implement. Object Selection Widgets are displayed on page 2
+ * of the Web services wizard.
+ */
+public interface IObjectSelectionWidget extends WidgetDataContributor
+{
+ /**
+ * The framework will call this method to set the initial selection
+ * value that the user has specified.
+ *
+ * @param initialSelection the initial selection the user specified.
+ */
+ public void setInitialSelection(IStructuredSelection initialSelection);
+
+ /**
+ * The intent of the Object Selection Widget is that the user has
+ * the opportunity change/find the object that they want to turn into
+ * a Web service.
+ *
+ * @return returns the an IStructuredSelection object that the user
+ * want to turn into a Web service. This object may be different than
+ * the initialSelection passed in by the setInitialSelection method.
+ */
+ public IStructuredSelection getObjectSelection();
+
+ /**
+ * Validates whether the objectSelection parameter is valid for
+ * this Object selection widget. An error status should be returned
+ * if this object is not value. Otherwise, and ok status should be
+ * returned
+ *
+ * @param objectSelection the object to be validated.
+ * @return the status of the validation.
+ */
+ public IStatus validateSelection(IStructuredSelection objectSelection);
+
+ /**
+ *
+ * @return returns the IProject that contains the selection
+ * object that the user has chosen with this widget. The value can be
+ * null if there is no IProject for this object.
+ */
+ public IProject getProject();
+
+ /**
+ *
+ * @return returns the name of the IVirtualComponent that contains the selection
+ * object that the user has chosen with this widget. The value can be
+ * null if there is no IVirtualComponent for this object
+ */
+ public String getComponentName();
+
+ /**
+ *
+ * @return returns the string to displayed in the UI for the selected object
+ */
+ public String getObjectSelectionDisplayableString();
+
+ /**
+ *
+ * @return returns the default initial size for the widget to be called from getInitialSize from any parent dialog
+ */
+ public Point getWidgetSize();
+
+ /**
+ *
+ * @param s A string representation of the object selection
+ * @return true if the string represents a valid object selection
+ */
+ public boolean validate(String s);
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/JavaBeanSelectionTransformer.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/JavaBeanSelectionTransformer.java
new file mode 100644
index 000000000..8e76b8884
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/JavaBeanSelectionTransformer.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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
+ * -------- -------- -----------------------------------------------------------
+ * 20070116 159618 makandre@ca.ibm.com - Andrew Mak, Project and EAR not defaulted properly when wizard launched from JSR-109 Web services branch in J2EE Project Explorer
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jst.j2ee.webservice.wsdd.ServiceImplBean;
+import org.eclipse.jst.j2ee.webservice.wsdd.ServletLink;
+import org.eclipse.jst.j2ee.webservice.wsdd.internal.impl.PortComponentImpl;
+import org.eclipse.wst.command.internal.env.core.data.Transformer;
+
+public class JavaBeanSelectionTransformer implements Transformer
+{
+ public Object transform(Object value)
+ {
+ if (value instanceof IStructuredSelection)
+ {
+ Object sel = ((IStructuredSelection)value).getFirstElement();
+ if (sel instanceof IFile)
+ {
+ return new StructuredSelection(computeFullyQualifiedJavaName((IFile)sel));
+ }
+ else if (sel instanceof ICompilationUnit)
+ {
+ IResource res = ((ICompilationUnit)sel).getResource();
+ if (res instanceof IFile)
+ return new StructuredSelection(computeFullyQualifiedJavaName((IFile)res));
+ }
+ else if (sel instanceof ServiceImplBean)
+ {
+ return new StructuredSelection(getBeanName((ServiceImplBean) sel));
+ }
+ else if(sel instanceof ServletLink)
+ {
+ return new StructuredSelection(getBeanName((ServletLink) sel));
+ }
+ }
+ return value;
+ }
+
+ private String computeFullyQualifiedJavaName(IFile resource)
+ {
+ IPath path = resource.getFullPath();
+ String basename = path.lastSegment();
+ String beanClass = "";
+ if (basename != null && basename.length() > 0)
+ {
+ String beanPackage = org.eclipse.jst.ws.internal.common.ResourceUtils.getJavaResourcePackageName(path);
+ beanClass = (beanPackage == null || beanPackage.length() == 0 ? basename : (beanPackage + "." + basename));
+ if (beanClass.toLowerCase().endsWith(".java") || beanClass.toLowerCase().endsWith(".class"))
+ beanClass = beanClass.substring(0, beanClass.lastIndexOf('.'));
+ }
+ return beanClass;
+ }
+
+ private String getBeanName(ServiceImplBean bean) {
+ EObject eObject = bean.eContainer();
+ if (eObject instanceof PortComponentImpl) {
+ PortComponentImpl pci = (PortComponentImpl) eObject;
+ return pci.getServiceEndpointInterface();
+ }
+ return "";
+ }
+
+ private String getBeanName(ServletLink link) {
+ EObject eObject = link.eContainer();
+ if (eObject instanceof ServiceImplBean)
+ return getBeanName((ServiceImplBean) eObject);
+ return "";
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/JavaBeanSelectionWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/JavaBeanSelectionWidget.java
new file mode 100644
index 000000000..b8d401a4d
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/JavaBeanSelectionWidget.java
@@ -0,0 +1,281 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jst.j2ee.webservice.wsdd.BeanLink;
+import org.eclipse.jst.j2ee.webservice.wsdd.internal.impl.PortComponentImpl;
+import org.eclipse.jst.j2ee.webservice.wsdd.internal.impl.ServiceImplBeanImpl;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.consumption.common.JavaResourceFilter;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.ui.common.UIUtils;
+import org.eclipse.jst.ws.internal.ui.dialog.DialogUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+
+public class JavaBeanSelectionWidget extends AbstractObjectSelectionWidget implements IObjectSelectionWidget
+{
+ private IProject serverProject_ = null;
+ private String serverComponentName_ = null;
+ private Composite parent_ = null;
+ private JavaResourceFilter filter_ = new JavaResourceFilter();
+ private IResource initialResource_ = null;
+ private Listener statusListener;
+
+ /*CONTEXT_ID PBCL0001 for the Bean Selection Page*/
+ private String INFOPOP_PBCL_PAGE = "PBCL0001";
+
+ private Text beanClassText_;
+ /*CONTEXT_ID PBCL0002 for the Bean Selection field of the Bean Selection Page*/
+ private String INFOPOP_PBCL_TEXT_BEAN_CLASS = "PBCL0002";
+
+ private Button beanClassBrowseButton_;
+ /*CONTEXT_ID PBCL0003 for the Bean Class Browse button of the Bean Selection Page*/
+ private String INFOPOP_PBCL_BUTTON_BEAN_CLASS_BROWSE = "PBCL0003";
+
+ private Button beanResourceBrowseButton_;
+ /*CONTEXT_ID PBCL0004 for the Bean Resource Browse button of the Bean Selection Page*/
+ private String INFOPOP_PBCL_BUTTON_BEAN_RESOURCE_BROWSE = "PBCL0004";
+
+ public WidgetDataEvents addControls( Composite parent, Listener statusListener )
+ {
+ String pluginId_ = "org.eclipse.jst.ws.consumption.ui";
+ this.statusListener = statusListener;
+ UIUtils uiUtils = new UIUtils( pluginId_ );
+
+ parent_ = parent;
+
+ Composite group = uiUtils.createComposite( parent, 4 );
+
+ group.setToolTipText( ConsumptionUIMessages.TOOLTIP_PBCL_PAGE );
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( group, pluginId_ + "." + INFOPOP_PBCL_PAGE );
+
+ beanClassText_ = uiUtils.createText( group, ConsumptionUIMessages.LABEL_BEAN_CLASS_NAME,
+ ConsumptionUIMessages.TOOLTIP_PBCL_TEXT_BEAN_CLASS,
+ INFOPOP_PBCL_TEXT_BEAN_CLASS,
+ SWT.SINGLE | SWT.BORDER);
+ beanClassText_.addModifyListener(
+ new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ handleModifyBeanClassText();
+ }
+ }
+ );
+
+ beanClassBrowseButton_ = uiUtils.createPushButton( group, ConsumptionUIMessages.BUTTON_BROWSE_CLASSES,
+ ConsumptionUIMessages.TOOLTIP_PBCL_BUTTON_BEAN_CLASS_BROWSE,
+ INFOPOP_PBCL_BUTTON_BEAN_CLASS_BROWSE );
+ beanClassBrowseButton_.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent evt )
+ {
+ handleBrowseClasses();
+ }
+ } );
+
+ beanResourceBrowseButton_ = uiUtils.createPushButton( group, ConsumptionUIMessages.BUTTON_BROWSE_FILES,
+ ConsumptionUIMessages.TOOLTIP_PBCL_BUTTON_BEAN_RESOURCE_BROWSE,
+ INFOPOP_PBCL_BUTTON_BEAN_RESOURCE_BROWSE );
+ beanResourceBrowseButton_.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent evt )
+ {
+ handleBrowseFiles();
+ }
+ } );
+ return this;
+ }
+
+ private void handleModifyBeanClassText()
+ {
+ statusListener.handleEvent(null);
+ serverProject_ = null;
+ serverComponentName_ = null;
+ }
+
+ private void handleBrowseClasses()
+ {
+ Shell shell = parent_.getShell();
+ IType itype = DialogUtils.browseClassesAsIType(shell, ResourcesPlugin.getWorkspace().getRoot().getProjects(), new ProgressMonitorDialog(shell));
+ if (itype != null)
+ {
+ beanClassText_.setText(itype.getFullyQualifiedName());
+ try
+ {
+ IResource res = itype.getCorrespondingResource();
+ if (res != null)
+ {
+ serverProject_ = res.getProject();
+ IVirtualComponent comp = ResourceUtils.getComponentOf(res);
+ if (comp!=null)
+ {
+ serverComponentName_ = comp.getName();
+ }
+ }
+ else
+ {
+ serverProject_ = null;
+ serverComponentName_ = null;
+ }
+ }
+ catch (JavaModelException jme)
+ {
+ serverProject_ = null;
+ serverComponentName_ = null;
+ }
+ }
+ }
+
+ private void handleBrowseFiles()
+ {
+ IResource topResource = ResourceUtils.getWorkspaceRoot();
+ IResource resource = DialogUtils.browseResources( parent_.getShell(), topResource, initialResource_, filter_ );
+ setBeanClass(resource);
+ }
+
+ private void setBeanClass(IResource resource)
+ {
+ if( resource != null && resource instanceof IFile )
+ {
+ IPath path = resource.getFullPath();
+ String basename = path.lastSegment();
+
+ if( basename != null && basename.length() > 0 )
+ {
+ String beanPackage = org.eclipse.jst.ws.internal.common.ResourceUtils.getJavaResourcePackageName(path);
+ String beanClass = (beanPackage == null || beanPackage.length() == 0 ? basename : (beanPackage + "." + basename));
+
+ if( beanClass.toLowerCase().endsWith(".java") || beanClass.toLowerCase().endsWith(".class" ) )
+ {
+ beanClass = beanClass.substring( 0, beanClass.lastIndexOf('.') );
+ }
+
+ beanClassText_.setText(beanClass);
+ serverProject_ = ResourceUtils.getProjectOf(path);
+ IVirtualComponent comp = ResourceUtils.getComponentOf(resource);
+
+ if (comp!=null)
+ {
+ serverComponentName_ = comp.getName();
+ }
+
+ }
+ }
+ }
+
+ private void setBeanClass(ServiceImplBeanImpl serviceImpl)
+ {
+ if( serviceImpl != null )
+ {
+ EObject eObject = serviceImpl.eContainer();
+ if(eObject instanceof PortComponentImpl){
+ PortComponentImpl pci = (PortComponentImpl)eObject;
+ String beanClass = pci.getServiceEndpointInterface();
+ beanClassText_.setText(beanClass);
+ }
+ }
+ }
+
+ private void setBeanClass(BeanLink serviceImpl)
+ {
+ if( serviceImpl != null )
+ {
+ EObject eObject = serviceImpl.eContainer();
+ if(eObject instanceof ServiceImplBeanImpl){
+ setBeanClass((ServiceImplBeanImpl)eObject);
+ }
+ }
+ }
+
+ public void setInitialSelection(IStructuredSelection initialSelection)
+ {
+ if (initialSelection != null && !initialSelection.isEmpty())
+ {
+ Object object = initialSelection.getFirstElement();
+ if (object instanceof IFile)
+ {
+ IFile iFile = (IFile)object;
+ String fileExt = iFile.getFileExtension().toLowerCase();
+ if (fileExt.equals("java") || fileExt.equals("class"))
+ setBeanClass(iFile);
+ }
+ else if (object instanceof ICompilationUnit)
+ setBeanClass(((ICompilationUnit)object).getResource());
+ else if (object instanceof ServiceImplBeanImpl)
+ setBeanClass((ServiceImplBeanImpl)object);
+ else if(object instanceof BeanLink)
+ setBeanClass((BeanLink)object);
+ }
+ }
+
+ public IStructuredSelection getObjectSelection()
+ {
+ return new StructuredSelection(beanClassText_.getText());
+ }
+
+ public IProject getProject()
+ {
+ return serverProject_;
+ }
+
+ public String getComponentName()
+ {
+ return serverComponentName_;
+ }
+
+ public IStatus getStatus()
+ {
+ String beanClassName = beanClassText_.getText().trim();
+ if (beanClassName == null || beanClassName.length() <= 0)
+ {
+ return StatusUtils.errorStatus(ConsumptionUIMessages.PAGE_MSG_BEAN_CANNOT_BE_EMPTY);
+ }
+ return Status.OK_STATUS;
+ }
+
+ public IStatus validateSelection(IStructuredSelection objectSelection)
+ {
+ return Status.OK_STATUS;
+ }
+
+ public String getObjectSelectionDisplayableString() {
+ // TODO Auto-generated method stub
+ return "Java bean string ";
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionFragment.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionFragment.java
new file mode 100644
index 000000000..ec77dc79b
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionFragment.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceImpl;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils2;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.wst.command.internal.env.core.common.Condition;
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+import org.eclipse.wst.command.internal.env.core.fragment.BooleanFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
+import org.eclipse.wst.command.internal.env.ui.widgets.SelectionCommand;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
+
+
+public class ObjectSelectionFragment extends SequenceFragment implements Condition
+{
+ private TypeRuntimeServer typeRuntimeServer;
+ private boolean hasObjectSelectionWidget;
+
+ public ObjectSelectionFragment()
+ {
+ super();
+ BooleanFragment boolFragment = new BooleanFragment(new SimpleFragment("ObjectSelectionWidget"), new SimpleFragment(""), this);
+ add(boolFragment);
+ add(new SimpleFragment(new ObjectSelectionOutputCommand(), ""));
+ hasObjectSelectionWidget = false;
+ }
+
+ /**
+ * This method is called retrieve the data mappings for this command fragment.
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry)
+ {
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ObjectSelectionWidget.class );
+ dataRegistry.addMapping(SelectionCommand.class, "InitialSelection", ObjectSelectionOutputCommand.class, "ObjectSelection", null);
+ dataRegistry.addMapping(ObjectSelectionFragment.class, "TypeRuntimeServer", ObjectSelectionWidget.class);
+ dataRegistry.addMapping(ObjectSelectionFragment.class, "TypeRuntimeServer", ObjectSelectionOutputCommand.class);
+
+ dataRegistry.addMapping(ObjectSelectionWidget.class, "ObjectSelection", ObjectSelectionOutputCommand.class);
+ dataRegistry.addMapping(ObjectSelectionWidget.class, "Project", ObjectSelectionOutputCommand.class);
+ dataRegistry.addMapping(ObjectSelectionWidget.class, "ComponentName", ObjectSelectionOutputCommand.class);
+ }
+
+ public boolean evaluate()
+ {
+ return hasObjectSelectionWidget;
+ }
+
+ public TypeRuntimeServer getTypeRuntimeServer()
+ {
+ return typeRuntimeServer;
+ }
+
+ /**
+ * @param typeRuntimeServer The typeRuntimeServer to set.
+ */
+ public void setTypeRuntimeServer(TypeRuntimeServer typeRuntimeServer)
+ {
+ this.typeRuntimeServer = typeRuntimeServer;
+ if (typeRuntimeServer != null)
+ {
+ String wst = typeRuntimeServer.getTypeId();
+
+ int scenario = WebServiceRuntimeExtensionUtils2.getScenarioFromTypeId(wst);
+ String implId = WebServiceRuntimeExtensionUtils2.getWebServiceImplIdFromTypeId(wst);
+ if (scenario == WebServiceScenario.TOPDOWN)
+ {
+ //Must have WSDL object selection. No choice.
+ hasObjectSelectionWidget=true;
+ }
+ else
+ {
+ WebServiceImpl wsimpl = WebServiceRuntimeExtensionUtils2.getWebServiceImplById(implId);
+ if (wsimpl!=null)
+ {
+ String objectSelectionWidgetId = wsimpl.getObjectSelectionWidget();
+ hasObjectSelectionWidget = objectSelectionWidgetId != null && objectSelectionWidgetId.length() > 0;
+ }
+ }
+ }
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionOutputCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionOutputCommand.java
new file mode 100644
index 000000000..5378e11d5
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionOutputCommand.java
@@ -0,0 +1,296 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060830 155114 pmoogk@ca.ibm.com - Peter Moogk, Updated patch for this defect.
+ * 20070116 159618 makandre@ca.ibm.com - Andrew Mak, Project and EAR not defaulted properly when wizard launched from JSR-109 Web services branch in J2EE Project Explorer
+ * 20070326 171071 makandre@ca.ibm.com - Andrew Mak, Create public utility method for copying WSDL files
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+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.emf.ecore.EObject;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceImpl;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils2;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.wst.command.internal.env.core.data.Transformer;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.environment.StatusException;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+import org.eclipse.wst.ws.internal.util.UniversalPathTransformer;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
+
+
+public class ObjectSelectionOutputCommand extends AbstractDataModelOperation
+{
+ private String objectSelectionWidgetId_;
+ private IStructuredSelection objectSelection_;
+ private IObjectSelectionWidget objectSelectionWidget_;
+ private IProject project_;
+ private String componentName_;
+ private WebServicesParser parser_;
+
+ private boolean topDown_ = false;
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+
+ // Transformation
+ if (objectSelectionWidgetId_ != null && objectSelectionWidgetId_.length() > 0)
+ {
+ Transformer transformer = ObjectSelectionRegistry.getInstance().getTransformer(objectSelectionWidgetId_);
+ Object transformedSelection = transformer == null ? null : transformer.transform(objectSelection_);
+
+ if (transformedSelection instanceof IStructuredSelection)
+ {
+ objectSelection_ = (IStructuredSelection)transformedSelection;
+ }
+ }
+
+ // Validation
+ IStatus status = (objectSelectionWidget_ != null) ? objectSelectionWidget_.validateSelection(getObjectSelection()) : Status.OK_STATUS;
+ if (status.getSeverity() != Status.OK && env != null)
+ {
+ try
+ {
+ env.getStatusHandler().report(status);
+ }
+ catch (StatusException se)
+ {
+ }
+ }
+
+ return status;
+ }
+
+ /**
+ * @param typeRuntimeServer The typeRuntimeServer to set.
+ */
+ public void setTypeRuntimeServer(TypeRuntimeServer typeRuntimeServer)
+ {
+ if (typeRuntimeServer != null)
+ {
+ String wst = typeRuntimeServer.getTypeId();
+
+ int scenario = WebServiceRuntimeExtensionUtils2.getScenarioFromTypeId(wst);
+ String implId = WebServiceRuntimeExtensionUtils2.getWebServiceImplIdFromTypeId(wst);
+
+ WebServiceImpl wsimpl = WebServiceRuntimeExtensionUtils2.getWebServiceImplById(implId);
+ //IWebServiceType wst = WebServiceRuntimeExtensionUtils2.getWebServiceTypeById(typeRuntimeServer.getTypeId());
+
+ if (wsimpl != null)
+ {
+ String objectSelectionWidgetId = null;
+ if (scenario == WebServiceScenario.TOPDOWN)
+ {
+ objectSelectionWidgetId = "org.eclipse.jst.ws.internal.consumption.ui.widgets.object.WSDLSelectionWidget";
+ topDown_ = true;
+ }
+ else
+ {
+ objectSelectionWidgetId = wsimpl.getObjectSelectionWidget();
+ }
+
+ objectSelectionWidgetId_ = objectSelectionWidgetId;
+
+ Object object = ObjectSelectionRegistry.getInstance().getSelectionWidget(objectSelectionWidgetId_);
+
+ if( object instanceof IObjectSelectionWidget )
+ {
+ objectSelectionWidget_ = (IObjectSelectionWidget)object;
+ }
+ }
+ }
+ }
+
+ /**
+ * @return Returns the selection.
+ */
+ public IStructuredSelection getObjectSelection()
+ {
+ return objectSelection_;
+ }
+ /**
+ * @param selection The selection to set.
+ */
+ public void setObjectSelection(IStructuredSelection objectSelection)
+ {
+ objectSelection_ = objectSelection;
+
+ //Set the project if you can
+ if (project_==null)
+ {
+ project_ = getProjectFromObjectSelection(objectSelection);
+ }
+
+ //Set the componentName if you can
+ if (componentName_ == null)
+ {
+ componentName_ = getComponentNameFromObjectSelection(objectSelection);
+ }
+
+ // Check if this is a WSDL selection object. If it is we need
+ // to unwrap it.
+ if( objectSelection != null && !objectSelection.isEmpty() )
+ {
+ Object object = objectSelection.getFirstElement();
+
+ if( object instanceof WSDLSelectionWrapper )
+ {
+ WSDLSelectionWrapper wsdlWrapper = (WSDLSelectionWrapper)object;
+
+ objectSelection_ = wsdlWrapper.wsdlSelection;
+ parser_ = wsdlWrapper.parser;
+ }
+ }
+ }
+
+ public IProject getProject()
+ {
+ if (project_ == null && topDown_)
+ project_ = getProjectFromTransformedSelection();
+ return project_;
+ }
+
+ public void setProject(IProject project)
+ {
+ this.project_ = project;
+ }
+
+ public String getComponentName()
+ {
+ if (componentName_ == null && topDown_)
+ componentName_ = getComponentNameFromTransformedSelection();
+ return componentName_;
+ }
+
+ public void setComponentName(String componentName)
+ {
+ this.componentName_ = componentName;
+ }
+
+ /**
+ * @return Returns the parser_.
+ */
+ public WebServicesParser getWebServicesParser()
+ {
+ return parser_;
+ }
+
+ private boolean hasProtocol(String url) {
+ return url.indexOf(":") != -1;
+ }
+
+ private IResource findResourceFromSelection(Object selection) throws CoreException {
+
+ IResource resource = ResourceUtils.getResourceFromSelection(selection);
+
+ // try finding at least the project using the EMF way
+ if (resource == null && selection instanceof EObject)
+ resource = ProjectUtilities.getProject(selection);
+
+ return resource;
+ }
+
+ private IProject getProjectFromTransformedSelection() {
+ if (objectSelection_ != null && objectSelection_.size() == 1)
+ {
+ Object obj = objectSelection_.getFirstElement();
+ if (obj instanceof String) {
+ String str = UniversalPathTransformer.toPath((String) obj);
+ if (hasProtocol(str)) return null;
+ return ResourceUtils.getProjectOf(new Path(str));
+ }
+ }
+ return null;
+ }
+
+ private IProject getProjectFromObjectSelection(IStructuredSelection selection)
+ {
+ if (selection != null && selection.size() == 1)
+ {
+ Object obj = selection.getFirstElement();
+ if (obj != null)
+ {
+ try
+ {
+ IResource resource = findResourceFromSelection(obj);
+ if (resource==null)
+ return null;
+ if (resource instanceof IProject)
+ return (IProject) resource;
+ IProject p = ResourceUtils.getProjectOf(resource.getFullPath());
+ return p;
+ } catch(CoreException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getComponentNameFromTransformedSelection() {
+ if (objectSelection_ != null && objectSelection_.size() == 1)
+ {
+ Object obj = objectSelection_.getFirstElement();
+ if (obj instanceof String) {
+ String str = UniversalPathTransformer.toPath((String) obj);
+ if (hasProtocol(str)) return null;
+ IVirtualComponent comp = ResourceUtils.getComponentOf(new Path(str));
+ return comp == null ? null : comp.getName();
+ }
+ }
+ return null;
+ }
+
+ private String getComponentNameFromObjectSelection(IStructuredSelection selection)
+ {
+ if (selection != null && selection.size() == 1)
+ {
+ Object obj = selection.getFirstElement();
+ if (obj != null)
+ {
+ try
+ {
+ IResource resource = findResourceFromSelection(obj);
+ if (resource==null)
+ return null;
+
+ IVirtualComponent comp = ResourceUtils.getComponentOf(resource);
+
+ if (comp!=null)
+ {
+ return comp.getName();
+ }
+ } catch(CoreException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionRegistry.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionRegistry.java
new file mode 100644
index 000000000..e6b29184e
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionRegistry.java
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060825 155114 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060830 155114 pmoogk@ca.ibm.com - Peter Moogk, Updated patch for this defect.
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import java.util.Hashtable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.IObjectSelectionLaunchable;
+import org.eclipse.wst.command.internal.env.core.data.Transformer;
+
+public class ObjectSelectionRegistry
+{
+ private static ObjectSelectionRegistry instance;
+ private IConfigurationElement[] elements;
+ private Hashtable cachedSelectionWidgets;
+
+ private ObjectSelectionRegistry()
+ {
+ elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.jst.ws.consumption.ui", "objectSelectionWidget");
+ cachedSelectionWidgets = new Hashtable();
+ }
+
+ public static ObjectSelectionRegistry getInstance()
+ {
+ if (instance == null)
+ {
+ instance = new ObjectSelectionRegistry();
+ }
+
+ return instance;
+ }
+
+ /**
+ *
+ * @param id if the selection widget object.
+ * @return returns the transformer class if has been specified. Otherwise
+ * null is returned.
+ */
+ public Transformer getTransformer( String id )
+ {
+ TableEntry entry = getTableEntry( id );
+ Transformer result = null;
+
+ if( entry != null )
+ {
+ try
+ {
+ Object object = entry.element.createExecutableExtension("transformer");
+
+ if( object instanceof Transformer )
+ {
+ result = (Transformer)object;
+ }
+ }
+ catch( CoreException exc ){}
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @param id if the selection widget object.
+ * @return returns the value of the external modify attribute if
+ * it has been specified. Otherwise false is returned.
+ */
+ public boolean getExternalModify( String id )
+ {
+ TableEntry entry = getTableEntry( id );
+ boolean result = false;
+
+ if( entry != null )
+ {
+ String modifyString = entry.element.getAttribute("external_modify");
+
+ result = new Boolean( modifyString ).booleanValue();
+ }
+
+ return result;
+ }
+
+ /**
+ * Gets the IObjectSelectionWidget based on the selectionId. If one is
+ * not found null is returned.
+ *
+ * @param selectionId the ID of the selection widget.
+ * @return returns the registered IObjectSelectionWidget object.
+ */
+ public Object getSelectionWidget( String selectionId )
+ {
+ TableEntry entry = getTableEntry( selectionId );
+
+ return entry == null ? null : entry.objectSelection;
+ }
+
+ public void cleanup()
+ {
+ instance = null;
+ elements = null;
+ cachedSelectionWidgets = null;
+ }
+
+ private TableEntry getTableEntry( String id )
+ {
+ if( id == null ) return null;
+
+ TableEntry entry = (TableEntry)cachedSelectionWidgets.get( id );
+
+ if( entry == null )
+ {
+ for( int index = 0; index < elements.length; index++ )
+ {
+ IConfigurationElement element = elements[index];
+ String elemId = element.getAttribute( "id" );
+
+ if( id.equals( elemId ) )
+ {
+ try
+ {
+ Object object = element.createExecutableExtension("class");
+
+ if( object instanceof IObjectSelectionWidget || object instanceof IObjectSelectionLaunchable )
+ {
+ entry = new TableEntry();
+ entry.element = element;
+ entry.objectSelection = object;
+ cachedSelectionWidgets.put( id, entry );
+ break;
+ }
+ }
+ catch( CoreException exc ){}
+ }
+ }
+ }
+
+ return entry;
+ }
+
+ private class TableEntry
+ {
+ public IConfigurationElement element;
+ public Object objectSelection;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionWidget.java
new file mode 100644
index 000000000..1a1a59700
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ObjectSelectionWidget.java
@@ -0,0 +1,258 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060224 129387 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060410 135441 joan@ca.ibm.com - Joan Haggarty
+ * 20060825 155114 pmoogk@ca.ibm.com - Peter Moogk
+ * 20061220 161232 makandre@ca.ibm.com - Andrew Mak, AbstractObjectSelectionWidget.setInitialSelection(IStructuredSelection initialSelection) called twice each time Browse pressed
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceImpl;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils2;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
+
+
+public class ObjectSelectionWidget extends AbstractObjectSelectionWidget implements IObjectSelectionWidget
+{
+ private Composite parent;
+ private Listener statusListener;
+ private Composite composite;
+ private IProject project;
+ private String componentName;
+ private IObjectSelectionWidget child;
+ private Point widgetSize_;
+
+ public WidgetDataEvents addControls(Composite parentComposite, Listener statListener)
+ {
+ this.parent = parentComposite;
+ this.statusListener = statListener;
+ composite = null;
+ return this;
+ }
+
+ public Control getControl(){
+ return composite;
+ }
+
+ /**
+ * @param typeRuntimeServer The typeRuntimeServer to set.
+ */
+ public void setTypeRuntimeServer(TypeRuntimeServer typeRuntimeServer)
+ {
+ if (composite != null)
+ {
+ composite.dispose();
+ child = null;
+ }
+ if (typeRuntimeServer != null)
+ {
+ String wst = typeRuntimeServer.getTypeId();
+ int scenario = WebServiceRuntimeExtensionUtils2.getScenarioFromTypeId(wst);
+ String implId = WebServiceRuntimeExtensionUtils2.getWebServiceImplIdFromTypeId(wst);
+ WebServiceImpl wsimpl = WebServiceRuntimeExtensionUtils2.getWebServiceImplById(implId);
+
+ //IWebServiceType wst = WebServiceRuntimeExtensionUtils.getWebServiceTypeById(typeRuntimeServer.getTypeId());
+ if (wsimpl != null)
+ {
+ String objectSelectionWidgetId = null;
+ if (scenario == WebServiceScenario.TOPDOWN)
+ {
+ objectSelectionWidgetId = "org.eclipse.jst.ws.internal.consumption.ui.widgets.object.WSDLSelectionWidget";
+ }
+ else
+ {
+ objectSelectionWidgetId = wsimpl.getObjectSelectionWidget();
+ }
+
+ Object object = ObjectSelectionRegistry.getInstance().getSelectionWidget( objectSelectionWidgetId );
+
+ if( object instanceof IObjectSelectionWidget )
+ {
+ child = (IObjectSelectionWidget)object;
+ }
+
+ if( child != null )
+ {
+ Control shell = parent.getShell();
+ composite = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout();
+ gl.marginHeight = 0;
+ gl.marginWidth = 0;
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ composite.setLayout(gl);
+ composite.setLayoutData(gd);
+ child.addControls(composite, statusListener);
+
+ Point origSize = shell.getSize();
+ Point compSize = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ int newX = origSize.x;
+ int newY = origSize.y;
+
+ // Note: we are trying to determine here if the wizard page should
+ // be resized based on the size of the control that is
+ // given to us by the extension. The hard coded constants
+ // below represent the vertical and horizontal pixels that need
+ // to go around object selection control. Hopefully, a more
+ // programatic method of doing this can be found in the future.
+ if( compSize.x + 20 > origSize.x )
+ {
+ newX = compSize.x + 20;
+ }
+
+ if( compSize.y + 205 > origSize.y )
+ {
+ newY = compSize.y + 205;
+ }
+
+ widgetSize_ = new Point(newX, newY);
+
+ return;
+ }
+ }
+ }
+ }
+
+ public IStatus getStatus()
+ {
+ return (child != null) ? child.getStatus() : Status.OK_STATUS;
+ }
+
+ public void setInitialSelection(IStructuredSelection initialSelection)
+ {
+ project = getProjectFromInitialSelection(initialSelection);
+ componentName = getComponentNameFromInitialSelection(initialSelection);
+ if (child != null)
+ child.setInitialSelection(initialSelection);
+ }
+
+ public IStructuredSelection getObjectSelection()
+ {
+ return (child != null) ? child.getObjectSelection() : null;
+ }
+
+ public IStatus validateSelection(IStructuredSelection objectSelection)
+ {
+ return (child != null) ? child.validateSelection(objectSelection) : Status.OK_STATUS;
+ }
+
+ public IProject getProject()
+ {
+ if (child != null)
+ {
+ IProject p = child.getProject();
+ if (p != null)
+ return p;
+ else
+ return project;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public String getComponentName()
+ {
+ if (child != null)
+ {
+ String cname = child.getComponentName();
+ if (cname != null && cname.length()>0)
+ return cname;
+ else
+ return componentName;
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+
+ private IProject getProjectFromInitialSelection(IStructuredSelection selection)
+ {
+ if (selection != null && selection.size() == 1)
+ {
+ Object obj = selection.getFirstElement();
+ if (obj != null)
+ {
+ try
+ {
+ IResource resource = ResourceUtils.getResourceFromSelection(obj);
+ if (resource==null)
+ return null;
+ IProject p = ResourceUtils.getProjectOf(resource.getFullPath());
+ return p;
+ } catch(CoreException e)
+ {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getComponentNameFromInitialSelection(IStructuredSelection selection)
+ {
+ if (selection != null && selection.size() == 1)
+ {
+ Object obj = selection.getFirstElement();
+ if (obj != null)
+ {
+ try
+ {
+ IResource resource = ResourceUtils.getResourceFromSelection(obj);
+ if (resource==null)
+ return null;
+
+ IVirtualComponent comp = ResourceUtils.getComponentOf(resource);
+ if (comp != null)
+ {
+ return comp.getName();
+ }
+ } catch(CoreException e)
+ {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getObjectSelectionDisplayableString() {
+ return child.getObjectSelectionDisplayableString();
+ }
+
+ public Point getWidgetSize()
+ {
+ Point childWidgetSize = child.getWidgetSize();
+ if (childWidgetSize == null)
+ return widgetSize_;
+ return childWidgetSize;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/Timer.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/Timer.java
new file mode 100644
index 000000000..165067d5e
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/Timer.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060803 152486 makandre@ca.ibm.com - Andrew Mak, Typing WSDL in Service definition field is very slow
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import java.util.Calendar;
+import org.eclipse.swt.widgets.Display;
+
+public class Timer extends Thread
+{
+ private final long ONE_SECOND = 1000;
+ private long refreshTime;
+ private boolean isRunning = true;
+ private Display display;
+ private Runnable runnable;
+
+ private Timer(Display display, Runnable runnable)
+ {
+ this.display = display;
+ this.runnable = runnable;
+ }
+
+ public synchronized static Timer newInstance(Timer timer, Display display, Runnable runnable)
+ {
+ if (!Timer.isRunning(timer))
+ return new Timer(display, runnable);
+
+ return timer;
+ }
+
+ public synchronized static boolean isRunning(Timer timer)
+ {
+ return timer != null && timer.isRunning;
+ }
+
+ public synchronized void startTimer()
+ {
+ refreshTime = getCurrentTime() + ONE_SECOND;
+ if (!isAlive())
+ this.start();
+ }
+
+ private long getCurrentTime()
+ {
+ return Calendar.getInstance().getTime().getTime();
+ }
+
+ public void run()
+ {
+ long currTime = getCurrentTime();
+ while (currTime < refreshTime)
+ {
+ try
+ {
+ sleep(refreshTime - currTime);
+ }
+ catch (InterruptedException ie)
+ {
+ }
+ currTime = getCurrentTime();
+ }
+ isRunning = false;
+ display.syncExec(runnable);
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ValidateWSDLJob.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ValidateWSDLJob.java
new file mode 100644
index 000000000..e27ee08da
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ValidateWSDLJob.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2005 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
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.wst.wsdl.validation.internal.IValidationMessage;
+import org.eclipse.wst.wsdl.validation.internal.IValidationReport;
+import org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLValidator;
+
+
+
+public class ValidateWSDLJob extends Job {
+
+ final public static String VALIDATE_WSDL_JOB_FAMILY = "ValidateWSDLJobJamily";
+
+ private String wsdlURI_ = null;
+ private IValidationMessage[] validationMessages_ = null;
+ private int validationMessageSeverity_ = -1; // default value
+
+ public ValidateWSDLJob(String wsdlURI) {
+ super("ValidateWSDLJob");
+ wsdlURI_ = wsdlURI;
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ WSDLValidator wsdlValidator = WSDLValidator.getInstance();
+ IValidationReport valReport = wsdlValidator.validate(wsdlURI_);
+ validationMessages_ = valReport.getValidationMessages();
+ reportSummary();
+ return Status.OK_STATUS;
+ }
+
+ // calculate the higher severity for all the validation messages
+ private void reportSummary() {
+ int i;
+ int severity;
+ int errorCount = 0;
+ int warningCount = 0;
+ for (i=0; i<validationMessages_.length && errorCount == 0; i++) {
+ severity = validationMessages_[i].getSeverity();
+ switch (severity) {
+ case IValidationMessage.SEV_ERROR:
+ errorCount++;
+ break;
+ case IValidationMessage.SEV_WARNING:
+ warningCount++;
+ break;
+ default:
+ break;
+ }
+ }
+ if (errorCount > 0) {
+ validationMessageSeverity_ = IValidationMessage.SEV_ERROR;
+ } else if (warningCount > 0) {
+ validationMessageSeverity_ = IValidationMessage.SEV_WARNING;
+ }
+
+ }
+
+ public boolean belongsTo(Object family)
+ {
+ return family == VALIDATE_WSDL_JOB_FAMILY;
+ }
+
+ public IValidationMessage[] getValidationMessages() {
+ return validationMessages_;
+ }
+
+ public int getValidationMessageSeverity() {
+ return validationMessageSeverity_;
+ }
+
+ public String getWsdlURI() {
+ return wsdlURI_;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ValidationMessageViewerWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ValidationMessageViewerWidget.java
new file mode 100644
index 000000000..177f5dcc0
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/ValidationMessageViewerWidget.java
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * 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
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060310 131352 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060411 136134 kathy@ca.ibm.com - Kathy Chan
+ * 20060420 136221 kathy@ca.ibm.com - Kathy Chan
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.wsdl.validation.internal.IValidationMessage;
+
+
+public class ValidationMessageViewerWidget extends SimpleWidgetDataContributor
+{
+ private int DEFAULT_TABLE_HEIGHT_HINT = 100;
+ private TableViewer tableViewer_;
+ private Table table_;
+ private String message = null;
+ static final String columns_[] = {ConsumptionUIMessages.TABLE_COLUMN_VALIDATION_SEVERITY,
+ ConsumptionUIMessages.TABLE_COLUMN_VALIDATION_LINE,
+ ConsumptionUIMessages.TABLE_COLUMN_VALIDATION_COLUMN,
+ ConsumptionUIMessages.TABLE_COLUMN_VALIDATION_MESSAGE};
+ static final int columnsWidth_[] = {12, 10, 10, 60};
+ static final int columnMins_[] = {60, 50, 50, 300};
+
+
+
+ public ValidationMessageViewerWidget()
+ {
+ }
+
+ public WidgetDataEvents addControls( Composite parent, Listener statusListener )
+ {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout();
+
+ gl.marginHeight = 0;
+ gl.marginWidth = 0;
+ composite.setLayout(gl);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Text messageLabel = new Text( composite, SWT.READ_ONLY);
+ messageLabel.setText( ConsumptionUIMessages.LABEL_VALIDATE_MESSAGES);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ messageLabel.setLayoutData(gd);
+ messageLabel.setToolTipText( ConsumptionUIMessages.TOOLTIP_VALIDATE_TEXT_MESSAGE );
+
+ table_ = new Table(composite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = DEFAULT_TABLE_HEIGHT_HINT;
+ table_.setLayoutData(gd);
+ table_.setHeaderVisible(true);
+ table_.setLinesVisible(true);
+ table_.setToolTipText(ConsumptionUIMessages.TOOLTIP_TABLE_VALIDATE_MESSAGE );
+ TableLayout tableLayout = new TableLayout();
+ for (int i = 0; i < columns_.length; i++)
+ {
+ TableColumn tableColumn = new TableColumn(table_, SWT.NONE);
+ tableColumn.setText(columns_[i]);
+ tableColumn.pack();
+ ColumnWeightData columnData = new ColumnWeightData(columnsWidth_[i], columnMins_[i], true);
+ tableLayout.addColumnData(columnData);
+ }
+ table_.setLayout(tableLayout);
+
+ tableViewer_ = new TableViewer(table_);
+
+ tableViewer_.setContentProvider(new ListContentProvider());
+ tableViewer_.setLabelProvider(new ListLabelProvider());
+
+ return this;
+ }
+
+ public void setInput(IValidationMessage[] messages)
+ {
+ tableViewer_.setInput(messages);
+ tableViewer_.refresh();
+ }
+
+ public void clearInput()
+ {
+ IValidationMessage emptyMessages[] = {};
+ this.setInput(emptyMessages);
+ }
+
+ public IContentProvider getContentProvider()
+ {
+ return tableViewer_.getContentProvider();
+ }
+
+ public IStatus getStatus()
+ {
+ return message == null ? Status.OK_STATUS :
+ StatusUtils.errorStatus(message );
+ }
+
+ public void refresh()
+ {
+ tableViewer_.refresh();
+ }
+
+ public TableItem[] getItems()
+ {
+ //internalRefresh();
+ return table_.getItems();
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ }
+
+ public void dispose()
+ {
+ if (table_ != null)
+ table_.dispose();
+ }
+
+ protected class ListContentProvider implements IStructuredContentProvider
+ {
+ public void dispose()
+ {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ tableViewer_.add(getElements(newInput));
+ }
+
+ public Object[] getElements(Object inputElement)
+ {
+ if (inputElement instanceof IValidationMessage[])
+ {
+ IValidationMessage[] valMessages = (IValidationMessage[]) inputElement;
+ return valMessages;
+ }
+ else
+ return new Object[0];
+ }
+ }
+
+ protected class ListLabelProvider implements ITableLabelProvider
+ {
+ public Image getColumnImage(Object element, int columnIndex)
+ {
+ if (element instanceof IValidationMessage)
+ {
+ IValidationMessage msg = (IValidationMessage) element;
+
+ if (columnIndex == 0)
+ {
+ int severity = msg.getSeverity();
+ if (severity == 0) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+ } else if (severity == 1) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+ } else if (severity == 2) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex)
+ {
+ String text = "";
+ if (element instanceof IValidationMessage)
+ {
+ IValidationMessage msg = (IValidationMessage) element;
+
+ switch (columnIndex) {
+ case 0:
+ // no text to display, only display severity as image
+ break;
+ case 1:
+ text = (new Integer(msg.getLine())).toString();
+ break;
+ case 2:
+ text = (new Integer(msg.getColumn())).toString();
+ break;
+ case 3:
+ text = msg.getMessage();
+ break;
+
+ default:
+ break;
+ }
+ }
+ return text;
+ }
+
+ public void addListener(ILabelProviderListener listener)
+ {
+ }
+
+ public void removeListener(ILabelProviderListener listener)
+ {
+ }
+
+ public boolean isLabelProperty(Object element, String property)
+ {
+ return true;
+ }
+
+ public void dispose()
+ {
+ }
+ }
+ }
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/WSDLSelectionTransformer.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/WSDLSelectionTransformer.java
new file mode 100644
index 000000000..d98c208ef
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/WSDLSelectionTransformer.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 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
+ * -------- -------- -----------------------------------------------------------
+ * 20070116 159618 makandre@ca.ibm.com - Andrew Mak, Project and EAR not defaulted properly when wizard launched from JSR-109 Web services branch in J2EE Project Explorer
+ * 20070327 172339 kathy@ca.ibm.com - Kathy Chan
+ * 20070713 191357 kathy@ca.ibm.com - Kathy Chan
+ * 20081208 257618 mahutch@ca.ibm.com - Mark Hutchinson, Add Mechanism for Adopters to map Services to WSDL URLs
+ * 20090310 242440 yenlu@ca.ibm.com - Yen Lu, Pluggable IFile to URI Converter
+ * 20100209 302009 mahutch@ca.ibm.com - Mark Hutchinson, ClassCastException when org.eclipse.wst.ws.ifile2uriconverter plugged in
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import java.net.MalformedURLException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jst.j2ee.webservice.wsclient.internal.impl.ServiceRefImpl;
+import org.eclipse.jst.j2ee.webservice.wsdd.BeanLink;
+import org.eclipse.jst.j2ee.webservice.wsdd.ServiceImplBean;
+import org.eclipse.jst.j2ee.webservice.wsdd.WebServiceDescription;
+import org.eclipse.jst.ws.internal.common.J2EEActionAdapterFactory;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.wst.command.internal.env.core.data.Transformer;
+import org.eclipse.wst.ws.internal.converter.IIFile2UriConverter;
+import org.eclipse.wst.ws.internal.plugin.WSPlugin;
+import org.eclipse.wst.ws.internal.ui.utils.AdapterUtils;
+import org.eclipse.wst.ws.internal.wsfinder.WSDLURLStringWrapper;
+import org.eclipse.wst.wsdl.internal.impl.ServiceImpl;
+import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
+
+public class WSDLSelectionTransformer implements Transformer
+{
+ public Object transform(Object value)
+ {
+ if (value instanceof IStructuredSelection)
+ {
+ IStructuredSelection selection = (IStructuredSelection)value;
+ if (selection != null && !selection.isEmpty()) {
+
+ Object sel = selection.getFirstElement();
+ if (sel instanceof IResource)
+ {
+ try
+ {
+ if (sel instanceof IFile)
+ {
+ IFile file = (IFile)sel;
+ IIFile2UriConverter converter = WSPlugin.getInstance().getIFile2UriConverter();
+ if (converter != null)
+ {
+ String wsdlUrl = converter.convert(file);
+ if (wsdlUrl != null || !converter.allowBaseConversionOnFailure())
+ return new StructuredSelection(wsdlUrl);
+ }
+ }
+ return new StructuredSelection(((IResource)sel).getLocation().toFile().toURL().toString());
+ }
+ catch (MalformedURLException murle)
+ {
+ }
+ }
+ else if (Platform.getAdapterManager().hasAdapter(sel, WSDLURLStringWrapper.class.getName())) {
+ Object adaptedObject = Platform.getAdapterManager().loadAdapter(sel, WSDLURLStringWrapper.class.getName());
+ WSDLURLStringWrapper wrapper = (WSDLURLStringWrapper)adaptedObject;
+ return new StructuredSelection(wrapper.getWSDLURLString());
+ }
+ else if (sel instanceof ServiceImpl)
+ {
+ return new StructuredSelection(J2EEActionAdapterFactory.getWSDLURI((ServiceImpl)sel));
+ }
+ else if (sel instanceof ServiceRefImpl)
+ {
+ return new StructuredSelection(J2EEActionAdapterFactory.getWSDLURI((ServiceRefImpl)sel));
+ }
+ else if (sel instanceof WSDLResourceImpl)
+ {
+ return new StructuredSelection(J2EEActionAdapterFactory.getWSDLURI((WSDLResourceImpl)sel));
+ }
+ /*
+ * TODO - Remove the cases below after bug 170834 is fixed
+ *
+ * WSDLSelectionTransformer should not need to handle ServiceImplBean and BeanLink which
+ * represent service classes. These catches are here for now since we incorrectly allow
+ * the wizard to default to top-down sceanrio when launch from these objects in the JSR-109
+ * branch.
+ */
+ else if (sel instanceof ServiceImplBean)
+ {
+ return new StructuredSelection(getWSDLURI((ServiceImplBean) sel));
+ }
+ else if (sel instanceof BeanLink)
+ {
+ return new StructuredSelection(getWSDLURI((BeanLink) sel));
+ } else {
+ String wsdlURI = AdapterUtils.getAdaptedWSDL(sel);
+ if (wsdlURI != null) {
+ return new StructuredSelection(wsdlURI);
+ }
+ }
+ }
+ }
+ return value;
+ }
+
+ private String getWSDLURI(ServiceImplBean bean) {
+ EObject eObject = bean.eContainer();
+ if (eObject == null)
+ return "";
+
+ eObject = eObject.eContainer();
+
+ if (eObject instanceof WebServiceDescription) {
+ WebServiceDescription wsd = (WebServiceDescription) eObject;
+ IProject project = ProjectUtilities.getProject(wsd);
+
+ // getWebContentPath returns the "WebContent" folder path for Web projects
+ // for EJB projects, it returns the "ebjModule" folder path
+ IPath path = J2EEUtils.getWebContentPath(project);
+ path = path.append(wsd.getWsdlFile());
+
+ return path.toString();
+ }
+ return "";
+ }
+
+ private String getWSDLURI(BeanLink link) {
+ EObject eObject = link.eContainer();
+ if (eObject instanceof ServiceImplBean)
+ return getWSDLURI((ServiceImplBean) eObject);
+ return "";
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/WSDLSelectionWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/WSDLSelectionWidget.java
new file mode 100644
index 000000000..5279a2851
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/WSDLSelectionWidget.java
@@ -0,0 +1,736 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060410 135441 joan@ca.ibm.com - Joan Haggarty
+ * 20060410 136011 kathy@ca.ibm.com - Kathy Chan
+ * 20060420 135912 joan@ca.ibm.com - Joan Haggarty
+ * 20060504 119296 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060525 142281 joan@ca.ibm.com - Joan Haggarty
+ * 20060607 144932 kathy@ca.ibm.com - Kathy Chan
+ * 20060612 145081 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060719 139977 kathy@ca.ibm.com - Kathy Chan
+ * 20060803 152701 cbrealey@ca.ibm.com - Chris Brealey
+ * 20060803 152486 makandre@ca.ibm.com - Andrew Mak, Typing WSDL in Service definition field is very slow
+ * 20060825 135570 makandre@ca.ibm.com - Andrew Mak, Service implementation URL not displayed properly on first page
+ * 20060831 155883 makandre@ca.ibm.com - Andrew Mak, service impl field doesn't work after switching from BU to TD
+ * 20061106 142500 david.schneider@unisys.com - David Schneider, WTP properties pages fonts don't follow Eclipse preferences
+ * 20061211 161589 makandre@ca.ibm.com - Andrew Mak, NPE in service generation after opening and cancelling from browse dialog
+ * 20070131 168786 makandre@ca.ibm.com - Andrew Mak, wsdl url on web service wizard page 1 is not reflected in browse dialog
+ * 20070326 171071 makandre@ca.ibm.com - Andrew Mak, Create public utility method for copying WSDL files
+ * 20090310 242440 yenlu@ca.ibm.com - Yen Lu, Pluggable IFile to URI Converter
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.IJobManager;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jst.j2ee.webservice.wsclient.ServiceRef;
+import org.eclipse.jst.ws.internal.common.J2EEActionAdapterFactory;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.consumption.common.WSDLParserFactory;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.TimedWSDLSelectionConditionCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.WSDLSelectionTreeWidget;
+import org.eclipse.jst.ws.internal.ui.common.DialogResourceBrowser;
+import org.eclipse.jst.ws.internal.ui.common.FileExtensionFilter;
+import org.eclipse.jst.ws.internal.ui.common.UIUtils;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.ws.internal.converter.IIFile2UriConverter;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServiceEntity;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+import org.eclipse.wst.ws.internal.plugin.WSPlugin;
+import org.eclipse.wst.ws.internal.preferences.PersistentWSDLValidationContext;
+import org.eclipse.wst.ws.internal.util.UniversalPathTransformer;
+import org.eclipse.wst.wsdl.internal.impl.ServiceImpl;
+import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
+import org.eclipse.wst.wsdl.validation.internal.IValidationMessage;
+
+public class WSDLSelectionWidget extends AbstractObjectSelectionWidget implements IObjectSelectionWidget, Runnable
+{
+ private String pluginId_;
+ private FileExtensionFilter wsFilter_;
+ private WebServicesParser webServicesParser;
+ private String wsdlURI_;
+
+ private Composite parent_;
+ private Listener statusListener_;
+ private ModifyListener modifyListener_;
+ private WSDLSelectionTreeWidget tree;
+
+ private Timer timer_ = null;
+
+ /*CONTEXT_ID PCON0001 for the WSDL Selection Page*/
+ private final String INFOPOP_PCON_PAGE = "PCON0001";
+
+ /*CONTEXT_ID PCON0002 for the WSDL Document text field of the WSDL Selection Page*/
+ private final String INFOPOP_PCON_TEXT_WSDL = "PCON0002";
+ private Text webServiceURI;
+
+ /*CONTEXT_ID PCON0003 for the WSDL Resource Browse button of the WSDL Selection Page*/
+ private final String INFOPOP_PCON_BUTTON_BROWSE_WSDL = "PCON0003";
+ private Button wsBrowseButton_;
+
+ /*CONTEXT_ID PCON0004 for the Wizard WSDL Validation table of the WSDL Selection Page*/
+ private ValidationMessageViewerWidget msgViewer_;
+ private ValidateWSDLJob validateWSDLJob_;
+ private JobChangeAdapter jobChangeAdapter_;
+
+ /*CONTEXT_ID PCON0005 for the Wizard WSDL Validation summary message of the WSDL Selection Page*/
+ private Text validationSummaryText_;
+ private Text validationSummaryText2_;
+
+ /*CONTEXT_ID PCON0006 for the Stop Wizard WSDL Validation button of the WSDL Selection Page*/
+ private Button stopValidationButton_;
+ private final String INFOPOP_PCON_BUTTON_STOP_VALIDATION = "PCON0006";
+
+ public WSDLSelectionWidget()
+ {
+ pluginId_ = "org.eclipse.jst.ws.consumption.ui";
+ wsFilter_ = new FileExtensionFilter(new String[] {"wsdl", "wsil", "html"});
+ webServicesParser = WSDLParserFactory.getWSDLParser();
+
+ final Runnable handleValidationMessages = new Runnable()
+ {
+ public void run()
+ {
+ msgViewer_.setInput(validateWSDLJob_.getValidationMessages());
+ updateValidationSummary(validateWSDLJob_.getValidationMessageSeverity());
+ setValidationInProgress(false);
+ }
+ };
+
+ jobChangeAdapter_ = new JobChangeAdapter()
+ {
+ public void done(IJobChangeEvent event)
+ {
+ if (msgViewer_!= null && msgViewer_.getContentProvider() != null) {
+ Display.getDefault().asyncExec( handleValidationMessages );
+ }
+ }
+ };
+ }
+
+ public WidgetDataEvents addControls( Composite parent, Listener statusListener )
+ {
+ UIUtils uiUtils = new UIUtils( pluginId_ );
+ parent_ = parent;
+ statusListener_ = statusListener;
+
+ parent.setToolTipText( ConsumptionUIMessages.TOOLTIP_PCON_PAGE );
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( parent, pluginId_ + "." + INFOPOP_PCON_PAGE );
+
+ Composite wsdlGroup = uiUtils.createComposite( parent, 2, 5, 0 );
+
+ Label wsLabel = new Label( wsdlGroup, SWT.WRAP);
+ wsLabel.setText( ConsumptionUIMessages.LABEL_WS_SELECTION);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ wsLabel.setLayoutData(gd);
+ wsLabel.setToolTipText( ConsumptionUIMessages.TOOLTIP_PCON_TEXT_WS );
+
+ webServiceURI = uiUtils.createText( wsdlGroup, null,
+ ConsumptionUIMessages.TOOLTIP_PCON_TEXT_WS,
+ INFOPOP_PCON_TEXT_WSDL, SWT.SINGLE | SWT.BORDER );
+ modifyListener_ =
+ new ModifyListener()
+ {
+ public void modifyText(ModifyEvent event)
+ {
+ handleWebServiceURIModifyEvent();
+ }
+ };
+
+ webServiceURI.addModifyListener(modifyListener_);
+
+// webServiceURI.addListener( SWT.Modify, statusListener );
+
+ wsBrowseButton_ = uiUtils.createPushButton( wsdlGroup, ConsumptionUIMessages.BUTTON_BROWSE,
+ ConsumptionUIMessages.TOOLTIP_PCON_BUTTON_BROWSE_WS,
+ INFOPOP_PCON_BUTTON_BROWSE_WSDL );
+ wsBrowseButton_.addSelectionListener(
+ new SelectionListener()
+ {
+ public void widgetDefaultSelected(SelectionEvent event)
+ {
+ handleWSDLButton();
+ }
+
+ public void widgetSelected(SelectionEvent event)
+ {
+ handleWSDLButton();
+ }
+ });
+
+ tree = new WSDLSelectionTreeWidget();
+ tree.addControls(parent, statusListener);
+ tree.setWebServicesParser(webServicesParser);
+
+ msgViewer_ = new ValidationMessageViewerWidget();
+ msgViewer_.addControls(parent, statusListener);
+
+ validationSummaryText_ = new Text( parent, SWT.WRAP);
+ validationSummaryText_.setEditable(false);
+ GridData gd1 = new GridData(SWT.FILL, SWT.FILL, false, false);
+ validationSummaryText_.setLayoutData(gd1);
+ validationSummaryText_.setToolTipText( ConsumptionUIMessages.TOOLTIP_VALIDATE_TEXT_MESSAGE_SUMMARY );
+
+ validationSummaryText2_ = new Text( parent, SWT.WRAP);
+ validationSummaryText2_.setEditable(false);
+ validationSummaryText2_.setLayoutData(gd1);
+
+ stopValidationButton_ = uiUtils.createPushButton(parent,
+ ConsumptionUIMessages.LABEL_BUTTON_STOP_WSDL_VALIDATION,
+ ConsumptionUIMessages.TOOLTIP_STOP_VALIDATION_BUTTON,
+ INFOPOP_PCON_BUTTON_STOP_VALIDATION);
+ setValidationInProgress(false);
+
+ stopValidationButton_.addSelectionListener(
+ new SelectionListener()
+ {
+ public void widgetDefaultSelected(SelectionEvent event)
+ {
+ handleStopValidationButton();
+ }
+
+ public void widgetSelected(SelectionEvent event)
+ {
+ handleStopValidationButton();
+ }
+ });
+
+ setMessageSummary();
+ Dialog.applyDialogFont(parent);
+ return this;
+ }
+
+ private void setMessageSummary() {
+ String validationMessageSummary = ConsumptionUIMessages.MESSAGE_VALIDATE_NO_WSDL;
+ PersistentWSDLValidationContext wsdlValidationContext = WSPlugin.getInstance().getWSDLValidationContext();
+ String validationSelection = wsdlValidationContext.getPersistentWSDLValidation();
+ if (PersistentWSDLValidationContext.VALIDATE_REMOTE_WSDL.equals(validationSelection)) {
+ validationMessageSummary = ConsumptionUIMessages.MESSAGE_VALIDATE_REMOTE_WSDL;
+ } else if (PersistentWSDLValidationContext.VALIDATE_ALL_WSDL.equals(validationSelection)) {
+ validationMessageSummary = ConsumptionUIMessages.MESSAGE_VALIDATE_ALL_WSDL;
+ }
+ validationSummaryText_.setText( validationMessageSummary );
+ validationSummaryText2_.setText(" ");
+ }
+
+ private void handleWebServiceURIModifyEvent()
+ {
+ if (webServiceURI.getText().indexOf(':') > 0) {
+ timer_ = Timer.newInstance(timer_, Display.getCurrent(), this);
+ timer_.startTimer();
+ }
+ else
+ handleWebServiceURI();
+ statusListener_.handleEvent(null);
+ }
+
+ private void handleWebServiceURI() {
+ handleWebServiceURI(webServiceURI.getText());
+ }
+
+ private void handleWebServiceURI(String wsURI)
+ {
+ if (wsURI.indexOf(':') < 0)
+ {
+ IFile file = uri2IFile(wsURI);
+ if (file != null)
+ wsURI = iFile2URI(file);
+ }
+ if (wsURI != null && wsURI.indexOf(':') >= 0 && webServicesParser.getWebServiceEntityByURI(wsURI) == null)
+ {
+ TimedWSDLSelectionConditionCommand cmd = new TimedWSDLSelectionConditionCommand();
+ cmd.setWebServicesParser(webServicesParser);
+ cmd.setWebServiceURI(wsURI);
+ cmd.execute(null, null);
+ }
+ WebServiceEntity entity = webServicesParser.getWebServiceEntityByURI(wsURI);
+ if (entity != null && entity.getType() == WebServiceEntity.TYPE_WSDL)
+ tree.setEnabled(false);
+ else
+ tree.setEnabled(true);
+ tree.setWebServiceURI(wsURI);
+ tree.refreshTreeViewer();
+ wsdlURI_ = wsURI;
+ }
+
+ public void run()
+ {
+ handleWebServiceURI();
+ statusListener_.handleEvent(null);
+ }
+
+ private void handleWSDLButton()
+ {
+ DialogResourceBrowser dialog = new DialogResourceBrowser( parent_.getShell(), null, wsFilter_);
+ dialog.open();
+ IResource res = dialog.getFirstSelection();
+ if( res != null )
+ {
+ wsdlURI_ = res.getFullPath().toString();
+ webServiceURI.setText( wsdlURI_ );
+ }
+
+ statusListener_.handleEvent(null);
+ }
+
+ private void setValidationInProgress(boolean validating) {
+ stopValidationButton_.setEnabled(validating);
+ }
+
+ private void handleStopValidationButton()
+ {
+ IJobManager jobManager = Platform.getJobManager();
+ Job[] jobs = jobManager.find( ValidateWSDLJob.VALIDATE_WSDL_JOB_FAMILY );
+ ValidateWSDLJob existingValidateWSDLJob = null;
+
+ if( jobs.length > 0 )
+ {
+ for (int i=0; i<jobs.length; i++) {
+ existingValidateWSDLJob = (ValidateWSDLJob)jobs[i];
+
+ if (existingValidateWSDLJob.getState() != Job.NONE) {
+ existingValidateWSDLJob.cancel();
+ }
+ }
+ }
+ clearValidationMessages();
+ setValidationInProgress(false);
+ }
+
+ private void clearValidationMessages() {
+ msgViewer_.clearInput();
+ validationSummaryText_.setText(" " );
+ validationSummaryText2_.setText(" ");
+ }
+
+ public IStatus getStatus()
+ {
+ // Timer validation
+ /*
+ * Commenting out because we don't want to block fast typers from hitting Next/Finish
+ if (Timer.isRunning())
+ return new SimpleStatus("", ConsumptionUIMessages.PAGE_MSG_LOADING_WEB_SERVICE_URI, Status.ERROR);
+ */
+
+ // Validate the String representation of the Web service URI
+ // For example, is it pointing to an existing resource in the workspace?
+ String wsPath = webServiceURI.getText();
+ if( wsPath == null || wsPath.length() <= 0 ) {
+ clearValidationMessages();
+ return StatusUtils.errorStatus( ConsumptionUIMessages.PAGE_MSG_INVALID_WEB_SERVICE_URI );
+ }
+ else if( wsPath.indexOf(':') < 0 )
+ {
+ IResource res = ResourceUtils.findResource(wsPath);
+ if( res == null ) {
+ clearValidationMessages();
+ return StatusUtils.errorStatus( NLS.bind(ConsumptionUIMessages.PAGE_MSG_NO_SUCH_FILE, new Object[] {wsPath}) );
+ }
+ else if( res.getType() != IResource.FILE ) {
+ clearValidationMessages();
+ return StatusUtils.errorStatus( ConsumptionUIMessages.PAGE_MSG_INVALID_WEB_SERVICE_URI );
+ }
+ }
+
+
+ // Validate the content of the Web service URI
+ // For example, is selection a WSDL URI?
+ if (!Timer.isRunning(timer_) && tree.isEnabled())
+ {
+ IStatus status = tree.getStatus();
+ if (status != null)
+ {
+ int severity = status.getSeverity();
+ if (severity == Status.ERROR || severity == Status.WARNING) {
+ clearValidationMessages();
+ return status;
+ }
+ }
+ }
+ else
+ {
+ if( wsPath.indexOf(':') < 0 )
+ {
+ String wsdlURI = iFile2URI((IFile)ResourceUtils.findResource(wsPath));
+ if (webServicesParser.getWSDLDefinition(wsdlURI) == null) {
+ clearValidationMessages();
+ return StatusUtils.errorStatus(ConsumptionUIMessages.PAGE_MSG_SELECTION_MUST_BE_WSDL );
+ }
+ }
+ }
+
+
+ if (!Timer.isRunning(timer_)) {
+ String wsdlURI1 = wsPath;
+ boolean isRemote = true;
+ if (tree.isEnabled()) { // is wsil
+ wsdlURI1 = tree.getWsdlURI();
+ if (wsdlURI1.startsWith("file:") || wsdlURI1.startsWith("platform:"))
+ {
+ isRemote = false;
+ }
+ } else {
+ if (wsPath.indexOf(':') < 0)
+ {
+ isRemote = false;
+ wsdlURI1 = iFile2URI((IFile)ResourceUtils.findResource(wsPath));
+ }
+ else if (wsPath.startsWith("file:") || wsPath.startsWith("platform:"))
+ {
+ isRemote = false;
+ }
+ }
+
+ setMessageSummary();
+ msgViewer_.clearInput();
+ validateWSDL(wsdlURI1, isRemote);
+ }
+
+
+ // OK status
+ return Status.OK_STATUS;
+ }
+
+ private void validateWSDL (String wsdlURI, boolean isRemote) {
+
+ String validationSelection = WSPlugin.getInstance().getWSDLValidationContext().getPersistentWSDLValidation();;
+ if ((PersistentWSDLValidationContext.VALIDATE_ALL_WSDL.equals(validationSelection)) ||
+ (PersistentWSDLValidationContext.VALIDATE_REMOTE_WSDL.equals(validationSelection) && isRemote)) {
+
+ IJobManager jobManager = Platform.getJobManager();
+ Job[] jobs = jobManager.find( ValidateWSDLJob.VALIDATE_WSDL_JOB_FAMILY );
+ ValidateWSDLJob existingValidateWSDLJob = null;
+
+ boolean startWSDLValidation = true;
+ validationSummaryText_.setText( ConsumptionUIMessages.MESSAGE_VALIDATE_IN_PROGRESS );
+ validationSummaryText2_.setText(" ");
+ if( jobs.length > 0 )
+ {
+ for (int i=0; i<jobs.length; i++) {
+ existingValidateWSDLJob = (ValidateWSDLJob)jobs[i];
+
+ if (existingValidateWSDLJob.getState() != Job.NONE) {
+ // Job running or to be run
+ // If the job is validating the same wsdlURI, let it finish running and ignore this one.
+ // It is not for the same wsdlURI, cancel the job and schedule this one.
+
+ if (!wsdlURI.equals(existingValidateWSDLJob.getWsdlURI())) {
+ existingValidateWSDLJob.cancel();
+ setValidationInProgress(false);
+ } else {
+ startWSDLValidation = false;
+ }
+ }
+ }
+ }
+
+ if (startWSDLValidation) {
+ startWSDLValidationJob(wsdlURI);
+ }
+ }
+ return;
+ }
+
+ private void startWSDLValidationJob (String wsdlURI) {
+ validateWSDLJob_ = new ValidateWSDLJob(wsdlURI);
+ validateWSDLJob_.addJobChangeListener( jobChangeAdapter_ );
+ validateWSDLJob_.schedule();
+ setValidationInProgress(true);
+ }
+
+ public void updateValidationSummary(int messageSeverity)
+ {
+
+ switch (messageSeverity) {
+ case IValidationMessage.SEV_ERROR:
+ validationSummaryText_.setText(ConsumptionUIMessages.ERROR_MESSAGES_IN_VALIDATION);
+ validationSummaryText2_.setText(ConsumptionUIMessages.WARNING_IF_CONTINUE);
+ break;
+ case IValidationMessage.SEV_WARNING:
+ validationSummaryText_.setText(ConsumptionUIMessages.WARNING_MESSAGES_IN_VALIDATION);
+ validationSummaryText2_.setText(ConsumptionUIMessages.WARNING_IF_CONTINUE);
+ break;
+ default:
+ validationSummaryText_.setText(ConsumptionUIMessages.VALIDATION_COMPLETED);
+ validationSummaryText2_.setText(" ");
+ break;
+ }
+ }
+
+ private IFile uri2IFile(String uri)
+ {
+ IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(uri);
+
+ if (res instanceof IFile)
+ return (IFile)res;
+ else
+ return null;
+ }
+
+ private String iFile2URI(IFile file)
+ {
+ String uri = null;
+ IIFile2UriConverter converter = WSPlugin.getInstance().getIFile2UriConverter();
+ boolean allowBaseConversionOnFailure = true;
+ if (converter != null)
+ {
+ uri = converter.convert(file);
+ if (uri == null)
+ allowBaseConversionOnFailure = converter.allowBaseConversionOnFailure();
+ }
+ if (uri == null && allowBaseConversionOnFailure)
+ {
+ File f = file.getLocation().toFile();
+ try
+ {
+ uri = f.toURL().toString();
+ }
+ catch (MalformedURLException murle)
+ {
+ uri = f.toString();
+ }
+ }
+ return uri;
+ }
+
+ public void setInitialSelection(IStructuredSelection initialSelection)
+ {
+ if (initialSelection != null && !initialSelection.isEmpty())
+ {
+ Object object = initialSelection.getFirstElement();
+ String wsdlURI = toWsdlURI(object);
+ wsdlURI_ = wsdlURI;
+
+ if (wsdlURI != null && webServiceURI != null)
+ {
+ handleWebServiceURI(wsdlURI);
+
+ webServiceURI.removeModifyListener(modifyListener_);
+ webServiceURI.setText(getObjectSelectionDisplayableString());
+ webServiceURI.addModifyListener(modifyListener_);
+ }
+ }
+ }
+
+ private String toWsdlURI(Object object)
+ {
+ if (object instanceof ServiceImpl)
+ return J2EEActionAdapterFactory.getWSDLURI((ServiceImpl)object);
+ else if (object instanceof WSDLResourceImpl)
+ return J2EEActionAdapterFactory.getWSDLURI((WSDLResourceImpl)object);
+ else if (object instanceof ServiceRef)
+ return J2EEActionAdapterFactory.getWSDLURI((ServiceRef)object);
+ else if (object instanceof IFile)
+ return ((IFile)object).getFullPath().toString();
+ else if (object instanceof String)
+ return (String)object;
+ else
+ return null;
+ }
+
+ public IStructuredSelection getObjectSelection()
+ {
+ StructuredSelection ss;
+ if (tree != null && tree.getWsdlURI() != null)
+ ss = new StructuredSelection(tree.getWsdlURI());
+ else
+ ss = new StructuredSelection(wsdlURI_);
+ return new StructuredSelection(
+ new WSDLSelectionWrapper( webServicesParser, ss));
+ }
+
+ public WebServicesParser getWebServicesParser()
+ {
+ return webServicesParser;
+ }
+
+ public IStatus validateSelection(IStructuredSelection objectSelection)
+ {
+ return Status.OK_STATUS;
+ }
+
+ public IProject getProject()
+ {
+ String wsdlURI;
+
+ if (tree != null)
+ wsdlURI = tree.getWsdlURI();
+ else
+ wsdlURI = wsdlURI_;
+
+ if (wsdlURI != null)
+ {
+ IProject p = getProjectFromURI(wsdlURI);
+ if (p!=null && p.exists())
+ return p;
+
+ String wsRelPath = wsdlURI_;
+ IResource wsRes = ResourceUtils.findResource(wsRelPath);
+ if (wsRes!=null && wsRes instanceof IFile)
+ {
+ IProject p2 = ((IFile)wsRes).getProject();
+ return p2;
+ }
+
+ }
+ return null;
+ }
+
+ public String getComponentName()
+ {
+
+ String wsdlURI;
+ if (tree != null)
+ wsdlURI = tree.getWsdlURI();
+ else
+ wsdlURI = wsdlURI_;
+
+ if (wsdlURI != null)
+ {
+ String cname = getComponentNameFromURI(wsdlURI);
+ if (cname!=null && cname.length()>0)
+ return cname;
+
+ String wsRelPath = wsdlURI_;
+ IResource wsRes = ResourceUtils.findResource(wsRelPath);
+ if (wsRes!=null && wsRes instanceof IFile)
+ {
+ IVirtualComponent comp = ResourceUtils.getComponentOf(wsRes);
+ if (comp!=null)
+ {
+ return comp.getName();
+ }
+ }
+
+ }
+ return null;
+ }
+
+ private IProject getProjectFromURI(String uri)
+ {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ String wkspcRootLoc = root.getLocation().toString();
+ int idx = uri.indexOf(wkspcRootLoc);
+ if (idx != -1)
+ {
+ String relPath = uri.substring(wkspcRootLoc.length()+idx);
+ IResource res = root.findMember(new Path(relPath));
+ if (res instanceof IFile)
+ {
+ IProject p = ((IFile)res).getProject();
+ return p;
+ }
+ }
+ return null;
+ }
+
+ private String getComponentNameFromURI(String uri)
+ {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ String wkspcRootLoc = root.getLocation().toString();
+ int idx = uri.indexOf(wkspcRootLoc);
+ if (idx != -1)
+ {
+ String relPath = uri.substring(wkspcRootLoc.length()+idx);
+ IResource res = root.findMember(new Path(relPath));
+ if (res instanceof IFile)
+ {
+ IVirtualComponent comp = ResourceUtils.getComponentOf(res);
+ if (comp!=null)
+ {
+ return comp.getName();
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getObjectSelectionDisplayableString()
+ {
+ if (tree != null)
+ {
+ return UniversalPathTransformer.toPath(tree.getWsdlURI());
+ }
+ else
+ {
+ return UniversalPathTransformer.toPath(wsdlURI_);
+ }
+ }
+
+ public Point getWidgetSize() {
+ return new Point( 580, 580);
+ }
+
+ public boolean validate(String s) {
+ String wsURI = s;
+
+ if (wsURI.indexOf(':') < 0)
+ {
+ IFile file = uri2IFile(wsURI);
+ if (file != null)
+ wsURI = iFile2URI(file);
+ }
+ if (wsURI != null && wsURI.indexOf(':') >= 0 && webServicesParser.getWebServiceEntityByURI(wsURI) == null)
+ {
+ TimedWSDLSelectionConditionCommand cmd = new TimedWSDLSelectionConditionCommand();
+ cmd.setWebServicesParser(webServicesParser);
+ cmd.setWebServiceURI(wsURI);
+ cmd.execute(null, null);
+ }
+
+ // prime widget based on the string
+ wsdlURI_ = wsURI;
+ if (tree != null)
+ tree.setWebServiceURI(wsURI);
+
+ WebServiceEntity entity = webServicesParser.getWebServiceEntityByURI(wsURI);
+ if (entity != null && entity.getType() == WebServiceEntity.TYPE_WSDL)
+ return true;
+ else
+ return false;
+
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/WSDLSelectionWrapper.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/WSDLSelectionWrapper.java
new file mode 100644
index 000000000..80a6c1823
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/object/WSDLSelectionWrapper.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.object;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
+
+/**
+ * This class is a very simple wrapper that binds a WSDL parser with
+ * a wsdlSelection object.
+ */
+public class WSDLSelectionWrapper
+{
+ public WebServicesParser parser;
+ public IStructuredSelection wsdlSelection;
+
+ public WSDLSelectionWrapper( WebServicesParser parser,
+ IStructuredSelection selection )
+ {
+ this.parser = parser;
+ this.wsdlSelection = selection;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java
new file mode 100644
index 000000000..358e599c2
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java
@@ -0,0 +1,1619 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 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
+ * -------- -------- -----------------------------------------------------------
+ * IBM Corporation. - initial API and implementation
+ * 20070523 158230 kathy@ca.ibm.com - Kathy Chan
+ * 20080326 171705 trungha@ca.ibm.com - Trung, improve AntTask errors report
+ * 20080326 221364 kathy@ca.ibm.com - Kathy Chan
+ * 20080402 225032 makandre@ca.ibm.com - Andrew Mak
+ * 20080415 227152 makandre@ca.ibm.com - Andrew Mak, Need a way to specify a backup Web service runtime
+ * 20080421 228054 makandre@ca.ibm.com - Andrew Mak, NPE in ClientRuntimeSelectionWidgetDefaultingCommand
+ * 20080527 234226 kathy@ca.ibm.com - Kathy Chan
+ * 20080731 242721 kathy@ca.ibm.com - Kathy Chan
+ * 20100929 326549 mahutch@ca.ibm.com - Mark Hutchinson, Web Service Wizard Can Default to invalid project type
+ * 20110118 334706 mahutch@ca.ibm.com - Mark Hutchinson, Web Service Wizard: Error: Template has not been defined
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.runtime;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.ILog;
+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.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.server.core.FacetUtil;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.common.ServerUtils;
+import org.eclipse.jst.ws.internal.consumption.common.FacetMatcher;
+import org.eclipse.jst.ws.internal.consumption.common.FacetUtils;
+import org.eclipse.jst.ws.internal.consumption.common.RequiredFacetVersion;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.common.DefaultingUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.common.ValidationUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
+import org.eclipse.jst.ws.internal.consumption.ui.preferences.PersistentServerRuntimeContext;
+import org.eclipse.jst.ws.internal.consumption.ui.preferences.ProjectTopologyContext;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.ClientRuntimeDescriptor;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.FacetMatchCache;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.RuntimeDescriptor;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.ServiceRuntimeDescriptor;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils2;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.jst.ws.internal.ui.WSUIPluginMessages;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.core.context.ResourceContext;
+import org.eclipse.wst.command.internal.env.core.selection.SelectionList;
+import org.eclipse.wst.command.internal.env.core.selection.SelectionListChoices;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.server.core.IRuntime;
+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.ws.internal.parser.wsil.WebServicesParser;
+import org.eclipse.wst.ws.internal.wsrt.IContext;
+import org.eclipse.wst.ws.internal.wsrt.ISelection;
+import org.eclipse.wst.ws.internal.wsrt.IWebServiceClient;
+import org.eclipse.wst.ws.internal.wsrt.IWebServiceRuntime;
+import org.eclipse.wst.ws.internal.wsrt.SimpleContext;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceClientInfo;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceState;
+
+public class ClientRuntimeSelectionWidgetDefaultingCommand extends AbstractDataModelOperation
+{
+ private String DEFAULT_CLIENT_EAR_PROJECT_EXT = "EAR";
+ private TypeRuntimeServer clientIds_;
+ private boolean clientIdsFixed_ = false;
+ private String clientRuntimeId_;
+ private String clientProjectName_;
+ private String clientEarProjectName_;
+ protected boolean clientNeedEAR_ = true;
+ private String clientComponentType_;
+ private FacetMatcher clientFacetMatcher_;
+
+ private IContext context_;
+ private ISelection selection_;
+ private IWebServiceClient webServiceClient_;
+ private ResourceContext resourceContext_;
+ private boolean test_;
+
+ //A note on initial projects ...
+ //The difference between clientInitialProject_ and initialProject_ is that
+ //clientInitialProject_ comes from the ObjectSelectionOutputCommand while initialProject_
+ //comes from SelectionCommand (i.e. it is the project containing the thing that was selected before
+ //the wizard was launched). In the defaulting algorithm, clientInitialProject_ will
+ //be given first priority. If, however, it is deemed that clientInitialProject_ is not a valid project
+ //because it contains the J2EE Web service for which we are trying to create a client, initialProject_
+ //will be given second priority.
+ private IProject initialProject_; //This is the project containing the selection prior to the wizard being launched.
+ private IProject clientInitialProject_; //This is the project containing the object selection from page 2.
+ private String wsdlURI_;
+ private WebServicesParser parser_;
+
+ public ClientRuntimeSelectionWidgetDefaultingCommand()
+ {
+ super();
+ }
+
+ public void setClientTypeRuntimeServer( TypeRuntimeServer ids )
+ {
+ clientIds_ = ids;
+ }
+
+ public TypeRuntimeServer getClientTypeRuntimeServer()
+ {
+ return clientIds_;
+ }
+
+ public void setClientIdsFixed(boolean b)
+ {
+ clientIdsFixed_ = b;
+ }
+
+ public String getClientRuntimeId()
+ {
+ return clientRuntimeId_;
+ }
+
+ public String getClientProjectName()
+ {
+ return clientProjectName_;
+ }
+
+ public String getClientEarProjectName()
+ {
+ return clientEarProjectName_;
+ }
+
+ public void setClientEarProjectName(String name)
+ {
+ clientEarProjectName_ = name;
+ }
+
+ public String getClientComponentType()
+ {
+ return clientComponentType_;
+ }
+
+ public IWebServiceClient getWebService()
+ {
+ return webServiceClient_;
+ }
+
+ public IContext getContext()
+ {
+ return context_;
+ }
+
+ public ISelection getSelection()
+ {
+ return selection_;
+ }
+
+ /**
+ * Defaults the following bits of information in the following order:
+ * clientRuntimeId_ : the clientRuntimeId. Must be defaulted to non-empty String.
+ * clientIds_.runtimeId_: the Web service runtime id. Must be defaulted to non-empty String.
+ * clientProjectName_ : the name of the client project. Must be non-empty. May or may not exist.
+ * clientComponentType_: the id of the client project template. Must be empty if the client
+ * project exists. Must be non-empty of the client project does not exist.
+ * clientIds_.serverId_: the server type id. May be an empty String if the defaulted Web service runtime
+ * does not require a server.
+ * clientIds_.serverInstanceId_: the server id. May be null or an empty String.
+ * clientNeedEAR_: true if an EAR is needed. False otherwise.
+ * clientEarProjectName_: the client EAR project. Must be empty if the clientNeedEAR_ is false.
+ * Must be non-empty if the clientNeedEAR_ is true.
+ * webServiceClient_ : the IWebServiceClient based on the calculated defaults. Must be non-null for "Next"
+ * button to be enabled on the page following this command.
+ * context_ : an IContext. Must be non-null for "Next" button to be enabled on the page following this command.
+ */
+ public IStatus execute(IProgressMonitor monitor, IAdaptable adaptable)
+ {
+
+ IEnvironment env = getEnvironment();
+
+ try
+ {
+
+ //**Step 1** Default the Web service runtime.
+
+ //clientIdsFixed_ is set to true for the Ant scenario. It's always false for the wizard
+ //scenarios.
+ if (clientIdsFixed_ && (clientProjectName_ == null))
+ {
+ // Set the clientRuntime based on the runtime, server, and initial
+ // selection.
+ DefaultRuntimeTriplet drt = getDefaultClientRuntimeForFixedRuntimeAndServer(clientInitialProject_, clientIds_.getServerId());
+ clientFacetMatcher_ = drt.getFacetMatcher();
+ clientProjectName_ = drt.getProjectName();
+ clientRuntimeId_ = drt.getRuntimeId();
+ }
+ else
+ {
+ ValidationUtils vu = new ValidationUtils();
+
+ // Set the runtime based on the project containing the object selection/initial selection.
+ DefaultRuntimeTriplet drt = null;
+
+ if (!vu.isProjectServiceProject(clientInitialProject_, wsdlURI_, parser_) && !clientIdsFixed_)
+ {
+ //If clientIntialProject_ does not contain the J2EE Web service, choose a clientRuntime based on it.
+ drt = getDefaultRuntime(clientInitialProject_, clientIds_.getTypeId(), true, clientIds_.getServerId());
+ clientFacetMatcher_ = drt.getFacetMatcher();
+ clientProjectName_ = drt.getProjectName();
+ clientRuntimeId_ = drt.getRuntimeId();
+ }
+ else
+ {
+ //clientInitialProject_ contains the J2EE Web service so don't use it.
+ //Try using the initalProject_ instead.
+ if (!vu.isProjectServiceProject(initialProject_, wsdlURI_, parser_) && !clientIdsFixed_)
+ {
+ //If intialProject_ does not contain the J2EE Web service, choose a clientRuntime based on it.
+ drt = getDefaultRuntime(initialProject_, clientIds_.getTypeId(), true, clientIds_.getServerId());
+ clientFacetMatcher_ = drt.getFacetMatcher();
+ clientProjectName_ = drt.getProjectName();
+ clientRuntimeId_ = drt.getRuntimeId();
+ }
+ else
+ {
+ //Both clientIntialProject_ and initialProject_ contain the J2EE Web service
+ //and cannot be used to influence clientRuntime defaulting.
+ //Choose a clientRuntime but don't choose clientInitialProject_
+ //as the clientProject.
+ drt = getDefaultRuntime(null, clientIds_.getTypeId(), true, clientIds_.getServerId());
+ clientRuntimeId_ = drt.getRuntimeId();
+ }
+ }
+
+ //Set the Web service runtime id from the clientRuntime
+ clientIds_.setRuntimeId(WebServiceRuntimeExtensionUtils2.getClientRuntimeDescriptorById(clientRuntimeId_).getRuntime()
+ .getId());
+ }
+
+ //**Step 2** Default the client project if it was not already defaulted
+ //as part of defaulting the Web service runtime.
+ if (clientProjectName_ == null)
+ {
+ // Project name did not get set when the runtime was set, so set it now
+ clientProjectName_ = getDefaultClientProjectName();
+ }
+
+ //**Step 3** Default the client project type.
+ IProject clientProject = ProjectUtilities.getProject(clientProjectName_);
+ if (!clientProject.exists())
+ {
+ // Set the project template
+ clientComponentType_ = getDefaultClientProjectTemplate();
+ }
+ else
+ {
+ //Set it to an empty String
+ clientComponentType_ = "";
+ }
+
+
+ //**Step 4** Default the client server if this is not an Ant scenario.
+ if (!clientIdsFixed_)
+ {
+ IStatus serverStatus = setClientDefaultServer();
+ if (serverStatus.getSeverity() == Status.ERROR)
+ {
+ env.getStatusHandler().reportError(serverStatus);
+ return serverStatus;
+ }
+ }
+
+ //**Step 5** Default clientNeedEAR and client EAR if an EAR is needed
+ setDefaultClientEarProject();
+
+
+ //**Step 6** Calculate default IWebServiceClient. This is need to make sure that
+ // Next is enabled on the page following this command.
+ setDefaultsForExtension(env);
+
+ return Status.OK_STATUS;
+
+ } catch (Exception e)
+ {
+ // Catch all Exceptions in order to give some feedback to the user
+ IStatus errorStatus = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_ERROR_TASK_EXCEPTED,
+ new String[] { e.getMessage() }), e);
+
+ // If the exception has no error msg, it's kind of useless to the user so let's log it
+ if ( e.getMessage() == null){
+ ILog pluginlog = WebServiceConsumptionUIPlugin.getInstance().getLog();
+ pluginlog.log(errorStatus);
+
+ // create a new IStatus which has a non-null msg, this is to be thrown to the user.
+ errorStatus = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_ERROR_TASK_EXCEPTED,
+ new String[] { WSUIPluginMessages.MSG_SEE_ERROR_LOG }), e);
+ }
+
+ env.getStatusHandler().reportError(errorStatus);
+ return errorStatus;
+ }
+ }
+
+ private void setDefaultClientEarProject()
+ {
+ //Don't need an ear if this is a Java project, or if the selected template is jst.utility
+ IProject clientProject = ProjectUtilities.getProject(clientProjectName_);
+ if (clientProject.exists())
+ {
+ clientNeedEAR_ = !(FacetUtils.isJavaProject(clientProject));
+ }
+ else
+ {
+ clientNeedEAR_ = !(FacetUtils.isUtilityTemplate(clientComponentType_));
+ }
+
+ //If clientNeedEAR_ is still true, it means that we're not dealing with a Java project
+ //or Java project type. Check the server.
+ if (clientNeedEAR_)
+ {
+ // Determine if an ear selection is needed based on the server type.
+
+ 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;
+ }
+ }
+ } else { // serverId == null, assume that it does not need EAR
+ clientNeedEAR_ = false;
+
+ }
+ }
+
+ if (clientNeedEAR_)
+ {
+ clientEarProjectName_ = DefaultingUtils.getDefaultEARProjectName(clientProjectName_);
+ }
+ else
+ {
+ clientEarProjectName_ = "";
+ }
+ }
+
+ private IStatus setClientDefaultServer()
+ {
+ //Choose an existing server the module is already associated with if possible
+ IProject clientProject = ProjectUtilities.getProject(clientProjectName_);
+ IServer[] configuredServers = ServerUtil.getServersByModule(ServerUtils.getModule(clientProject), null);
+
+ if (configuredServers!=null && configuredServers.length>0 && configuredServers[0].getServerType() != null)
+ {
+ clientIds_.setServerId(configuredServers[0].getServerType().getId());
+ clientIds_.setServerInstanceId(configuredServers[0].getId());
+ return Status.OK_STATUS;
+ }
+
+ //If the project exists, choose a suitable server or server type based on the existing project's runtime or facets
+ if (clientProject.exists())
+ {
+ IServer server = getServerFromProject(clientProjectName_, clientFacetMatcher_);
+ if (server != null && server.getServerType() != null)
+ {
+ clientIds_.setServerId(server.getServerType().getId());
+ clientIds_.setServerInstanceId(server.getId());
+ return Status.OK_STATUS;
+ }
+ else
+ {
+ IServerType serverType = getServerTypeFromProject(clientProjectName_, clientFacetMatcher_);
+ if (serverType != null)
+ {
+ clientIds_.setServerId(serverType.getId());
+ return Status.OK_STATUS;
+ }
+ }
+ }
+
+ //Haven't picked a server/server type on the basis of the project. Pick a server/server type
+ //that is compatible with the clientRuntimeId.
+ IServer server = getServerFromClientRuntimeId();
+ if (server!=null && server.getServerType() != null)
+ {
+ clientIds_.setServerId(server.getServerType().getId());
+ clientIds_.setServerInstanceId(server.getId());
+ return Status.OK_STATUS;
+ }
+
+ IServerType serverType = getServerTypeFromClientRuntimeId();
+ if (serverType != null)
+ {
+ clientIds_.setServerId(serverType.getId());
+ return Status.OK_STATUS;
+ }
+
+ // No suitable server was found. Popup an error if the default Web service
+ // runtime requires a server.
+ RuntimeDescriptor runtimeDescriptor = WebServiceRuntimeExtensionUtils2.getRuntimeById(clientIds_.getRuntimeId());
+ if (runtimeDescriptor.getServerRequired())
+ {
+ String runtimeLabel = WebServiceRuntimeExtensionUtils2.getRuntimeLabelById(clientIds_.getRuntimeId());
+ IStatus status = StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_ERROR_NO_SERVER_RUNTIME, new String[] {
+ runtimeLabel}));
+ return status;
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ private IServer getServerFromClientRuntimeId()
+ {
+ IServer[] servers = ServerCore.getServers();
+ if (servers != null && servers.length > 0) {
+
+ PersistentServerRuntimeContext context = WebServiceConsumptionUIPlugin.getInstance().getServerRuntimeContext();
+ String preferredServerFactoryId = context.getServerFactoryId();
+
+ //If a server of the preferred server type is present, check that one first
+ for (int j = 0; j < servers.length; j++)
+ {
+ if (servers[j] != null && servers[j].getServerType() != null)
+ {
+ String serverFactoryId = servers[j].getServerType().getId();
+ if (serverFactoryId.equals(preferredServerFactoryId))
+ {
+ if (WebServiceRuntimeExtensionUtils2.doesClientRuntimeSupportServer(clientRuntimeId_, serverFactoryId))
+ {
+ return servers[j];
+ }
+ }
+ }
+ }
+
+ //A server of the preferred server type could not be found or did not match. Check all the existing servers.
+
+ for (int i = 0; i < servers.length; i++)
+ {
+ if (servers[i] != null && servers[i].getServerType() != null)
+ {
+ String serverFactoryId = servers[i].getServerType().getId();
+ if (WebServiceRuntimeExtensionUtils2.doesClientRuntimeSupportServer(clientRuntimeId_, serverFactoryId))
+ {
+ return servers[i];
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private IServerType getServerTypeFromClientRuntimeId()
+ {
+ String[] serverTypes = WebServiceRuntimeExtensionUtils2.getServerFactoryIdsByClientRuntime(clientRuntimeId_);
+ if (serverTypes!=null && serverTypes.length>0)
+ {
+ //Return the preferred one if it is in the list
+ PersistentServerRuntimeContext context = WebServiceConsumptionUIPlugin.getInstance().getServerRuntimeContext();
+ String preferredServerFactoryId = context.getServerFactoryId();
+ for (int i=0; i<serverTypes.length; i++)
+ {
+ if (serverTypes[i].equals(preferredServerFactoryId))
+ {
+ return ServerCore.findServerType(serverTypes[i]);
+ }
+ }
+
+ return ServerCore.findServerType(serverTypes[0]);
+ }
+
+ return null;
+ }
+
+ protected IServer getServerFromProject(String projectName, FacetMatcher facetMatcher)
+ {
+ IServer server = null;
+
+ IProject project = ProjectUtilities.getProject(projectName);
+ IServer[] servers = ServerCore.getServers();
+
+ if (servers.length > 0)
+ {
+ PersistentServerRuntimeContext context = WebServiceConsumptionUIPlugin.getInstance().getServerRuntimeContext();
+ String preferredServerFactoryId = context.getServerFactoryId();
+
+ // Get the runtime.
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime fRuntime = null;
+ IFacetedProject fProject = null;
+
+ if (project != null && project.exists())
+ {
+ try
+ {
+ fProject = ProjectFacetsManager.create(project);
+ if (fProject != null)
+ {
+ fRuntime = fProject.getPrimaryRuntime();
+ }
+ } catch (CoreException ce)
+ {
+
+ }
+ }
+
+ if (fRuntime != null)
+ {
+ // Get an existing server that has the same runtime.
+ IServer firstMatchingServer = null;
+ IRuntime sRuntime = FacetUtil.getRuntime(fRuntime);
+ for (int i = 0; i < servers.length; i++)
+ {
+ IServer thisServer = servers[i];
+ IRuntime thisServerRuntime = thisServer.getRuntime();
+ if ( thisServerRuntime != null && sRuntime != null && thisServerRuntime.getId().equals(sRuntime.getId()))
+ {
+ if (firstMatchingServer==null)
+ {
+ firstMatchingServer = thisServer;
+ }
+
+ if (thisServer != null && thisServer.getServerType() != null && thisServer.getServerType().getId().equals(preferredServerFactoryId))
+ {
+
+ server = thisServer;
+ break;
+ }
+ }
+ }
+
+ //If a server of the preferred server type was not found but
+ //there was a server that matched, return that one.
+ if (server == null && firstMatchingServer != null)
+ {
+ server = firstMatchingServer;
+ }
+ }
+
+ // If an existing server could not be chosen on the basis of the project's
+ // runtime,
+ // try to find an existing server using the project's facets and the
+ // facetsToAdd.
+ if (server == null)
+ {
+ if (project!=null && project.exists())
+ {
+ Set facets = FacetUtils.getFacetsForProject(project.getName());
+ if (facets != null)
+ {
+ Set facetsClone = new HashSet();
+ facetsClone.addAll(facets);
+ if (facetMatcher != null && facetMatcher.getFacetsToAdd() != null)
+ {
+ Iterator itr = facetMatcher.getFacetsToAdd().iterator();
+ while (itr.hasNext())
+ {
+ facetsClone.add(itr.next());
+ }
+ }
+ server = getServerFromFacets(facetsClone);
+ }
+ }
+ }
+ }
+ return server;
+ }
+
+ protected IServer getServerFromFacets(Set facets)
+ {
+ IServer server = null;
+ Set runtimes = FacetUtils.getRuntimes(new Set[]{facets});
+ Iterator itr = runtimes.iterator();
+ IServer[] servers = ServerCore.getServers();
+ PersistentServerRuntimeContext context = WebServiceConsumptionUIPlugin.getInstance().getServerRuntimeContext();
+ String preferredServerFactoryId = context.getServerFactoryId();
+
+ //If one of the servers is of the preferred type, and its runtime
+ //is in the set of matching runtimes, return that server.
+ for (int j=0; j<servers.length; j++)
+ {
+ IServer thisServer = servers[j];
+ if (thisServer != null && thisServer.getServerType() != null && thisServer.getRuntime() != null && thisServer.getServerType().getId().equals(preferredServerFactoryId))
+ {
+ IRuntime thisServerRuntime = thisServer.getRuntime();
+ //Check to see if it matches any of the runtimes.
+ Iterator runtimesItr = runtimes.iterator();
+ while(runtimesItr.hasNext())
+ {
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime fRuntime = (org.eclipse.wst.common.project.facet.core.runtime.IRuntime)runtimesItr.next();
+ IRuntime sRuntime = FacetUtil.getRuntime(fRuntime);
+ if (sRuntime != null && thisServerRuntime.getId().equals(sRuntime.getId()))
+ {
+ server = thisServer;
+ }
+ }
+ }
+ }
+
+ if (server == null)
+ {
+ outer: while (itr.hasNext())
+ {
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime fRuntime = (org.eclipse.wst.common.project.facet.core.runtime.IRuntime) itr
+ .next();
+ IRuntime sRuntime = FacetUtil.getRuntime(fRuntime);
+ for (int i = 0; i < servers.length; i++)
+ {
+ IServer thisServer = servers[i];
+ IRuntime thisServerRuntime = thisServer.getRuntime();
+ if (thisServerRuntime != null && sRuntime != null && thisServerRuntime.getId().equals(sRuntime.getId()))
+ {
+ server = thisServer;
+ break outer;
+ }
+ }
+ }
+ }
+
+ return server;
+
+ }
+
+ protected IServerType getServerTypeFromProject(String projectName, FacetMatcher facetMatcher)
+ {
+ IServerType serverType = null;
+ PersistentServerRuntimeContext context = WebServiceConsumptionUIPlugin.getInstance().getServerRuntimeContext();
+ String preferredServerFactoryId = context.getServerFactoryId();
+
+ IProject project = ProjectUtilities.getProject(projectName);
+ IServerType[] serverTypes = ServerCore.getServerTypes();
+
+ //Get the runtime.
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime fRuntime = null;
+ IFacetedProject fProject = null;
+
+ if (project != null && project.exists())
+ {
+ try
+ {
+ fProject = ProjectFacetsManager.create(project);
+ if (fProject != null)
+ {
+ fRuntime = fProject.getPrimaryRuntime();
+ }
+ } catch (CoreException ce)
+ {
+
+ }
+ }
+
+ if (fRuntime != null)
+ {
+ //Get a server type that has the same runtime type.
+ IRuntime sRuntime = FacetUtil.getRuntime(fRuntime);
+ if (sRuntime != null)
+ {
+ IRuntimeType sRuntimeType = sRuntime.getRuntimeType();
+ IServerType firstMatchingServerType = null;
+ for (int i=0; i<serverTypes.length; i++)
+ {
+ IServerType thisServerType = serverTypes[i];
+ IRuntimeType thisServerRuntimeType = thisServerType.getRuntimeType();
+ if (sRuntimeType != null && thisServerRuntimeType != null && thisServerRuntimeType.getId().equals(sRuntimeType.getId()))
+ {
+ if (firstMatchingServerType == null)
+ {
+ firstMatchingServerType = thisServerType;
+ }
+ if (thisServerType.getId().equals(preferredServerFactoryId))
+ {
+ serverType = thisServerType;
+ break;
+ }
+ }
+ }
+
+ //If the preferred server type was not found but
+ //there was a server type that matched, return that one.
+ if (serverType == null && firstMatchingServerType != null)
+ {
+ serverType = firstMatchingServerType;
+ }
+ }
+ }
+
+ //If a server type could not be chosen on the basis of the project's runtime,
+ //try to find a server type using the project's facets and the facetsToAdd.
+ if (serverType == null)
+ {
+ if (project != null && project.exists())
+ {
+ Set facets = FacetUtils.getFacetsForProject(project.getName());
+ if (facets != null)
+ {
+ Set facetsClone = new HashSet();
+ facetsClone.addAll(facets);
+ if (facetMatcher != null && facetMatcher.getFacetsToAdd() != null)
+ {
+ Iterator itr = facetMatcher.getFacetsToAdd().iterator();
+ while (itr.hasNext())
+ {
+ facetsClone.add(itr.next());
+ }
+ }
+ serverType = getServerTypeFromFacets(facetsClone);
+ }
+ }
+ }
+
+ return serverType;
+
+ }
+
+ protected IServerType getServerTypeFromFacets(Set facets)
+ {
+ IServerType serverType = null;
+ Set runtimes = FacetUtils.getRuntimes(new Set[]{facets});
+ Iterator itr = runtimes.iterator();
+ IServerType[] serverTypes = ServerCore.getServerTypes();
+ PersistentServerRuntimeContext context = WebServiceConsumptionUIPlugin.getInstance().getServerRuntimeContext();
+ String preferredServerFactoryId = context.getServerFactoryId();
+
+ //If one of the server types is of the preferred type, and its runtime
+ //is in the set of matching runtimes, return that server type.
+ for (int j=0; j<serverTypes.length; j++)
+ {
+ IServerType thisServerType = serverTypes[j];
+ IRuntimeType thisServerTypeRuntimeType = thisServerType.getRuntimeType();
+ if (thisServerTypeRuntimeType != null && thisServerType.getId().equals(preferredServerFactoryId))
+ {
+ //Check to see if it matches any of the runtimes.
+ Iterator runtimesItr = runtimes.iterator();
+ while(runtimesItr.hasNext())
+ {
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime fRuntime = (org.eclipse.wst.common.project.facet.core.runtime.IRuntime)runtimesItr.next();
+ IRuntime sRuntime = FacetUtil.getRuntime(fRuntime);
+ if (sRuntime != null)
+ {
+ IRuntimeType sRuntimeType = sRuntime.getRuntimeType();
+ if (sRuntimeType != null && thisServerTypeRuntimeType.getId().equals(sRuntimeType.getId()))
+ {
+ serverType = thisServerType;
+ }
+ }
+ }
+ }
+ }
+
+
+ if (serverType == null)
+ {
+ outer: while (itr.hasNext())
+ {
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime fRuntime = (org.eclipse.wst.common.project.facet.core.runtime.IRuntime) itr
+ .next();
+ IRuntime sRuntime = FacetUtil.getRuntime(fRuntime);
+ if (sRuntime != null)
+ {
+ IRuntimeType sRuntimeType = sRuntime.getRuntimeType();
+ for (int i = 0; i < serverTypes.length; i++)
+ {
+ IServerType thisServerType = serverTypes[i];
+ if (thisServerType != null)
+ {
+ IRuntimeType thisServerTypeRuntimeType = thisServerType.getRuntimeType();
+ if (sRuntimeType != null && thisServerTypeRuntimeType != null && thisServerTypeRuntimeType.getId().equals(sRuntimeType.getId()))
+ {
+ serverType = thisServerType;
+ break outer;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return serverType;
+
+ }
+
+ protected IServer getServerFromProjectType(String templateId, FacetMatcher facetMatcher)
+ {
+ IServer server = null;
+ Set facets = FacetUtils.getInitialFacetVersionsFromTemplate(templateId);
+ if (facetMatcher.getFacetsToAdd() != null)
+ {
+ Iterator itr = facetMatcher.getFacetsToAdd().iterator();
+ while (itr.hasNext())
+ {
+ facets.add(itr.next());
+ }
+ }
+ server = getServerFromFacets(facets);
+ return server;
+ }
+
+ protected IServerType getServerTypeFromProjectType(String templateId, FacetMatcher facetMatcher)
+ {
+ IServerType serverType = null;
+ Set facets = FacetUtils.getInitialFacetVersionsFromTemplate(templateId);
+ if (facetMatcher.getFacetsToAdd() != null)
+ {
+ Iterator itr = facetMatcher.getFacetsToAdd().iterator();
+ while (itr.hasNext())
+ {
+ facets.add(itr.next());
+ }
+ }
+ //TODO Instead of passing in a single set of facets, pass in multiple sets, if the
+ //jst.java facet is one of them and the clientRuntimeId allows newer.
+ serverType = getServerTypeFromFacets(facets);
+ return serverType;
+ }
+
+ private String getDefaultClientProjectTemplate()
+ {
+ String[] templates = WebServiceRuntimeExtensionUtils2.getClientProjectTemplates(clientIds_.getTypeId(), clientIds_.getRuntimeId());
+
+ //Walk the list of client project types in the project topology preference
+ ProjectTopologyContext ptc= WebServiceConsumptionUIPlugin.getInstance().getProjectTopologyContext();
+ String[] preferredTemplateIds = ptc.getClientTypes();
+ for (int j=0; j<preferredTemplateIds.length; j++)
+ {
+ for (int i=0; i<templates.length; i++)
+ {
+ String templateId = templates[i];
+ if (templateId.equals(preferredTemplateIds[j]))
+ {
+
+ boolean matches = WebServiceRuntimeExtensionUtils2.doesClientRuntimeSupportTemplate(clientRuntimeId_, templateId);
+ if (matches)
+ {
+ return templates[i];
+ }
+ }
+ }
+ }
+
+ //Since the preferredTemplateIds contains the union of all project types for all client runtimes, we are
+ //guaranteed to have returned by now, so the code below will never be executed under normal
+ //circumstances. Just return something to satisfy the compiler.
+ if (templates.length > 0)
+ return templates[0];
+
+ return "";
+ }
+
+ private String getDefaultClientProjectName()
+ {
+ ValidationUtils vu = new ValidationUtils();
+ IProject[] projects = FacetUtils.getAllProjects();
+ ClientRuntimeDescriptor desc = WebServiceRuntimeExtensionUtils2.getClientRuntimeDescriptorById(clientRuntimeId_);
+ RequiredFacetVersion[] rfvs = desc.getRequiredFacetVersions();
+
+ //Check each project and its facetRuntime for compatibility with the clientRuntime
+ for (int i=0; i<projects.length; i++)
+ {
+ if (!vu.isProjectServiceProject(projects[i], wsdlURI_, parser_))
+ {
+ Set facetVersions = FacetUtils.getFacetsForProject(projects[i].getName());
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime fRuntime = null;
+ String fRuntimeName = null;
+ fRuntime = FacetUtils.getFacetRuntimeForProject(projects[i].getName());
+ if (fRuntime != null)
+ {
+ fRuntimeName = fRuntime.getName();
+ }
+
+ if (facetVersions != null)
+ {
+
+ // FacetMatcher fm = FacetUtils.match(rfvs, facetVersions);
+ FacetMatcher fm = FacetMatchCache.getInstance().getMatchForProject(true, clientRuntimeId_, projects[i].getName());
+ boolean facetRuntimeMatches = true;
+ if (fRuntimeName != null)
+ {
+ facetRuntimeMatches = FacetUtils.isFacetRuntimeSupported(rfvs, fRuntimeName);
+ }
+
+ if (fm.isMatch() && facetRuntimeMatches)
+ {
+ clientFacetMatcher_ = fm;
+ return projects[i].getName();
+ }
+ }
+ }
+ }
+
+ //No project was suitable, return a new project name
+ return ResourceUtils.getDefaultWebProjectName();
+
+ }
+
+ private DefaultRuntimeTriplet getDefaultClientRuntimeForFixedRuntimeAndServer(IProject project, String runtimePreferredServer)
+ {
+ String[] clientRuntimes = WebServiceRuntimeExtensionUtils2.getClientRuntimesByType(clientIds_.getTypeId(), runtimePreferredServer);
+ ArrayList validClientRuntimes = new ArrayList();
+ for (int i=0; i<clientRuntimes.length; i++ )
+ {
+ ClientRuntimeDescriptor desc = WebServiceRuntimeExtensionUtils2.getClientRuntimeDescriptorById(clientRuntimes[i]);
+ if (desc.getRuntime().getId().equals(clientIds_.getRuntimeId()))
+ {
+ //Check if this client runtime supports the server
+ if (WebServiceRuntimeExtensionUtils2.doesClientRuntimeSupportServer(desc.getId(), clientIds_.getServerId()))
+ {
+ validClientRuntimes.add(desc.getId());
+ if (project != null && project.exists())
+ {
+ //RequiredFacetVersion[] rfv = desc.getRequiredFacetVersions();
+ Set facetVersions = FacetUtils.getFacetsForProject(project.getName());
+ if (facetVersions != null)
+ {
+ //FacetMatcher fm = FacetUtils.match(rfv, facetVersions);
+ FacetMatcher fm = FacetMatchCache.getInstance().getMatchForProject(true, clientRuntimes[i], project.getName());
+ if (fm.isMatch())
+ {
+ DefaultRuntimeTriplet drt = new DefaultRuntimeTriplet();
+ drt.setFacetMatcher(fm);
+ drt.setProjectName(project.getName());
+ drt.setRuntimeId(desc.getId());
+ return drt;
+ }
+ }
+ }
+
+ }
+ }
+
+ }
+
+ if (validClientRuntimes.size() > 0)
+ {
+ //We couldn't match to the initially selected project so return the first valid runtime.
+ DefaultRuntimeTriplet drt = new DefaultRuntimeTriplet();
+ drt.setFacetMatcher(null);
+ drt.setProjectName(null);
+ drt.setRuntimeId(((String[])validClientRuntimes.toArray(new String[0]))[0]);
+ return drt;
+ }
+ else
+ {
+ //There are no client runtimes that match the fixed runtime and server. Fall back to original algorithm
+ clientIdsFixed_ = false;
+ return getDefaultRuntime(project, clientIds_.getTypeId(), true, clientIds_.getServerId());
+ }
+ }
+
+ protected DefaultRuntimeTriplet getDefaultRuntime(IProject project, String typeId, boolean isClient, String runtimePreferredServer)
+ {
+ String[] runtimes = null;
+ if (isClient)
+ {
+ runtimes = WebServiceRuntimeExtensionUtils2.getClientRuntimesByType(typeId, runtimePreferredServer);
+ }
+ else
+ {
+ runtimes = WebServiceRuntimeExtensionUtils2.getServiceRuntimesByServiceType(typeId, runtimePreferredServer);
+ }
+
+ //Split the array of service/client runtimes into one containing the preferred set and one containing the rest.
+ PersistentServerRuntimeContext context = WebServiceConsumptionUIPlugin.getInstance().getServerRuntimeContext();
+ String preferredRuntimeId = context.getRuntimeId();
+ String fallbackRuntimeId = context.getFallbackRuntimeId();
+ ArrayList preferredRuntimeIdsList = new ArrayList();
+ ArrayList otherRuntimeIdsList = new ArrayList();
+ for (int k=0; k<runtimes.length; k++ )
+ {
+ String descRuntimeId = null;
+ if (isClient)
+ {
+ ClientRuntimeDescriptor desc = WebServiceRuntimeExtensionUtils2.getClientRuntimeDescriptorById(runtimes[k]);
+ descRuntimeId = desc.getRuntime().getId();
+ }
+ else
+ {
+ ServiceRuntimeDescriptor desc = WebServiceRuntimeExtensionUtils2.getServiceRuntimeDescriptorById(runtimes[k]);
+ descRuntimeId = desc.getRuntime().getId();
+ }
+
+ if (descRuntimeId.equals(preferredRuntimeId))
+ {
+ preferredRuntimeIdsList.add(runtimes[k]);
+ }
+ else if (descRuntimeId.equals(fallbackRuntimeId))
+ {
+ otherRuntimeIdsList.add(0, runtimes[k]); // add to beginning of otherRuntimeIdsList
+ }
+ else
+ {
+ otherRuntimeIdsList.add(runtimes[k]);
+ }
+ }
+ String[] preferredRuntimeIds = (String[])preferredRuntimeIdsList.toArray(new String[0]);
+ String[] otherRuntimeIds = (String[])otherRuntimeIdsList.toArray(new String[0]);
+
+ Set facetVersions = null;
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime fRuntime = null;
+ String fRuntimeName = null;
+
+ //If the initially selected project exists and facets can be inferred from it, look for
+ //a service/client runtime that matches the project's facets and also, if possible, its facet runtime.
+ //Preference should be given to the preferred service/client runtimes.
+ if (project != null && project.exists())
+ {
+ facetVersions = FacetUtils.getFacetsForProject(project.getName());
+ fRuntime = FacetUtils.getFacetRuntimeForProject(project.getName());
+ fRuntimeName = null;
+ if (fRuntime != null)
+ {
+ fRuntimeName = fRuntime.getName();
+ }
+
+ if (facetVersions != null)
+ {
+ //1. First check to see if one of the preferred service/client runtimes matches the existing
+ //project's facets and runtime.
+ for (int p = 0; p < preferredRuntimeIds.length; p++)
+ {
+ RequiredFacetVersion[] prfv = null;
+ if (isClient)
+ {
+ prfv = WebServiceRuntimeExtensionUtils2.getClientRuntimeDescriptorById(preferredRuntimeIds[p]).getRequiredFacetVersions();
+ }
+ else
+ {
+ prfv = WebServiceRuntimeExtensionUtils2.getServiceRuntimeDescriptorById(preferredRuntimeIds[p]).getRequiredFacetVersions();
+ }
+
+ //FacetMatcher fm = FacetUtils.match(prfv, facetVersions);
+ FacetMatcher fm = FacetMatchCache.getInstance().getMatchForProject(isClient, preferredRuntimeIds[p], project.getName());
+ boolean facetRuntimeMatches = true;
+ if (fRuntimeName != null)
+ {
+ facetRuntimeMatches = FacetUtils.isFacetRuntimeSupported(prfv, fRuntimeName);
+ }
+
+ if (fm.isMatch() && facetRuntimeMatches)
+ {
+ DefaultRuntimeTriplet drt = new DefaultRuntimeTriplet();
+ drt.setFacetMatcher(fm);
+ drt.setProjectName(project.getName());
+ drt.setRuntimeId(preferredRuntimeIds[p]);
+ return drt;
+ }
+ }
+
+ //2. Second, check to see if one of the other clientRuntimes matches the existing
+ //project's facets and runtime.
+ for (int i=0; i<otherRuntimeIds.length; i++)
+ {
+ RequiredFacetVersion[] rfv = null;
+ if (isClient)
+ {
+ rfv = WebServiceRuntimeExtensionUtils2.getClientRuntimeDescriptorById(otherRuntimeIds[i]).getRequiredFacetVersions();
+ }
+ else
+ {
+ rfv = WebServiceRuntimeExtensionUtils2.getServiceRuntimeDescriptorById(otherRuntimeIds[i]).getRequiredFacetVersions();
+ }
+
+ FacetMatcher fm = FacetMatchCache.getInstance().getMatchForProject(isClient, otherRuntimeIds[i], project.getName());
+ boolean facetRuntimeMatches = true;
+ if (fRuntimeName != null)
+ {
+ facetRuntimeMatches = FacetUtils.isFacetRuntimeSupported(rfv, fRuntimeName);
+ }
+ if (fm.isMatch() && facetRuntimeMatches)
+ {
+ DefaultRuntimeTriplet drt = new DefaultRuntimeTriplet();
+ drt.setFacetMatcher(fm);
+ drt.setProjectName(project.getName());
+ drt.setRuntimeId(otherRuntimeIds[i]);
+ return drt;
+ }
+ }
+
+ //3. Third, check to see if one of the preferred clientRuntimes matches the existing
+ //project's facets.
+ for (int p = 0; p < preferredRuntimeIds.length; p++)
+ {
+ FacetMatcher fm = FacetMatchCache.getInstance().getMatchForProject(isClient, preferredRuntimeIds[p], project.getName());
+ if (fm.isMatch())
+ {
+ DefaultRuntimeTriplet drt = new DefaultRuntimeTriplet();
+ drt.setFacetMatcher(fm);
+ drt.setProjectName(project.getName());
+ drt.setRuntimeId(preferredRuntimeIds[p]);
+ return drt;
+ }
+ }
+
+ //4. Fourth, check to see if the one the other clientRuntimes matches the existing
+ //project's facets.
+ for (int i=0; i<otherRuntimeIds.length; i++)
+ {
+ FacetMatcher fm = FacetMatchCache.getInstance().getMatchForProject(isClient, otherRuntimeIds[i], project.getName());
+ if (fm.isMatch())
+ {
+ DefaultRuntimeTriplet drt = new DefaultRuntimeTriplet();
+ drt.setFacetMatcher(fm);
+ drt.setProjectName(project.getName());
+ drt.setRuntimeId(otherRuntimeIds[i]);
+ return drt;
+ }
+ }
+ }
+ }
+
+ //Haven't returned yet so this means that the intitially selected project cannot be used
+ //to influence the selection of the service/client runtime.
+
+ //Use the preferred project types to influence the selection of a runtime.
+ ProjectTopologyContext ptc = WebServiceConsumptionUIPlugin.getInstance().getProjectTopologyContext();
+ String[] preferredTemplateIds = null;
+ if (isClient)
+ {
+ preferredTemplateIds = ptc.getClientTypes();
+ }
+ else
+ {
+ preferredTemplateIds = ptc.getServiceTypes();
+ }
+
+
+ for (int n=0; n<preferredTemplateIds.length; n++)
+ {
+ String preferredTemplateId = preferredTemplateIds[n];
+
+ for (int m=0; m<preferredRuntimeIds.length; m++)
+ {
+ //If this client or service runtime supports this template, choose it and exit.
+ boolean matches = false;
+ if (isClient)
+ {
+ matches = WebServiceRuntimeExtensionUtils2.doesClientRuntimeSupportTemplate(preferredRuntimeIds[m], preferredTemplateId) &&
+ WebServiceRuntimeExtensionUtils2.doesClientRuntimeSupportServer(preferredRuntimeIds[m], runtimePreferredServer);
+ }
+ else
+ {
+ matches = WebServiceRuntimeExtensionUtils2.doesServiceRuntimeSupportTemplate(preferredRuntimeIds[m], preferredTemplateId) &&
+ WebServiceRuntimeExtensionUtils2.doesServiceRuntimeSupportServer(preferredRuntimeIds[m], runtimePreferredServer);
+ }
+
+ if (matches)
+ {
+ DefaultRuntimeTriplet drt = new DefaultRuntimeTriplet();
+ drt.setFacetMatcher(null);
+ //If the project doesn't exist, use the name of the project that was passed in.
+ //If the project exists, it means that previous code in this method
+ //determined it to not be a suitable project. Clear the project name.
+ if (project==null || project.exists())
+ {
+ drt.setProjectName(null);
+ }
+ else
+ {
+ drt.setProjectName(project.getName());
+ }
+ drt.setRuntimeId(preferredRuntimeIds[m]);
+ return drt;
+ }
+ }
+ }
+
+
+ //Still haven't returned. Return the first preferred service/client runtime id.
+ if (preferredRuntimeIds.length > 0)
+ {
+ DefaultRuntimeTriplet drt = new DefaultRuntimeTriplet();
+ drt.setFacetMatcher(null);
+ //If the project doesn't exist, use the name of the project that was passed in.
+ //If the project exists, it means that previous code in this method
+ //determined it to not be a suitable project. Clear the project name.
+ if (project==null || project.exists())
+ {
+ drt.setProjectName(null);
+ }
+ else
+ {
+ drt.setProjectName(project.getName());
+ }
+ drt.setRuntimeId(preferredRuntimeIds[0]);
+ return drt;
+ }
+
+ if (otherRuntimeIds.length > 0)
+ {
+ DefaultRuntimeTriplet drt = new DefaultRuntimeTriplet();
+ drt.setFacetMatcher(null);
+ //If the project doesn't exist, use the name of the project that was passed in.
+ //If the project exists, it means that previous code in this method
+ //determined it to not be a suitable project. Clear the project name.
+ if (project==null || project.exists())
+ {
+ drt.setProjectName(null);
+ }
+ else
+ {
+ drt.setProjectName(project.getName());
+ }
+ drt.setRuntimeId(otherRuntimeIds[0]);
+ return drt;
+ }
+ else
+ {
+ DefaultRuntimeTriplet drt = new DefaultRuntimeTriplet();
+ drt.setFacetMatcher(null);
+ //If the project doesn't exist, use the name of the project that was passed in.
+ //If the project exists, it means that previous code in this method
+ //determined it to not be a suitable project. Clear the project name.
+ if (project==null || project.exists())
+ {
+ drt.setProjectName(null);
+ }
+ else
+ {
+ drt.setProjectName(project.getName());
+ }
+ drt.setRuntimeId(null);
+ return drt;
+ }
+ }
+ /**
+ *
+ * @param project
+ * @return
+ */
+ protected SelectionListChoices getProjectEARChoice(IProject project)
+ {
+ String[] flexProjects = getAllFlexibleProjects();
+ SelectionList list = new SelectionList(flexProjects, 0);
+ return new SelectionListChoices(list, null);
+ }
+
+ protected SelectionList getEARProjects()
+ {
+ String[] flexProjects = getAllFlexibleProjects();
+ return new SelectionList(flexProjects, 0);
+ }
+
+ protected IResource getResourceFromInitialSelection(IStructuredSelection selection)
+ {
+ if (selection != null && selection.size() == 1)
+ {
+ Object obj = selection.getFirstElement();
+ if (obj != null)
+ {
+ try
+ {
+ IResource resource = ResourceUtils.getResourceFromSelection(obj);
+ return resource;
+ } catch(CoreException e)
+ {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+
+
+ /*
+ * Set defaults for the client-side from the service-side if possible.
+ * Sets clientProjectName_ to a value based on the service project name.
+ *
+ * Returns an IStatus.OK if the service side values for server and Web
+ * service runtime can be used to set the values for clientRuntimeId_,
+ * clientComponentType_, all the values in clientIds_, and clientEarProjectName_.
+ *
+ * Returns an IStatus.ERROR otherwise, leaving only the clientProjectName_ set.
+ */
+ protected IStatus defaultClientSideFromServiceSide(String serviceProjectName, TypeRuntimeServer serviceIds, boolean serviceNeedEAR, String serviceEarProjectName)
+ {
+ //1. Start with setting the default client project name based on the service project name.
+ boolean isEJB = false;
+ String implId = WebServiceRuntimeExtensionUtils2.getWebServiceImplIdFromTypeId(serviceIds.getTypeId());
+ isEJB = (implId.equals("org.eclipse.jst.ws.wsImpl.ejb"));
+ String[] updatedNames = ResourceUtils.getClientProjectComponentName(serviceProjectName, serviceProjectName, isEJB);
+ clientProjectName_ = updatedNames[0];
+
+ //2. Ideally, the server and runtime on the client-side will be defaulted
+ // to the same values as the service side. If a client runtime id that
+ // supports clientProjectName_ and the service-side server and runtime defaults
+ // can be found, choose it.
+ IProject clientProject = ProjectUtilities.getProject(clientProjectName_);
+ TypeRuntimeServer testIds = new TypeRuntimeServer();
+ testIds.setTypeId(clientIds_.getTypeId());
+ testIds.setRuntimeId(serviceIds.getRuntimeId());
+ testIds.setServerId(serviceIds.getServerId());
+ testIds.setServerInstanceId(serviceIds.getServerInstanceId());
+
+ if (clientProject.exists())
+ {
+ clientComponentType_ = "";
+ clientRuntimeId_ = WebServiceRuntimeExtensionUtils2.getClientRuntimeId(testIds, clientProjectName_, clientComponentType_);
+ if (clientRuntimeId_ != null && clientRuntimeId_.length()>0)
+ {
+ clientIds_.setRuntimeId(serviceIds.getRuntimeId());
+ clientIds_.setServerId(serviceIds.getServerId());
+ clientIds_.setServerInstanceId(serviceIds.getServerInstanceId());
+ }
+ }
+ else
+ {
+ //See if there is a client project type that supports the service-side
+ //server and runtime defaults. Pick a client project type based on project topology preferences.
+ //Choose the clientRuntimeId_ accordingly.
+ String[] templateIds = WebServiceRuntimeExtensionUtils2.getClientProjectTemplates(clientIds_.getTypeId(), testIds.getRuntimeId());
+ if (templateIds != null && templateIds.length > 0)
+ {
+ ProjectTopologyContext ptc = WebServiceConsumptionUIPlugin.getInstance().getProjectTopologyContext();
+ String[] preferredTemplateIds = ptc.getClientTypes();
+ outer: for (int j = 0; j < preferredTemplateIds.length; j++)
+ {
+ for (int i = 0; i < templateIds.length; i++)
+ {
+ String templateId = templateIds[i];
+ if (templateId.equals(preferredTemplateIds[j]))
+ {
+ // Get a clientRuntimeId for this template
+ String newClientRuntimeId = WebServiceRuntimeExtensionUtils2.getClientRuntimeId(testIds, clientProjectName_,
+ templateId);
+ if (newClientRuntimeId.length() > 0)
+ {
+ clientRuntimeId_ = newClientRuntimeId;
+ clientComponentType_ = templateId;
+ clientIds_.setRuntimeId(serviceIds.getRuntimeId());
+ clientIds_.setServerId(serviceIds.getServerId());
+ clientIds_.setServerInstanceId(serviceIds.getServerInstanceId());
+ break outer;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //3. If step 2 was successful, clientRuntimeId_ should now be set, along with clientProjectName_,
+ // clientComponentType_, and all the values in clientIds_. All that remains is setting the EAR.
+ if (clientRuntimeId_ != null && clientRuntimeId_.length()>0)
+ {
+ setDefaultClientEarProject();
+ //Update the client side EAR from the service side EAR if necessary.
+ if (serviceNeedEAR)
+ {
+ defaultClientEarFromServiceEar(serviceProjectName, serviceEarProjectName);
+ }
+ return Status.OK_STATUS;
+ }
+ else
+ {
+ //Step 2 was not successful. Client side defaulting cannot be done using the service side server
+ //and web service runtime defaults. Return an error status.
+ return StatusUtils.errorStatus("");
+ }
+ }
+
+ protected void defaultClientEarFromServiceEar(String serviceProjectName, String serviceEarProjectName)
+ {
+ //Client side
+ if (clientNeedEAR_)
+ {
+ IProject clientProject = ProjectUtilities.getProject(clientProjectName_);
+ if(clientProject==null || !clientProject.exists()
+ || !(clientEarProjectName_.equalsIgnoreCase(serviceEarProjectName)))
+ {
+ ProjectTopologyContext ptc= WebServiceConsumptionUIPlugin.getInstance().getProjectTopologyContext();
+ if (!ptc.isUseTwoEARs())
+ {
+ clientEarProjectName_ = serviceEarProjectName;
+ }
+ else
+ {
+ IProject proxyEARProject = getUniqueClientEAR(clientEarProjectName_, serviceEarProjectName, clientProjectName_, serviceProjectName);
+ clientEarProjectName_ = proxyEARProject.getName();
+ }
+ }
+ }
+
+ }
+
+ private IProject getUniqueClientEAR(String earProjectName, String serviceEARProject, String clientProjectName, String serviceProjectName) {
+
+ String projectName = new String();
+ //If the client project doesn't exist and the service project does, ensure the
+ //the client side EAR's J2EE level is such that the service project could be added to it.
+ //This will ensure we don't default the page with a client project EAR at a lower
+ //J2EE level than the service side.
+ boolean goodJ2EELevel = true;
+ if (!earProjectName.equalsIgnoreCase(serviceEARProject))
+ {
+ IProject clientProject = ProjectUtilities.getProject(clientProjectName);
+ IProject serviceProject = ProjectUtilities.getProject(serviceProjectName);
+ IProject earProject = ProjectUtilities.getProject(earProjectName);
+ if (!clientProject.exists() && serviceProject.exists())
+ {
+ boolean canAssociate = J2EEUtils.canAssociateProjectToEARWithoutWarning(serviceProject, earProject);
+ goodJ2EELevel = (canAssociate);
+ }
+ }
+
+ if (!earProjectName.equalsIgnoreCase(serviceEARProject) && goodJ2EELevel) {
+ projectName = earProjectName;
+ }
+ else {
+ projectName = clientProjectName+DEFAULT_CLIENT_EAR_PROJECT_EXT;
+ int i=1;
+ while (projectName.equalsIgnoreCase(serviceEARProject)) {
+ projectName = projectName+i;
+ i++;
+ }
+ }
+ return projectName.equals("") ? null : ResourceUtils.getWorkspaceRoot().getProject(projectName);
+
+ }
+
+ private void setDefaultsForExtension(IEnvironment env)
+ {
+ IWebServiceRuntime wsrt = WebServiceRuntimeExtensionUtils2.getClientRuntime(clientRuntimeId_);
+ if (wsrt != null)
+ {
+ WebServiceClientInfo wsInfo = new WebServiceClientInfo();
+ wsInfo.setServerFactoryId(clientIds_.getServerId());
+ wsInfo.setServerInstanceId(clientIds_.getServerInstanceId());
+ wsInfo.setState(WebServiceState.UNKNOWN_LITERAL);
+ wsInfo.setWebServiceRuntimeId(clientIds_.getRuntimeId());
+ wsInfo.setWsdlURL(wsdlURI_);
+
+ webServiceClient_ = wsrt.getWebServiceClient(wsInfo);
+ WebServiceScenario scenario = WebServiceScenario.CLIENT_LITERAL;
+ if (resourceContext_ != null)
+ {
+ context_ = new SimpleContext(true, true, true, true, true, true, test_, false, scenario, resourceContext_.isOverwriteFilesEnabled(), resourceContext_
+ .isCreateFoldersEnabled(), resourceContext_.isCheckoutFilesEnabled());
+ }
+ }
+
+ }
+
+ public void setClientInitialSelection(IStructuredSelection selection)
+ {
+ if (clientInitialProject_ == null)
+ {
+ clientInitialProject_ = getProjectFromInitialSelection(selection);
+ }
+ }
+
+ // This is for the Ant scenario where the client project name can be set in the property file.
+ // If the user has set the ClientProjectName use it for defaulting purposes
+ public void setClientProjectName(String name)
+ {
+ clientProjectName_ = name;
+ }
+
+ public void setClientInitialProject(IProject clientInitialProject)
+ {
+ clientInitialProject_ = clientInitialProject;
+ }
+
+ /**
+ * @param initialInitialSelection_ The initialInitialSelection_ to set.
+ */
+ public void setInitialInitialSelection(IStructuredSelection initialInitialSelection)
+ {
+ initialProject_ = getProjectFromInitialSelection(initialInitialSelection);
+ }
+
+ public boolean getClientNeedEAR()
+ {
+ return clientNeedEAR_;
+ }
+
+ /**
+ * @param parser_ The parser_ to set.
+ */
+ public void setWebServicesParser(WebServicesParser parser) {
+ parser_ = parser;
+ }
+
+ public void setWsdlURI(String wsdlURI)
+ {
+ wsdlURI_ = wsdlURI;
+ }
+
+ public void setTestService(boolean testService)
+ {
+ test_ = testService;
+ }
+
+ public void setResourceContext( ResourceContext resourceContext )
+ {
+ resourceContext_ = resourceContext;
+ }
+
+ private IProject getProjectFromInitialSelection(IStructuredSelection selection)
+ {
+ if (selection != null && selection.size() == 1)
+ {
+ Object obj = selection.getFirstElement();
+ if (obj != null)
+ {
+ try
+ {
+ IResource resource = ResourceUtils.getResourceFromSelection(obj);
+ if (resource==null)
+ return null;
+ IProject p = ResourceUtils.getProjectOf(resource.getFullPath());
+ return p;
+ } catch(CoreException e)
+ {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ protected String[] getAllFlexibleProjects()
+ {
+ Vector v = new Vector();
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (int i = 0; i < projects.length; i++)
+ {
+ if (!projects[i].getName().equals("Servers") && !projects[i].getName().startsWith("."))
+ {
+ v.add(projects[i].getName());
+ }
+ }
+
+ return (String[])v.toArray(new String[0]);
+
+ }
+
+ protected class FacetRuntimeMatcher
+ {
+ FacetMatcher facetMatcher;
+ boolean runtimeMatches;
+
+ public FacetMatcher getFacetMatcher()
+ {
+ return facetMatcher;
+ }
+ public void setFacetMatcher(FacetMatcher facetMatcher)
+ {
+ this.facetMatcher = facetMatcher;
+ }
+ public boolean isRuntimeMatches()
+ {
+ return runtimeMatches;
+ }
+ public void setRuntimeMatches(boolean runtimeMatches)
+ {
+ this.runtimeMatches = runtimeMatches;
+ }
+ }
+
+ protected class DefaultRuntimeTriplet
+ {
+ FacetMatcher facetMatcher_;
+ String projectName_;
+ String runtimeId_;
+
+
+ public DefaultRuntimeTriplet()
+ {
+ }
+
+ public FacetMatcher getFacetMatcher()
+ {
+ return facetMatcher_;
+ }
+ public void setFacetMatcher(FacetMatcher facetMatcher_)
+ {
+ this.facetMatcher_ = facetMatcher_;
+ }
+ public String getProjectName()
+ {
+ return projectName_;
+ }
+ public void setProjectName(String projectName_)
+ {
+ this.projectName_ = projectName_;
+ }
+ public String getRuntimeId()
+ {
+ return runtimeId_;
+ }
+ public void setRuntimeId(String runtimeId_)
+ {
+ this.runtimeId_ = runtimeId_;
+ }
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ProjectSelectionWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ProjectSelectionWidget.java
new file mode 100644
index 000000000..d736e6c59
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ProjectSelectionWidget.java
@@ -0,0 +1,790 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2015 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060204 124143 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060221 122661 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060223 129020 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060227 124392 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060413 135581 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060427 138058 joan@ca.ibm.com - Joan Haggarty
+ * 20060510 140868 sengpl@ca.ibm.com - Seng Phung-Lu
+ * 20060524 141024 joan@ca.ibm.com - Joan Haggarty
+ * 20060829 145449 makandre@ca.ibm.com - Andrew Mak, Web service client project type dropdown disabled after selecting client project
+ * 20060829 180833 ericdp@ca.ibm.com - Eric D. Peters, New Web Service wizard service settings dialog has unlabelled enabled text fields
+ * 20080409 226047 kathy@ca.ibm.com - Kathy Chan
+ * 20080428 224726 pmoogk@ca.ibm.com - Peter Moogk
+ * 20081001 243869 ericdp@ca.ibm.com - Eric D. Peters, Web Service tools allowing mixed J2EE levels
+ * 20090302 249602 ericdp@ca.ibm.com - Eric D. Peters, PII- association warning message needs update
+ * 20090910 289113 ericdp@ca.ibm.com - Eric D. Peters - Linux: usability issue when selecting a Java Project in the Specify Client Project Settings dialog
+ * 20100929 326549 mahutch@ca.ibm.com - Mark Hutchinson, Web Service Wizard Can Default to invalid project type
+ * 20150311 461526 jgwest@ca.ibm.com - Jonathan West, Allow OSGi bundles to be selected in the Wizard *
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.runtime;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.common.ServerUtils;
+import org.eclipse.jst.ws.internal.consumption.common.FacetUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.common.DefaultingUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
+import org.eclipse.jst.ws.internal.consumption.ui.preferences.ProjectTopologyContext;
+import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils2;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.jst.ws.internal.ui.common.ComboWithHistory;
+import org.eclipse.jst.ws.internal.ui.common.UIUtils;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+
+public class ProjectSelectionWidget extends SimpleWidgetDataContributor {
+
+
+
+ private String pluginId_ = "org.eclipse.jst.ws.consumption.ui";
+
+ //private SelectionListChoices projects_;
+
+ private boolean needEAR_;
+
+ private TypeRuntimeServer trsIds_;
+
+ private Listener statusListener_;
+
+ private Text messageText_;
+
+ private boolean isClient_ = false;
+
+ private byte CREATE_PROJECT = (byte) 1;
+
+ private byte CREATE_EAR = (byte) 2;
+
+ private byte ADD_EAR_ASSOCIATION = (byte) 4;
+
+ private Composite parent_;
+ private Combo moduleProject_;
+
+ private Label earProjectLabel_;
+ private Combo earProject_;
+
+ private Combo projectType_;
+
+ private String[] templates_;
+
+ //private String componentType_;
+
+ private ModifyListener projectTypeListener_;
+ private ModifyListener moduleProjectListener_;
+ private ModifyListener earProjectListener_;
+
+ /*
+ * CONTEXT_ID PWRS0016 for the service-side Web project combo box of the
+ * runtime selection Page
+ */
+ private String INFOPOP_PWRS_COMBO_PROJECT = "PWRS0016";
+
+ //private Combo module_;
+
+ /* CONTEXT_ID PWRS0018 for the client project type combo box of the runtime selection Page */
+ private String INFOPOP_PWRS_COMBO_CLIENT_PROJECT_TYPE = "PWRS0018";
+
+ /* CONTEXT_ID PWRS0020 for the service project type combo box of the runtime selection Page */
+ private String INFOPOP_PWRS_COMBO_SERVICE_PROJECT_TYPE = "PWRS0020";
+
+ //private Combo earModule_;
+
+ /*
+ * Default Constructor
+ */
+ public ProjectSelectionWidget() {
+ }
+
+ /*
+ * ProjectSelectionWidget @param isClient
+ */
+ public ProjectSelectionWidget(boolean isClient) {
+ this.isClient_ = isClient;
+ }
+
+ public WidgetDataEvents addControls(Composite parent, Listener statusListener) {
+
+ parent_ = parent;
+ UIUtils uiUtils = new UIUtils(pluginId_);
+
+ statusListener_ = statusListener;
+
+ boolean isOSGISelected = isOSGISelected();
+
+ if (isClient_)
+ {
+ moduleProject_ = uiUtils.createCombo(parent, ConsumptionUIMessages.LABEL_CLIENT_PROJECT, ConsumptionUIMessages.LABEL_CLIENT_PROJECT, INFOPOP_PWRS_COMBO_PROJECT, SWT.SINGLE | SWT.BORDER );
+ projectType_ = uiUtils.createCombo(parent, ConsumptionUIMessages.LABEL_CLIENT_TYPE, ConsumptionUIMessages.TOOLTIP_PWCR_COMBO_CLIENT_TYPE, INFOPOP_PWRS_COMBO_CLIENT_PROJECT_TYPE, SWT.SINGLE | SWT.BORDER |SWT.READ_ONLY);
+
+ String earProjectLabel = isOSGISelected ? ConsumptionUIMessages.LABEL_CLIENT_OSGI_PROJECT : ConsumptionUIMessages.LABEL_CLIENT_EAR_PROJECT;
+
+ Widget[] earProjectResult = createCombo(parent, earProjectLabel, earProjectLabel, INFOPOP_PWRS_COMBO_PROJECT, SWT.SINGLE | SWT.BORDER, null );
+ earProject_ = (Combo)earProjectResult[0];
+ earProjectLabel_ = (Label)earProjectResult[1];
+ }
+ else
+ {
+ moduleProject_ = uiUtils.createCombo(parent, ConsumptionUIMessages.LABEL_SERVICE_PROJECT, ConsumptionUIMessages.LABEL_SERVICE_PROJECT, INFOPOP_PWRS_COMBO_PROJECT, SWT.SINGLE | SWT.BORDER );
+ projectType_ = uiUtils.createCombo(parent, ConsumptionUIMessages.LABEL_SERVICE_TYPE, ConsumptionUIMessages.TOOLTIP_PWCR_COMBO_SERVICE_TYPE, INFOPOP_PWRS_COMBO_SERVICE_PROJECT_TYPE, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+
+ String earProjectLabel = isOSGISelected ? ConsumptionUIMessages.LABEL_SERVICE_OSGI_PROJECT : ConsumptionUIMessages.LABEL_SERVICE_EAR_PROJECT;
+
+
+ Widget[] earProjectResult = createCombo(parent, earProjectLabel, earProjectLabel, INFOPOP_PWRS_COMBO_PROJECT, SWT.SINGLE | SWT.BORDER, null );
+ earProject_ = (Combo)earProjectResult[0];
+ earProjectLabel_ = (Label)earProjectResult[1];
+ }
+
+ //Temporarily remove the listeners
+
+ projectTypeListener_ = new ModifyListener()
+ {
+ public void modifyText(ModifyEvent evt)
+ {
+ handleProjectTypeChanged();
+ statusListener_.handleEvent( null );
+ }
+ };
+
+ moduleProjectListener_ = new ModifyListener()
+ {
+ public void modifyText(ModifyEvent evt)
+ {
+ handleProjectChanged();
+ updateEARState();
+ statusListener_.handleEvent( null );
+ }
+ };
+
+ earProjectListener_ = new ModifyListener()
+ {
+ public void modifyText(ModifyEvent evt)
+ {
+ statusListener_.handleEvent( null );
+ }
+ };
+
+ // message area
+ messageText_ = uiUtils.createText(parent, ConsumptionUIMessages.LABEL_NO_LABEL, ConsumptionUIMessages.LABEL_NO_LABEL, null, SWT.WRAP | SWT.MULTI | SWT.READ_ONLY);
+ messageText_.setBackground(parent.getBackground());
+ setEarProjectItems();
+
+ updateTextForOSGI();
+
+ return this;
+ }
+
+ private void listenersOn()
+ {
+ projectType_.addModifyListener(projectTypeListener_);
+ moduleProject_.addModifyListener( moduleProjectListener_ );
+ earProject_.addModifyListener( earProjectListener_ );
+ }
+
+ private void listenersOff()
+ {
+ projectType_.removeModifyListener(projectTypeListener_);
+ moduleProject_.removeModifyListener( moduleProjectListener_ );
+ earProject_.removeModifyListener( earProjectListener_ );
+ }
+
+ public String getProjectName()
+ {
+ return moduleProject_.getText();
+ }
+
+ public void setProjectName( String name )
+ {
+ listenersOff();
+ moduleProject_.setText( name );
+ handleProjectChanged();
+ updateEARState();
+ listenersOn();
+ }
+
+ public String getEarProjectName()
+ {
+ return earProject_.getText();
+ }
+
+ public void setEarProjectName( String name )
+ {
+ listenersOff();
+ earProject_.setText( name );
+ listenersOn();
+ }
+
+ public void setComponentType( String type )
+ {
+ listenersOff();
+ if (type != null && type.length()>0)
+ {
+ String label = FacetUtils.getTemplateLabelById(type);
+ projectType_.setText(label);
+ }
+ else
+ projectType_.setText("");
+
+ handleProjectTypeChanged();
+ listenersOn();
+ }
+
+ public String getComponentType()
+ {
+ int idx = projectType_.getSelectionIndex();
+ if (templates_ != null && idx > -1)
+ {
+ return templates_[idx];
+ }
+ else
+ {
+ String templateLabel = projectType_.getText();
+ String templateId = FacetUtils.getTemplateIdByLabel(templateLabel);
+ return templateId;
+ }
+
+ }
+
+ public boolean getNeedEAR()
+ {
+ return needEAR_;
+ }
+
+ public void setNeedEAR(boolean b)
+ {
+ listenersOff();
+ needEAR_ = b;
+ if (needEAR_)
+ {
+ earProject_.setEnabled(true);
+ populateEARCombos();
+ }
+ else
+ {
+ earProject_.setEnabled(false);
+ earProject_.setText("");
+ }
+ listenersOn();
+ }
+
+ public void setTypeRuntimeServer(TypeRuntimeServer trs)
+ {
+ trsIds_ = trs;
+ if (earProject_ != null)
+ {
+ listenersOff();
+ updateEARState();
+ listenersOn();
+ }
+ }
+
+ public void refreshProjectItems()
+ {
+ listenersOff();
+ String selectedModuleProject = moduleProject_.getText();
+ String runtimeId = trsIds_.getRuntimeId();
+ String serverId = trsIds_.getServerId();
+ String typeId = trsIds_.getTypeId();
+
+ //Get all the projects that are compatible with the type and runtime
+ String[] projectNames = null;
+ if (isClient_)
+ {
+ projectNames = WebServiceRuntimeExtensionUtils2.getProjectsForClientTypeAndRuntime(typeId, runtimeId, serverId);
+ }
+ else
+ {
+ projectNames = WebServiceRuntimeExtensionUtils2.getProjectsForServiceTypeAndRuntime(typeId, runtimeId);
+ }
+
+ moduleProject_.setItems(projectNames);
+ moduleProject_.setText(selectedModuleProject);
+ handleProjectChanged();
+ updateEARState();
+ listenersOn();
+ }
+
+ public void setEarProjectItems()
+ {
+ IVirtualComponent[] ears = J2EEUtils.getAllEARComponents();
+ String[] earProjectNames = new String[ears.length];
+ for (int i=0; i<earProjectNames.length; i++)
+ {
+ earProjectNames[i]=ears[i].getProject().getName();
+ }
+ earProject_.setItems(earProjectNames);
+
+ if (earProjectNames.length > 0)
+ earProject_.select(0);
+ }
+
+ private void handleProjectTypeChanged()
+ {
+ updateEARState();
+ }
+
+ private void handleProjectChanged()
+ {
+ updateTemplates();
+ }
+
+ private void updateTemplates()
+ {
+ String projectName = moduleProject_.getText();
+ if (projectName != null && projectName.length()>0)
+ {
+ IProject project = ProjectUtilities.getProject(projectName);
+ if (project.exists())
+ {
+ projectType_.setEnabled(false);
+ projectType_.deselectAll();
+ }
+ else
+ {
+ populateProjectTypeCombo();
+ projectType_.setEnabled(true);
+ }
+ }
+ }
+
+ private void populateProjectTypeCombo()
+ {
+ //Get the old value if there was one.
+ String oldTemplateId = getComponentType();
+
+ String[] templates = null;
+ if (trsIds_ != null)
+ {
+ if (isClient_)
+ {
+ templates = WebServiceRuntimeExtensionUtils2.getClientProjectTemplates(trsIds_.getTypeId(), trsIds_.getRuntimeId(), trsIds_.getServerId());
+ }
+ else
+ {
+ templates = WebServiceRuntimeExtensionUtils2.getServiceProjectTemplates(trsIds_.getTypeId(), trsIds_.getRuntimeId(), trsIds_.getServerId());
+ }
+
+ String[] templateLabels = FacetUtils.getTemplateLabels(templates);
+ projectType_.setItems(templateLabels);
+ templates_ = templates;
+
+ if (templates.length > 0)
+ {
+
+ //Select the previous template selection if that one is in the list.
+ int idx = getIndexOfTemplateId(templates, oldTemplateId);
+ if (idx > -1)
+ {
+ projectType_.select(idx);
+ }
+ else
+ {
+ // Select the preferred client project type.
+ ProjectTopologyContext ptc = WebServiceConsumptionUIPlugin.getInstance().getProjectTopologyContext();
+ String[] preferredTemplateIds = null;
+ if (isClient_)
+ {
+ preferredTemplateIds = ptc.getClientTypes();
+ }
+ else
+ {
+ preferredTemplateIds = ptc.getServiceTypes();
+ }
+
+ boolean selected = false;
+ outer: for (int j = 0; j < preferredTemplateIds.length; j++)
+ {
+ for (int i = 0; i < templates.length; i++)
+ {
+ String templateId = templates[i];
+ if (templateId.equals(preferredTemplateIds[j]))
+ {
+ projectType_.select(i);
+ selected = true;
+ break outer;
+ }
+ }
+ }
+
+ if (!selected)
+ {
+ projectType_.select(0);
+ }
+ }
+ }
+ }
+ }
+
+
+ private int getIndexOfTemplateId(String[] templateIds, String templateId)
+ {
+ for (int i=0; i<templateIds.length; i++)
+ {
+ if (templateIds[i].equals(templateId))
+ {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ private boolean isOSGISelected() {
+ try {
+ if(projectType_ != null && !projectType_.isDisposed()) {
+ int index = projectType_.getSelectionIndex();
+ if(index >= 0) {
+ String item = projectType_.getItem(index);
+ if(item != null) {
+ String id = FacetUtils.getTemplateIdByLabel(item);
+ if(DefaultingUtils.isOSGITemplate(id)) {
+ return true;
+ }
+
+ }
+ }
+ }
+
+ if(moduleProject_ != null && !moduleProject_.isDisposed()) {
+ String text = moduleProject_.getText();
+
+ if(text != null && text.trim().length() > 0 && DefaultingUtils.isOSGIProject(text)) {
+ return true;
+ }
+ }
+ } catch(Exception e) {
+ // Ignore -- First, do no harm.
+ e.printStackTrace();
+ }
+
+
+ return false;
+
+ }
+
+ private void updateTextForOSGI() {
+ try {
+
+ if(moduleProject_ != null) {
+
+ boolean isOSGISelected = isOSGISelected();
+
+ if(isOSGISelected) {
+
+ if(isClient_) {
+ earProjectLabel_.setText(ConsumptionUIMessages.LABEL_CLIENT_OSGI_PROJECT);
+ earProjectLabel_.setToolTipText(ConsumptionUIMessages.LABEL_CLIENT_OSGI_PROJECT);
+ earProject_.setToolTipText(ConsumptionUIMessages.LABEL_CLIENT_OSGI_PROJECT);
+ } else {
+ earProjectLabel_.setText(ConsumptionUIMessages.LABEL_SERVICE_OSGI_PROJECT);
+ earProjectLabel_.setToolTipText(ConsumptionUIMessages.LABEL_SERVICE_OSGI_PROJECT);
+ earProject_.setToolTipText(ConsumptionUIMessages.LABEL_SERVICE_OSGI_PROJECT);
+ }
+ } else {
+
+ if(isClient_) {
+ earProjectLabel_.setText(ConsumptionUIMessages.LABEL_CLIENT_EAR_PROJECT);
+ earProjectLabel_.setToolTipText(ConsumptionUIMessages.LABEL_CLIENT_EAR_PROJECT);
+ earProject_.setToolTipText(ConsumptionUIMessages.LABEL_CLIENT_EAR_PROJECT);
+ } else {
+ earProjectLabel_.setText(ConsumptionUIMessages.LABEL_SERVICE_EAR_PROJECT);
+ earProjectLabel_.setToolTipText(ConsumptionUIMessages.LABEL_SERVICE_EAR_PROJECT);
+ earProject_.setToolTipText(ConsumptionUIMessages.LABEL_SERVICE_EAR_PROJECT);
+ }
+
+ }
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ // Ignore -- First, do no harm.
+ }
+
+ }
+
+
+ private void updateEARState()
+ {
+ updateTextForOSGI();
+
+ if(!projectNeedsEAR(moduleProject_.getText()))
+ {
+ earProject_.setEnabled(false);
+ earProject_.setText("");
+ needEAR_ = false;
+ }
+ else
+ {
+ needEAR_ = true;
+ earProject_.setEnabled(true);
+ populateEARCombos();
+ }
+
+ }
+
+ private void populateEARCombos()
+ {
+ earProject_.removeAll();
+ setEarProjectItems();
+
+ String earName = "";
+
+ if(isOSGISelected()) {
+ earName = DefaultingUtils.getDefaultOSGIAppProjectName(moduleProject_.getText());
+ } else {
+ earName = DefaultingUtils.getDefaultEARProjectName(moduleProject_.getText());
+ }
+
+ earProject_.setText(earName);
+ }
+
+ private boolean projectNeedsEAR(String projectName)
+ {
+ //If the project is a simple Java project or the project type is
+ //Java utility return false.
+ if (projectName != null && projectName.length()>0)
+ {
+ IProject project = ProjectUtilities.getProject(projectName);
+ if (project.exists())
+ {
+ if (FacetUtils.isJavaProject(project))
+ {
+ return false;
+ }
+ }
+ }
+
+ //Project didn't rule out the need for an EAR
+ //so check the proect type
+ String templateId = getComponentType();
+ if (templateId != null && templateId.length()>0)
+ {
+ if (FacetUtils.isUtilityTemplate(templateId))
+ {
+ return false;
+ }
+ }
+
+
+ //Project or project type didn't rule out the need for an EAR
+ //so check the server type.
+ if (trsIds_ != null && trsIds_.getServerId() != null)
+ {
+ String targetId = ServerUtils.getRuntimeTargetIdFromFactoryId(trsIds_.getServerId());
+ if (targetId!=null && targetId.length()>0)
+ {
+ if (!ServerUtils.isTargetValidForEAR(targetId,"13")) //rm j2ee
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+
+ private IStatus handleSetMessageText() {
+ IStatus status = Status.OK_STATUS;
+ try {
+ byte result = (byte) 0;
+ if (moduleProject_.getText().length() != 0 && earProject_.getText().length() != 0) {
+ String projectText = moduleProject_.getText();
+ String earText = earProject_.getText();
+ IProject project = ResourceUtils.getWorkspaceRoot().getProject(projectText);
+ IProject ear = ResourceUtils.getWorkspaceRoot().getProject(earText);
+ if (project != null) {
+ if (!project.exists()) {
+ result = (byte) (result | CREATE_PROJECT);
+ }
+ if (!ear.exists()) {
+ result = (byte) (result | CREATE_EAR);
+ }
+
+ if (project.exists() && J2EEUtils.exists(project) && ear.exists() && J2EEUtils.exists(ear)) {
+ if (!J2EEUtils.isComponentAssociated(ear, project)) result = (byte) (result | ADD_EAR_ASSOCIATION);
+ }
+ }
+ }
+ if (isClient_) {
+ messageText_.setText(getValidationMessage(result, ConsumptionUIMessages.MSG_CLIENT_SUB));
+ }
+ else {
+ messageText_.setText(getValidationMessage(result, ConsumptionUIMessages.MSG_SERVICE_SUB));
+ }
+ parent_.layout(); //force message area resize/wrap
+ }
+ catch (Exception e) {
+ return StatusUtils.errorStatus( ConsumptionUIMessages.PAGE_MSG_VALIDATION_INTERNAL_ERROR, e );
+ }
+ return status;
+ }
+
+ private String getValidationMessage(byte result, String serviceOrClient) {
+ String msg = null;
+ boolean isOSGI = isOSGISelected();
+ switch (result) {
+ case 0:
+ return "";
+ case 1:
+ case 5:
+ msg = ConsumptionUIMessages.MSG_PROJECT_WILL_BE_CREATED;
+ break;
+ case 2:
+ case 6:
+ if(isOSGI) {
+ msg = ConsumptionUIMessages.MSG_OSGIAPP_WILL_BE_CREATED;
+ } else {
+ msg = ConsumptionUIMessages.MSG_EAR_WILL_BE_CREATED;
+ }
+ break;
+ case 3:
+ case 7:
+ if(isOSGI) {
+ msg = ConsumptionUIMessages.MSG_PROJECT_AND_OSGIAPP_CREATED;
+ } else {
+ msg = ConsumptionUIMessages.MSG_PROJECT_AND_EAR_CREATED;
+ }
+
+ break;
+ case 4:
+ if(isOSGI) {
+ msg = ConsumptionUIMessages.MSG_OSGIAPP_WILL_BE_ASSOCIATED;
+ } else {
+ msg = ConsumptionUIMessages.MSG_EAR_WILL_BE_ASSOCIATED;
+ }
+
+ break;
+ }
+ return msg != null ? NLS.bind(msg, new Object[] { serviceOrClient}) : "";
+ }
+
+ public IStatus getStatus()
+ {
+ IStatus finalStatus = Status.OK_STATUS;
+ handleSetMessageText();
+ String projectText = moduleProject_.getText();
+ String earText = earProject_.getText();
+
+ boolean isOSGI = isOSGISelected();
+
+ if (projectText==null || projectText.length()==0)
+ {
+ if (isClient_)
+ return StatusUtils.errorStatus( NLS.bind(ConsumptionUIMessages.MSG_CLIENT_PROJECT_EMPTY, new String[]{""} ) );
+ else
+ return StatusUtils.errorStatus( NLS.bind(ConsumptionUIMessages.MSG_SERVICE_PROJECT_EMPTY, new String[]{""} ) );
+ }
+
+ if (needEAR_ && (earText==null || earText.length()==0))
+ {
+ if (isClient_)
+ {
+ if(isOSGI) {
+ return StatusUtils.errorStatus( NLS.bind(ConsumptionUIMessages.MSG_CLIENT_OSGIAPP_EMPTY, new String[]{""} ) );
+ } else {
+ return StatusUtils.errorStatus( NLS.bind(ConsumptionUIMessages.MSG_CLIENT_EAR_EMPTY, new String[]{""} ) );
+ }
+
+ }
+ else
+ {
+ if(isOSGI) {
+ return StatusUtils.errorStatus( NLS.bind(ConsumptionUIMessages.MSG_SERVICE_OSGIAPP_EMPTY, new String[]{""} ) );
+ } else {
+ return StatusUtils.errorStatus( NLS.bind(ConsumptionUIMessages.MSG_SERVICE_EAR_EMPTY, new String[]{""} ) );
+ }
+
+ }
+ }
+
+ //If the project and EAR both exist and the project is not already associated with the EAR, ensure
+ //they can be associated.
+ if (needEAR_)
+ {
+ IProject p = ProjectUtilities.getProject(projectText.trim());
+ IProject ep = ProjectUtilities.getProject(earText.trim());
+ if (p.exists() && ep.exists())
+ {
+ if (!J2EEUtils.isComponentAssociated(ep,p))
+ {
+ boolean associateStatus = J2EEUtils.canAssociateProjectToEARWithoutWarning(p, ep);
+ if (!associateStatus)
+ {
+ if (isClient_)
+ {
+ return StatusUtils.warningStatus( NLS.bind(ConsumptionUIMessages.MSG_CLIENT_CANNOT_ASSOCIATE, new String[]{p.getName(), ep.getName()} ) );
+ }
+ else
+ {
+ return StatusUtils.warningStatus( NLS.bind(ConsumptionUIMessages.MSG_SERVICE_CANNOT_ASSOCIATE, new String[]{p.getName(), ep.getName()} ) );
+ }
+ }
+ }
+ }
+ }
+
+ return finalStatus;
+ }
+
+ private Widget[] createCombo( Composite parent, String labelName, String tooltip, String infopop, int style, IDialogSettings settings )
+ {
+ Widget[] result = new Widget[2];
+
+ tooltip = tooltip == null ? labelName : tooltip;
+ Combo combo;
+ if( labelName != null )
+ {
+ Label label = new Label( parent, SWT.WRAP);
+ label.setText( labelName );
+ label.setToolTipText( tooltip );
+ result[1] = label;
+ }
+ if (settings == null)
+ combo = new Combo( parent, style );
+ else
+ combo = new ComboWithHistory(parent, style, settings);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+
+ combo.setLayoutData( griddata );
+ combo.setToolTipText( tooltip );
+
+ if( infopop != null ) PlatformUI.getWorkbench().getHelpSystem().setHelp( combo, pluginId_ + "." + infopop );
+
+ result[0] = combo;
+
+ return result;
+
+ }
+
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestDelegateCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestDelegateCommand.java
new file mode 100644
index 000000000..660e4e760
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestDelegateCommand.java
@@ -0,0 +1,377 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2015 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060524 142635 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20060608 145529 kathy@ca.ibm.com - Kathy Chan
+ * 20080325 184761 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080610 224433 makandre@ca.ibm.com - Andrew Mak, Need better error message in sample JSP generation when Java proxy bean does not exist (cont.)
+ * 20150311 461526 jgwest@ca.ibm.com - Jonathan West, Allow OSGi bundles to be selected in the Wizard *
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import java.util.List;
+import java.util.Vector;
+
+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.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.context.ScenarioContext;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.jst.ws.internal.ext.test.WebServiceTestExtension;
+import org.eclipse.jst.ws.internal.ext.test.WebServiceTestRegistry;
+import org.eclipse.wst.command.internal.env.core.ICommandFactory;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.core.selection.BooleanSelection;
+import org.eclipse.wst.command.internal.env.core.selection.SelectionList;
+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.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.ws.internal.wsrt.IWebServiceTester;
+import org.eclipse.wst.ws.internal.wsrt.TestInfo;
+
+
+/*
+* The JSPGeneration task runs the jsp generation engine found in the
+* JBWizard Plugin
+*
+*
+*/
+public class ClientTestDelegateCommand extends AbstractDataModelOperation
+{
+ private WebServiceTestRegistry testRegistry;
+ private SelectionList testFacilities;
+ private String jspFolder;
+ private BooleanSelection[] methods;
+ private String sampleServerTypeID;
+ private IServer sampleExistingServer;
+ private String proxyBean;
+ private boolean runTestClient;
+ private boolean canRunTestClient = true;
+ private String sampleProject;
+ private String sampleP;
+ private String clientProject;
+ private String clientP;
+ private String clientC;
+ private boolean clientNeedEAR;
+ private String clientEarProjectName;
+ private String clientEarComponentName;
+ private TypeRuntimeServer serverIds;
+ private String serviceProject;
+ private String serviceP;
+ private String wsdlServiceURL;
+ private boolean isTestWidget = false;
+ private String setEndpointMethod;
+ private List endpoints;
+
+ private String clientOsgiAppProjectName;
+
+ public ClientTestDelegateCommand ()
+ {
+ testRegistry = WebServiceTestRegistry.getInstance();
+ }
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+ IStatus status = Status.OK_STATUS;
+ String clientTestID = testFacilities.getSelection();
+
+ //Get the webservice extension
+
+ WebServiceTestExtension wscte = (WebServiceTestExtension)testRegistry.getWebServiceExtensionsByName(clientTestID);
+ TestInfo testInfo = getTestInfo();
+
+ if (wscte.isCodeGenNeeded() && testInfo.getProxyBean() == null)
+ return StatusUtils.errorStatus(ConsumptionUIMessages.MSG_ERROR_JTS_PROXY_NOT_COMPILED);
+
+ IWebServiceTester iwst = (IWebServiceTester)wscte.getWebServiceExecutableExtension();
+
+ status = commandFactoryExecution(iwst.generate(testInfo),env, monitor );
+ if(status.getSeverity() == Status.ERROR){
+ return status;
+ }
+
+ testInfo.setRunTestClient(runTestClient);
+
+ if(canRunTestClient){
+ status = commandFactoryExecution(iwst.launch(testInfo),env, monitor );
+ if(status.getSeverity() == Status.ERROR){
+ return status;
+ }
+ }
+ return status;
+ }
+
+ private IStatus commandFactoryExecution(ICommandFactory commandFactory,IEnvironment env, IProgressMonitor monitor )
+ {
+ IStatus status = Status.OK_STATUS;
+
+ while(commandFactory.hasNext())
+ {
+ AbstractDataModelOperation operation = commandFactory.getNextCommand();
+ operation.setEnvironment( env );
+
+ try
+ {
+ status = operation.execute( monitor, null );
+ }
+ catch( Exception exc )
+ {
+ status = StatusUtils.errorStatus( exc );
+ }
+
+ if(status.getSeverity() == Status.ERROR){
+ IStatusHandler sHandler = env.getStatusHandler();
+ sHandler.reportError(status);
+ return status;
+ }
+ }
+ return status;
+ }
+
+
+ //Helper method which sets up the TestInfo data structure
+ private TestInfo getTestInfo()
+ {
+ IServer serviceExistingServer = null;
+ String serviceServerTypeID = null;
+
+ //service server info
+ if(serverIds != null){
+ if (serverIds.getServerInstanceId() != null)
+ serviceExistingServer = ServerCore.findServer(serverIds.getServerInstanceId());
+ }
+ if (serviceExistingServer != null)
+ serviceServerTypeID = serviceExistingServer.getServerType().getId();
+
+
+ if(clientProject != null){
+ int index = clientProject.indexOf("/");
+ if (index!=-1){
+ clientP = clientProject.substring(0,index);
+ clientC = clientProject.substring(index + 1);
+ }
+ }
+
+
+ if(sampleProject != null){
+ int index = sampleProject.indexOf("/");
+ if (index!=-1){
+ sampleP = sampleProject.substring(0,index);
+ }
+ }
+
+ TestInfo testInfo = new TestInfo();
+ testInfo.setClientExistingServer(sampleExistingServer);
+ testInfo.setClientServerTypeID(sampleServerTypeID);
+ testInfo.setJspFolder(jspFolder);
+ testInfo.setExternalBrowser(false);
+ testInfo.setEndpoint(endpoints);
+ testInfo.setGenerationProject(sampleP);
+ testInfo.setProxyBean(proxyBean);
+ testInfo.setSetEndpointMethod(setEndpointMethod);
+ testInfo.setClientProject(clientP);
+ testInfo.setClientModule(clientC);
+ testInfo.setClientNeedEAR(clientNeedEAR);
+ testInfo.setClientEARProject(clientEarProjectName);
+ testInfo.setClientEARModule(clientEarComponentName);
+ testInfo.setClientOsgiAppProject(clientOsgiAppProjectName);
+ testInfo.setMethods(methods);
+
+ //if this is a client scenario the service stuff is empty
+ if(serviceServerTypeID == null){
+ serviceServerTypeID = sampleServerTypeID;
+ serviceExistingServer = sampleExistingServer;
+ }
+
+
+ testInfo.setServiceServerTypeID(serviceServerTypeID);
+ testInfo.setServiceExistingServer(serviceExistingServer);
+ //wsdl stuff
+ testInfo.setServiceProject(getWSDLProject());
+ testInfo.setWsdlServiceURL(wsdlServiceURL);
+ return testInfo;
+ }
+
+
+
+ //The test facilities retrieved from the extension
+ //plus the default
+ public void setTestFacility(SelectionList selection)
+ {
+ testFacilities = selection;
+ }
+
+ public void setFolder(String folder)
+ {
+ }
+
+ public void setJspFolder(String jspFolder)
+ {
+ this.jspFolder = jspFolder;
+ }
+
+ public void setMethods(BooleanSelection[] methods)
+ {
+ this.methods = methods;
+ }
+
+ public void setRunTestClient(boolean runTestClient)
+ {
+ this.runTestClient = runTestClient;
+ }
+
+ public void setProxyBean(String proxyBean)
+ {
+ this.proxyBean = proxyBean;
+ }
+
+ public void setSampleProject(String sampleProject)
+ {
+ this.sampleProject = sampleProject;
+ }
+
+ public void setClientProject(String clientProject)
+ {
+ this.clientProject = clientProject;
+ }
+
+ public void setScenarioContext(ScenarioContext scenarioContext)
+ {
+ }
+
+ public void setClientTestRegistry(WebServiceTestRegistry testRegistry)
+ {
+ this.testRegistry = testRegistry;
+ }
+
+ public void setSampleServerTypeID(String sampleServerTypeID)
+ {
+ this.sampleServerTypeID = sampleServerTypeID;
+ }
+
+ public void setSampleExistingServer(IServer sampleExistingServer)
+ {
+ this.sampleExistingServer = sampleExistingServer;
+ }
+
+ public void setClientTypeRuntimeServer(TypeRuntimeServer ids)
+ {
+ }
+
+ public void setServiceTypeRuntimeServer(TypeRuntimeServer ids)
+ {
+ serverIds = ids;
+ }
+
+ public String getSampleServerTypeID()
+ {
+ return sampleServerTypeID;
+ }
+
+ public IServer getSampleExistingServer()
+ {
+ return sampleExistingServer;
+ }
+
+ public void setClientServer(String clientServer)
+ {
+ }
+
+ public void setServerProject(String serviceProject)
+ {
+ this.serviceProject = serviceProject;
+ }
+
+ public String getWSDLProject()
+ {
+ if(serviceProject != null){
+ int index = serviceProject.indexOf("/");
+ if (index!=-1) {
+ serviceP = serviceProject.substring(0,index);
+ return serviceP;
+ }
+ }
+
+ return clientP;
+ }
+
+ public void setWsdlURI(String wsdlServiceURL)
+ {
+ this.wsdlServiceURL = wsdlServiceURL;
+ }
+
+ public void setGenerateProxy(boolean generateProxy)
+ {
+ }
+
+ public boolean getIsTestWidget()
+ {
+ return isTestWidget;
+ }
+
+ public void setClientEarProjectName(String clientEarProjectName)
+ {
+ this.clientEarProjectName = clientEarProjectName;
+ }
+
+ public void setClientEarComponentName(String clientEarComponentName)
+ {
+ this.clientEarComponentName = clientEarComponentName;
+ }
+
+ public void setCanRunTestClient(boolean canRunTestClient){
+ this.canRunTestClient = canRunTestClient;
+ }
+
+ /**
+ * @param setEndpointMethod The setEndpointMethod to set.
+ */
+ public void setSetEndpointMethod(String setEndpointMethod)
+ {
+ this.setEndpointMethod = setEndpointMethod;
+ }
+ /**
+ * @param endpoint The endpoint to set.
+ */
+ public void setEndpoint(String endpoint)
+ {
+ if (endpoint != null && endpoint.length() > 0)
+ {
+ Vector v = new Vector();
+ v.add(endpoint);
+ setEndpoints(v);
+ }
+ }
+
+ public void setEndpoints(List endpoints)
+ {
+ this.endpoints = endpoints;
+ }
+
+ public boolean getClientNeedEAR() {
+ return clientNeedEAR;
+ }
+
+ public void setClientNeedEAR(boolean clientNeedEAR) {
+ this.clientNeedEAR = clientNeedEAR;
+ }
+
+ public void setClientOsgiAppProjectName(String clientOsgiAppProjectName) {
+ this.clientOsgiAppProjectName = clientOsgiAppProjectName;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestFragment.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestFragment.java
new file mode 100644
index 000000000..08638af05
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestFragment.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060727 144354 kathy@ca.ibm.com - Kathy Chan
+ * 20070502 180304 gilberta@ca.ibm.com - Gilbert Andrews
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import org.eclipse.wst.command.internal.env.core.common.Condition;
+import org.eclipse.wst.command.internal.env.core.fragment.BooleanFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
+
+
+public class ClientTestFragment extends BooleanFragment
+{
+ private boolean testService;
+ private boolean genProxy; // This actually represent whether client test is requested
+ private boolean launchedTest = false;
+ private boolean canGenProxy;
+
+ public ClientTestFragment( String id )
+ {
+ SequenceFragment clientTestRoot = new SequenceFragment();
+ Condition condition = new Condition()
+ {
+ public boolean evaluate()
+ {
+ return testService && genProxy;
+ }
+ };
+ setCondition( condition );
+
+
+ Condition jspCondition = new Condition()
+ {
+ public boolean evaluate()
+ {
+ return canGenProxy;
+ }
+ };
+
+ SimpleFragment simpleJSPFragment = new SimpleFragment( new WebServiceClientTestArrivalCommand(), "" );
+ BooleanFragment choiceJSPFragment = new BooleanFragment();
+ choiceJSPFragment.setTrueFragment(simpleJSPFragment);
+ choiceJSPFragment.setCondition(jspCondition);
+ clientTestRoot.add(choiceJSPFragment);
+
+ clientTestRoot.add( new SimpleFragment( id ) );
+ setTrueFragment( clientTestRoot );
+
+ }
+
+ public void setGenerateProxy( boolean genProxy )
+ {
+ this.genProxy = genProxy;
+ }
+
+ public void setCanGenerateProxy( boolean canGenProxy )
+ {
+ this.canGenProxy = canGenProxy;
+ }
+
+ public void setTestService( Boolean testService )
+ {
+ this.testService = testService.booleanValue();
+ }
+
+
+
+ public boolean getLaunchedTest()
+ {
+ return launchedTest;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestWidget.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestWidget.java
new file mode 100644
index 000000000..511b50a1e
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestWidget.java
@@ -0,0 +1,806 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2015 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060524 142635 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20060815 104870 makandre@ca.ibm.com - Andrew Mak, enable/disable test page controls base on settings in test facility extension
+ * 20060815 153903 makandre@ca.ibm.com - Andrew Mak, Browse does not work in generate client test page
+ * 20080325 184761 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080425 221232 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080506 227848 makandre@ca.ibm.com - Andrew Mak, Disabled "Run on Server" checkbox is in checked state
+ * 20080527 234192 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080616 237298 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080619 237797 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080723 241303 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080808 243602 rkklai@ca.ibm.com - Raymond Lai, fix NPE when changing runtime (the server combo)
+ * 20090302 242462 ericdp@ca.ibm.com - Eric D. Peters, Save Web services wizard settings
+ * 20090324 247535 mahutch@ca.ibm.com - Mark Hutchinson, Wrong server instance(s) is chosen during JAX-RPC sample generation
+ * 20150311 461526 jgwest@ca.ibm.com - Jonathan West, Allow OSGi bundles to be selected in the Wizard
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.jst.ws.internal.consumption.common.FacetUtils;
+import org.eclipse.jst.ws.internal.consumption.common.FolderResourceFilter;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.common.DefaultingUtils;
+import org.eclipse.jst.ws.internal.consumption.ui.common.LabelsAndIds;
+import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
+import org.eclipse.jst.ws.internal.ext.test.WebServiceTestExtension;
+import org.eclipse.jst.ws.internal.ext.test.WebServiceTestRegistry;
+import org.eclipse.jst.ws.internal.ui.common.ComboWithHistory;
+import org.eclipse.jst.ws.internal.ui.common.UIUtils;
+import org.eclipse.jst.ws.internal.ui.dialog.DialogUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.core.selection.BooleanSelection;
+import org.eclipse.wst.command.internal.env.core.selection.SelectionList;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
+import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
+import org.eclipse.wst.server.core.IRuntime;
+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.internal.facets.FacetUtil;
+
+
+public class ClientTestWidget extends SimpleWidgetDataContributor
+{
+ private String pluginId_ = "org.eclipse.jst.ws.consumption.ui";
+
+ /*CONTEXT_ID PWSM0001 for the Sample Page*/
+ private String INFOPOP_PWSM_PAGE = "PWSM0001";
+ //
+ private Button testCheckbox_;
+ /*CONTEXT_ID PWSM0002 for the Test check box of the Sample Page*/
+ private String INFOPOP_PWSM_CHECKBOX_TEST = "PWSM0002";
+
+ private Combo testTypeCombo_;
+ /*CONTEXT_ID PWSM0003 for the Test Type Combo box of the Sample Page*/
+ private String INFOPOP_PWSM_COMBOBOX_TEST = "PWSM0003";
+
+ private Combo runtimesCombo;
+ /*CONTEXT_ID PWSM0004 for the server type combo box of the Sample Page*/
+ private String INFOPOP_PWSM_COMBOBOX_SERVER = "PWSM0004";
+
+ private Combo serverInstanceTypeCombo_;
+ /*CONTEXT_ID PWSM0005 for the server instance combo box of the Sample Page*/
+ private String INFOPOP_PWSM_COMBOBOX_SERVER_INSTANCE = "PWSM0005";
+
+ private Text jspFolderText_;
+ /*CONTEXT_ID PWSM0008 for the JSP Folder field of the Sample Page*/
+ private String INFOPOP_PWSM_TEXT_JSP_FOLDER = "PWSM0008";
+
+ private Button sampleFolderBrowseButton_;
+ /*CONTEXT_ID PWSM0009 for the JSP Folder Browse button of the Sample Page*/
+ private String INFOPOP_PWSM_BUTTON_JSP_FOLDER_BROWSE = "PWSM0009";
+
+ private Text projectCombo_;
+ /*CONTEXT_ID PWSM0010 for the Project combo box of the Sample Page*/
+ private String INFOPOP_PWSM_COMBO_PROJECT = "PWSM0010";
+
+ private Tree methodsTree_;
+
+ private Button selectAllMethodsButton_;
+ /*CONTEXT_ID PWSM0006 for the Select All button of the Sample Page*/
+ private String INFOPOP_PWSM_BUTTON_SELECT_ALL = "PWSM0006";
+
+ private Button deselectAllMethodsButton_;
+ /*CONTEXT_ID PWSM0007 for the Deselect All button of the Sample Page*/
+ private String INFOPOP_PWSM_BUTTON_DESELECT_ALL = "PWSM0007";
+
+ private ComboWithHistory sampleFolderText_;
+ /*CONTEXT_ID PWSM0014 for the Folder field of the Sample Page*/
+ private String INFOPOP_PWSM_TEXT_SAMPLE_FOLDER = "PWSM0014";
+ private ModifyListener sampleFolderTextModifyListener;
+
+ //
+ private Button runTestCheckbox_;
+ /*CONTEXT_ID PWSM0015 for the run test check box of the Sample Page*/
+ private String INFOPOP_PWSM_CHECKBOX_LAUNCH = "PWSM0015";
+ //
+
+ private Label earLabel_;
+ private Text earCombo_;
+ /*CONTEXT_ID PWSM0016 for the EAR combo box of the Sample Page*/
+ private String INFOPOP_PWSM_EAR_COMBO = "PWSM0016";
+
+ private Composite comboGroup_;
+ private SelectionList testFacilities_;
+ private FolderResourceFilter folderFilter_ = new FolderResourceFilter();
+ private IStructuredSelection initialSelection_;
+ private boolean isTestWidget = false;
+ private boolean isPopup = false;
+ private boolean isWebProject = false;
+
+ private LabelsAndIds runtimes_;
+ private LabelsAndIds serverInstances_;
+
+ private IPath webContentPath_;
+ private IResource webContent_;
+
+ public WidgetDataEvents addControls( Composite parent, Listener statusListener )
+ {
+
+
+ isTestWidget = true;
+ UIUtils uiUtils = new UIUtils( pluginId_ );
+
+ parent.setToolTipText( ConsumptionUIMessages.TOOLTIP_PWSM_PAGE );
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( parent, pluginId_ + "." + INFOPOP_PWSM_PAGE );
+
+ testCheckbox_ = uiUtils.createCheckbox( parent, ConsumptionUIMessages.BUTTON_TEST,
+ ConsumptionUIMessages.TOOLTIP_PWSM_CHECKBOX_TEST,
+ INFOPOP_PWSM_CHECKBOX_TEST );
+ testCheckbox_.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent evt )
+ {
+ handleTestButton();
+ }
+ });
+
+ comboGroup_ = uiUtils.createComposite( parent, 3, 5, 0 );
+
+ testTypeCombo_ = uiUtils.createCombo( comboGroup_, ConsumptionUIMessages.LABEL_TEST_TYPES,
+ ConsumptionUIMessages.TOOLTIP_PWSM_COMBOBOX_TEST,
+ INFOPOP_PWSM_COMBOBOX_TEST,
+ SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY );
+ testTypeCombo_.addSelectionListener(
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleTestFacilitySelection();
+ }
+ }
+ );
+
+
+
+ new Label( comboGroup_, SWT.NONE );
+
+ projectCombo_ = uiUtils.createText( comboGroup_, ConsumptionUIMessages.LABEL_JSP_PROJECT_NAME,
+ ConsumptionUIMessages.TOOLTIP_PWSM_COMBO_PROJECT,
+ INFOPOP_PWSM_COMBO_PROJECT,
+ SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY );
+
+ new Label( comboGroup_, SWT.NONE );
+
+
+ Object[] earComboWidgets = createText( comboGroup_, ConsumptionUIMessages.LABEL_EAR_PROJECTS,
+ ConsumptionUIMessages.TOOLTIP_PWSM_EAR_PROJECT,
+ INFOPOP_PWSM_EAR_COMBO,
+ SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY );
+
+ earCombo_ = (Text)earComboWidgets[0];
+ earLabel_ = (Label)earComboWidgets[1];
+
+ new Label( comboGroup_, SWT.NONE );
+
+ sampleFolderText_ = uiUtils.createComboWithHistory(comboGroup_, ConsumptionUIMessages.LABEL_FOLDER_NAME,
+ ConsumptionUIMessages.TOOLTIP_PWSM_TEXT_SAMPLE_FOLDER,
+ INFOPOP_PWSM_TEXT_SAMPLE_FOLDER,
+ SWT.SINGLE | SWT.BORDER , WebServiceConsumptionUIPlugin.getInstance().getDialogSettings());
+
+
+ sampleFolderTextModifyListener = new ModifyListener()
+ {
+ public void modifyText(ModifyEvent evt) {
+ handleFolderText();
+ }
+
+ };
+
+ sampleFolderText_.addModifyListener(sampleFolderTextModifyListener);
+
+ sampleFolderBrowseButton_ = uiUtils.createPushButton( comboGroup_, ConsumptionUIMessages.BUTTON_BROWSE,
+ ConsumptionUIMessages.TOOLTIP_PWSM_BUTTON_JSP_FOLDER_BROWSE,
+ INFOPOP_PWSM_BUTTON_JSP_FOLDER_BROWSE );
+ sampleFolderBrowseButton_.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent evt )
+ {
+ handleSampleBrowse();
+ }
+ });
+
+ jspFolderText_ = uiUtils.createText(comboGroup_, ConsumptionUIMessages.LABEL_JSP_FOLDER_NAME,
+ ConsumptionUIMessages.TOOLTIP_PWSM_TEXT_JSP_FOLDER,
+ INFOPOP_PWSM_TEXT_JSP_FOLDER,
+ SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY );
+
+
+ new Label( comboGroup_, SWT.NONE );
+
+ Group methodsGroup = uiUtils.createGroup( parent, ConsumptionUIMessages.LABEL_METHODS,
+ ConsumptionUIMessages.TOOLTIP_PWSM_TREE_METHODS, null );
+
+ methodsGroup.setLayoutData( uiUtils.createFillAll() );
+
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ methodsGroup.setLayout( layout );
+
+ // TODO No infopop for this tree.
+ methodsTree_ = uiUtils.createTree( methodsGroup, ConsumptionUIMessages.TOOLTIP_PWSM_TREE_METHODS,
+ null,
+ SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.CHECK );
+
+ Composite selectButtons = uiUtils.createComposite( methodsGroup, 2 );
+
+ selectAllMethodsButton_
+ = uiUtils.createPushButton( selectButtons, ConsumptionUIMessages.BUTTON_SELECT_ALL,
+ ConsumptionUIMessages.TOOLTIP_PWSM_BUTTON_SELECT_ALL,
+ INFOPOP_PWSM_BUTTON_SELECT_ALL );
+ selectAllMethodsButton_.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent evt )
+ {
+ handleSelectAll( true );
+ }
+ });
+
+ deselectAllMethodsButton_
+ = uiUtils.createPushButton( selectButtons, ConsumptionUIMessages.BUTTON_DESELECT_ALL,
+ ConsumptionUIMessages.TOOLTIP_PWSM_BUTTON_DESELECT_ALL,
+ INFOPOP_PWSM_BUTTON_DESELECT_ALL );
+ deselectAllMethodsButton_.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent evt )
+ {
+ handleSelectAll( false );
+ }
+ });
+
+ runTestCheckbox_ = uiUtils.createCheckbox( parent, ConsumptionUIMessages.BUTTON_RUN_TEST,
+ ConsumptionUIMessages.TOOLTIP_PWSM_CHECKBOX_LAUNCH,
+ INFOPOP_PWSM_CHECKBOX_LAUNCH );
+ runTestCheckbox_.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent evt )
+ {
+ handleRunTestCheckBox();
+ }
+ });
+
+ return this;
+ }
+
+ private void handleRunTestCheckBox(){
+ boolean enabled = runTestCheckbox_.getSelection();
+ runtimesCombo.setEnabled(enabled);
+ serverInstanceTypeCombo_.setEnabled(enabled);
+
+ }
+
+ private void handleFolderText()
+ {
+ // webContentPath_ is set when jspFolderText_ is set for the first time. Therefore,
+ // if webContentPath_ is still null, there is no need to touch jspFolderText_ yet.
+
+ if (webContentPath_ == null)
+ return;
+
+ String folder = sampleFolderText_.getText();
+ jspFolderText_.setText(webContentPath_.toString() + IPath.SEPARATOR + folder);
+ }
+
+ private void handleSampleBrowse()
+ {
+ IPath selectedPath = null;
+ IResource initialResource = null;
+
+ try
+ {
+ initialResource = ResourceUtils.getResourceFromSelection( initialSelection_ );
+ }
+ catch( CoreException exc )
+ {
+ }
+
+ if( initialResource == null )initialResource = webContent_;
+
+ IResource resource = DialogUtils.browseResources( comboGroup_.getShell(),
+ webContent_,
+ initialResource,
+ folderFilter_ );
+
+ if( resource != null )
+ {
+ selectedPath = resource.getFullPath();
+
+ int webModuleSegments = selectedPath.matchingFirstSegments(webContentPath_);
+
+ sampleFolderText_.removeModifyListener(sampleFolderTextModifyListener);
+ sampleFolderText_.removeAll();
+
+ if ( webModuleSegments < webContentPath_.segmentCount() )
+ {
+ sampleFolderText_.add("", 0);
+ handleFolderText();
+ }
+ else
+ {
+ sampleFolderText_.add(selectedPath.removeFirstSegments(webModuleSegments).toString(), 0);
+ handleFolderText();
+ }
+ sampleFolderText_.select(0);
+ sampleFolderText_.restoreWidgetHistory("org.eclipse.jst.ws.internal.consumption.ui.widgets.test.ClientTestWidget.sampleFolderText_");
+ sampleFolderText_.addModifyListener(sampleFolderTextModifyListener);
+
+ }
+ }
+
+ private void handleTestButton()
+ {
+ boolean enabled = testCheckbox_.getSelection();
+
+ testTypeCombo_.setEnabled( enabled );
+
+ if (enabled && testFacilities_ != null) {
+ handleTestFacilitySelection();
+ return;
+ }
+
+ sampleFolderText_.setEnabled( enabled );
+ methodsTree_.setEnabled( enabled );
+ if(canRunTestClient_)
+ runTestCheckbox_.setEnabled( enabled );
+ selectAllMethodsButton_.setEnabled( enabled );
+ deselectAllMethodsButton_.setEnabled( enabled );
+ sampleFolderBrowseButton_.setEnabled( enabled );
+
+
+
+ }
+
+ private void handleTestFacilitySelection() {
+
+ String clientTestID = getTestFacility().getSelection();
+
+ WebServiceTestExtension testExtension =
+ (WebServiceTestExtension) WebServiceTestRegistry.getInstance()
+ .getWebServiceExtensionsByName(clientTestID);
+
+ boolean hasCodeGen = testExtension.isCodeGenNeeded();
+
+ // folder selection is only applicable for test facilities with codegen
+ sampleFolderText_.setEnabled( hasCodeGen );
+ sampleFolderBrowseButton_.setEnabled( hasCodeGen && webContent_ != null );
+
+ boolean hasMethods = testExtension.areMethodsNeeded();
+
+ // method selection is only applicable for test facilities with methods
+ methodsTree_.setEnabled( hasMethods );
+ selectAllMethodsButton_.setEnabled( hasMethods );
+ deselectAllMethodsButton_.setEnabled( hasMethods );
+
+ // run on server only applicable for test facilities that needs launching
+ if(canRunTestClient_)
+ runTestCheckbox_.setEnabled( testExtension.isServerNeeded() );
+ }
+
+ private void handleSelectAll( boolean value )
+ {
+ TreeItem[] items = methodsTree_.getItems();
+
+ for( int i = 0; i < items.length; i++ )
+ {
+ items[i].setChecked(value);
+ }
+ }
+
+ private void handleServerChange()
+ {
+ int selection = runtimesCombo.getSelectionIndex();
+ serverInstances_.clear();
+ serverInstanceTypeCombo_.removeAll();
+ IServer[] servers = org.eclipse.wst.server.core.ServerCore.getServers();
+ for(int j =0; j<servers.length;j++){
+ String id = runtimes_.getId(selection);
+ if(id.equals(servers[j].getServerType().getId())){
+ serverInstances_.add(servers[j].getId(), servers[j].getName());
+ serverInstanceTypeCombo_.add(servers[j].getName());
+ }
+ }
+ serverInstanceTypeCombo_.select(0);
+
+ serverInstanceTypeCombo_.setEnabled(serverInstances_.size() > 0 );
+ }
+
+ // Here are the getters and setters for this widget.
+ public void setTestService( Boolean testService )
+ {
+ testCheckbox_.setSelection( testService.booleanValue() );
+ handleTestButton();
+ }
+
+ public Boolean getTestService()
+ {
+ return new Boolean( testCheckbox_.getSelection() );
+ }
+
+ public void setTestFacility( SelectionList testFacilities )
+ {
+ testFacilities_ = testFacilities;
+ testTypeCombo_.setItems( testFacilities.getList() );
+ testTypeCombo_.select( testFacilities.getIndex() );
+ handleTestFacilitySelection();
+ }
+
+ public SelectionList getTestFacility()
+ {
+ testFacilities_.setIndex( testTypeCombo_.getSelectionIndex() );
+ return testFacilities_;
+ }
+
+ public String getTestID()
+ {
+ return testTypeCombo_.getText();
+ }
+
+ /**
+ * Given a project name which may be of the (obsolete) format "project/module",
+ * return only the project part of the name
+ *
+ * @param project The project name.
+ * @return If the name has the format "project/module", returns only "project",
+ * otherwise returns the name as is.
+ */
+ private String extractProjectName(String project) {
+
+ int index = project.indexOf("/");
+
+ if (index != -1)
+ project = project.substring(0, index);
+
+ return project;
+ }
+
+ private String getServerTypeIdForRuntime(IRuntime rt) {
+ IServerType[] serverTypes = ServerCore.getServerTypes();
+ for (IServerType sType : serverTypes) {
+ if (sType.getRuntimeType() == rt.getRuntimeType() ){
+ return sType.getId();
+
+ }
+ }
+ return null;
+ }
+
+ public void initServersTypes()
+ {
+ if(runtimes_ == null)
+ runtimes_ = new LabelsAndIds();
+ IServer[] servers = org.eclipse.wst.server.core.ServerCore.getServers();
+ IRuntime[] runtimes = org.eclipse.wst.server.core.ServerCore.getRuntimes();
+
+ String projectName = projectCombo_.getText();
+
+ Set projectFacets = FacetUtils.getFacetsForProject(projectName);
+ for(int i = 0;i<runtimes.length;i++){
+ boolean showServer = false;
+
+ if(runtimes[i].isStub()){
+ for(int l =0; l<servers.length;l++){
+ if(servers[l].getRuntime() != null){
+ if(runtimes[i].getId().equals(servers[l].getRuntime().getId())){
+ showServer = true;
+ }
+ }
+ }
+ }
+ else showServer = true;
+
+ if(showServer && canRunTestClient_){
+ if(isWebProject){
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime runtime = FacetUtil.getRuntime(runtimes[i]);
+ if(FacetUtils.doesRuntimeSupportFacets(runtime, projectFacets)){
+ runtimes_.add(getServerTypeIdForRuntime(runtimes[i]), runtimes[i].getName());
+ runtimesCombo.add( runtimes[i].getName() );
+ }
+ }
+ else{
+ runtimes_.add(getServerTypeIdForRuntime(runtimes[i]), runtimes[i].getName());
+ runtimesCombo.add( runtimes[i].getName() );
+ }
+ }
+ }
+
+ runtimesCombo.select(0);
+ if(serverInstances_ == null)
+ serverInstances_ = new LabelsAndIds();
+
+
+ String id = runtimes_.getId(0);
+ if(id != null){
+ for(int k =0; k<servers.length;k++){
+ if(servers[k].getServerType() != null){
+ if(id.equals(servers[k].getServerType().getId())&& canRunTestClient_){
+ serverInstances_.add(servers[k].getId(), servers[k].getName());
+ serverInstanceTypeCombo_.add(servers[k].getName());
+ }
+ }
+ }
+ serverInstanceTypeCombo_.select(0);
+ }
+
+ serverInstanceTypeCombo_.setEnabled(canRunTestClient_ && runTestCheckbox_.getSelection());
+ runtimesCombo.setEnabled(canRunTestClient_ && runTestCheckbox_.getSelection());
+ }
+
+
+
+
+ public void setSampleProject(String clientProject)
+ {
+ projectCombo_.setText(extractProjectName(clientProject));
+ }
+
+ public void setSampleProjectEAR(String clientProjectEAR)
+ {
+ earCombo_.setText(extractProjectName(clientProjectEAR));
+ updateEARText();
+ }
+
+ public String getFolder()
+ {
+ return sampleFolderText_.getText();
+ }
+
+ public void setFolder( String folder )
+ {
+ sampleFolderText_.removeModifyListener(sampleFolderTextModifyListener);
+ sampleFolderText_.removeAll();
+ sampleFolderText_.add( folder);
+ sampleFolderText_.select(0);
+ sampleFolderText_.addModifyListener(sampleFolderTextModifyListener);
+
+ }
+
+ public boolean getIsTestWidget()
+ {
+ return isTestWidget;
+ }
+
+ public void setJspFolder( String folder )
+ {
+ webContentPath_ = (new Path(folder)).removeLastSegments(1);
+ webContent_ = ResourceUtils.findResource(webContentPath_);
+ sampleFolderBrowseButton_.setEnabled(webContent_ != null);
+
+ jspFolderText_.setText( folder );
+ }
+
+ public String getJspFolder()
+ {
+ return jspFolderText_.getText();
+ }
+
+ public void setLaunchedServiceTestName (String launchedServiceTestName)
+ {
+ }
+
+ public boolean getRunTestClient()
+ {
+ return runTestCheckbox_.getSelection();
+ }
+
+ public void setRunTestClient( boolean value )
+ {
+ runTestCheckbox_.setSelection( value );
+ }
+
+ public void setIsWebProject( boolean value )
+ {
+ isWebProject = value;
+ }
+
+ private boolean canRunTestClient_;
+
+ public void setCanRunTestClient(boolean canRunTestClient){
+ canRunTestClient_ = canRunTestClient;
+ if(!canRunTestClient_) {
+ runTestCheckbox_.setSelection(false);
+ runTestCheckbox_.setEnabled(false);
+ }
+ }
+
+ public void setPopup(boolean popup){
+ isPopup = popup;
+ if(isPopup){
+ UIUtils uiUtils = new UIUtils( pluginId_ );
+ runtimesCombo = uiUtils.createCombo( comboGroup_, ConsumptionUIMessages.LABEL_SERVERS_LIST,
+ ConsumptionUIMessages.TOOLTIP_PWSM_COMBOBOX_SERVER,
+ INFOPOP_PWSM_COMBOBOX_SERVER,
+ SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY );
+ runtimesCombo.addSelectionListener(
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleServerChange();
+ }
+ }
+ );
+
+ new Label( comboGroup_, SWT.NONE );
+
+
+ serverInstanceTypeCombo_ = uiUtils.createCombo( comboGroup_, ConsumptionUIMessages.LABEL_SERVERS_INSTANCES,
+ ConsumptionUIMessages.TOOLTIP_PWSM_COMBOBOX_SERVER_INSTANCE,
+ INFOPOP_PWSM_COMBOBOX_SERVER_INSTANCE,
+ SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY );
+
+ new Label( comboGroup_, SWT.NONE );
+ initServersTypes();
+
+ }
+ }
+
+ public boolean getCanRunTestClient()
+ {
+ return canRunTestClient_;
+ }
+
+ public String getServerInstanceId(){
+ int instanceLabel = serverInstanceTypeCombo_.getSelectionIndex();
+ if(instanceLabel == -1) return null;
+ return serverInstances_.getId(instanceLabel);
+ }
+
+
+ public String getExistingServerId(){
+ int typeLabel = runtimesCombo.getSelectionIndex();
+ if(typeLabel == -1) return null;
+ return runtimes_.getId(typeLabel);
+ }
+
+ public BooleanSelection[] getMethods()
+ {
+ TreeItem[] items = methodsTree_.getItems();
+ BooleanSelection[] methods = new BooleanSelection[items.length];
+
+ for( int index = 0; index < items.length; index++ )
+ {
+ methods[index] = new BooleanSelection( items[index].getText(), items[index].getChecked() );
+ }
+
+ return methods;
+ }
+
+ public void setMethods( BooleanSelection[] methods )
+ {
+ methodsTree_.removeAll();
+
+ for( int index = 0; index < methods.length; index++ )
+ {
+ if(methods[index] == null)continue;
+ TreeItem item = new TreeItem( methodsTree_, SWT.NULL );
+ item.setText( methods[index].getValue() );
+ item.setChecked( methods[index].isSelected() );
+ }
+ }
+
+ public void setInitialSelection( IStructuredSelection selection )
+ {
+ initialSelection_ = selection;
+ }
+
+ public IStatus getStatus() {
+ if(!canRunTestClient_)
+ return StatusUtils.warningStatus(ConsumptionUIMessages.MSG_SERVER_NOT_FOUND_WARNING);
+
+ return Status.OK_STATUS;
+ }
+
+public void externalize() {
+ super.externalize();
+ sampleFolderText_.storeWidgetHistory("org.eclipse.jst.ws.internal.consumption.ui.widgets.test.ClientTestWidget.sampleFolderText_");
+}
+
+public void internalize() {
+ sampleFolderText_.removeModifyListener(sampleFolderTextModifyListener);
+ sampleFolderText_.restoreWidgetHistory("org.eclipse.jst.ws.internal.consumption.ui.widgets.test.ClientTestWidget.sampleFolderText_");
+ sampleFolderText_.addModifyListener(sampleFolderTextModifyListener);
+}
+
+
+
+ /** Returns [ Text, Label] */
+ private Object[] createText( Composite parent, String labelName, String tooltip, String infopop, int style )
+ {
+ tooltip = tooltip == null ? labelName : tooltip;
+
+ Label label = null;
+ if( labelName != null )
+ {
+ label = new Label( parent, SWT.LEAD);
+ label.setText( labelName );
+ label.setToolTipText( tooltip );
+ }
+
+ Text text = new Text( parent, style );
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+
+ text.setLayoutData( griddata );
+ text.setToolTipText( tooltip);
+
+ if( infopop != null ) PlatformUI.getWorkbench().getHelpSystem().setHelp( text, pluginId_ + "." + infopop );
+
+ Object[] result = new Object[2];
+ result[0] = text;
+ result[1] = label;
+
+ return result;
+ }
+
+
+ private boolean isOSGI()
+ {
+ if(earCombo_ != null)
+ {
+ if(DefaultingUtils.isOSGIProject(earCombo_.getText()))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ private void updateEARText() {
+ if(isOSGI() ) {
+ if(earCombo_ != null) {
+ earCombo_.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWSM_OSGI_PROJECT);
+ }
+ if(earLabel_ != null) {
+ earLabel_.setText(ConsumptionUIMessages.LABEL_OSGI_PROJECTS);
+ earLabel_.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWSM_OSGI_PROJECT);
+ }
+
+
+ } else {
+ if(earCombo_ != null) {
+ earCombo_.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWSM_EAR_PROJECT);
+ }
+ if(earLabel_ != null) {
+ earLabel_.setText(ConsumptionUIMessages.LABEL_EAR_PROJECTS);
+ earLabel_.setToolTipText(ConsumptionUIMessages.TOOLTIP_PWSM_EAR_PROJECT);
+ }
+
+ }
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/CopyWebServiceUtilsJarCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/CopyWebServiceUtilsJarCommand.java
new file mode 100644
index 000000000..b87d2725f
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/CopyWebServiceUtilsJarCommand.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * 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
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060912 157039 makandre@ca.ibm.com - Andrew Mak, new webserviceutils.jar not copied in client generation
+ * 20061025 161250 makandre@ca.ibm.com - Andrew Mak, Installations or workspace paths with spaces break Sample Gen and Java Editor Launch
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import java.io.File;
+import java.net.URL;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.FileLocator;
+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.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages;
+import org.eclipse.jst.ws.internal.consumption.plugin.WebServiceConsumptionPlugin;
+import org.eclipse.wst.command.internal.env.common.FileResourceUtils;
+import org.eclipse.wst.command.internal.env.core.common.ProgressUtils;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.core.context.ResourceContext;
+import org.eclipse.wst.command.internal.env.core.context.TransientResourceContext;
+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.common.BundleUtils;
+
+
+public class CopyWebServiceUtilsJarCommand extends AbstractDataModelOperation
+{
+ private String sampleProject;
+
+/**
+ * Default CTOR;
+ */
+
+
+public CopyWebServiceUtilsJarCommand()
+{
+
+}
+
+/**
+ * Execute the command
+ */
+public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+{
+ IEnvironment env = getEnvironment();
+
+ try
+ {
+ ProgressUtils.report( monitor, ConsumptionMessages.PROGRESS_INFO_COPY_WEBSERVICE_UTILS );
+ IProject sampleIProject = ProjectUtilities.getProject(sampleProject);
+ IPath webModulePath = J2EEUtils.getWebContentPath(sampleIProject);
+ if (webModulePath == null)
+ return StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_PROJECT_NOT_FOUND );
+
+ IStatus status = copyIFile("webserviceutils.jar",webModulePath,"WEB-INF/lib/webserviceutils.jar", WebServiceConsumptionPlugin.getInstance(),env, monitor);
+ if(status.getSeverity() == Status.ERROR){
+ IStatusHandler sHandler = env.getStatusHandler();
+ IStatus errorStatus = StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_FILECOPY_WEBSERVICE_UTILS );
+ sHandler.reportError(errorStatus);
+ return status;
+ }
+
+
+ }
+ catch (Exception e) {
+ IStatusHandler sHandler = env.getStatusHandler();
+ IStatus errorStatus = StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_FILECOPY_WEBSERVICE_UTILS );
+ sHandler.reportError(errorStatus);
+ return StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_FILECOPY_WEBSERVICE_UTILS, e);
+ }
+ return Status.OK_STATUS;
+}
+
+/**
+ *
+ */
+private IStatus copyIFile(String source, IPath targetPath, String targetFile, Plugin plugin,IEnvironment env, IProgressMonitor monitor )
+{
+
+ if (plugin != null)
+ {
+ IPath target = targetPath.append(new Path(targetFile));
+
+ ProgressUtils.report( monitor, ConsumptionMessages.PROGRESS_INFO_COPYING_FILE );
+ try
+ {
+ ResourceContext context = new TransientResourceContext();
+ context.setOverwriteFilesEnabled(true);
+ context.setCreateFoldersEnabled(true);
+ context.setCheckoutFilesEnabled(true);
+ IResource resource = FileResourceUtils.findResource(target);
+ URL sourceURL = BundleUtils.getURLFromBundle( WebServiceConsumptionPlugin.ID, source );
+ if(resource != null) {
+ File sourceFile = new File(FileLocator.toFileURL(sourceURL).getPath());
+ if (resource.getLocation().toFile().length() == sourceFile.length())
+ return Status.OK_STATUS;
+ }
+ FileResourceUtils.createFile(context,
+ target,
+ sourceURL.openStream(),
+ monitor,
+ env.getStatusHandler());
+ }
+ catch (Exception e) {
+ return StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_FILECOPY_WEBSERVICE_UTILS ,e);
+ }
+ }
+ return Status.OK_STATUS;
+}
+
+public void setSampleProject(String sampleProject)
+{
+ this.sampleProject = sampleProject;
+}
+
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/FinishDefaultCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/FinishDefaultCommand.java
new file mode 100644
index 000000000..df4282269
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/FinishDefaultCommand.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * -------- -------- -----------------------------------------------------------
+ * 20080425 221232 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080527 234169 gilberta@ca.ibm.com - Gilbert Andrews
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+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.jst.ws.internal.consumption.command.common.CreateServerCommand;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+
+
+/*
+* The JSPGeneration task runs the jsp generation engine found in the
+* JBWizard Plugin
+*
+*
+*/
+public class FinishDefaultCommand extends AbstractDataModelOperation
+{
+ private String sampleServerTypeID;
+ private IServer sampleExistingServer;
+ private String sampleServerInstanceId;
+
+
+ public FinishDefaultCommand ()
+ {
+ }
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IStatus status = Status.OK_STATUS;
+ if(sampleServerInstanceId != null){
+ sampleExistingServer = ServerCore.findServer(sampleServerInstanceId);
+ if (sampleExistingServer != null)
+ sampleServerTypeID = sampleExistingServer.getServerType().getId();
+ }
+ else if(sampleServerTypeID != null){
+ CreateServerCommand createServer = new CreateServerCommand();
+ createServer.setServerFactoryid(sampleServerTypeID);
+ createServer.execute(monitor, adaptable);
+ sampleServerInstanceId = createServer.getServerInstanceId();
+ if(sampleServerInstanceId != null)
+ sampleExistingServer = ServerCore.findServer(sampleServerInstanceId);
+
+ }
+ return status;
+
+ }
+
+ public void setServerInstanceId(String serverInstanceId)
+ {
+ this.sampleServerInstanceId = serverInstanceId;
+ }
+
+ public String getSampleServerTypeID()
+ {
+ return sampleServerTypeID;
+
+ }
+
+ public IServer getSampleExistingServer()
+ {
+ return sampleExistingServer;
+ }
+
+ public void setExistingServerId(String existingServerId)
+ {
+ sampleServerTypeID=existingServerId;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/FinishJavaTestFragment.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/FinishJavaTestFragment.java
new file mode 100644
index 000000000..94ca347e7
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/FinishJavaTestFragment.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+/*
+ * Created on May 4, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import org.eclipse.jst.ws.internal.consumption.command.common.BuildProjectCommand;
+import org.eclipse.wst.command.internal.env.core.common.Condition;
+import org.eclipse.wst.command.internal.env.core.fragment.BooleanFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
+
+
+/**
+ * @author gilberta
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class FinishJavaTestFragment extends BooleanFragment
+{
+ private boolean generateProxy;
+
+ public FinishJavaTestFragment()
+ {
+ SequenceFragment javaTestRoot = new SequenceFragment();
+ Condition condition = new Condition()
+ {
+ public boolean evaluate()
+ {
+ return generateProxy;
+ }
+ };
+ setCondition(condition);
+ javaTestRoot.add(new SimpleFragment(new TestClientDepartureInitCommand(), ""));
+ javaTestRoot.add(new SimpleFragment(new BuildProjectCommand(), ""));
+ setTrueFragment(javaTestRoot);
+ }
+
+ public void setGenerateProxy(boolean generateProxy)
+ {
+ this.generateProxy = generateProxy;
+ }
+
+ public void setIsJSPGen(boolean jspGen)
+ {
+
+ }
+
+
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/FinishTestFragment.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/FinishTestFragment.java
new file mode 100644
index 000000000..c9eb16fe2
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/FinishTestFragment.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060727 144354 kathy@ca.ibm.com - Kathy Chan
+ * 20070502 180304 gilberta@ca.ibm.com - Gilbert Andrews
+ *******************************************************************************/
+/*
+ * Created on May 4, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import org.eclipse.jst.ws.internal.context.ScenarioContext;
+import org.eclipse.jst.ws.internal.ext.test.WebServiceTestExtension;
+import org.eclipse.jst.ws.internal.ext.test.WebServiceTestRegistry;
+import org.eclipse.jst.ws.internal.plugin.WebServicePlugin;
+import org.eclipse.wst.command.internal.env.core.common.Condition;
+import org.eclipse.wst.command.internal.env.core.fragment.BooleanFragment;
+
+
+/**
+ * @author gilberta
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class FinishTestFragment extends BooleanFragment{
+
+ private boolean isTestWidget;
+ private boolean generateProxy; // This actually represent whether client test is requested
+ private String launchedServiceTestName;
+ private boolean testService;
+ private String testID;
+ public FinishTestFragment()
+ {
+ Condition condition = new Condition()
+ {
+ public boolean evaluate()
+ {
+ if(!testService) return false;
+ if(launchedServiceTestName == null) return true;
+ if(launchedServiceTestName != null)
+ if((!launchedServiceTestName.equals("") && (!isPreferedAWSDLTest() || (isTestWidget && isClientTestJava())) && generateProxy) || launchedServiceTestName.equals("")) return true;
+
+ return false;
+ }
+ };
+
+ setTrueFragment(new WebServiceTestClientDepartureFragment());
+ setCondition(condition);
+ }
+
+ public void setLaunchedServiceTestName(String launchedServiceTestName)
+ {
+ this.launchedServiceTestName = launchedServiceTestName;
+ }
+
+ public boolean isPreferedAWSDLTest()
+ {
+ ScenarioContext scenarioContext = WebServicePlugin.getInstance().getScenarioContext().copy();
+ String[] testTypes = scenarioContext.getWebServiceTestTypes();
+ WebServiceTestRegistry wsttRegistry = WebServiceTestRegistry.getInstance();
+ WebServiceTestExtension wscte = (WebServiceTestExtension)wsttRegistry.getWebServiceExtensionsByName(testTypes[0]);
+ if(wscte.testWSDL())
+ return true;
+ return false;
+ }
+
+ public boolean isClientTestJava()
+ {
+ if(testID == null) return false;
+ WebServiceTestRegistry wsttRegistry = WebServiceTestRegistry.getInstance();
+ WebServiceTestExtension wscte = (WebServiceTestExtension)wsttRegistry.getWebServiceExtensionsByName(testID);
+ if(!wscte.testWSDL())
+ return true;
+ return false;
+ }
+
+
+ public void setTestService(boolean testService)
+ {
+ this.testService = testService;
+ }
+
+ public void setCanGenerateProxy(boolean generateProxy)
+ {
+ this.generateProxy = generateProxy;
+ }
+
+ public void setTestID(String testID)
+ {
+ this.testID = testID;
+ }
+
+ public void setIsTestWidget(boolean isTestWidget)
+ {
+ this.isTestWidget = isTestWidget;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/TestClientDepartureInitCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/TestClientDepartureInitCommand.java
new file mode 100644
index 000000000..21f2f7466
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/TestClientDepartureInitCommand.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+/*
+ * Created on Mar 25, 2004
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import org.eclipse.core.commands.ExecutionException;
+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.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+
+/**
+ * @author gilberta
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class TestClientDepartureInitCommand extends AbstractDataModelOperation
+{
+
+ private boolean forceBuild;
+
+ public TestClientDepartureInitCommand()
+ {
+ forceBuild = true;
+ }
+
+ public boolean getForceBuild()
+ {
+ return forceBuild;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ return Status.OK_STATUS;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/TestDefaultingFragment.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/TestDefaultingFragment.java
new file mode 100644
index 000000000..e1b94fc30
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/TestDefaultingFragment.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060727 144354 kathy@ca.ibm.com - Kathy Chan
+ * 20060821 153833 makandre@ca.ibm.com - Andrew Mak, Allow the Web Service Test extension point to specify the supported client runtime
+ * 20060907 156606 makandre@ca.ibm.com - Andrew Mak, no sample JSP in the pop-up action of Generate Sample JSPs
+ * 20090724 284582 mahutch@ca.ibm.com - Mark Hutchinson, WS Test facility selection ignored when wizard completes. Default always chosen
+ *******************************************************************************/
+/*
+ * Created on May 4, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.jst.ws.internal.context.ScenarioContext;
+import org.eclipse.jst.ws.internal.ext.test.WebServiceTestExtension;
+import org.eclipse.jst.ws.internal.ext.test.WebServiceTestRegistry;
+import org.eclipse.jst.ws.internal.plugin.WebServicePlugin;
+import org.eclipse.wst.command.internal.env.core.selection.SelectionList;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+
+
+/**
+ * @author gilberta
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class TestDefaultingFragment extends AbstractDataModelOperation
+{
+
+ private SelectionList testFacilities;
+ private String launchedServiceTestName;
+ private ScenarioContext scenarioContext;
+ private boolean generateProxy; // This actually represent whether client test is requested
+
+ private String clientRuntimeId_;
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IStatus status = Status.OK_STATUS;
+
+ scenarioContext = WebServicePlugin.getInstance().getScenarioContext().copy();
+ if (generateProxy || testFacilities == null) {
+ selectTestFacility();
+ }
+ return status;
+ }
+
+ // The test facilities retrieved from the extension
+ // plus the default
+ public SelectionList getTestFacility()
+ {
+ return testFacilities;
+ }
+
+
+
+ // ***********************
+ // This method uses the preference to
+ // select the correct test facility
+ //
+ //***********************
+ private void selectTestFacility()
+ {
+ //if we find something we launched earlier
+ //put it on the bottom
+ String[] testTypes = scenarioContext.getWebServiceTestTypes();
+ List newTestTypes = new ArrayList();
+ String[] wsdlCases = scenarioContext.getNonJavaTestService();
+ boolean launched = false;
+
+ for(int i = 0;i<testTypes.length;i++){
+
+ WebServiceTestExtension extension =
+ (WebServiceTestExtension) WebServiceTestRegistry.getInstance()
+ .getWebServiceExtensionsByName(testTypes[i]);
+
+ if (clientRuntimeId_ != null && !extension.supportsRuntime(clientRuntimeId_))
+ continue;
+
+ if(testTypes[i].equals(launchedServiceTestName))
+ launched = true;
+ else{
+ newTestTypes.add(testTypes[i]);
+ }
+ }
+
+ if(launched)
+ newTestTypes.add(launchedServiceTestName);
+
+
+ if(!generateProxy)
+ testFacilities = new SelectionList(wsdlCases,0);
+ else {
+ String[] tempArray = new String[newTestTypes.size()];
+ testFacilities = new SelectionList((String[]) newTestTypes.toArray(tempArray), 0);
+ }
+ }
+
+ public void setServiceTestFacilities(SelectionList facilities) {
+ this.testFacilities = facilities;
+ }
+
+ public void setLaunchedServiceTestName(String launchedServiceTestName)
+ {
+ this.launchedServiceTestName = launchedServiceTestName;
+ }
+
+ public void setGenerateProxy(boolean generateProxy)
+ {
+ this.generateProxy = generateProxy;
+ }
+
+ /**
+ * Sets the client runtime ID.
+ *
+ * @param clientRuntimeId The client runtime ID.
+ */
+ public void setClientRuntimeId(String clientRuntimeId) {
+ clientRuntimeId_ = clientRuntimeId;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/TestWebServiceClient.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/TestWebServiceClient.java
new file mode 100644
index 000000000..a4efaabcb
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/TestWebServiceClient.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 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
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import org.eclipse.wst.command.internal.env.core.ICommandFactory;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.ws.internal.wsrt.AbstractWebServiceClient;
+import org.eclipse.wst.ws.internal.wsrt.IContext;
+import org.eclipse.wst.ws.internal.wsrt.ISelection;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceClientInfo;
+
+public class TestWebServiceClient extends AbstractWebServiceClient {
+
+ public TestWebServiceClient(WebServiceClientInfo clientInfo){
+ super(clientInfo);
+ }
+
+ public ICommandFactory assemble(IEnvironment env, IContext ctx, ISelection sel,
+ String project, String earProject){
+ return null;
+ }
+
+ public ICommandFactory deploy(IEnvironment env, IContext ctx, ISelection sel,
+ String project, String earProject){
+ return null;
+ }
+
+
+ public ICommandFactory develop(IEnvironment env, IContext ctx, ISelection sel,
+ String project, String earProject){
+ return null;
+ }
+
+ public ICommandFactory install(IEnvironment env, IContext ctx, ISelection sel,
+ String project, String earProject){
+ return null;
+ }
+
+
+ public ICommandFactory run(IEnvironment env, IContext ctx, ISelection sel,
+ String project, String earProject){
+ return null;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WSDLFinishFragment.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WSDLFinishFragment.java
new file mode 100644
index 000000000..74553e5de
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WSDLFinishFragment.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+/*
+ * Created on May 4, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import org.eclipse.wst.command.internal.env.core.fragment.BooleanFragment;
+
+/**
+ * @author gilberta
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class WSDLFinishFragment extends BooleanFragment{
+
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WSDLTestLaunchCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WSDLTestLaunchCommand.java
new file mode 100644
index 000000000..646a72ad5
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WSDLTestLaunchCommand.java
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+/*
+ * Created on May 4, 2004
+ *
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import java.util.List;
+
+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.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.data.TypeRuntimeServer;
+import org.eclipse.jst.ws.internal.ext.test.WebServiceTestExtension;
+import org.eclipse.jst.ws.internal.ext.test.WebServiceTestRegistry;
+import org.eclipse.wst.command.internal.env.core.ICommandFactory;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+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.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.ws.internal.wsrt.IWebServiceTester;
+import org.eclipse.wst.ws.internal.wsrt.TestInfo;
+
+/**
+ * @author gilberta
+ *
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class WSDLTestLaunchCommand extends AbstractDataModelOperation
+{
+ private String testID;
+ private String launchedServiceTestName;
+ private TypeRuntimeServer serviceids;
+ private String serverProject;
+ private String serverModule;
+ private String wsdlURI;
+ private boolean externalBrowser;
+ private List endpoints;
+ private IServer serviceExistingServer = null;
+ private String serviceServerTypeID = null;
+ private String serviceServerInstanceId = null;
+
+ public WSDLTestLaunchCommand()
+ {
+ }
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+ IStatus status = Status.OK_STATUS;
+
+ WebServiceTestRegistry testRegistry = WebServiceTestRegistry.getInstance();
+ WebServiceTestExtension wscte = (WebServiceTestExtension)testRegistry.getWebServiceExtensionsByName(testID);
+ IWebServiceTester iwst = (IWebServiceTester)wscte.getWebServiceExecutableExtension();
+ TestInfo testInfo = getTestInfo();
+
+
+ status = commandFactoryExecution(iwst.launch(testInfo),env, monitor);
+
+ //Dont need to shut everything down because the wsdl test doesnt work
+ if(status.getSeverity() != Status.OK){
+ IStatusHandler sHandler = env.getStatusHandler();
+ IStatus infoStatus = StatusUtils.infoStatus( ConsumptionUIMessages.MSG_ERROR_UNABLE_TO_LAUNCH_WSDL_TEST );
+ sHandler.reportInfo(infoStatus);
+ return infoStatus;
+ }
+ return status;
+
+ }
+
+ private IStatus commandFactoryExecution(ICommandFactory commandFactory,IEnvironment env, IProgressMonitor monitor)
+ {
+ IStatus status = Status.OK_STATUS;
+ while(commandFactory.hasNext())
+ {
+ AbstractDataModelOperation operation = commandFactory.getNextCommand();
+
+ if (operation != null)
+ {
+ try
+ {
+ operation.setEnvironment( env );
+ status = operation.execute( monitor, null );
+ }
+ catch( Exception exc )
+ {
+ status = StatusUtils.errorStatus( exc );
+ }
+ }
+
+ if(status.getSeverity() == Status.ERROR){
+ IStatusHandler sHandler = env.getStatusHandler();
+ sHandler.reportError(status);
+ return status;
+ }
+ }
+ return status;
+ }
+
+
+ private TestInfo getTestInfo()
+ {
+ // get the server stuff
+ if (serviceids.getServerInstanceId() != null)
+ serviceExistingServer = ServerCore.findServer(serviceids.getServerInstanceId());
+ else if (serviceServerInstanceId!=null)
+ serviceExistingServer = ServerCore.findServer(serviceServerInstanceId);
+
+ if (serviceExistingServer != null)
+ serviceServerTypeID = serviceExistingServer.getServerType().getId();
+ else
+ serviceServerTypeID = serviceids.getServerId();
+ // server will be created in ServerDeployableConfigurationCommand
+
+ TestInfo testInfo = new TestInfo();
+ if (serviceExistingServer!=null)
+ testInfo.setServiceExistingServer(serviceExistingServer);
+ testInfo.setServiceServerTypeID(serviceServerTypeID);
+ testInfo.setServiceProject(serverProject);
+ testInfo.setWsdlServiceURL(wsdlURI);
+ testInfo.setExternalBrowser(externalBrowser);
+ testInfo.setEndpoint(endpoints);
+ return testInfo;
+
+ }
+
+
+ public void setTestID(String testID)
+ {
+ this.testID = testID;
+ }
+
+ public String getLaunchedServiceTestName()
+ {
+ return launchedServiceTestName;
+ }
+ public void setWsdlURI(String wsdlURI)
+ {
+ this.wsdlURI = wsdlURI;
+ }
+
+ public void setServerProject(String serverProject)
+ {
+ this.serverProject = serverProject;
+ }
+
+
+ public void setServiceTypeRuntimeServer(TypeRuntimeServer serviceids)
+ {
+ this.serviceids = serviceids;
+ }
+
+ public void setExternalBrowser(boolean externalBrowser)
+ {
+ this.externalBrowser = externalBrowser;
+ }
+
+ public void setEndpoint(List endpoints)
+ {
+ this.endpoints = endpoints;
+ }
+
+public String getServerModule() {
+ return serverModule;
+}
+
+public void setServerModule(String serverModule) {
+ this.serverModule = serverModule;
+}
+
+public void setServiceServerInstanceId(String ssInstanceId){
+ this.serviceServerInstanceId = ssInstanceId;
+}
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WebServiceClientTestArrivalCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WebServiceClientTestArrivalCommand.java
new file mode 100644
index 000000000..419488bf0
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WebServiceClientTestArrivalCommand.java
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2015 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060608 144500 mahutch@ca.ibm.com - Mark Hutchinson
+ * 20060818 153903 makandre@ca.ibm.com - Andrew Mak, Browse does not work in generate client test page
+ * 20060906 154548 gilberta@ca.ibm.com - Gilbert Andrews, This fixes name collisions when creating a sample project
+ * 20060922 158177 makandre@ca.ibm.com - Andrew Mak, NPE when creating web service client into existing Java project with test
+ * 20080507 224433 makandre@ca.ibm.com - Andrew Mak, Need better error message in sample JSP generation when Java proxy bean does not exist
+ * 20150311 461526 jgwest@ca.ibm.com - Jonathan West, Allow OSGi bundles to be selected in the Wizard
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import java.util.List;
+import java.util.ListIterator;
+
+import org.eclipse.core.resources.IProject;
+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.Status;
+import org.eclipse.jem.java.JavaClass;
+import org.eclipse.jem.java.JavaHelpers;
+import org.eclipse.jem.java.Method;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.consumption.command.common.JavaMofReflectionCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.core.selection.BooleanSelection;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.environment.IStatusHandler;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+
+
+/**
+* This task sets up all the defaults for the webservice test
+* client page
+*
+*/
+public class WebServiceClientTestArrivalCommand extends AbstractDataModelOperation
+{
+ public static final String DEFAULT_WEB_MODULE_ROOT = "WebContent";
+ public static final String DEFAULT_SAMPLE_WEB_PROJECT_EXT = "Sample";
+
+ public static String SAMPLE_DIR = "sample";
+
+ private String clientProject;
+ private String clientProjectEAR;
+ private String clientP;
+ private String clientC;
+ private IProject clientIProject;
+ private String folder;
+ private String jspFolder;
+ private BooleanSelection[] methods;
+ private String proxyBean;
+ private String sampleProject;
+ private String sampleP;
+ private String sampleC;
+ private String sampleProjectEAR;
+
+ private String clientProjectOSGI;
+
+
+ /**
+ * Constructs a new WebServiceClientTestArrivalTask object with the given label and description.
+ */
+ public WebServiceClientTestArrivalCommand ()
+ {
+
+ }
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+
+ if(proxyBean == null){
+ IStatusHandler sHandler = env.getStatusHandler();
+ IStatus errorStatus = StatusUtils.errorStatus( ConsumptionUIMessages.MSG_ERROR_JTS_PROXY_NOT_COMPILED );
+ sHandler.reportError(errorStatus);
+ return errorStatus;
+
+ }
+
+ IStatus status = Status.OK_STATUS;
+
+ sampleProjectAndEarSetup(env);
+ IPath webcontentPath = null;
+
+ // *need* to double-check that clientIProject is a web project
+ if (J2EEUtils.isWebComponent(clientIProject))
+ webcontentPath = J2EEUtils.getWebContentPath(clientIProject);
+
+ //Get the sample Folder ready
+ StringBuffer sb = new StringBuffer();
+
+ if (webcontentPath != null)
+ {
+ String path = webcontentPath.toString();
+ sb.append(path).append("/");
+ }
+ else
+ { //then just use the default
+ sb.append("/").append(sampleC).append("/").append(DEFAULT_WEB_MODULE_ROOT).append("/");
+ }
+ folder = SAMPLE_DIR + getBean();
+
+ sb.append(folder);
+ jspFolder = sb.toString();
+
+ //get the method names ready
+ //find the full path of the file in the project
+ /*
+ * Getting the method names using javamof introspection
+ */
+
+ JavaMofReflectionCommand javamofcommand = new JavaMofReflectionCommand();
+ javamofcommand.setProxyBean(proxyBean);
+ javamofcommand.setClientProject(clientP);
+ javamofcommand.setEnvironment( env );
+
+
+
+ try{
+ IStatus mofStatus = javamofcommand.execute( monitor, null);
+ if(mofStatus.getSeverity() == Status.ERROR)
+ return mofStatus;
+ }catch(Exception exc){
+ IStatusHandler sHandler = env.getStatusHandler();
+ IStatus errorStatus = StatusUtils.errorStatus( ConsumptionUIMessages.MSG_ERROR_JTS_PROXY_NOT_COMPILED );
+ sHandler.reportError(errorStatus);
+ return errorStatus;
+ }
+ JavaHelpers javaHelpers = javamofcommand.getJavaClass();
+ if (javaHelpers == null) return status;
+
+ JavaClass javaClass = null;
+ if(javaHelpers instanceof JavaClass)
+ javaClass = (JavaClass)javaHelpers;
+ else return status;
+ List methodList = javaClass.getPublicMethods();
+ BooleanSelection[] tempMethods = new BooleanSelection[methodList.size()];
+ ListIterator listIterator = methodList.listIterator();
+
+ int j = 0;
+ while (listIterator.hasNext())
+ {
+ Method method = (Method)listIterator.next();
+ if(method.isConstructor()) continue;
+
+ tempMethods[j] = new BooleanSelection( method.getMethodElementSignature(), true);
+ j++;
+ }
+ methods = tempMethods;
+ return status;
+ }
+ public static final String DEFAULT_SAMPLE_EAR_PROJECT_EXT = "EAR";
+
+ private void sampleProjectAndEarSetup(IEnvironment env)
+ {
+ if(clientProject == null) return;
+ else{
+ int index = clientProject.indexOf("/");
+ clientP = clientProject.substring(0,index);
+ clientC = clientProject.substring(index + 1);
+ }
+
+ clientIProject = (IProject)ProjectUtilities.getProject(clientP);
+
+ if(J2EEUtils.isWebComponent(clientIProject)){
+ sampleProject = clientProject;
+ sampleP = clientP;
+ sampleC = clientC;
+ }
+ else{
+ sampleP = clientP + DEFAULT_SAMPLE_WEB_PROJECT_EXT;
+ sampleC = clientC + DEFAULT_SAMPLE_WEB_PROJECT_EXT;
+ sampleProject = sampleP + "/" + sampleC;
+
+ String sampleTemp = sampleP;
+
+ boolean nameFound = false;
+ int i = 1;
+ while(!nameFound){
+ IProject sampleIProject = (IProject)ProjectUtilities.getProject(sampleTemp);
+ if(sampleIProject.exists() && !J2EEProjectUtilities.isDynamicWebProject(sampleIProject)){
+ sampleTemp = sampleP + Integer.toString(i);
+ sampleProject = sampleTemp + "/" + sampleC;
+
+ }
+ else
+ nameFound = true;
+
+ i++;
+ }
+ sampleP = sampleTemp;
+
+ }
+
+
+ if(clientProjectEAR != null && clientProjectEAR.length() > 0) {
+ sampleProjectEAR = clientProjectEAR;
+ } else if(clientProjectOSGI != null && clientProjectOSGI.trim().length() > 0) {
+ sampleProjectEAR = clientProjectOSGI;
+ } else {
+ sampleProjectEAR = sampleP + DEFAULT_SAMPLE_EAR_PROJECT_EXT + "/" + sampleC + DEFAULT_SAMPLE_EAR_PROJECT_EXT;
+ }
+
+
+ }
+
+ //getters and setters
+
+ private String getBean()
+ {
+ int index = proxyBean.lastIndexOf(".");
+ String end = "";
+ if(index != -1){
+ end = proxyBean.substring(index + 1);
+ }
+ String bean = end.substring(0,end.length());
+
+ return bean;
+ }
+
+
+
+
+ public String getFolder()
+ {
+ return folder;
+ }
+
+ public String getJspFolder()
+ {
+ return jspFolder;
+ }
+
+ public BooleanSelection[] getMethods()
+ {
+ return methods;
+ }
+
+ public String getSampleProject()
+ {
+ return sampleProject;
+ }
+
+ public void setClientProject(String clientProject)
+ {
+ this.clientProject = clientProject;
+ }
+
+
+ public void setClientProjectEAR(String clientProjectEAR)
+ {
+ this.clientProjectEAR = clientProjectEAR;
+ }
+
+
+ public void setProxyBean(String proxyBean)
+ {
+ this.proxyBean = proxyBean;
+ }
+
+ public String getSampleProjectEAR()
+ {
+ return sampleProjectEAR;
+ }
+
+ public String getClientProjectOSGI() {
+ return clientProjectOSGI;
+}
+ public void setClientProjectOSGI(String clientProjectOSGI) {
+ this.clientProjectOSGI = clientProjectOSGI;
+}
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WebServiceTestClientDepartureFragment.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WebServiceTestClientDepartureFragment.java
new file mode 100644
index 000000000..fd945a71d
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/WebServiceTestClientDepartureFragment.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ *******************************************************************************/
+/*
+ * Created on Mar 25, 2004
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test;
+
+import org.eclipse.jst.ws.internal.consumption.command.common.BuildProjectCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.wssample.AddModuleDependenciesCommand;
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
+
+
+/**
+ * @author gilberta
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class WebServiceTestClientDepartureFragment extends SequenceFragment
+{
+ public WebServiceTestClientDepartureFragment()
+ {
+ add(new SimpleFragment(new FinishDefaultCommand(),""));
+ add(new SimpleFragment(new ClientTestDelegateCommand(),""));
+ }
+
+ public void registerDataMappings(DataMappingRegistry dataRegistry)
+ {
+ dataRegistry.addMapping(TestClientDepartureInitCommand.class, "ForceBuild",BuildProjectCommand.class);
+ dataRegistry.addMapping(FinishDefaultCommand.class, "SampleServerTypeID",AddModuleDependenciesCommand.class);
+ dataRegistry.addMapping(FinishDefaultCommand.class, "SampleExistingServer",AddModuleDependenciesCommand.class);
+ dataRegistry.addMapping(FinishDefaultCommand.class, "SampleServerTypeID",ClientTestDelegateCommand.class);
+ dataRegistry.addMapping(FinishDefaultCommand.class, "SampleExistingServer",ClientTestDelegateCommand.class);
+
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/ExplorerServiceTestCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/ExplorerServiceTestCommand.java
new file mode 100644
index 000000000..bee7b6325
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/ExplorerServiceTestCommand.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test.explorer;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+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.jst.ws.internal.ext.test.WSDLTestFinishCommand;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.ws.internal.explorer.LaunchOption;
+import org.eclipse.wst.ws.internal.explorer.LaunchOptions;
+import org.eclipse.wst.ws.internal.explorer.WSExplorerLauncherCommand;
+import org.eclipse.wst.ws.internal.explorer.plugin.ExplorerPlugin;
+
+public class ExplorerServiceTestCommand extends AbstractDataModelOperation implements WSDLTestFinishCommand
+{
+
+ private boolean externalBrowser = true;
+ private String wsdlServiceURL;
+ private List endpoints;
+
+ /**
+ * Constructs a new WebServiceExplorerLaunch object with the given label and description.
+ */
+ public ExplorerServiceTestCommand ()
+ {
+ }
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+
+ IStatus status = Status.OK_STATUS;
+
+ WSExplorerLauncherCommand launchCommand = new WSExplorerLauncherCommand();
+ launchCommand.setForceLaunchOutsideIDE(externalBrowser);
+ Vector launchOptionVector = new Vector();
+ String stateLocation = ExplorerPlugin.getInstance().getPluginStateLocation();
+ String defaultFavoritesLocation = ExplorerPlugin.getInstance().getDefaultFavoritesLocation();
+ launchOptionVector.add(new LaunchOption(LaunchOptions.STATE_LOCATION,stateLocation));
+ launchOptionVector.add(new LaunchOption(LaunchOptions.DEFAULT_FAVORITES_LOCATION,defaultFavoritesLocation));
+ launchOptionVector.add(new LaunchOption(LaunchOptions.WSDL_URL,wsdlServiceURL));
+ if (endpoints != null)
+ for (Iterator it = endpoints.iterator(); it.hasNext();)
+ launchOptionVector.add(new LaunchOption(LaunchOptions.WEB_SERVICE_ENDPOINT, it.next().toString()));
+ launchCommand.setLaunchOptions((LaunchOption[])launchOptionVector.toArray(new LaunchOption[0]));
+ launchCommand.setEnvironment( env );
+ status = launchCommand.execute( monitor, null );
+ return status;
+ }
+
+ public void setExternalBrowser(boolean externalBrowser)
+ {
+ this.externalBrowser = externalBrowser;
+ }
+
+ public void setWsdlServiceURL(String wsdlServiceURL)
+ {
+ this.wsdlServiceURL = wsdlServiceURL;
+ }
+
+ public void setServerTypeID(String serviceServerTypeID)
+ {
+ //TODO: Type mappings to this property should be removed.
+ }
+
+ public void setExistingServer(IServer serviceExistingServer)
+ {
+ //TODO: Type mappings to this property should be removed.
+ }
+
+ public void setServiceProject(String serviceProject)
+ {
+ //TODO: Type mappings to this property should be removed.
+ }
+
+ public void setEndpoint(List endpoints)
+ {
+ this.endpoints = endpoints;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/WSEGenerateCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/WSEGenerateCommand.java
new file mode 100644
index 000000000..8ad6eeb12
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/WSEGenerateCommand.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2005 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
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test.explorer;
+
+import java.util.Iterator;
+import java.util.Vector;
+
+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.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.explorer.LaunchOption;
+import org.eclipse.wst.ws.internal.explorer.LaunchOptions;
+import org.eclipse.wst.ws.internal.explorer.WSExplorerLauncherCommand;
+import org.eclipse.wst.ws.internal.explorer.plugin.ExplorerPlugin;
+import org.eclipse.wst.ws.internal.wsrt.TestInfo;
+
+public class WSEGenerateCommand extends AbstractDataModelOperation
+{
+
+ private TestInfo testInfo;
+
+ public WSEGenerateCommand(TestInfo testInfo){
+ this.testInfo = testInfo;
+ }
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+
+ IStatus status = Status.OK_STATUS;
+
+ WSExplorerLauncherCommand launchCommand = new WSExplorerLauncherCommand();
+ launchCommand.setForceLaunchOutsideIDE(testInfo.getExternalBrowser());
+ Vector launchOptionVector = new Vector();
+ String stateLocation = ExplorerPlugin.getInstance().getPluginStateLocation();
+ String defaultFavoritesLocation = ExplorerPlugin.getInstance().getDefaultFavoritesLocation();
+ launchOptionVector.add(new LaunchOption(LaunchOptions.STATE_LOCATION,stateLocation));
+ launchOptionVector.add(new LaunchOption(LaunchOptions.DEFAULT_FAVORITES_LOCATION,defaultFavoritesLocation));
+ launchOptionVector.add(new LaunchOption(LaunchOptions.WSDL_URL,testInfo.getWsdlServiceURL()));
+ if (testInfo.getEndpoint() != null)
+ for (Iterator it = testInfo.getEndpoint().iterator(); it.hasNext();)
+ launchOptionVector.add(new LaunchOption(LaunchOptions.WEB_SERVICE_ENDPOINT, it.next().toString()));
+ launchCommand.setLaunchOptions((LaunchOption[])launchOptionVector.toArray(new LaunchOption[0]));
+ launchCommand.setEnvironment( env );
+ status = launchCommand.execute( monitor, null );
+ return status;
+ }
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/WSEWebServiceTester.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/WSEWebServiceTester.java
new file mode 100644
index 000000000..cfa116d05
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/WSEWebServiceTester.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2005 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
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test.explorer;
+
+import java.util.Vector;
+
+import org.eclipse.wst.command.internal.env.core.ICommandFactory;
+import org.eclipse.wst.command.internal.env.core.SimpleCommandFactory;
+import org.eclipse.wst.ws.internal.wsrt.IWebServiceTester;
+import org.eclipse.wst.ws.internal.wsrt.TestInfo;
+
+public class WSEWebServiceTester implements IWebServiceTester {
+
+ public ICommandFactory generate(TestInfo testInfo){
+ Vector commands = new Vector();
+ return new SimpleCommandFactory(commands);
+ }
+
+ public ICommandFactory launch(TestInfo testInfo){
+ Vector commands = new Vector();
+ commands.add(new WSEGenerateCommand(testInfo));
+ return new SimpleCommandFactory(commands);
+ }
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/WebServiceExplorerExecutable.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/WebServiceExplorerExecutable.java
new file mode 100644
index 000000000..dbfc9ae16
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/explorer/WebServiceExplorerExecutable.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test.explorer;
+
+import org.eclipse.jst.ws.internal.ext.WebServiceExecutable;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+
+/**
+* This is the interface for objects that represent a kind of
+* Web Service-Server-Runtime artifact. The primary purpose of a WebServiceServerRuntimeType
+* object is to manufacture the wizard pages that support the type, server, and runtime configuration.
+*/
+public class WebServiceExplorerExecutable implements WebServiceExecutable
+{
+ // Copyright
+ public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
+
+
+ public AbstractDataModelOperation getFinishCommand()
+ {
+ return new ExplorerServiceTestCommand();
+ }
+
+}
+
+
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/AddModuleDependenciesCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/AddModuleDependenciesCommand.java
new file mode 100644
index 000000000..c604bf8be
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/AddModuleDependenciesCommand.java
@@ -0,0 +1,248 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060324 122799 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060503 138478 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060510 141115 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20071212 200193 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080211 117924 trungha@ca.ibm.com - Trung Ha
+ * 20080325 184761 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080527 234169 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20081001 243869 ericdp@ca.ibm.com - Eric D. Peters, Web Service tools allowing mixed J2EE levels
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test.wssample;
+
+import java.io.IOException;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+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.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jst.j2ee.classpathdep.UpdateClasspathAttributeUtil;
+import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.consumption.command.common.AddModuleToServerCommand;
+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.common.RequiredFacetVersion;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.command.StartServerCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.common.ValidationUtils;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.wsrt.TestInfo;
+
+public class AddModuleDependenciesCommand extends AbstractDataModelOperation
+{
+
+ private TestInfo testInfo;
+
+ private IProject sampleIProject;
+ private IProject clientIProject;
+ private IProject sampleEARIProject;
+ private String sampleEARProject;
+
+ public AddModuleDependenciesCommand(TestInfo testInfo)
+ {
+ this.testInfo = testInfo;
+ }
+
+ /**
+ * Execute WebServerDefaultingTask Set the default server name and id given a
+ * deployable.
+ */
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+ //1. Create a Web project for the sample if one does not already exist.
+ sampleIProject = ProjectUtilities.getProject(testInfo.getGenerationProject());
+ boolean createdSampleProject = false;
+ ValidationUtils vu = new ValidationUtils();
+ boolean serverNeedsEAR = vu.serverNeedsEAR(testInfo.getClientServerTypeID());
+ if (serverNeedsEAR) {
+ if (testInfo.getClientEARProject() == null
+ || testInfo.getClientEARProject().length() == 0) {
+ sampleEARProject = testInfo.getGenerationProject() + DEFAULT_SAMPLE_EAR_PROJECT_EXT;
+ } else {
+ sampleEARProject = testInfo.getClientEARProject();
+ }
+ }
+ if (!sampleIProject.exists())
+ {
+ CreateFacetedProjectCommand command = new CreateFacetedProjectCommand();
+ command.setProjectName(testInfo.getGenerationProject());
+ command.setTemplateId(IJ2EEModuleConstants.JST_WEB_TEMPLATE);
+ // RequiredFacetVersions is set to an empty array because we don't need to impose any additional constraints.
+ // We just want to create the highest level of Web project that the selected server supports.
+ command.setRequiredFacetVersions(new RequiredFacetVersion[0]);
+ command.setServerFactoryId(testInfo.getClientServerTypeID());
+ command.setServerInstanceId(testInfo.getClientExistingServer().getId());
+ command.setEarProjectName(sampleEARProject);
+ IStatus status = command.execute( monitor, adaptable );
+ if (status.getSeverity() == Status.ERROR)
+ {
+ env.getStatusHandler().reportError( status );
+ return status;
+ }
+ createdSampleProject = true;
+ }
+
+ //2. If the selected server requires an EAR and no EAR name
+ //has been provided, choose an EAR name and create it if it doesn't exist.
+ if (serverNeedsEAR) {
+ sampleEARIProject = ProjectUtilities.getProject(sampleEARProject);
+ if (sampleEARIProject == null || !sampleEARIProject.exists())
+ {
+ CreateFacetedProjectCommand command = new CreateFacetedProjectCommand();
+ command.setProjectName(sampleEARProject);
+ command.setTemplateId(IJ2EEModuleConstants.JST_EAR_TEMPLATE);
+ // RequiredFacetVersions is set to an empty array because we don't need to impose any additional constraints.
+ // We just want to create the highest level of Web project that the selected server supports.
+ command.setRequiredFacetVersions(new RequiredFacetVersion[0]);
+ command.setServerFactoryId(testInfo.getClientServerTypeID());
+ command.setServerInstanceId(testInfo.getClientExistingServer().getId());
+ IStatus status = command.execute( monitor, adaptable );
+ if (status.getSeverity() == Status.ERROR)
+ {
+ env.getStatusHandler().reportError( status );
+ return status;
+ }
+ }
+
+ }
+
+ // 3. If the selected server requires an EAR, and the sample project has
+ // not already been added to the EAR, add it.
+ if (serverNeedsEAR)
+ {
+ AssociateModuleWithEARCommand associateCommand = new AssociateModuleWithEARCommand();
+ associateCommand.setProject(testInfo.getGenerationProject());
+ associateCommand.setEARProject(sampleEARProject);
+ associateCommand.setEar(sampleEARProject);
+ associateCommand.setEnvironment( env );
+ IStatus status = associateCommand.execute( monitor, null );
+ if (status.getSeverity()==Status.ERROR)
+ {
+ env.getStatusHandler().reportError(status);
+ }
+ }
+
+
+
+
+ // 4. If server requires an EAR, and the sample EAR has not already been
+ // added to the server, add it.
+ // If no EAR is required, and sample project has not been added to the server add it.
+ if (serverNeedsEAR && testInfo.getClientExistingServer() != null)
+ {
+ //Add sampleEARIProject to the server if needed.
+ AddModuleToServerCommand modToServer = new AddModuleToServerCommand();
+ modToServer.setModule(sampleEARProject);
+ modToServer.setProject(sampleEARProject);
+ modToServer.setServerInstanceId(testInfo.getClientExistingServer().getId());
+ modToServer.setEnvironment( env );
+ IStatus status = modToServer.execute( monitor, null );
+ if (status.getSeverity()==Status.ERROR)
+ {
+ env.getStatusHandler().reportError(status);
+ }
+ }
+ else
+ {
+ //add sampleIProject directly to the server if needed.
+ if(testInfo.getClientExistingServer()!= null){
+ AddModuleToServerCommand addToServer = new AddModuleToServerCommand();
+ addToServer.setModule(testInfo.getGenerationProject());
+ addToServer.setProject(testInfo.getGenerationProject());
+ addToServer.setServerInstanceId(testInfo.getClientExistingServer().getId());
+ addToServer.setEnvironment( env );
+ IStatus status = addToServer.execute( monitor, null );
+ if (status.getSeverity()==Status.ERROR)
+ {
+ env.getStatusHandler().reportError(status);
+ }
+ }
+ }
+
+ //5. Call StartServerCommand if this command had to create the sample project.
+ if (createdSampleProject)
+ {
+ StartServerCommand startServer = new StartServerCommand(true);
+ startServer.setServerInstanceId(testInfo.getClientExistingServer().getId());
+ startServer.setEnvironment( env );
+ IStatus status = startServer.execute( monitor, null );
+ if (status.getSeverity()==Status.ERROR)
+ {
+ env.getStatusHandler().reportError(status);
+ }
+ }
+
+
+ //6. Establish all necessary dependencies between client project, sample project, and EAR
+
+ clientIProject = ProjectUtilities.getProject(testInfo.getClientProject());
+
+ if (clientIProject != null && !J2EEUtils.isWebComponent(clientIProject)) {
+ if (J2EEUtils.isJavaComponent(clientIProject)) {
+ J2EEUtils.addJavaProjectAsUtilityJar(clientIProject, sampleEARIProject, monitor);
+ J2EEUtils.addJavaProjectAsUtilityJar(clientIProject, sampleIProject,monitor);
+ }
+
+ try
+ {
+ String uri = clientIProject.getName() + ".jar";
+ J2EEUtils.addJAROrModuleDependency(sampleIProject, uri);
+
+ // Adding the attribute to the referenced project's classpath entries of 'lib' kind
+ // so that these libs will be bundled along with the project when exported
+ IClasspathEntry[] classPath = JavaCore.create(clientIProject).getRawClasspath();
+ for (int i = 0; i < classPath.length; i++) {
+ IClasspathEntry classpathEntry = classPath[i];
+ if ( classpathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY ){
+ UpdateClasspathAttributeUtil.addDependencyAttribute(monitor, clientIProject.getName(), classpathEntry);
+ }
+ }
+
+ } catch (CoreException ce)
+ {
+ String errorMessage = NLS.bind(ConsumptionUIMessages.MSG_ERROR_MODULE_DEPENDENCY, new String[]{sampleIProject.getName(), clientIProject.getName()});
+ IStatus errorStatus = StatusUtils.errorStatus(errorMessage);
+ env.getStatusHandler().reportError(errorStatus);
+ } catch (IOException ioe)
+ {
+ String errorMessage = NLS.bind(ConsumptionUIMessages.MSG_ERROR_MODULE_DEPENDENCY, new String[]{sampleIProject.getName(), clientIProject.getName()});
+ IStatus errorStatus = StatusUtils.errorStatus(errorMessage);
+ env.getStatusHandler().reportError(errorStatus);
+ } catch (ExecutionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ }
+
+ return Status.OK_STATUS;
+ }
+
+
+
+
+ public static final String DEFAULT_SAMPLE_EAR_PROJECT_EXT = "EAR";
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCGenerateCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCGenerateCommand.java
new file mode 100644
index 000000000..3ee6aecdc
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCGenerateCommand.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2012 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
+ * -------- -------- -----------------------------------------------------------
+ * 20120409 376345 yenlu@ca.ibm.com, kchong@ca.ibm.com - Stability improvements to web services commands/operations
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test.wssample;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+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.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.consumption.command.common.BuildProjectCommand;
+import org.eclipse.jst.ws.internal.consumption.sampleapp.codegen.InputFileGenerator;
+import org.eclipse.jst.ws.internal.consumption.sampleapp.codegen.MethodFileGenerator;
+import org.eclipse.jst.ws.internal.consumption.sampleapp.codegen.ResultFileGenerator;
+import org.eclipse.jst.ws.internal.consumption.sampleapp.codegen.TestClientFileGenerator;
+import org.eclipse.jst.ws.internal.consumption.sampleapp.command.GeneratePageCommand;
+import org.eclipse.jst.ws.internal.consumption.sampleapp.command.JavaToModelCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.CopyWebServiceUtilsJarCommand;
+import org.eclipse.wst.command.internal.env.ui.eclipse.EnvironmentUtils;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.datamodel.Model;
+import org.eclipse.wst.ws.internal.wsrt.TestInfo;
+
+public class GSTCGenerateCommand extends AbstractDataModelOperation
+{
+
+ public static String INPUT = "Input.jsp";
+ public static String TEST_CLIENT = "TestClient.jsp";
+ public static String RESULT = "Result.jsp";
+ public static String METHOD = "Method.jsp";
+
+ private TestInfo testInfo;
+ private Model proxyModel;
+ private String jspfolder;
+
+ public GSTCGenerateCommand(TestInfo testInfo){
+ this.testInfo = testInfo;
+ }
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+ IStatus status = Status.OK_STATUS;
+ CopyWebServiceUtilsJarCommand copy = new CopyWebServiceUtilsJarCommand();
+ copy.setSampleProject(testInfo.getGenerationProject());
+ copy.setEnvironment( env );
+ status = copy.execute( monitor, null);
+ if (status.getSeverity() == Status.ERROR) return status;
+ setJSPFolder();
+ status = createModel(env, monitor);
+ if (status.getSeverity() == Status.ERROR) return status;
+ status = generatePages(env);
+ if (status.getSeverity() == Status.ERROR) return status;
+ BuildProjectCommand buildProjectCommand = new BuildProjectCommand();
+ buildProjectCommand.setEnvironment(env);
+ buildProjectCommand.setForceBuild(true);
+ buildProjectCommand.setProject(ResourcesPlugin.getWorkspace().getRoot().getProject(testInfo.getGenerationProject()));
+ return buildProjectCommand.execute(monitor, adaptable);
+ }
+
+ private void setJSPFolder(){
+ //if the client is not a webcomponent then the
+ //sample must have been created, we must now factor in
+ //flexible projects
+
+ IProject clientIProject = ProjectUtilities.getProject(testInfo.getClientProject());
+ if (clientIProject != null && !J2EEUtils.isWebComponent(clientIProject)){
+ IProject project = ProjectUtilities.getProject(testInfo.getGenerationProject());
+ IPath path = J2EEUtils.getWebContentPath(project);
+ int index = testInfo.getJspFolder().lastIndexOf("/");
+ String jsp = testInfo.getJspFolder().substring(index + 1);
+ StringBuffer sb = new StringBuffer();
+ sb.append("/").append(path.toString()).append("/").append(jsp);
+ jspfolder = sb.toString();
+ }
+ else
+ jspfolder = testInfo.getJspFolder();
+
+
+ }
+
+ //create the model from the resource
+ private IStatus createModel(IEnvironment env, IProgressMonitor monitor ) {
+ JavaToModelCommand jtmc = new JavaToModelCommand();
+ jtmc.setMethods(testInfo.getMethods());
+ jtmc.setClientProject(testInfo.getClientProject());
+ jtmc.setProxyBean(testInfo.getProxyBean());
+ jtmc.setEnvironment( env );
+ IStatus status = jtmc.execute( monitor, null);
+ if (status.getSeverity() == Status.ERROR) return status;
+ proxyModel = jtmc.getJavaDataModel();
+ return status;
+ }
+
+ /**
+ * Generate the four jsps that make up this
+ * sample app.
+ */
+ private IStatus generatePages(IEnvironment env)
+ {
+ IStatus status = Status.OK_STATUS;
+ IPath fDestinationFolderPath = new Path(jspfolder);
+ fDestinationFolderPath = fDestinationFolderPath.makeAbsolute();
+ IWorkspaceRoot fWorkspace = ResourcesPlugin.getWorkspace().getRoot();
+
+ IPath pathTest = fDestinationFolderPath.append(TEST_CLIENT);
+ IFile fileTest = fWorkspace.getFile(pathTest);
+ GeneratePageCommand gpcTest = new GeneratePageCommand(EnvironmentUtils.getResourceContext(env), proxyModel,
+ new TestClientFileGenerator(INPUT,METHOD,RESULT),fileTest);
+ //gpcTest.setStatusMonitor(getStatusMonitor());
+ gpcTest.setEnvironment( env );
+ status = gpcTest.execute( null, null );
+ if (status.getSeverity() == Status.ERROR )
+ return status;
+
+
+ //input codegen
+ IPath pathInput = fDestinationFolderPath.append(INPUT);
+ IFile fileInput = fWorkspace.getFile(pathInput);
+ InputFileGenerator inputGenerator = new InputFileGenerator(RESULT);
+ GeneratePageCommand gpcInput = new GeneratePageCommand(EnvironmentUtils.getResourceContext(env), proxyModel,
+ inputGenerator,fileInput);
+ //gpcInput.setStatusMonitor(getStatusMonitor());
+ gpcInput.setEnvironment( env );
+ status = gpcInput.execute( null, null );
+ if (status.getSeverity() == Status.ERROR )
+ return status;
+
+ //method codegen
+ IPath pathMethod = fDestinationFolderPath.append(METHOD);
+ IFile fileMethod = fWorkspace.getFile(pathMethod);
+ MethodFileGenerator methodGenerator = new MethodFileGenerator(INPUT);
+ methodGenerator.setClientFolderPath(jspfolder);
+ GeneratePageCommand gpcMethod = new GeneratePageCommand(EnvironmentUtils.getResourceContext(env), proxyModel,
+ methodGenerator,fileMethod);
+ //gpcMethod.setStatusMonitor(getStatusMonitor());
+ gpcMethod.setEnvironment( env );
+ status = gpcMethod.execute( null, null );
+ if (status.getSeverity() == Status.ERROR )
+ return status;
+
+
+ //result codegen
+ IPath pathResult = fDestinationFolderPath.append(RESULT);
+ IFile fileResult = fWorkspace.getFile(pathResult);
+ ResultFileGenerator rfg = new ResultFileGenerator();
+ rfg.setClientFolderPath(jspfolder);
+ rfg.setSetEndpointMethod(testInfo.getSetEndpointMethod());
+ GeneratePageCommand gpcResult = new GeneratePageCommand(EnvironmentUtils.getResourceContext(env), proxyModel,
+ rfg,fileResult);
+ gpcResult.setEnvironment( env );
+ status = gpcResult.execute( null, null );
+
+ return status;
+ }
+
+
+
+
+
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCLaunchCommand.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCLaunchCommand.java
new file mode 100644
index 000000000..08bb7825c
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCLaunchCommand.java
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 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
+ * -------- -------- -----------------------------------------------------------
+ * 20060418 134322 rsinha@ca.ibm.com - Rupam Kuehner
+ * 20060424 124368 kathy@ca.ibm.com - Kathy Chan
+ * 20090312 250984 mahutch@ca.ibm.com - Mark Hutchinson, Use another mechanism to wait for build to be completed
+ * 20091201 296529 yenlu@ca.ibm.com - Yen Lu, Determination of when the sample JSP goes live is not robust.
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test.wssample;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+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.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.common.ServerUtils;
+import org.eclipse.jst.ws.internal.consumption.command.common.BuildBeanCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
+import org.eclipse.jst.ws.internal.consumption.ui.command.StartServerCommand;
+import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.browser.IWebBrowser;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.environment.ILog;
+import org.eclipse.wst.common.environment.StatusException;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.wsrt.TestInfo;
+
+public class GSTCLaunchCommand extends AbstractDataModelOperation
+{
+
+ public static String INPUT = "Input.jsp";
+ public static String TEST_CLIENT = "TestClient.jsp";
+ public static String RESULT = "Result.jsp";
+ public static String METHOD = "Method.jsp";
+
+ private TestInfo testInfo;
+ private String jspfolder;
+
+ public GSTCLaunchCommand(TestInfo testInfo){
+ this.testInfo = testInfo;
+ }
+
+ public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
+ {
+ IEnvironment env = getEnvironment();
+
+ setJSPFolder();
+
+ return launchSample(env, monitor);
+ }
+ private void setJSPFolder(){
+ //if the client is not a webcomponent then the
+ //sample must have been created, we must now factor in
+ //flexible projects
+
+ IProject clientIProject = ProjectUtilities.getProject(testInfo.getClientProject());
+ if (clientIProject != null && !J2EEUtils.isWebComponent(clientIProject)){
+ IProject project = ProjectUtilities.getProject(testInfo.getGenerationProject());
+ IPath path = J2EEUtils.getWebContentPath(project);
+ int index = testInfo.getJspFolder().lastIndexOf("/");
+ String jsp = testInfo.getJspFolder().substring(index + 1);
+ StringBuffer sb = new StringBuffer();
+ sb.append("/").append(path.toString()).append("/").append(jsp);
+ jspfolder = sb.toString();
+ }
+ else
+ jspfolder = testInfo.getJspFolder();
+
+
+ }
+
+ private IStatus launchSample (IEnvironment env, IProgressMonitor monitor ) {
+ IStatus status = Status.OK_STATUS;
+ IPath fDestinationFolderPath = new Path(jspfolder);
+ fDestinationFolderPath = fDestinationFolderPath.makeAbsolute();
+
+ IProject sampleProject = ProjectUtilities.getProject(testInfo.getGenerationProject());
+
+ BuildBeanCommand buildCommand = new BuildBeanCommand();
+ buildCommand.setEnvironment(env);
+ buildCommand.setProject(sampleProject);
+ try {
+ //ensure the sample project is built
+ buildCommand.execute(monitor, null);
+ } catch (ExecutionException e2) {
+ //just ignore and see if we can move on
+ }
+
+ StartServerCommand serverCommand = new StartServerCommand( true );
+ serverCommand.setServerInstanceId( testInfo.getClientExistingServer().getId() );
+ serverCommand.setEnvironment( env );
+
+ status = serverCommand.execute(monitor, null);
+ if (status.getSeverity() == Status.ERROR) return status;
+
+ String newPath = ServerUtils.getWebComponentURL(sampleProject, testInfo.getClientServerTypeID(),testInfo.getClientExistingServer());
+ int count = J2EEUtils.getWebContentPath(sampleProject).segmentCount();
+
+ newPath = newPath + "/" + fDestinationFolderPath.removeFirstSegments(count);
+ StringBuffer urlString = new StringBuffer( newPath + "/" + TEST_CLIENT );
+ if (testInfo.getEndpoint() != null && !testInfo.getEndpoint().isEmpty())
+ {
+ urlString.append("?endpoint=");
+ urlString.append(testInfo.getEndpoint().get(0).toString());
+ }
+
+ try{
+ URL url;
+ url = new URL(urlString.toString());
+
+ for( int retries = 0; retries < 20; retries++ )
+ {
+ try
+ {
+ // Test the URLs
+ URL sampleUrl = new URL(newPath + "/" + RESULT);
+ HttpURLConnection urlConn = (HttpURLConnection)sampleUrl.openConnection();
+ int responseCode = urlConn.getResponseCode();
+ //System.out.println(retries + ": result HTTP code = " + responseCode);
+ //dumpUrlContents(urlConn);
+ if (responseCode != HttpURLConnection.HTTP_OK)
+ throw new IOException();
+
+ sampleUrl = new URL(newPath + "/" + METHOD);
+ urlConn = (HttpURLConnection)sampleUrl.openConnection();
+ responseCode = urlConn.getResponseCode();
+ //System.out.println(retries + ": method HTTP code = " + responseCode);
+ //dumpUrlContents(urlConn);
+ if (responseCode != HttpURLConnection.HTTP_OK)
+ throw new IOException();
+
+ sampleUrl = new URL(newPath + "/" + INPUT);
+ urlConn = (HttpURLConnection)sampleUrl.openConnection();
+ responseCode = urlConn.getResponseCode();
+ //System.out.println(retries + ": input HTTP code = " + responseCode);
+ //dumpUrlContents(urlConn);
+ if (responseCode != HttpURLConnection.HTTP_OK)
+ throw new IOException();
+
+ sampleUrl = new URL(newPath + "/" + TEST_CLIENT);
+ urlConn = (HttpURLConnection)sampleUrl.openConnection();
+ responseCode = urlConn.getResponseCode();
+ //System.out.println(retries + ": test client HTTP code = " + responseCode);
+ //dumpUrlContents(urlConn);
+ if (responseCode != HttpURLConnection.HTTP_OK)
+ throw new IOException();
+
+ // Looks good, exit loop
+ break;
+ }
+ catch( IOException ioe )
+ {
+ try
+ {
+ Thread.sleep(1000);
+ }
+ catch (InterruptedException ie) {}
+ }
+ }
+
+ IWorkbenchBrowserSupport browserSupport = WebServiceConsumptionUIPlugin.getInstance().getWorkbench().getBrowserSupport();
+ IWebBrowser browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR, null, null, null);
+ browser.openURL(url);
+ return status;
+ }catch(PartInitException exc){
+ env.getLog().log(ILog.ERROR, 5048, this, "launchSample", exc);
+ status = StatusUtils.errorStatus(exc.getMessage(), exc);
+ env.getStatusHandler().reportError(status);
+ return status;
+ }catch(MalformedURLException exc){
+ env.getLog().log(ILog.WARNING, 5048, this, "launchSample", exc);
+ status = StatusUtils.warningStatus( ConsumptionUIMessages.MSG_ERROR_MALFORMED_URL, exc );
+ try {
+ env.getStatusHandler().report(status);
+ } catch (StatusException e) {
+ status = StatusUtils.errorStatus( ConsumptionUIMessages.MSG_ERROR_MALFORMED_URL, e );
+ }
+ return status;
+ }
+ }
+/*
+ private void dumpUrlContents(URLConnection conn)
+ {
+ InputStream is = null;
+ try
+ {
+ is = conn.getInputStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ String s = null;
+ while ((s = br.readLine()) != null)
+ System.out.println(s);
+ }
+ catch (IOException e)
+ {
+ }
+ finally
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ }
+*/
+}
diff --git a/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCWebServiceTester.java b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCWebServiceTester.java
new file mode 100644
index 000000000..ea068568d
--- /dev/null
+++ b/core/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCWebServiceTester.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060608 145529 kathy@ca.ibm.com - Kathy Chan
+ *******************************************************************************/
+
+package org.eclipse.jst.ws.internal.consumption.ui.widgets.test.wssample;
+
+import java.util.Vector;
+
+import org.eclipse.wst.command.internal.env.core.ICommandFactory;
+import org.eclipse.wst.command.internal.env.core.SimpleCommandFactory;
+import org.eclipse.wst.ws.internal.wsrt.IWebServiceTester;
+import org.eclipse.wst.ws.internal.wsrt.TestInfo;
+
+public class GSTCWebServiceTester implements IWebServiceTester {
+
+ public ICommandFactory generate(TestInfo testInfo){
+ Vector commands = new Vector();
+ commands.add(new AddModuleDependenciesCommand(testInfo));
+ commands.add(new GSTCGenerateCommand(testInfo));
+ return new SimpleCommandFactory(commands);
+ }
+
+ public ICommandFactory launch(TestInfo testInfo){
+ Vector commands = new Vector();
+ if (testInfo.getRunTestClient()) {
+ commands.add(new GSTCLaunchCommand(testInfo));
+ }
+ return new SimpleCommandFactory(commands);
+ }
+
+}

Back to the top