Skip to main content
summaryrefslogtreecommitdiffstats
blob: 2096c8d90c422bf5bfe6a9762dfd576f823a78a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*******************************************************************************
 * 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.creation.ui.widgets.test;

import java.util.List;
import java.util.Vector;

import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.WSDLTestLaunchCommand;
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.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.Listener;
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.common.environment.IEnvironment;


public class ServiceTestWidget extends SimpleWidgetDataContributor
{
  private String createPluginId_ = "org.eclipse.jst.ws.creation.ui";

  private Combo testTypeCombo_;
  /*CONTEXT_ID PSTP0001 for the Test Type Combo box of the Service Test Page*/
  private final String INFOPOP_PSTP_COMBOBOX_TEST = "PSTP0001";

  private Button launchButton_;
  /*CONTEXT_ID PSTP0002 for the launch button of the Service Test Page*/
  private final String INFOPOP_PSTP_LAUNCH_BUTTON = "PSTP0002";

  
  private SelectionList facilities_;
  
  private String serviceServerInstanceId = null;
  
  public WidgetDataEvents addControls( Composite parent, Listener statusListener )
  {
    UIUtils      uiUtils  = new UIUtils(createPluginId_ );
        
    Composite testComposite = uiUtils.createComposite( parent, 3, 0, 0 );
    
    testTypeCombo_ = uiUtils.createCombo( testComposite, ConsumptionUIMessages.LABEL_TEST_TYPES,
    									ConsumptionUIMessages.TOOLTIP_PSTP_COMBOBOX_TEST,
                                          INFOPOP_PSTP_COMBOBOX_TEST,
                                          SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY );
    
    launchButton_ = uiUtils.createPushButton( testComposite, ConsumptionUIMessages.BUTTON_LAUNCH_SERVICE_TEST,
    									ConsumptionUIMessages.TOOLTIP_PSTP_LAUNCH_BUTTON,
                                          INFOPOP_PSTP_LAUNCH_BUTTON );
    launchButton_.addSelectionListener( new SelectionAdapter()
                                        {
                                          public void widgetSelected( SelectionEvent event )
                                          {
                                            handleLaunchButton();
                                          }
                                        });
    
     
    return this;
  }
  
  private TypeRuntimeServer serviceids;
  private String serverProject;
  private String module;
  private String wsdlURI;
  private String launchedServiceTestName = "";
  private IEnvironment env;
  private List endpoints;
  
  private void handleLaunchButton()
  {
	// Split up the project and module
	int p = serverProject.indexOf("/");
	if (p != -1){
		module = serverProject.substring(p+1);
		serverProject = serverProject.substring(0,p);
	}
  	
  	String testID = testTypeCombo_.getText();
  	launchedServiceTestName = testID;
  	WSDLTestLaunchCommand wtlc = new WSDLTestLaunchCommand();
  	wtlc.setTestID(testID);
  	wtlc.setServiceTypeRuntimeServer(serviceids);
	  wtlc.setServiceServerInstanceId(serviceServerInstanceId);
  	wtlc.setServerProject(serverProject);
	  wtlc.setServerModule(module);
  	wtlc.setWsdlURI(wsdlURI);
  	wtlc.setExternalBrowser(true);
  	wtlc.setEndpoint(endpoints);
  	wtlc.setEnvironment( env );
  	wtlc.execute( null, null );
  }
  
  public void setServiceTestFacilities( SelectionList facilities )
  {
    facilities_ = facilities;
    testTypeCombo_.setItems( facilities.getList() );
    testTypeCombo_.select( facilities.getIndex() );
  }
  
  public SelectionList getServiceTestFacilities()
  {
    facilities_.setIndex( testTypeCombo_.getSelectionIndex() );
    return facilities_;
  }

  public String getTestID()
  {
  	return testTypeCombo_.getText();
  }
  
  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 String getLaunchedServiceTestName()
  {
    return launchedServiceTestName;
  }

  public void setEnvironment(IEnvironment env)
  {
  	this.env = env;
  }

  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 void setServiceServerInstanceId(String ssInstanceId){
	  this.serviceServerInstanceId = ssInstanceId;
  }
  
}

Back to the top