|
Link Here
|
| 14 |
* 20070327 172339 kathy@ca.ibm.com - Kathy Chan |
14 |
* 20070327 172339 kathy@ca.ibm.com - Kathy Chan |
| 15 |
* 20080123 216372 kathy@ca.ibm.com - Kathy Chan |
15 |
* 20080123 216372 kathy@ca.ibm.com - Kathy Chan |
| 16 |
* 20090122 257618 mahutch@ca.ibm.com - Mark Hutchinson, Add Mechanism for Adopters to map Services to WSDL URLs |
16 |
* 20090122 257618 mahutch@ca.ibm.com - Mark Hutchinson, Add Mechanism for Adopters to map Services to WSDL URLs |
|
|
17 |
* 20090310 242440 yenlu@ca.ibm.com - Yen Lu, Pluggable IFile to URI Converter |
| 17 |
*******************************************************************************/ |
18 |
*******************************************************************************/ |
| 18 |
package org.eclipse.wst.ws.internal.explorer.popup; |
19 |
package org.eclipse.wst.ws.internal.explorer.popup; |
| 19 |
|
20 |
|
|
Link Here
|
| 23 |
import java.util.List; |
24 |
import java.util.List; |
| 24 |
import java.util.Vector; |
25 |
import java.util.Vector; |
| 25 |
|
26 |
|
|
|
27 |
import org.eclipse.core.resources.IFile; |
| 26 |
import org.eclipse.core.resources.IResource; |
28 |
import org.eclipse.core.resources.IResource; |
|
|
29 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 30 |
import org.eclipse.core.runtime.Path; |
| 27 |
import org.eclipse.core.runtime.Platform; |
31 |
import org.eclipse.core.runtime.Platform; |
| 28 |
import org.eclipse.jface.action.Action; |
32 |
import org.eclipse.jface.action.Action; |
| 29 |
import org.eclipse.jface.action.IAction; |
33 |
import org.eclipse.jface.action.IAction; |
| 30 |
import org.eclipse.jface.viewers.ISelection; |
34 |
import org.eclipse.jface.viewers.ISelection; |
| 31 |
import org.eclipse.jface.viewers.IStructuredSelection; |
35 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 32 |
import org.eclipse.ui.IActionDelegate; |
36 |
import org.eclipse.ui.IActionDelegate; |
|
|
37 |
import org.eclipse.wst.ws.internal.converter.IIFile2UriConverter; |
| 33 |
import org.eclipse.wst.ws.internal.explorer.LaunchOption; |
38 |
import org.eclipse.wst.ws.internal.explorer.LaunchOption; |
| 34 |
import org.eclipse.wst.ws.internal.explorer.LaunchOptions; |
39 |
import org.eclipse.wst.ws.internal.explorer.LaunchOptions; |
| 35 |
import org.eclipse.wst.ws.internal.explorer.WSExplorerLauncherCommand; |
40 |
import org.eclipse.wst.ws.internal.explorer.WSExplorerLauncherCommand; |
| 36 |
import org.eclipse.wst.ws.internal.explorer.plugin.ExplorerPlugin; |
41 |
import org.eclipse.wst.ws.internal.explorer.plugin.ExplorerPlugin; |
| 37 |
import org.eclipse.wst.ws.internal.monitor.GetMonitorCommand; |
42 |
import org.eclipse.wst.ws.internal.monitor.GetMonitorCommand; |
| 38 |
import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser; |
43 |
import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser; |
|
|
44 |
import org.eclipse.wst.ws.internal.plugin.WSPlugin; |
| 39 |
import org.eclipse.wst.ws.internal.ui.utils.AdapterUtils; |
45 |
import org.eclipse.wst.ws.internal.ui.utils.AdapterUtils; |
| 40 |
import org.eclipse.wst.ws.internal.wsfinder.WSDLURLStringWrapper; |
46 |
import org.eclipse.wst.ws.internal.wsfinder.WSDLURLStringWrapper; |
| 41 |
import org.eclipse.wst.wsdl.Definition; |
47 |
import org.eclipse.wst.wsdl.Definition; |
|
Link Here
|
| 66 |
Object object = it.next(); |
72 |
Object object = it.next(); |
| 67 |
if (object instanceof IResource) |
73 |
if (object instanceof IResource) |
| 68 |
{ |
74 |
{ |
| 69 |
File wsdlFile = ((IResource)object).getLocation().toFile(); |
75 |
File wsdlFile = ((IResource)object).getLocation().toFile(); |
| 70 |
try |
76 |
try |
| 71 |
{ |
77 |
{ |
| 72 |
wsdlURL = wsdlFile.toURL().toString(); |
78 |
wsdlURL = wsdlFile.toURL().toString(); |
| 73 |
} |
79 |
} |
| 74 |
catch (MalformedURLException murle) |
80 |
catch (MalformedURLException murle) |
| 75 |
{ |
81 |
{ |
| 76 |
wsdlURL = wsdlFile.toString(); |
82 |
wsdlURL = wsdlFile.toString(); |
| 77 |
} |
83 |
} |
|
|
84 |
if (object instanceof IFile) |
| 85 |
wsdlURL = getConvertedURIFromIFile((IFile)object,wsdlURL); |
| 78 |
} |
86 |
} |
| 79 |
else if (Platform.getAdapterManager().hasAdapter(object, WSDLURLStringWrapper.class.getName())) { |
87 |
else if (Platform.getAdapterManager().hasAdapter(object, WSDLURLStringWrapper.class.getName())) { |
| 80 |
Object adaptedObject = Platform.getAdapterManager().loadAdapter(object, WSDLURLStringWrapper.class.getName()); |
88 |
Object adaptedObject = Platform.getAdapterManager().loadAdapter(object, WSDLURLStringWrapper.class.getName()); |
|
Link Here
|
| 85 |
{ |
93 |
{ |
| 86 |
ServiceImpl serviceImpl = (ServiceImpl)object; |
94 |
ServiceImpl serviceImpl = (ServiceImpl)object; |
| 87 |
Definition definition = serviceImpl.getEnclosingDefinition(); |
95 |
Definition definition = serviceImpl.getEnclosingDefinition(); |
| 88 |
wsdlURL = definition.getLocation(); |
96 |
wsdlURL = getConvertedURIFromURI(definition.getLocation()); |
| 89 |
} else if (object instanceof WSDLResourceImpl) |
97 |
} else if (object instanceof WSDLResourceImpl) |
| 90 |
{ |
98 |
{ |
| 91 |
WSDLResourceImpl WSDLRImpl = (WSDLResourceImpl)object; |
99 |
WSDLResourceImpl WSDLRImpl = (WSDLResourceImpl)object; |
| 92 |
Definition definition = WSDLRImpl.getDefinition(); |
100 |
Definition definition = WSDLRImpl.getDefinition(); |
| 93 |
wsdlURL = definition.getLocation(); |
101 |
wsdlURL = getConvertedURIFromURI(definition.getLocation()); |
| 94 |
} else if (object instanceof String) { |
102 |
} else if (object instanceof String) { |
| 95 |
wsdlURL = (String) object; |
103 |
wsdlURL = (String) object; |
| 96 |
} else { |
104 |
} else { |
|
Link Here
|
| 100 |
// If not found, wsdlURL would still be null. |
108 |
// If not found, wsdlURL would still be null. |
| 101 |
wsdlURL = AdapterUtils.getAdaptedWSDL(object); |
109 |
wsdlURL = AdapterUtils.getAdaptedWSDL(object); |
| 102 |
} |
110 |
} |
| 103 |
|
111 |
if (wsdlURL != null) |
| 104 |
addLaunchOptions(launchOptions, wsdlURL, stateLocation, defaultFavoritesLocation); |
112 |
addLaunchOptions(launchOptions, wsdlURL, stateLocation, defaultFavoritesLocation); |
| 105 |
} |
113 |
} |
| 106 |
} |
114 |
} |
| 107 |
command.setLaunchOptions((LaunchOption[])launchOptions.toArray(new LaunchOption[0])); |
115 |
command.setLaunchOptions((LaunchOption[])launchOptions.toArray(new LaunchOption[0])); |
|
Link Here
|
| 148 |
this.selection = null; |
156 |
this.selection = null; |
| 149 |
} |
157 |
} |
| 150 |
|
158 |
|
|
|
159 |
private String getConvertedURIFromIFile(IFile file,String defaultURI) |
| 160 |
{ |
| 161 |
String convertedLocation = null; |
| 162 |
boolean allowBaseConversionOnFailure = true; |
| 163 |
if (file != null && file.exists()) |
| 164 |
{ |
| 165 |
IIFile2UriConverter converter = WSPlugin.getInstance().getIFile2UriConverter(); |
| 166 |
if (converter != null) |
| 167 |
{ |
| 168 |
convertedLocation = converter.convert(file); |
| 169 |
allowBaseConversionOnFailure = converter.allowBaseConversionOnFailure(); |
| 170 |
} |
| 171 |
} |
| 172 |
if (convertedLocation == null && allowBaseConversionOnFailure) |
| 173 |
return defaultURI; |
| 174 |
return convertedLocation; |
| 175 |
} |
| 176 |
|
| 177 |
private String getConvertedURIFromURI(String originalURI) |
| 178 |
{ |
| 179 |
IFile file = null; |
| 180 |
if (originalURI != null) |
| 181 |
{ |
| 182 |
String platformResource = "platform:/resource"; |
| 183 |
if (originalURI.startsWith(platformResource)) |
| 184 |
file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(originalURI.substring(platformResource.length()))); |
| 185 |
else if (originalURI.startsWith("file:")) |
| 186 |
{ |
| 187 |
String filePath = convertToRelative(originalURI); |
| 188 |
file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)); |
| 189 |
} |
| 190 |
} |
| 191 |
return getConvertedURIFromIFile(file,originalURI); |
| 192 |
} |
| 193 |
|
| 194 |
public static String convertToRelative(String uri) |
| 195 |
{ |
| 196 |
//remove file: |
| 197 |
String file = "file:/"; |
| 198 |
String fileL = "file:"; |
| 199 |
String root = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString(); |
| 200 |
root = file + root; |
| 201 |
String rootL = fileL + root; |
| 202 |
if(uri.startsWith(root) || uri.startsWith(rootL)){ |
| 203 |
return uri.substring(root.length()); |
| 204 |
} |
| 205 |
return uri; |
| 206 |
} |
| 207 |
|
| 151 |
} |
208 |
} |