Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 165544 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tptp/wsdm/tooling/util/internal/XsdUtils.java (-11 / +1 lines)
Lines 421-437 Link Here
421
	 */
421
	 */
422
	public static String getType(XSDTypeDefinition typeDefinition)
422
	public static String getType(XSDTypeDefinition typeDefinition)
423
	{
423
	{
424
		return typeDefinition.getName();
424
		return typeDefinition.getName();		
425
		/*
426
		 * if (typeDefinition instanceof XSDSimpleTypeDefinition) {
427
		 * XSDSimpleTypeDefinition simpleTypeDefinition =
428
		 * (XSDSimpleTypeDefinition) typeDefinition; String type =
429
		 * simpleTypeDefinition.getName(); return type; } else if(typeDefinition
430
		 * instanceof XSDComplexTypeDefinition) { XSDComplexTypeDefinition
431
		 * complexTypeDefinition = (XSDComplexTypeDefinition) typeDefinition;
432
		 * String type = complexTypeDefinition.getName(); return type; } return
433
		 * "";
434
		 */
435
	}
425
	}
436
426
437
	/**
427
	/**
(-)src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java (-51 / +54 lines)
Lines 39-44 Link Here
39
import org.eclipse.core.runtime.CoreException;
39
import org.eclipse.core.runtime.CoreException;
40
import org.eclipse.core.runtime.IProgressMonitor;
40
import org.eclipse.core.runtime.IProgressMonitor;
41
import org.eclipse.emf.common.util.URI;
41
import org.eclipse.emf.common.util.URI;
42
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.EclipseEnvironment;
42
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
43
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
43
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages;
44
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages;
44
import org.eclipse.xsd.XSDComplexTypeDefinition;
45
import org.eclipse.xsd.XSDComplexTypeDefinition;
Lines 51-57 Link Here
51
import org.w3c.dom.Document;
52
import org.w3c.dom.Document;
52
import org.w3c.dom.Element;
53
import org.w3c.dom.Element;
53
import org.w3c.dom.NodeList;
54
import org.w3c.dom.NodeList;
54
import org.xml.sax.InputSource;
55
import org.xml.sax.SAXException;
55
import org.xml.sax.SAXException;
56
56
57
import com.ibm.wsdl.extensions.schema.SchemaConstants;
57
import com.ibm.wsdl.extensions.schema.SchemaConstants;
Lines 83-100 Link Here
83
	public static CapabilityDefinition getCapabilityDefinition(IFile wsdlFile)
83
	public static CapabilityDefinition getCapabilityDefinition(IFile wsdlFile)
84
			throws Exception
84
			throws Exception
85
	{
85
	{
86
		String wsdlFileLocation = wsdlFile.getRawLocation().toString();
86
		String iFileLocation = wsdlFile.getFullPath().toString();
87
		InputStream is = wsdlFile.getContents();
87
		String path = "platform:/resource" + iFileLocation;
88
		InputSource source = new InputSource(is);
88
		URI wsdlFileURI = URI.createURI(path);
89
		return getCapabilityDefinition(wsdlFileURI);
90
	}
91
92
	/**
93
	 * Returns the EMF based object Definition of the given WSDL file.
94
	 * 
95
	 * @param wsdlFile
96
	 *            Any WSDL file available in eclipse workbench
97
	 * 
98
	 * @return EMF based Definition object
99
	 * @throws Exception
100
	 */
101
	public static CapabilityDefinition getCapabilityDefinition(URI wsdlFileURI)
102
			throws Exception
103
	{
104
		EclipseEnvironment eclipseEnv = new EclipseEnvironment();
105
		String path = wsdlFileURI.toString();
106
		Document document = org.apache.muse.ws.wsdl.WsdlUtils.createWSDL(
107
				eclipseEnv, path, true);
108
		Element cleanDocument = org.apache.muse.ws.wsdl.WsdlUtils
109
				.removeSchemaReferences(document.getDocumentElement());
110
		cleanDocument = org.apache.muse.ws.wsdl.WsdlUtils
111
				.removeWsdlReferences(cleanDocument);
89
		WSDLFactory factory = WSDLFactory.newInstance();
112
		WSDLFactory factory = WSDLFactory.newInstance();
90
		WSDLReader reader = factory.newWSDLReader();
113
		WSDLReader reader = factory.newWSDLReader();
91
		Definition definition = reader.readWSDL(wsdlFileLocation, source);
114
		Definition definition = reader.readWSDL(null, cleanDocument);
92
		CapabilityDefinition capabilityDefinition = new CapabilityDefinition(
115
		CapabilityDefinition capabilityDefinition = new CapabilityDefinition(
93
				definition);
116
				definition);
94
		String iFileLocation = wsdlFile.getFullPath().toString();
117
		capabilityDefinition.setWSDLResourceProtocolURI(wsdlFileURI);
95
		URI resourceProtocolURI = URI.createURI("platform:/resource"
96
				+ iFileLocation);
97
		capabilityDefinition.setWSDLResourceProtocolURI(resourceProtocolURI);
98
		return capabilityDefinition;
118
		return capabilityDefinition;
99
	}
119
	}
100
120
Lines 195-241 Link Here
195
	}
215
	}
196
216
197
	/**
217
	/**
198
	 * Saves an WSDL Definition into IFile in formatted representation.
199
	 * 
200
	 * @param definition
201
	 *            WSDL Definition object to be saved.
202
	 * 
203
	 * @param wsdlFile
204
	 *            Eclipse file to which WSDL Definition object will be saved.
205
	 * 
206
	 * @param monitor
207
	 *            Progress monitor.
208
	 * @throws IOException
209
	 * @throws CoreException
210
	 */
211
	public static void serializeAndFormatWSDL(Definition definition,
212
			IFile wsdlFile, IProgressMonitor monitor) throws IOException,
213
			CoreException
214
	{
215
		// String fileURI = wsdlFile.getFullPath().toString();
216
		// ByteArrayOutputStream baos = saveWSDLDefinition(definition, fileURI,
217
		// null);
218
		// String serializedString = CapUtils.getSerializedDocument(baos
219
		// .toString());
220
		// ByteArrayInputStream baInputStream = new ByteArrayInputStream(
221
		// serializedString.getBytes());
222
		// try
223
		// {
224
		// if (wsdlFile.exists())
225
		// wsdlFile.setContents(baInputStream, IFile.FORCE, monitor);
226
		// else
227
		// wsdlFile.create(baInputStream, IFile.FORCE, monitor);
228
		// } catch (CoreException e)
229
		// {
230
		// WsdmToolingLog
231
		// .logError(Messages.FAILED_TO_SAVE_MCAP_FILE_ERROR_, e);
232
		// throw e;
233
		// }
234
235
		// TODO
236
	}
237
238
	/**
239
	 * Returns XSDElementDeclaration for return type of operation.
218
	 * Returns XSDElementDeclaration for return type of operation.
240
	 */
219
	 */
241
	public static XSDElementDeclaration getReturnTypeElement(
220
	public static XSDElementDeclaration getReturnTypeElement(
Lines 298-304 Link Here
298
					.getXSDModelGroup(complexTypeDefinition);
277
					.getXSDModelGroup(complexTypeDefinition);
299
			return XsdUtils.getElementDeclarations(modelGroup);
278
			return XsdUtils.getElementDeclarations(modelGroup);
300
		}
279
		}
301
		return new XSDElementDeclaration[] { element };
280
		return new XSDElementDeclaration[]
281
		{ element };
302
	}
282
	}
303
283
304
	/**
284
	/**
Lines 562-565 Link Here
562
		return element;
542
		return element;
563
	}
543
	}
564
544
545
	/**
546
	 * Returns the WSDL message from WSDL definition object. 
547
	 */
548
	public static Message getWSDLMessage(Definition definition,
549
			String messageName)
550
	{
551
		Map messagesMap = definition.getMessages();
552
		if (messagesMap == null || messagesMap.size() == 0)
553
			return null;
554
		Iterator it = messagesMap.values().iterator();
555
		while (it.hasNext())
556
		{
557
			Object object = it.next();
558
			if (object instanceof Message)
559
			{
560
				Message message = (Message) object;
561
				if (message.getQName().getLocalPart().equals(messageName))
562
					return message;
563
			}
564
		}
565
		return null;
566
	}
567
565
}
568
}
(-)src/org/eclipse/tptp/wsdm/tooling/util/internal/IFile2Capability.java (-48 / +23 lines)
Lines 12-97 Link Here
12
12
13
package org.eclipse.tptp.wsdm.tooling.util.internal;
13
package org.eclipse.tptp.wsdm.tooling.util.internal;
14
14
15
import java.io.InputStream;
16
import java.util.LinkedList;
17
import java.util.List;
18
19
import javax.wsdl.Definition;
15
import javax.wsdl.Definition;
20
import javax.wsdl.factory.WSDLFactory;
16
import javax.wsdl.factory.WSDLFactory;
21
import javax.wsdl.xml.WSDLReader;
17
import javax.wsdl.xml.WSDLReader;
22
18
23
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IFile;
24
import org.eclipse.emf.common.util.URI;
20
import org.eclipse.emf.common.util.URI;
21
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.EclipseEnvironment;
25
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
22
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
26
import org.xml.sax.InputSource;
23
import org.w3c.dom.Document;
24
import org.w3c.dom.Element;
25
26
/**
27
 * 
28
 * This class can convert a proper IFile object to Capability object.
29
 *
30
 */
27
31
28
public class IFile2Capability
32
public class IFile2Capability extends Definition2Capability
29
{
33
{
30
	protected IFile _mcapFile;
34
	protected IFile _mcapFile;
31
	protected Capability _capability;
32
	protected List _errorDiagonistics = new LinkedList();
33
	protected List _warningDiagonistics = new LinkedList();
34
35
35
	public IFile2Capability(IFile mcapFile)
36
	public IFile2Capability(IFile mcapFile)
36
	{
37
	{
38
		super(parse(mcapFile));
37
		_mcapFile = mcapFile;
39
		_mcapFile = mcapFile;
38
	}
40
	}
39
41
40
	public Capability getCapability()
42
	public Capability getCapability()
41
	{
43
	{
42
		Definition definition = parse();
43
		Definition2Capability def2Cap = new Definition2Capability(definition);
44
		URI capabilityURI = URI.createPlatformResourceURI(_mcapFile
44
		URI capabilityURI = URI.createPlatformResourceURI(_mcapFile
45
				.getFullPath().toString());
45
				.getFullPath().toString());
46
		_capability = def2Cap.getCapability(capabilityURI);
46
		return getCapability(capabilityURI);
47
		_errorDiagonistics.addAll(def2Cap.getErrorDiagonistics());
48
		_warningDiagonistics.addAll(def2Cap.getWarningDiagonistics());
49
		return _capability;
50
	}
47
	}
51
48
52
	private Definition parse()
49
	private static Definition parse(IFile mcapFile)
53
	{
50
	{
54
		try
51
		try
55
		{
52
		{
56
			String wsdlFileLocation = _mcapFile.getRawLocation().toString();
53
			EclipseEnvironment eclipseEnv = new EclipseEnvironment();
57
			InputStream is = _mcapFile.getContents();
54
			String iFileLocation = mcapFile.getFullPath().toString();
58
			InputSource source = new InputSource(is);
55
			String path = "platform:/resource" + iFileLocation;
56
			Document document = org.apache.muse.ws.wsdl.WsdlUtils.createWSDL(
57
					eclipseEnv, path, true);
58
			Element cleanDocument = org.apache.muse.ws.wsdl.WsdlUtils
59
					.removeSchemaReferences(document.getDocumentElement());
60
			cleanDocument = org.apache.muse.ws.wsdl.WsdlUtils
61
					.removeWsdlReferences(cleanDocument);
59
			WSDLFactory factory = WSDLFactory.newInstance();
62
			WSDLFactory factory = WSDLFactory.newInstance();
60
			WSDLReader reader = factory.newWSDLReader();
63
			WSDLReader reader = factory.newWSDLReader();
61
			Definition definition = reader.readWSDL(wsdlFileLocation, source);
64
			Definition definition = reader.readWSDL(null, cleanDocument);
62
			return definition;
65
			return definition;
63
		}
66
		}
64
		catch (Exception e)
67
		catch (Exception e)
65
		{
68
		{
66
			prepareErrorDiagnostics(e.getMessage());
67
		}
69
		}
68
69
		return null;
70
		return null;
70
	}
71
	}
71
72
	/**
73
	 * Returns the error diagnostics list.
74
	 */
75
	public List getErrorDiagonistics()
76
	{
77
		return _errorDiagonistics;
78
	}
79
80
	/**
81
	 * Returns the warning diagnostics list.
82
	 */
83
	public List getWarningDiagonistics()
84
	{
85
		return _warningDiagonistics;
86
	}
87
88
	protected void prepareErrorDiagnostics(String message)
89
	{
90
		_errorDiagonistics.add(message);
91
	}
92
93
	protected void prepareWarningDiagnostics(String message)
94
	{
95
		_warningDiagonistics.add(message);
96
	}
97
}
72
}
(-)src/org/eclipse/tptp/wsdm/tooling/util/internal/MrtUtils.java (-12 / +13 lines)
Lines 34-39 Link Here
34
import org.eclipse.emf.ecore.resource.Resource;
34
import org.eclipse.emf.ecore.resource.Resource;
35
import org.eclipse.emf.ecore.resource.ResourceSet;
35
import org.eclipse.emf.ecore.resource.ResourceSet;
36
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
36
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
37
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator;
37
import org.eclipse.tptp.wsdm.tooling.editor.internal.CategoryCollection;
38
import org.eclipse.tptp.wsdm.tooling.editor.internal.CategoryCollection;
38
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
39
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
39
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType;
40
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType;
Lines 160-168 Link Here
160
	public static Collection getWSRPCapabilityUris(boolean includeOptional)
161
	public static Collection getWSRPCapabilityUris(boolean includeOptional)
161
	{
162
	{
162
		List retVal = new LinkedList();
163
		List retVal = new LinkedList();
163
		String ns = "org.eclipse.tptp.wsdm.model";
164
		IExtensionPoint iep = Platform.getExtensionRegistry()
164
		IExtensionPoint iep = Platform.getExtensionRegistry()
165
				.getExtensionPoint(ns, "mrCapability");
165
				.getExtensionPoint(Activator.MODEL_PLUGIN_ID,
166
						Activator.MR_CAPABILITY_EXT_PT);
166
		if (iep != null)
167
		if (iep != null)
167
		{
168
		{
168
			IExtension[] extensions = iep.getExtensions();
169
			IExtension[] extensions = iep.getExtensions();
Lines 189-197 Link Here
189
	public static Collection getMandatoryCapabilityUris(boolean includeOptional)
190
	public static Collection getMandatoryCapabilityUris(boolean includeOptional)
190
	{
191
	{
191
		List retVal = new LinkedList();
192
		List retVal = new LinkedList();
192
		String ns = "org.eclipse.tptp.wsdm.model";
193
		IExtensionPoint iep = Platform.getExtensionRegistry()
193
		IExtensionPoint iep = Platform.getExtensionRegistry()
194
				.getExtensionPoint(ns, "mrCapability");
194
				.getExtensionPoint(Activator.MODEL_PLUGIN_ID,
195
						Activator.MR_CAPABILITY_EXT_PT);
195
		if (iep != null)
196
		if (iep != null)
196
		{
197
		{
197
			IExtension[] extensions = iep.getExtensions();
198
			IExtension[] extensions = iep.getExtensions();
Lines 222-230 Link Here
222
	 */
223
	 */
223
	public static boolean isCapabilityEditable(String name)
224
	public static boolean isCapabilityEditable(String name)
224
	{
225
	{
225
		String ns = "org.eclipse.tptp.wsdm.model";
226
		IExtensionPoint iep = Platform.getExtensionRegistry()
226
		IExtensionPoint iep = Platform.getExtensionRegistry()
227
				.getExtensionPoint(ns, "mrCapability");
227
				.getExtensionPoint(Activator.MODEL_PLUGIN_ID,
228
						Activator.MR_CAPABILITY_EXT_PT);
228
		if (iep != null)
229
		if (iep != null)
229
		{
230
		{
230
			IExtension[] extensions = iep.getExtensions();
231
			IExtension[] extensions = iep.getExtensions();
Lines 254-262 Link Here
254
	 */
255
	 */
255
	public static boolean isSystemCapability(String name)
256
	public static boolean isSystemCapability(String name)
256
	{
257
	{
257
		String ns = "org.eclipse.tptp.wsdm.model";
258
		IExtensionPoint iep = Platform.getExtensionRegistry()
258
		IExtensionPoint iep = Platform.getExtensionRegistry()
259
				.getExtensionPoint(ns, "mrCapability");
259
				.getExtensionPoint(Activator.MODEL_PLUGIN_ID,
260
						Activator.MR_CAPABILITY_EXT_PT);
260
		if (iep != null)
261
		if (iep != null)
261
		{
262
		{
262
			IExtension[] extensions = iep.getExtensions();
263
			IExtension[] extensions = iep.getExtensions();
Lines 284-292 Link Here
284
	public static List getMrCapabilityWsdls()
285
	public static List getMrCapabilityWsdls()
285
	{
286
	{
286
		List retVal = new LinkedList();
287
		List retVal = new LinkedList();
287
		String ns = "org.eclipse.tptp.wsdm.model";
288
		IExtensionPoint iep = Platform.getExtensionRegistry()
288
		IExtensionPoint iep = Platform.getExtensionRegistry()
289
				.getExtensionPoint(ns, "mrCapability");
289
				.getExtensionPoint(Activator.MODEL_PLUGIN_ID,
290
						Activator.MR_CAPABILITY_EXT_PT);
290
		if (iep != null)
291
		if (iep != null)
291
		{
292
		{
292
			IExtension[] extensions = iep.getExtensions();
293
			IExtension[] extensions = iep.getExtensions();
Lines 312-320 Link Here
312
	public static List getMandatoryWsdls(boolean includeOptional)
313
	public static List getMandatoryWsdls(boolean includeOptional)
313
	{
314
	{
314
		List retVal = new LinkedList();
315
		List retVal = new LinkedList();
315
		String ns = "org.eclipse.tptp.wsdm.model";
316
		IExtensionPoint iep = Platform.getExtensionRegistry()
316
		IExtensionPoint iep = Platform.getExtensionRegistry()
317
				.getExtensionPoint(ns, "mrCapability");
317
				.getExtensionPoint(Activator.MODEL_PLUGIN_ID,
318
						Activator.MR_CAPABILITY_EXT_PT);
318
		if (iep != null)
319
		if (iep != null)
319
		{
320
		{
320
			IExtension[] extensions = iep.getExtensions();
321
			IExtension[] extensions = iep.getExtensions();
(-)src/org/eclipse/tptp/wsdm/tooling/util/internal/CapUtils.java (-89 / +9 lines)
Lines 64-74 Link Here
64
			"volatile", "const", "float", "native", "super", "while", "true",
64
			"volatile", "const", "float", "native", "super", "while", "true",
65
			"false", "null" });
65
			"false", "null" });
66
66
67
	// This map will contain Capability URI as key and List of Capability WSDL
68
	// Definition as value
69
	// all of which have the same capability uri
70
	private static Map standardCapabilityMap = null;
71
72
	// Capability operation name should not be conflicted with their super java
67
	// Capability operation name should not be conflicted with their super java
73
	// implementation classes.
68
	// implementation classes.
74
	private static Method[] abstractCapabilityMethods = new Method[0];
69
	private static Method[] abstractCapabilityMethods = new Method[0];
Lines 205-215 Link Here
205
		{
200
		{
206
			if (XsdUtils.isReferencedElement(elementRefs[i]))
201
			if (XsdUtils.isReferencedElement(elementRefs[i]))
207
			{
202
			{
208
				/*
209
				 * WsdlElementResolver resolver = new WsdlElementResolver(
210
				 * definition, resourcePropertyElement, elementRefs[i]);
211
				 * XSDElementDeclaration resolvedElement = resolver.resolve();
212
				 */
213
				XSDElementDeclaration resolvedElement = elementRefs[i]
203
				XSDElementDeclaration resolvedElement = elementRefs[i]
214
						.getResolvedElementDeclaration();
204
						.getResolvedElementDeclaration();
215
				if (resolvedElement != null)
205
				if (resolvedElement != null)
Lines 321-331 Link Here
321
		{
311
		{
322
			if (XsdUtils.isReferencedElement(elementRefs[i]))
312
			if (XsdUtils.isReferencedElement(elementRefs[i]))
323
			{
313
			{
324
				/*
325
				 * WsdlElementResolver resolver = new WsdlElementResolver(
326
				 * definition, resourcePropertyElement, elementRefs[i]);
327
				 * XSDElementDeclaration resolvedElement = resolver.resolve();
328
				 */
329
				XSDElementDeclaration resolvedElement = elementRefs[i]
314
				XSDElementDeclaration resolvedElement = elementRefs[i]
330
						.getResolvedElementDeclaration();
315
						.getResolvedElementDeclaration();
331
				if (resolvedElement != null)
316
				if (resolvedElement != null)
Lines 456-535 Link Here
456
		return XsdUtils.getName(property.getElement());
441
		return XsdUtils.getName(property.getElement());
457
	}
442
	}
458
443
459
	// TODO Uncomment it
460
461
	// /**
462
	// * Returns the Map of All capabilites available (Standarad+Workspace).
463
	// * Key will be Capability URI and Value will be List of Capability WSDL
464
	// Definition
465
	// * which maps to same Capability URI.
466
	// * @throws Exception
467
	// */
468
	// public static Map getAllCapabilitiesMap() throws Exception{
469
	// if(standardCapabilityMap == null){
470
	// standardCapabilityMap = new HashMap();
471
	// // Get All ManagementCapabilities
472
	// Definition[] caps = (Definition[])
473
	// MrtUtils.getManagementCapabilities().toArray(new Definition[0]);
474
	// poplulateCapabilityMap(standardCapabilityMap, caps);
475
	// // Get All ManagementRelatedCapabilities
476
	// caps = (Definition[])
477
	// MrtUtils.getManagementRelatedCapabilities().toArray(new Definition[0]);
478
	// poplulateCapabilityMap(standardCapabilityMap, caps);
479
	// // Get All ResourcePropertyCapabilities
480
	// caps = (Definition[])
481
	// MrtUtils.getResourcePropertyCapabilities().toArray(new Definition[0]);
482
	// poplulateCapabilityMap(standardCapabilityMap, caps);
483
	// // Get All ResourceLifetimeCapabilities
484
	// caps = (Definition[])
485
	// MrtUtils.getResourceLifetimeCapabilities().toArray(new Definition[0]);
486
	// poplulateCapabilityMap(standardCapabilityMap, caps);
487
	// }
488
	// Map allCapabilities = new HashMap();
489
	// allCapabilities.putAll(standardCapabilityMap);
490
	// // Get All WorkspaceCapabilities
491
	// Definition[] workspaceCapabilities = getAllWorkspaceCapabilities();
492
	// poplulateCapabilityMap(allCapabilities, workspaceCapabilities);
493
	// return allCapabilities;
494
	// }
495
	//    
496
	// private static void poplulateCapabilityMap(Map map, Definition[]
497
	// capabilities){
498
	// for(int i=0;i<capabilities.length;i++){
499
	// String key = capabilities[i].getNamespace("capabilityURI");
500
	// if(key == null)
501
	// key = capabilities[i].getTargetNamespace();
502
	// Object value = map.get(key);
503
	// if(value == null){
504
	// List list = new LinkedList();
505
	// list.add(capabilities[i]);
506
	// map.put(key, list);
507
	// }
508
	// else{
509
	// List list = (List) value;
510
	// list.add(capabilities[i]);
511
	// }
512
	// }
513
	// }
514
	//    
515
	//    
516
	// /**
517
	// * Returns all the Workspace capabilities.
518
	// */
519
	// public static Definition[] getAllWorkspaceCapabilities() throws
520
	// Exception{
521
	// IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
522
	// List allWSDLs = new LinkedList();
523
	// List wsdls = EclipseUtils.getResourcesOfExtension(root, "mcap");
524
	// for (int i=0;i<wsdls.size();i++) {
525
	// IFile wsdlFile = (IFile)wsdls.get(i);
526
	// Definition wsdlDef = WsdlUtils.getWSDLDefinition(wsdlFile);
527
	// if(wsdlDef!=null)
528
	// allWSDLs.add(wsdlDef);
529
	// }
530
	// return (Definition[]) allWSDLs.toArray(new Definition[allWSDLs.size()]);
531
	// }
532
533
	/**
444
	/**
534
	 * Returns true if given operation name conflicted with super java
445
	 * Returns true if given operation name conflicted with super java
535
	 * capability implementation classes. Note : Fix for defect 167792
446
	 * capability implementation classes. Note : Fix for defect 167792
Lines 548-565 Link Here
548
		return false;
459
		return false;
549
	}
460
	}
550
461
462
	/**
463
	 * Creates DOM document from InputSource.
464
	 */
551
	public static Document createDocument(InputSource source)
465
	public static Document createDocument(InputSource source)
552
			throws IOException, SAXException
466
			throws IOException, SAXException
553
	{
467
	{
554
		return createBuilder().parse(source);
468
		return createBuilder().parse(source);
555
	}
469
	}
556
470
471
	/**
472
	 * Creates DOM document from InputStream.
473
	 */
557
	public static Document createDocument(InputStream stream)
474
	public static Document createDocument(InputStream stream)
558
			throws IOException, SAXException
475
			throws IOException, SAXException
559
	{
476
	{
560
		return createBuilder().parse(stream);
477
		return createBuilder().parse(stream);
561
	}
478
	}
562
479
480
	/**
481
	 * Creates DOM document from XML String.
482
	 */
563
	public static Document createDocument(String xml) throws IOException,
483
	public static Document createDocument(String xml) throws IOException,
564
			SAXException
484
			SAXException
565
	{
485
	{
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/AbstractCapabilityEditor.java (-43 / +75 lines)
Lines 18-26 Link Here
18
import javax.wsdl.Operation;
18
import javax.wsdl.Operation;
19
19
20
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.resources.IFile;
21
import org.eclipse.core.resources.IStorage;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.core.runtime.Path;
24
import org.eclipse.emf.common.util.URI;
24
import org.eclipse.emf.common.util.URI;
25
import org.eclipse.jface.dialogs.MessageDialog;
25
import org.eclipse.jface.dialogs.MessageDialog;
26
import org.eclipse.tptp.wsdm.model.MetadataDescriptor;
26
import org.eclipse.tptp.wsdm.model.MetadataDescriptor;
Lines 47-52 Link Here
47
import org.eclipse.ui.IEditorPart;
47
import org.eclipse.ui.IEditorPart;
48
import org.eclipse.ui.IEditorSite;
48
import org.eclipse.ui.IEditorSite;
49
import org.eclipse.ui.IFileEditorInput;
49
import org.eclipse.ui.IFileEditorInput;
50
import org.eclipse.ui.IStorageEditorInput;
50
import org.eclipse.ui.PartInitException;
51
import org.eclipse.ui.PartInitException;
51
import org.eclipse.ui.part.MultiPageEditorPart;
52
import org.eclipse.ui.part.MultiPageEditorPart;
52
import org.eclipse.xsd.XSDElementDeclaration;
53
import org.eclipse.xsd.XSDElementDeclaration;
Lines 118-143 Link Here
118
	{
119
	{
119
		buildModel();
120
		buildModel();
120
		_overviewPage = createOverviewPage();
121
		_overviewPage = createOverviewPage();
122
		_pages.add(_overviewPage);
121
123
122
		_propertyPage = createPropertyPage();
124
		_propertyPage = createPropertyPage();
125
		_pages.add(_propertyPage);
123
126
124
		_operationPage = createOperationPage();
127
		_operationPage = createOperationPage();
128
		_pages.add(_operationPage);
125
129
126
		_topicPage = createTopicPage();
130
		_topicPage = createTopicPage();
131
		_pages.add(_topicPage);
127
132
128
		if (loadWSDLSourcePage())
133
		if (loadWSDLSourcePage())
129
		{
134
		{
130
			_wsdlSourcePage = createWSDLSourcePage();
135
			_wsdlSourcePage = createWSDLSourcePage();
136
			_pages.add(_wsdlSourcePage);
131
			_create_wsdl_source = true;
137
			_create_wsdl_source = true;
132
		}
138
		}
133
		if (loadXSDSourcePage())
139
		if (loadXSDSourcePage())
134
		{
140
		{
135
			_xsdSourcePage = createXSDSourcePage();
141
			_xsdSourcePage = createXSDSourcePage();
142
			_pages.add(_xsdSourcePage);
136
			_create_xsd_source = true;
143
			_create_xsd_source = true;
137
		}
144
		}
138
		if (loadRMDSourcePage())
145
		if (loadRMDSourcePage())
139
		{
146
		{
140
			_rmdSourcePage = createRMDSourcePage();
147
			_rmdSourcePage = createRMDSourcePage();
148
			_pages.add(_rmdSourcePage);
141
			_create_rmd_source = true;
149
			_create_rmd_source = true;
142
		}
150
		}
143
		firePropertyChange(IEditorPart.PROP_DIRTY);
151
		firePropertyChange(IEditorPart.PROP_DIRTY);
Lines 290-320 Link Here
290
				return;
298
				return;
291
			}
299
			}
292
		}
300
		}
293
		// TODO
301
		else if (getEditorInput() instanceof IStorageEditorInput)
294
		// else if(getEditorInput() instanceof IStorageEditorInput)
302
		{
295
		// {
303
			IStorageEditorInput input = (IStorageEditorInput) getEditorInput();
296
		// IStorageEditorInput input = (IStorageEditorInput)getEditorInput();
304
			IStorage storage = null;
297
		// IStorage storage = null;
305
			try
298
		// try
306
			{
299
		// {
307
				storage = input.getStorage();
300
		// storage = input.getStorage();
308
				_read_only = storage.isReadOnly();
301
		// _read_only = storage.isReadOnly();
309
			}
302
		// }
310
			catch (CoreException e1)
303
		// catch (CoreException e1)
311
			{
304
		// {
312
				e1.printStackTrace();
305
		// e1.printStackTrace();
313
			}
306
		// }
314
			URI capFileURI = URI.createURI(storage.getFullPath().toString());
307
		// URI capFileURI = URI.createURI(storage.getFullPath().toString());
315
			try
308
		// try
316
			{
309
		// {
317
				capabilityDefinition = WsdlUtils
310
		// wsdlDefinition = WsdlUtils.getWSDLDefinition(capFileURI);
318
						.getCapabilityDefinition(capFileURI);
311
		// }
319
				if (capFileURI.toString().startsWith("platform:/resource"))
312
		// catch (Exception e)
320
				{
313
		// {
321
					IFile macpFile = EclipseUtils.getIFile(capFileURI
314
		// org.eclipse.wsdl.capability.util.WsdmToolingLog.logError(Messages.IMPROPER_WSDL_FILE_ERROR_,e);
322
							.toString());
315
		// return;
323
					_capabilityDomain.setCapabilityIFile(macpFile);
316
		// }
324
				}
317
		// }
325
			}
326
			catch (Exception e)
327
			{
328
				WsdmToolingLog.logError(Messages.IMPROPER_WSDL_FILE_ERROR_, e);
329
				return;
330
			}
331
		}
318
		else
332
		else
319
			return;
333
			return;
320
334
Lines 361-378 Link Here
361
		if (metadataDescriptorLocation != null
375
		if (metadataDescriptorLocation != null
362
				&& metadataDescriptorName != null)
376
				&& metadataDescriptorName != null)
363
		{
377
		{
364
			URI capabilityFileLocationURI = capabilityDefinition
378
			URI rmdFileLocationURI = null;
365
					.getWSDLFileProtocalURI();
379
			if (capabilityDefinition.getWSDLFileProtocalURI() != null)
366
			URI rmdFileLocationURI = URI.createURI(capabilityFileLocationURI
380
			{
367
					.trimSegments(1).toString()
381
				URI capabilityFileLocationURI = capabilityDefinition
368
					+ "/" + metadataDescriptorLocation);
382
						.getWSDLFileProtocalURI();
383
				rmdFileLocationURI = URI.createURI(capabilityFileLocationURI
384
						.trimSegments(1).toString()
385
						+ "/" + metadataDescriptorLocation);
386
			}
387
			else if (capabilityDefinition.getWSDLResourceProtocolURI() != null)
388
			{
389
				URI capabilityFileLocationURI = capabilityDefinition
390
						.getWSDLResourceProtocolURI();
391
				rmdFileLocationURI = URI.createURI(capabilityFileLocationURI
392
						.trimSegments(1).toString()
393
						+ "/" + metadataDescriptorLocation);
394
			}
369
			rmdRoot = MetaDataUtils.getDocumentRoot(rmdFileLocationURI);
395
			rmdRoot = MetaDataUtils.getDocumentRoot(rmdFileLocationURI);
370
			if (rmdRoot != null)
396
			if (rmdRoot != null)
371
			{
397
			{
372
				IFile capabilityFile = _capabilityDomain.getCapabilityIFile();
373
				IFile rmdFile = capabilityFile.getParent().getFile(
374
						new Path(metadataDescriptorLocation));
375
				_capabilityDomain.setCapabilityRmdIFile(rmdFile);
376
				MetadataDescriptor rmdDescriptor = new MetadataDescriptor(
398
				MetadataDescriptor rmdDescriptor = new MetadataDescriptor(
377
						capability, rmdRoot, metadataDescriptorName);
399
						capability, rmdRoot, metadataDescriptorName);
378
			}
400
			}
Lines 669-683 Link Here
669
		}
691
		}
670
692
671
		// Remove rmd file of capability
693
		// Remove rmd file of capability
672
		IFile rmdFile = _capabilityDomain.getCapabilityRmdIFile();
694
		if (_capabilityDomain.getCapability().getMetadata() != null)
673
		if (rmdFile != null && rmdFile.exists())
674
		{
695
		{
675
			String title = Messages.CONFIRM_DELETE;
696
			MetadataDescriptor rmdDescriptor = _capabilityDomain
676
			String message = Messages.bind(Messages.FILE_DELETE_QUESTION,
697
					.getCapability().getMetadata();
677
					rmdFile.getName());
698
			DocumentRoot rmdRoot = rmdDescriptor.getDocumentRoot();
678
			if (MessageDialog
699
			if (rmdRoot != null)
679
					.openQuestion(getSite().getShell(), title, message))
700
			{
680
				rmdFile.delete(true, null);
701
				String rmdRootURIPath = rmdRoot.eResource().getURI().toString();
702
				IFile rmdFile = EclipseUtils.getIFile(rmdRootURIPath);
703
				if (rmdFile != null && rmdFile.exists())
704
				{
705
					String title = Messages.CONFIRM_DELETE;
706
					String message = Messages.bind(
707
							Messages.FILE_DELETE_QUESTION, rmdFile.getName());
708
					if (MessageDialog.openQuestion(getSite().getShell(), title,
709
							message))
710
						rmdFile.delete(true, null);
711
				}
712
			}
681
		}
713
		}
682
	}
714
	}
683
715
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityDomain.java (-18 lines)
Lines 45-52 Link Here
45
45
46
	private IFile _capabilityFile;
46
	private IFile _capabilityFile;
47
47
48
	private IFile _rmdFile;
49
50
	private Bundle _artifactsPlugin;
48
	private Bundle _artifactsPlugin;
51
49
52
	/**
50
	/**
Lines 77-90 Link Here
77
	}
75
	}
78
76
79
	/**
77
	/**
80
	 * Returns the capability rmd file.
81
	 */
82
	public IFile getCapabilityRmdIFile()
83
	{
84
		return _rmdFile;
85
	}
86
87
	/**
88
	 * Returns the property schema of capability.
78
	 * Returns the property schema of capability.
89
	 */
79
	 */
90
	public XSDSchema getPropertySchema()
80
	public XSDSchema getPropertySchema()
Lines 141-154 Link Here
141
	}
131
	}
142
132
143
	/**
133
	/**
144
	 * Sets the capability rmd file.
145
	 */
146
	public void setCapabilityRmdIFile(IFile rmdFile)
147
	{
148
		_rmdFile = rmdFile;
149
	}
150
151
	/**
152
	 * Sets the property schema for capability.
134
	 * Sets the property schema for capability.
153
	 */
135
	 */
154
	public void setPropertySchema(XSDSchema propertySchema)
136
	public void setPropertySchema(XSDSchema propertySchema)
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityEditor.java (-9 / +1 lines)
Lines 76-82 Link Here
76
		_operationPageIndex = addPage(operationPage.getForm());
76
		_operationPageIndex = addPage(operationPage.getForm());
77
		setPageText(_operationPageIndex, Messages.OPERATIONS);
77
		setPageText(_operationPageIndex, Messages.OPERATIONS);
78
		addPropertyListener(operationPage);
78
		addPropertyListener(operationPage);
79
		_pages.add(operationPage);
80
		return operationPage;
79
		return operationPage;
81
	}
80
	}
82
81
Lines 91-97 Link Here
91
		_overviewPageIndex = addPage(overviewPage.getForm());
90
		_overviewPageIndex = addPage(overviewPage.getForm());
92
		setPageText(_overviewPageIndex, Messages.OVERVIEW);
91
		setPageText(_overviewPageIndex, Messages.OVERVIEW);
93
		addPropertyListener(overviewPage);
92
		addPropertyListener(overviewPage);
94
		_pages.add(overviewPage);
95
		return overviewPage;
93
		return overviewPage;
96
	}
94
	}
97
95
Lines 106-112 Link Here
106
		_propertyPageIndex = addPage(propertyPage.getForm());
104
		_propertyPageIndex = addPage(propertyPage.getForm());
107
		setPageText(_propertyPageIndex, Messages.PROPERTIES);
105
		setPageText(_propertyPageIndex, Messages.PROPERTIES);
108
		addPropertyListener(propertyPage);
106
		addPropertyListener(propertyPage);
109
		_pages.add(propertyPage);
110
		return propertyPage;
107
		return propertyPage;
111
	}
108
	}
112
109
Lines 120-126 Link Here
120
		_topicPageIndex = addPage(topicPage.getForm());
117
		_topicPageIndex = addPage(topicPage.getForm());
121
		setPageText(_topicPageIndex, Messages.TOPICS);
118
		setPageText(_topicPageIndex, Messages.TOPICS);
122
		addPropertyListener(topicPage);
119
		addPropertyListener(topicPage);
123
		_pages.add(topicPage);
124
		return topicPage;
120
		return topicPage;
125
	}
121
	}
126
122
Lines 133-139 Link Here
133
		rmdSourcePage.create();
129
		rmdSourcePage.create();
134
		_rmdSourcePageIndex = addPage(rmdSourcePage.getControl());
130
		_rmdSourcePageIndex = addPage(rmdSourcePage.getControl());
135
		setPageText(_rmdSourcePageIndex, Messages.RMD_SOURCE);
131
		setPageText(_rmdSourcePageIndex, Messages.RMD_SOURCE);
136
		_pages.add(rmdSourcePage);
137
		return rmdSourcePage;
132
		return rmdSourcePage;
138
	}
133
	}
139
134
Lines 146-152 Link Here
146
		sourcePage.create();
141
		sourcePage.create();
147
		_wsdlSourcePageIndex = addPage(sourcePage.getControl());
142
		_wsdlSourcePageIndex = addPage(sourcePage.getControl());
148
		setPageText(_wsdlSourcePageIndex, Messages.WSDL_SOURCE);
143
		setPageText(_wsdlSourcePageIndex, Messages.WSDL_SOURCE);
149
		_pages.add(sourcePage);
150
		return sourcePage;
144
		return sourcePage;
151
	}
145
	}
152
146
Lines 159-165 Link Here
159
		sourcePage.create();
153
		sourcePage.create();
160
		_xsdSourcePageIndex = addPage(sourcePage.getControl());
154
		_xsdSourcePageIndex = addPage(sourcePage.getControl());
161
		setPageText(_xsdSourcePageIndex, Messages.XSD_SOURCE);
155
		setPageText(_xsdSourcePageIndex, Messages.XSD_SOURCE);
162
		_pages.add(sourcePage);
163
		return sourcePage;
156
		return sourcePage;
164
	}
157
	}
165
158
Lines 214-221 Link Here
214
			List topicSpaces = _capabilityDomain.getCapability()
207
			List topicSpaces = _capabilityDomain.getCapability()
215
					.getTopicSpaces();
208
					.getTopicSpaces();
216
			propertyMetaDataDescriptor.saveTopicSpaces(topicSpaces);
209
			propertyMetaDataDescriptor.saveTopicSpaces(topicSpaces);
217
			IFile rmdFile = _capabilityDomain.getCapabilityRmdIFile();
210
			MetaDataUtils.save(propertyMetaDataDescriptor, monitor);
218
			MetaDataUtils.save(propertyMetaDataDescriptor, rmdFile, monitor);
219
		}
211
		}
220
	}
212
	}
221
213
(-)src/org/eclipse/tptp/wsdm/tooling/editor/internal/CapabilityDefinition.java (-9 / +17 lines)
Lines 31-39 Link Here
31
import org.w3c.dom.Element;
31
import org.w3c.dom.Element;
32
import org.w3c.dom.Text;
32
import org.w3c.dom.Text;
33
33
34
/**
35
 * Its a wrapper class for WSDL4j Definition object. 
36
 *
37
 */
38
34
public class CapabilityDefinition extends WSDLDefinition
39
public class CapabilityDefinition extends WSDLDefinition
35
{
40
{
36
41
42
	/**
43
	 * Creates the instance of this class. 
44
	 */
37
	public CapabilityDefinition(Definition definition)
45
	public CapabilityDefinition(Definition definition)
38
	{
46
	{
39
		super(definition);
47
		super(definition);
Lines 71-85 Link Here
71
		XSDSchema schema = XsdUtils.createNewXSDSchema(tns);
79
		XSDSchema schema = XsdUtils.createNewXSDSchema(tns);
72
		schema.updateElement(true);
80
		schema.updateElement(true);
73
		_definedSchemaList.add(schema);
81
		_definedSchemaList.add(schema);
74
		/*
75
		 * try { Schema schemaExtensibilityElement = (Schema) _definition
76
		 * .getExtensionRegistry().createExtension(Types.class,
77
		 * SchemaConstants.Q_ELEM_XSD_2001);
78
		 * schemaExtensibilityElement.setElement(schema.getElement());
79
		 * _definition.getTypes().addExtensibilityElement(
80
		 * schemaExtensibilityElement); _definedSchemaList.add(schema); } catch
81
		 * (WSDLException e) { e.printStackTrace(); return null; }
82
		 */
83
		return schema;
82
		return schema;
84
	}
83
	}
85
84
Lines 130-135 Link Here
130
		return null;
129
		return null;
131
	}
130
	}
132
131
132
	/**
133
	 * Returns the resource property element for this capability. 
134
	 */
133
	public XSDElementDeclaration getResourcePropertyElement()
135
	public XSDElementDeclaration getResourcePropertyElement()
134
	{
136
	{
135
		Map metadataMap = WsdlUtils.getMetadataFromPortType(_definition);
137
		Map metadataMap = WsdlUtils.getMetadataFromPortType(_definition);
Lines 151-156 Link Here
151
		return null;
153
		return null;
152
	}
154
	}
153
155
156
	/**
157
	 * Returns the rmd location for this capability. 
158
	 */
154
	public String getMetadataDescriptorLocation()
159
	public String getMetadataDescriptorLocation()
155
	{
160
	{
156
		Map metadataMap = WsdlUtils.getMetadataFromPortType(_definition);
161
		Map metadataMap = WsdlUtils.getMetadataFromPortType(_definition);
Lines 158-163 Link Here
158
				.get(WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY);
163
				.get(WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY);
159
	}
164
	}
160
165
166
	/**
167
	 * Returns the MetadataDescriptor name for this capability. 
168
	 */
161
	public String getMetadataDescriptorName()
169
	public String getMetadataDescriptorName()
162
	{
170
	{
163
		Map metadataMap = WsdlUtils.getMetadataFromPortType(_definition);
171
		Map metadataMap = WsdlUtils.getMetadataFromPortType(_definition);
(-)src/org/eclipse/tptp/wsdm/tooling/editor/internal/Activator.java (-2 / +21 lines)
Lines 25-33 Link Here
25
public final class Activator extends EMFPlugin
25
public final class Activator extends EMFPlugin
26
{
26
{
27
27
28
	// The plug-in ID
28
	// The model plug-in ID
29
	public static final String MODEL_PLUGIN_ID = "org.eclipse.tptp.wsdm.model";
30
31
	// The editor plug-in ID
29
	public static final String PLUGIN_ID = "org.eclipse.tptp.wsdm.editor";
32
	public static final String PLUGIN_ID = "org.eclipse.tptp.wsdm.editor";
30
33
34
	// Management capability extension point
35
	public static final String MR_CAPABILITY_EXT_PT = "mrCapability";
36
37
	// Capability validator extension point
38
	public static final String CAPABILITY_VALIDATOR_EXT_PT = "capabilityValidator";
39
40
	// MRT validator extension point
41
	public static final String MRT_VALIDATOR_EXT_PT = "mrtValidator";
42
43
	// DD validator extension point
44
	public static final String DD_VALIDATOR_EXT_PT = "ddeValidator";
45
46
	// Codegen extension point
47
	public static final String CODEGEN_EXT_PT = "codeGeneration";
48
31
	/**
49
	/**
32
	 * Keep track of the singleton. <!-- begin-user-doc --> <!-- end-user-doc
50
	 * Keep track of the singleton. <!-- begin-user-doc --> <!-- end-user-doc
33
	 * -->
51
	 * -->
Lines 51-57 Link Here
51
	 */
69
	 */
52
	public Activator()
70
	public Activator()
53
	{
71
	{
54
		super(new ResourceLocator[] {});
72
		super(new ResourceLocator[]
73
		{});
55
	}
74
	}
56
75
57
	/**
76
	/**
(-)src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/internal/messages.properties (-1 / +1 lines)
Lines 90-96 Link Here
90
RMD_SOURCE = RMDSource
90
RMD_SOURCE = RMDSource
91
91
92
FAILED_TO_SAVE_MCAP_FILE_ERROR_ = IWAT0542E Failed to save MCAP file
92
FAILED_TO_SAVE_MCAP_FILE_ERROR_ = IWAT0542E Failed to save MCAP file
93
IMPROPER_WSDL_FILE_ERROR_ = IWAT0547E Capability WSDL file is not a proper WSLD file
93
IMPROPER_WSDL_FILE_ERROR_ = IWAT0547E Capability WSDL file is not a proper WSDL file
94
RMD_FILE_DOESNT_EXISTS_ERROR_ = IWAT0548E RMD file doesn't exists
94
RMD_FILE_DOESNT_EXISTS_ERROR_ = IWAT0548E RMD file doesn't exists
95
FAILED_TO_LOAD_RMD_ERROR_ = IWAT0549E Failed to load the RMD file
95
FAILED_TO_LOAD_RMD_ERROR_ = IWAT0549E Failed to load the RMD file
96
INVALID_IEDITOR_ERROR_ = IWAT0550E Invalid Input: Must be IFileEditorInput
96
INVALID_IEDITOR_ERROR_ = IWAT0550E Invalid Input: Must be IFileEditorInput
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ChangeOperationReturnTypeCommand.java (-3 / +11 lines)
Lines 26-31 Link Here
26
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataType;
26
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataType;
27
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataTypesCollection;
27
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataTypesCollection;
28
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
28
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
29
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.INewNameGenerator;
30
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.NewWSDLMessageNameGenerator;
31
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.NewXSDElementNameGenerator;
29
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
32
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
30
import org.eclipse.xsd.XSDElementDeclaration;
33
import org.eclipse.xsd.XSDElementDeclaration;
31
import org.eclipse.xsd.XSDFactory;
34
import org.eclipse.xsd.XSDFactory;
Lines 87-93 Link Here
87
			{
90
			{
88
				message = definition.createMessage();
91
				message = definition.createMessage();
89
				String ns = definition.getTargetNamespace();
92
				String ns = definition.getTargetNamespace();
90
				message.setQName(new QName(ns, responseName));
93
				INewNameGenerator generator = new NewWSDLMessageNameGenerator(
94
						definition, responseName);
95
				String messageName = generator.getNewName();
96
				message.setQName(new QName(ns, messageName));
91
				definition.addMessage(message);
97
				definition.addMessage(message);
92
				output.setMessage(message);
98
				output.setMessage(message);
93
			}
99
			}
Lines 109-118 Link Here
109
				}
115
				}
110
			}
116
			}
111
			_element = XSDFactory.eINSTANCE.createXSDElementDeclaration();
117
			_element = XSDFactory.eINSTANCE.createXSDElementDeclaration();
112
			_element.setName(responseName);
113
114
			XSDSchema schema = capabilityDefinition
118
			XSDSchema schema = capabilityDefinition
115
					.createOrFindSchema(definition.getTargetNamespace());
119
					.createOrFindSchema(definition.getTargetNamespace());
120
			INewNameGenerator generator = new NewXSDElementNameGenerator(
121
					schema, responseName);
122
			String elementName = generator.getNewName();
123
			_element.setName(elementName);
116
			schema.getContents().add(_element);
124
			schema.getContents().add(_element);
117
			part_0.setElementName(new QName(_element.getTargetNamespace(),
125
			part_0.setElementName(new QName(_element.getTargetNamespace(),
118
					_element.getName()));
126
					_element.getName()));
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ListSection.java (-2 / +59 lines)
Lines 15-22 Link Here
15
import java.util.Collection;
15
import java.util.Collection;
16
import java.util.List;
16
import java.util.List;
17
17
18
import javax.wsdl.Definition;
18
import javax.wsdl.Operation;
19
import javax.wsdl.Operation;
19
20
21
import org.eclipse.core.resources.IFile;
22
import org.eclipse.emf.common.util.URI;
23
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.jface.resource.ImageRegistry;
24
import org.eclipse.jface.resource.ImageRegistry;
21
import org.eclipse.jface.viewers.IStructuredContentProvider;
25
import org.eclipse.jface.viewers.IStructuredContentProvider;
22
import org.eclipse.jface.viewers.LabelProvider;
26
import org.eclipse.jface.viewers.LabelProvider;
Lines 24-29 Link Here
24
import org.eclipse.jface.viewers.StructuredSelection;
28
import org.eclipse.jface.viewers.StructuredSelection;
25
import org.eclipse.jface.viewers.Viewer;
29
import org.eclipse.jface.viewers.Viewer;
26
import org.eclipse.jface.window.Window;
30
import org.eclipse.jface.window.Window;
31
import org.eclipse.jface.wizard.WizardDialog;
27
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.SWT;
28
import org.eclipse.swt.events.ControlAdapter;
33
import org.eclipse.swt.events.ControlAdapter;
29
import org.eclipse.swt.events.ControlEvent;
34
import org.eclipse.swt.events.ControlEvent;
Lines 38-47 Link Here
38
import org.eclipse.swt.widgets.Listener;
43
import org.eclipse.swt.widgets.Listener;
39
import org.eclipse.swt.widgets.Shell;
44
import org.eclipse.swt.widgets.Shell;
40
import org.eclipse.swt.widgets.Table;
45
import org.eclipse.swt.widgets.Table;
46
import org.eclipse.tptp.wsdm.tooling.dialog.provisional.WSDLBrowseDialog;
41
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.AddOperationCommand;
47
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.AddOperationCommand;
42
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.ChangeInputParamTypeCommand;
48
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.ChangeInputParamTypeCommand;
43
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.ChangeOperationReturnTypeCommand;
49
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.ChangeOperationReturnTypeCommand;
44
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.RemoveOperationCommand;
50
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.RemoveOperationCommand;
51
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl.OperationImportWizard;
45
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.AbstractCapabilityEditor;
52
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.AbstractCapabilityEditor;
46
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
53
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
47
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataType;
54
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataType;
Lines 51-56 Link Here
51
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
58
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
52
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages;
59
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages;
53
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
60
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
61
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
54
import org.eclipse.tptp.wsdm.tooling.viewers.internal.IViewerClient;
62
import org.eclipse.tptp.wsdm.tooling.viewers.internal.IViewerClient;
55
import org.eclipse.tptp.wsdm.tooling.viewers.internal.StructuredTableViewer;
63
import org.eclipse.tptp.wsdm.tooling.viewers.internal.StructuredTableViewer;
56
import org.eclipse.ui.forms.widgets.FormToolkit;
64
import org.eclipse.ui.forms.widgets.FormToolkit;
Lines 71-76 Link Here
71
79
72
	private Button _addOperationButton;
80
	private Button _addOperationButton;
73
81
82
	private Button _importOperationButton;
83
74
	private Button _removeOperationButton;
84
	private Button _removeOperationButton;
75
85
76
	private Label _errorLabel;
86
	private Label _errorLabel;
Lines 143-152 Link Here
143
					}
153
					}
144
				});
154
				});
145
		gd = new GridData(GridData.CENTER, SWT.NONE, false, false);
155
		gd = new GridData(GridData.CENTER, SWT.NONE, false, false);
146
		gd.widthHint = 50;
156
		gd.widthHint = 100;
147
		_addOperationButton.setLayoutData(gd);
157
		_addOperationButton.setLayoutData(gd);
148
		_addOperationButton.setEnabled(!_editor.isReadOnly());
158
		_addOperationButton.setEnabled(!_editor.isReadOnly());
149
159
160
		_importOperationButton = createPushButton(
161
				_buttonClient,
162
				toolkit,
163
				org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.IMPORT_OPERATIONS,
164
				new Listener()
165
				{
166
					public void handleEvent(Event event)
167
					{
168
						importOperation();
169
					}
170
				});
171
		gd = new GridData(GridData.CENTER, SWT.NONE, false, false);
172
		gd.widthHint = 100;
173
		_importOperationButton.setLayoutData(gd);
174
		_importOperationButton.setEnabled(!_editor.isReadOnly());
175
150
		_removeOperationButton = createPushButton(
176
		_removeOperationButton = createPushButton(
151
				_buttonClient,
177
				_buttonClient,
152
				toolkit,
178
				toolkit,
Lines 159-165 Link Here
159
					}
185
					}
160
				});
186
				});
161
		gd = new GridData(GridData.CENTER, SWT.NONE, false, false);
187
		gd = new GridData(GridData.CENTER, SWT.NONE, false, false);
162
		gd.widthHint = 50;
188
		gd.widthHint = 100;
163
		_removeOperationButton.setLayoutData(gd);
189
		_removeOperationButton.setLayoutData(gd);
164
		_removeOperationButton.setEnabled(false);
190
		_removeOperationButton.setEnabled(false);
165
191
Lines 206-211 Link Here
206
		}
232
		}
207
	}
233
	}
208
234
235
	private void importOperation()
236
	{
237
		WSDLBrowseDialog dialog = new WSDLBrowseDialog(getForm().getShell());
238
		if (dialog.open() == Window.OK)
239
		{
240
			IFile wsdlFile = (IFile) dialog.getFirstResult();
241
			Definition wsdlDefinition = null;
242
			try
243
			{
244
				wsdlDefinition = WsdlUtils.getCapabilityDefinition(wsdlFile)
245
						.getDefinition();
246
			}
247
			catch (Exception e)
248
			{
249
				MessageDialog
250
						.openError(
251
								getForm().getShell(),
252
								"Error",
253
								org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.IMPROPER_WSDL_FILE);
254
				return;
255
			}
256
			OperationImportWizard importOperationWizard = new OperationImportWizard(
257
					_editor.getCapabilityDomain(), wsdlDefinition);
258
			importOperationWizard.setImportedWsdlURI(URI.createPlatformResourceURI(wsdlFile.getFullPath().toString()));
259
			WizardDialog wizardDialog = new WizardDialog(getForm().getShell(),
260
					importOperationWizard);
261
			wizardDialog.open();
262
			_page.setDirty();
263
		}
264
	}
265
209
	private void removeOperation()
266
	private void removeOperation()
210
	{
267
	{
211
		CapabilityDomain capabilityDomain = _editor.getCapabilityDomain();
268
		CapabilityDomain capabilityDomain = _editor.getCapabilityDomain();
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewOperationDialog.java (-9 / +28 lines)
Lines 60-65 Link Here
60
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataTypesContentProvider;
60
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataTypesContentProvider;
61
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
61
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
62
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.NewNameGenerator;
62
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.NewNameGenerator;
63
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.INewNameGenerator;
64
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.NewWSDLMessageNameGenerator;
65
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.NewXSDElementNameGenerator;
63
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
66
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
64
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages;
67
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages;
65
import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils;
68
import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils;
Lines 119-127 Link Here
119
	private CapabilityDomain _capabilityDomain;
122
	private CapabilityDomain _capabilityDomain;
120
123
121
	// TODO Check it out
124
	// TODO Check it out
122
	// private static final String BASE_FAULT_FILE =
125
	private static final String BASE_FAULT_FILE = "platform:/plugin/org.apache.muse.tools/artifacts/managementCapabilities/WS-BaseFaults-1_2.xsd";
123
	// "platform:/plugin/org.apache.muse.tools/artifacts/managementCapabilities/WS-BaseFaults-1_2.xsd";
126
	// private final String BASE_FAULT_FILE =
124
	private final String BASE_FAULT_FILE = "artifacts/managementCapabilities/WS-BaseFaults-1_2.xsd";
127
	// "artifacts/managementCapabilities/WS-BaseFaults-1_2.xsd";
125
128
126
	private DataType _returnType;
129
	private DataType _returnType;
127
130
Lines 253-260 Link Here
253
		gd.horizontalSpan = ((GridLayout) rhsComposite.getLayout()).numColumns;
256
		gd.horizontalSpan = ((GridLayout) rhsComposite.getLayout()).numColumns;
254
		_paramViewer.getControl().setLayoutData(gd);
257
		_paramViewer.getControl().setLayoutData(gd);
255
258
256
		String[] header = new String[] { Messages.PARAM_NAME,
259
		String[] header = new String[]
257
				Messages.PARAM_TYPE };
260
		{ Messages.PARAM_NAME, Messages.PARAM_TYPE };
258
		for (int i = 0; i < header.length; i++)
261
		for (int i = 0; i < header.length; i++)
259
		{
262
		{
260
			TableColumn col = new TableColumn(_paramViewer.getTable(),
263
			TableColumn col = new TableColumn(_paramViewer.getTable(),
Lines 511-517 Link Here
511
				.getTargetNamespace());
514
				.getTargetNamespace());
512
		_capabilityDefinition.createOrFindPrefix(WsdmConstants.WSBF_NS, "wsbf");
515
		_capabilityDefinition.createOrFindPrefix(WsdmConstants.WSBF_NS, "wsbf");
513
		XsdUtils.createImportStatement(_typesSchema, WsdmConstants.WSBF_NS,
516
		XsdUtils.createImportStatement(_typesSchema, WsdmConstants.WSBF_NS,
514
				getBaseFaultFileURI());
517
				BASE_FAULT_FILE);
515
518
516
		_operation.setName(_methodName.getText());
519
		_operation.setName(_methodName.getText());
517
520
Lines 600-605 Link Here
600
	{
603
	{
601
		String tns = _capabilityDomain.getCapability().getNamespace();
604
		String tns = _capabilityDomain.getCapability().getNamespace();
602
		Message message = _capabilityDefinition.getDefinition().createMessage();
605
		Message message = _capabilityDefinition.getDefinition().createMessage();
606
		Definition _definition = _capabilityDefinition.getDefinition();
607
		INewNameGenerator nameGenerator = new NewWSDLMessageNameGenerator(
608
				_definition, name);
609
		name = nameGenerator.getNewName();
603
		message.setQName(new QName(tns, name));
610
		message.setQName(new QName(tns, name));
604
		message.setUndefined(false);
611
		message.setUndefined(false);
605
612
Lines 618-624 Link Here
618
	{
625
	{
619
		XSDElementDeclaration inputParamHolderElement = XSDFactory.eINSTANCE
626
		XSDElementDeclaration inputParamHolderElement = XSDFactory.eINSTANCE
620
				.createXSDElementDeclaration();
627
				.createXSDElementDeclaration();
621
		inputParamHolderElement.setName(_methodName.getText());
628
		String name = _methodName.getText();
629
		INewNameGenerator generator = new NewXSDElementNameGenerator(
630
				_typesSchema, name);
631
		name = generator.getNewName();
632
		inputParamHolderElement.setName(name);
622
		_typesSchema.getContents().add(inputParamHolderElement);
633
		_typesSchema.getContents().add(inputParamHolderElement);
623
		if (_paramList.size() == 0)
634
		if (_paramList.size() == 0)
624
		{
635
		{
Lines 655-661 Link Here
655
	{
666
	{
656
		XSDElementDeclaration outputTypeElement = XSDFactory.eINSTANCE
667
		XSDElementDeclaration outputTypeElement = XSDFactory.eINSTANCE
657
				.createXSDElementDeclaration();
668
				.createXSDElementDeclaration();
658
		outputTypeElement.setName(_methodName.getText() + "Response");
669
		String name = _methodName.getText() + "Response";
670
		INewNameGenerator generator = new NewXSDElementNameGenerator(
671
				_typesSchema, name);
672
		name = generator.getNewName();
673
		outputTypeElement.setName(name);
659
		_typesSchema.getContents().add(outputTypeElement);
674
		_typesSchema.getContents().add(outputTypeElement);
660
		_returnType = (DataType) getSelectedViewerObject();
675
		_returnType = (DataType) getSelectedViewerObject();
661
		return outputTypeElement;
676
		return outputTypeElement;
Lines 665-671 Link Here
665
	{
680
	{
666
		XSDElementDeclaration faultElement = XSDFactory.eINSTANCE
681
		XSDElementDeclaration faultElement = XSDFactory.eINSTANCE
667
				.createXSDElementDeclaration();
682
				.createXSDElementDeclaration();
668
		faultElement.setName(_methodName.getText() + "Fault");
683
		String name = _methodName.getText() + "Fault";
684
		INewNameGenerator generator = new NewXSDElementNameGenerator(
685
				_typesSchema, name);
686
		name = generator.getNewName();
687
		faultElement.setName(name);
669
		_typesSchema.getContents().add(faultElement);
688
		_typesSchema.getContents().add(faultElement);
670
689
671
		XSDComplexTypeDefinition complexTypeDefinition = XSDFactory.eINSTANCE
690
		XSDComplexTypeDefinition complexTypeDefinition = XSDFactory.eINSTANCE
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/util/internal/MetaDataUtils.java (-2 / +14 lines)
Lines 48-53 Link Here
48
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.impl.MetadataDescriptorFactoryImpl;
48
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.impl.MetadataDescriptorFactoryImpl;
49
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.util.MetadataDescriptorResourceImpl;
49
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.util.MetadataDescriptorResourceImpl;
50
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages;
50
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages;
51
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
51
import org.eclipse.tptp.wsdm.tooling.util.internal.MyMetadataDescriptorResourceFactoryImpl;
52
import org.eclipse.tptp.wsdm.tooling.util.internal.MyMetadataDescriptorResourceFactoryImpl;
52
import org.eclipse.tptp.wsdm.tooling.util.internal.RmdUtils;
53
import org.eclipse.tptp.wsdm.tooling.util.internal.RmdUtils;
53
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants;
54
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants;
Lines 420-429 Link Here
420
	}
421
	}
421
422
422
	public static void save(MetadataDescriptor metadataDescriptor,
423
	public static void save(MetadataDescriptor metadataDescriptor,
423
			IFile rmdFile, IProgressMonitor monitor)
424
			IProgressMonitor monitor)
424
	{
425
	{
425
		DocumentRoot _root = metadataDescriptor.getDocumentRoot();
426
		DocumentRoot _root = metadataDescriptor.getDocumentRoot();
426
		RmdUtils.serializeAndFormat(_root, rmdFile, monitor);
427
		String rmdRootURIPath = _root.eResource().getURI().toString();
428
		IFile rmdFile = null;
429
		try
430
		{
431
			rmdFile = EclipseUtils.getIFile(rmdRootURIPath);
432
		}
433
		catch (CoreException e)
434
		{
435
			WsdmToolingLog.logError(e.getMessage(), e);
436
		}
437
		if (rmdFile != null)
438
			RmdUtils.serializeAndFormat(_root, rmdFile, monitor);
427
	}
439
	}
428
440
429
	public static MetadataDescriptor createMetaDataDescriptor(
441
	public static MetadataDescriptor createMetaDataDescriptor(
(-)src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java (-15 / +71 lines)
Lines 19-24 Link Here
19
import java.util.HashMap;
19
import java.util.HashMap;
20
import java.util.Map;
20
import java.util.Map;
21
21
22
import javax.wsdl.Operation;
22
import javax.wsdl.PortType;
23
import javax.wsdl.PortType;
23
import javax.wsdl.Types;
24
import javax.wsdl.Types;
24
import javax.xml.namespace.QName;
25
import javax.xml.namespace.QName;
Lines 33-46 Link Here
33
import org.eclipse.core.runtime.IStatus;
34
import org.eclipse.core.runtime.IStatus;
34
import org.eclipse.core.runtime.Path;
35
import org.eclipse.core.runtime.Path;
35
import org.eclipse.core.runtime.Status;
36
import org.eclipse.core.runtime.Status;
37
import org.eclipse.emf.common.util.URI;
36
import org.eclipse.jface.dialogs.MessageDialog;
38
import org.eclipse.jface.dialogs.MessageDialog;
37
import org.eclipse.jface.operation.IRunnableWithProgress;
39
import org.eclipse.jface.operation.IRunnableWithProgress;
38
import org.eclipse.jface.viewers.ISelection;
40
import org.eclipse.jface.viewers.ISelection;
39
import org.eclipse.jface.viewers.IStructuredSelection;
41
import org.eclipse.jface.viewers.IStructuredSelection;
40
import org.eclipse.jface.wizard.Wizard;
42
import org.eclipse.jface.wizard.Wizard;
43
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.ImportOperationCommand;
44
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ImportPropertyCommand;
45
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl.OperationImportWizardPage;
46
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.PropertyImportWizardPage;
41
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityEditor;
47
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityEditor;
42
import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils;
48
import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils;
43
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
49
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
50
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.INewNameGenerator;
51
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.NewIFileNameGenerator;
52
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
44
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DocumentRoot;
53
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DocumentRoot;
45
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages;
54
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages;
46
import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils;
55
import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils;
Lines 71-77 Link Here
71
80
72
	private NewCapabilityWizardPage _newCapPage;
81
	private NewCapabilityWizardPage _newCapPage;
73
82
74
	// private CapabilityFileWizardPage _capFilesPage;
83
	private CapabilityModelImporterPage _importerPage;
84
85
	private PropertyImportWizardPage _importPropertyPage;
86
87
	private OperationImportWizardPage _importOperationPage;
75
88
76
	private ISelection _selection;
89
	private ISelection _selection;
77
90
Lines 105-112 Link Here
105
		_newCapPage = new NewCapabilityWizardPage(_selection, this);
118
		_newCapPage = new NewCapabilityWizardPage(_selection, this);
106
		addPage(_newCapPage);
119
		addPage(_newCapPage);
107
120
108
		// _capFilesPage = new CapabilityFileWizardPage(_selection, this);
121
		_importerPage = new CapabilityModelImporterPage(_selection, this);
109
		// addPage(_capFilesPage);
122
		addPage(_importerPage);
123
124
		_importPropertyPage = new PropertyImportWizardPage();
125
		addPage(_importPropertyPage);
126
127
		_importOperationPage = new OperationImportWizardPage();
128
		addPage(_importOperationPage);
110
	}
129
	}
111
130
112
	/**
131
	/**
Lines 123-136 Link Here
123
			capPrefix = "tns";
142
			capPrefix = "tns";
124
		String capNS = _newCapPage.getNamespace();
143
		String capNS = _newCapPage.getNamespace();
125
		String targetCapFileName = _newCapPage.getTargetFileName();
144
		String targetCapFileName = _newCapPage.getTargetFileName();
126
		// String xsdFilePath = _capFilesPage.getXSDFilePath();
145
127
		// String xsdFileName = _capFilesPage.getXSDFileName();
146
		IResource resource = ResourcesPlugin.getWorkspace().getRoot()
128
		// String rmdFilePath = _capFilesPage.getRMDFilePath();
147
				.findMember(new Path(containerName));
129
		// String rmdFileName = _capFilesPage.getRMDFileName();
148
		INewNameGenerator generator = new NewIFileNameGenerator(resource,
130
		String xsdFilePath = containerName + "/" + capabilityName + ".xsd";
149
				capabilityName + ".xsd");
131
		String xsdFileName = capabilityName + ".xsd";
150
		String xsdFileName = generator.getNewName();
132
		String rmdFilePath = containerName + "/" + capabilityName + ".rmd";
151
		generator = new NewIFileNameGenerator(resource, capabilityName + ".rmd");
133
		String rmdFileName = capabilityName + ".rmd";
152
		String rmdFileName = generator.getNewName();
153
		String xsdFilePath = containerName + "/" + xsdFileName;
154
		String rmdFilePath = containerName + "/" + rmdFileName;
134
155
135
		String capNamespace = capNS;
156
		String capNamespace = capNS;
136
		String xsdNS = capNS;
157
		String xsdNS = capNS;
Lines 146-151 Link Here
146
			capFilePath = containerName + targetCapFileName;
167
			capFilePath = containerName + targetCapFileName;
147
		}
168
		}
148
169
170
		Property[] importedProperties = new Property[0];
171
		Operation[] importedOperations = new Operation[0];
172
173
		if (_importerPage.isFromXSDButtonSelected())
174
			importedProperties = _importPropertyPage.getImportedProperties();
175
		else if (_importerPage.isFromWSDLButtonSelected())
176
			importedOperations = _importOperationPage.getImportedOperations();
177
149
		_options.put(CapabilityWizardKeys.CONTAINER_NAME_KEY, containerName);
178
		_options.put(CapabilityWizardKeys.CONTAINER_NAME_KEY, containerName);
150
		_options.put(CapabilityWizardKeys.CAP_NS_KEY, capNamespace);
179
		_options.put(CapabilityWizardKeys.CAP_NS_KEY, capNamespace);
151
		_options.put(CapabilityWizardKeys.CAP_PREFIX_KEY, capPrefix);
180
		_options.put(CapabilityWizardKeys.CAP_PREFIX_KEY, capPrefix);
Lines 161-166 Link Here
161
		_options.put(CapabilityWizardKeys.RMD_FILE_NAME_KEY, rmdFileName);
190
		_options.put(CapabilityWizardKeys.RMD_FILE_NAME_KEY, rmdFileName);
162
		_options.put(CapabilityWizardKeys.RMD_NS_KEY, rmdNS);
191
		_options.put(CapabilityWizardKeys.RMD_NS_KEY, rmdNS);
163
192
193
		_options.put(CapabilityWizardKeys.IMPORT_PROPERTY_KEY,
194
				importedProperties);
195
		_options.put(CapabilityWizardKeys.IMPORT_OPERATION_KEY,
196
				importedOperations);
197
164
		IRunnableWithProgress shouldOverwriteOperation = new IRunnableWithProgress()
198
		IRunnableWithProgress shouldOverwriteOperation = new IRunnableWithProgress()
165
		{
199
		{
166
			public void run(IProgressMonitor monitor)
200
			public void run(IProgressMonitor monitor)
Lines 473-478 Link Here
473
		resourcePropertyElement.setName(capName + "Properties");
507
		resourcePropertyElement.setName(capName + "Properties");
474
		resourcePropertyElement.setTypeDefinition(null);
508
		resourcePropertyElement.setTypeDefinition(null);
475
		schema.getContents().add(resourcePropertyElement);
509
		schema.getContents().add(resourcePropertyElement);
510
511
		Property[] importedProperties = (Property[]) _options
512
				.get(CapabilityWizardKeys.IMPORT_PROPERTY_KEY);
513
		ImportPropertyCommand command = new ImportPropertyCommand(
514
				resourcePropertyElement, importedProperties);
515
		command.execute();
476
	}
516
	}
477
517
478
	private void createAnnotation(XSDSchema schema)
518
	private void createAnnotation(XSDSchema schema)
Lines 503-508 Link Here
503
		portType.setQName(new QName(capNS, capName + "PortType"));
543
		portType.setQName(new QName(capNS, capName + "PortType"));
504
		portType.setUndefined(false);
544
		portType.setUndefined(false);
505
		_wsdlCapDefinition.getDefinition().addPortType(portType);
545
		_wsdlCapDefinition.getDefinition().addPortType(portType);
546
547
		Operation[] importOperations = (Operation[]) _options
548
				.get(CapabilityWizardKeys.IMPORT_OPERATION_KEY);
549
		URI importedWsdlURI = _importOperationPage.getImportedWsdlURI();
550
		ImportOperationCommand command = new ImportOperationCommand(
551
				_wsdlCapDefinition, importOperations, importedWsdlURI);
552
		command.execute();
506
	}
553
	}
507
554
508
	private void wsdlEdit()
555
	private void wsdlEdit()
Lines 533-542 Link Here
533
		return _newCapPage;
580
		return _newCapPage;
534
	}
581
	}
535
582
536
	/*
583
	public OperationImportWizardPage getOperationImportWizardPage()
537
	 * protected CapabilityFileWizardPage getCapabilityFileWizardPage() { return
584
	{
538
	 * _capFilesPage; }
585
		return _importOperationPage;
539
	 */
586
	}
587
588
	public PropertyImportWizardPage getPropertyImportWizardPage()
589
	{
590
		return _importPropertyPage;
591
	}
540
}
592
}
541
593
542
class CapabilityWizardKeys
594
class CapabilityWizardKeys
Lines 569-572 Link Here
569
	static final String IMPORT_XSD_KEY = "IMPORT_XSD";
621
	static final String IMPORT_XSD_KEY = "IMPORT_XSD";
570
622
571
	static final String IMPORT_WSDL_KEY = "IMPORT_WSDL";
623
	static final String IMPORT_WSDL_KEY = "IMPORT_WSDL";
624
625
	static final String IMPORT_PROPERTY_KEY = "IMPORT_PROPERTY";
626
627
	static final String IMPORT_OPERATION_KEY = "IMPORT_OPERATION";
572
}
628
}
(-)src/org/eclipse/tptp/wsdm/tooling/validation/util/internal/ValidationUtils.java (-19 / +10 lines)
Lines 18-23 Link Here
18
import org.eclipse.core.runtime.IConfigurationElement;
18
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IExtension;
19
import org.eclipse.core.runtime.IExtension;
20
import org.eclipse.core.runtime.IExtensionPoint;
20
import org.eclipse.core.runtime.IExtensionPoint;
21
import org.eclipse.core.runtime.IExtensionRegistry;
21
import org.eclipse.core.runtime.Platform;
22
import org.eclipse.core.runtime.Platform;
22
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator;
23
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator;
23
import org.eclipse.tptp.wsdm.tooling.nls.messages.validation.internal.Messages;
24
import org.eclipse.tptp.wsdm.tooling.nls.messages.validation.internal.Messages;
Lines 37-65 Link Here
37
public class ValidationUtils
38
public class ValidationUtils
38
{
39
{
39
40
40
	public static final String CAPABILITY_VALIDATOR_EXT_POINTID = "capabilityValidator";
41
42
	public static final String MRT_VALIDATOR_EXT_POINTID = "mrtValidator";
43
44
	public static final String DDE_VALIDATOR_EXT_POINTID = "ddeValidator";
45
46
	/**
47
	 * Returns IExtensionPoint of given name.
48
	 */
49
	public static IExtensionPoint getExtensionPoint(String point)
50
	{
51
		String pluginID = Activator.getPlugin().getBundle().getSymbolicName();
52
		return Platform.getExtensionRegistry().getExtensionPoint(pluginID,
53
				point);
54
	}
55
56
	/**
41
	/**
57
	 * Returns all the capability validators by reading the plugin registry.
42
	 * Returns all the capability validators by reading the plugin registry.
58
	 */
43
	 */
59
	public static ICapabilityValidator[] getAllCapabilityValidators()
44
	public static ICapabilityValidator[] getAllCapabilityValidators()
60
	{
45
	{
61
		List validators = new ArrayList();
46
		List validators = new ArrayList();
62
		IExtensionPoint iep = getExtensionPoint(CAPABILITY_VALIDATOR_EXT_POINTID);
47
		IExtensionRegistry er = Platform.getExtensionRegistry();
48
		IExtensionPoint iep = er.getExtensionPoint(Activator.PLUGIN_ID,
49
				Activator.CAPABILITY_VALIDATOR_EXT_PT);
63
		if (iep == null)
50
		if (iep == null)
64
		{
51
		{
65
			WsdmToolingLog.logWarning(Messages.COULDNT_FIND_CAP_VALIDATOR_EXT);
52
			WsdmToolingLog.logWarning(Messages.COULDNT_FIND_CAP_VALIDATOR_EXT);
Lines 97-103 Link Here
97
	public static IMrtValidator[] getAllMrtValidators()
84
	public static IMrtValidator[] getAllMrtValidators()
98
	{
85
	{
99
		List validators = new ArrayList();
86
		List validators = new ArrayList();
100
		IExtensionPoint iep = getExtensionPoint(MRT_VALIDATOR_EXT_POINTID);
87
		IExtensionRegistry er = Platform.getExtensionRegistry();
88
		IExtensionPoint iep = er.getExtensionPoint(Activator.PLUGIN_ID,
89
				Activator.MRT_VALIDATOR_EXT_PT);
101
		if (iep == null)
90
		if (iep == null)
102
		{
91
		{
103
			WsdmToolingLog.logWarning(Messages.COULDNT_FIND_MRT_VALIDATOR_EXT);
92
			WsdmToolingLog.logWarning(Messages.COULDNT_FIND_MRT_VALIDATOR_EXT);
Lines 135-141 Link Here
135
	public static IDdeValidator[] getAllDdeValidators()
124
	public static IDdeValidator[] getAllDdeValidators()
136
	{
125
	{
137
		List validators = new ArrayList();
126
		List validators = new ArrayList();
138
		IExtensionPoint iep = getExtensionPoint(DDE_VALIDATOR_EXT_POINTID);
127
		IExtensionRegistry er = Platform.getExtensionRegistry();
128
		IExtensionPoint iep = er.getExtensionPoint(Activator.PLUGIN_ID,
129
				Activator.DD_VALIDATOR_EXT_PT);
139
		if (iep == null)
130
		if (iep == null)
140
		{
131
		{
141
			WsdmToolingLog.logWarning(Messages.COULDNT_FIND_DDE_VALIDATOR_EXT);
132
			WsdmToolingLog.logWarning(Messages.COULDNT_FIND_DDE_VALIDATOR_EXT);
(-)src/org/eclipse/tptp/wsdm/tooling/validation/capability/internal/CapabilityValidator.java (-30 lines)
Lines 51-84 Link Here
51
		}
51
		}
52
		return report;
52
		return report;
53
	}
53
	}
54
55
	/**
56
	 * Perform RMD validation
57
	 */
58
	/*
59
	 * public IValidationReport validateRMD(Definition definition, DocumentRoot
60
	 * root) { CapabilityRMDValidator rmdValidator = new
61
	 * CapabilityRMDValidator(); IValidationReport rmdReport =
62
	 * rmdValidator.validate(definition, root); return rmdReport; }
63
	 */
64
65
	/**
66
	 * Perform WSDL validation
67
	 */
68
	/*
69
	 * public IValidationReport validateWSDL(Definition definition) {
70
	 * CapabilityWSDLValidator wsdlValidator = new CapabilityWSDLValidator();
71
	 * IValidationReport wsdlReport = wsdlValidator.validate(definition); return
72
	 * wsdlReport; }
73
	 */
74
75
	/**
76
	 * Perform XSD validation
77
	 */
78
	/*
79
	 * public IValidationReport validateXSD(Definition definition, XSDSchema
80
	 * propertySchema) { CapabilityXSDValidator xsdValidator = new
81
	 * CapabilityXSDValidator(); IValidationReport xsdReport =
82
	 * xsdValidator.validate(definition, propertySchema); return xsdReport; }
83
	 */
84
}
54
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/ListSection.java (-3 / +44 lines)
Lines 14-22 Link Here
14
14
15
import java.util.List;
15
import java.util.List;
16
16
17
import org.eclipse.core.resources.IFile;
17
import org.eclipse.jface.viewers.SelectionChangedEvent;
18
import org.eclipse.jface.viewers.SelectionChangedEvent;
18
import org.eclipse.jface.viewers.StructuredSelection;
19
import org.eclipse.jface.viewers.StructuredSelection;
19
import org.eclipse.jface.window.Window;
20
import org.eclipse.jface.window.Window;
21
import org.eclipse.jface.wizard.WizardDialog;
20
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.events.ControlAdapter;
23
import org.eclipse.swt.events.ControlAdapter;
22
import org.eclipse.swt.events.ControlEvent;
24
import org.eclipse.swt.events.ControlEvent;
Lines 29-40 Link Here
29
import org.eclipse.swt.widgets.Label;
31
import org.eclipse.swt.widgets.Label;
30
import org.eclipse.swt.widgets.Listener;
32
import org.eclipse.swt.widgets.Listener;
31
import org.eclipse.swt.widgets.Tree;
33
import org.eclipse.swt.widgets.Tree;
34
import org.eclipse.tptp.wsdm.tooling.dialog.provisional.XSDBrowseDialog;
32
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.AddPropertyCommand;
35
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.AddPropertyCommand;
33
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangeModifiabilityCommand;
36
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangeModifiabilityCommand;
34
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangeMutabilityCommand;
37
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangeMutabilityCommand;
35
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangePropertyCardinalityCommand;
38
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangePropertyCardinalityCommand;
36
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangePropertyTypeCommand;
39
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangePropertyTypeCommand;
37
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.RemovePropertyCommand;
40
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.RemovePropertyCommand;
41
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.PropertyImportWizard;
38
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.AbstractCapabilityEditor;
42
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.AbstractCapabilityEditor;
39
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
43
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
40
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.AbstractPageSection;
44
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.AbstractPageSection;
Lines 42-52 Link Here
42
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.IUIPage;
46
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.IUIPage;
43
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
47
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
44
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.property.internal.Messages;
48
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.property.internal.Messages;
49
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
45
import org.eclipse.tptp.wsdm.tooling.viewers.internal.IViewerClient;
50
import org.eclipse.tptp.wsdm.tooling.viewers.internal.IViewerClient;
46
import org.eclipse.tptp.wsdm.tooling.viewers.internal.StructuredTreeViewer;
51
import org.eclipse.tptp.wsdm.tooling.viewers.internal.StructuredTreeViewer;
47
import org.eclipse.ui.forms.widgets.FormToolkit;
52
import org.eclipse.ui.forms.widgets.FormToolkit;
48
import org.eclipse.ui.forms.widgets.ScrolledForm;
53
import org.eclipse.ui.forms.widgets.ScrolledForm;
49
import org.eclipse.xsd.XSDElementDeclaration;
54
import org.eclipse.xsd.XSDElementDeclaration;
55
import org.eclipse.xsd.XSDSchema;
50
56
51
/**
57
/**
52
 * 
58
 * 
Lines 65-70 Link Here
65
71
66
	private Button _addPropertyButton;
72
	private Button _addPropertyButton;
67
73
74
	private Button _importPropertyButton;
75
68
	private Button _editMetadataButton;
76
	private Button _editMetadataButton;
69
77
70
	private Button _removePropertyButton;
78
	private Button _removePropertyButton;
Lines 138-147 Link Here
138
					}
146
					}
139
				});
147
				});
140
		gd = new GridData(GridData.CENTER, SWT.NONE, false, false);
148
		gd = new GridData(GridData.CENTER, SWT.NONE, false, false);
141
		gd.widthHint = 80;
149
		gd.widthHint = 100;
142
		_addPropertyButton.setLayoutData(gd);
150
		_addPropertyButton.setLayoutData(gd);
143
		_addPropertyButton.setEnabled(!_editor.isReadOnly());
151
		_addPropertyButton.setEnabled(!_editor.isReadOnly());
144
152
153
		_importPropertyButton = createPushButton(
154
				_buttonClient,
155
				toolkit,
156
				org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.IMPORT_PROPERTIES,
157
				new Listener()
158
				{
159
					public void handleEvent(Event event)
160
					{
161
						importProperty();
162
					}
163
				});
164
		gd = new GridData(GridData.CENTER, SWT.NONE, false, false);
165
		gd.widthHint = 100;
166
		_importPropertyButton.setLayoutData(gd);
167
		_importPropertyButton.setEnabled(!_editor.isReadOnly());
168
145
		_editMetadataButton = createPushButton(_buttonClient, toolkit,
169
		_editMetadataButton = createPushButton(_buttonClient, toolkit,
146
				Messages.EDIT_METADATA_LABEL, new Listener()
170
				Messages.EDIT_METADATA_LABEL, new Listener()
147
				{
171
				{
Lines 151-157 Link Here
151
					}
175
					}
152
				});
176
				});
153
		gd = new GridData(GridData.CENTER, SWT.NONE, false, false);
177
		gd = new GridData(GridData.CENTER, SWT.NONE, false, false);
154
		gd.widthHint = 80;
178
		gd.widthHint = 100;
155
		_editMetadataButton.setLayoutData(gd);
179
		_editMetadataButton.setLayoutData(gd);
156
		_editMetadataButton.setEnabled(false);
180
		_editMetadataButton.setEnabled(false);
157
181
Lines 167-173 Link Here
167
					}
191
					}
168
				});
192
				});
169
		gd = new GridData(GridData.CENTER, SWT.NONE, false, false);
193
		gd = new GridData(GridData.CENTER, SWT.NONE, false, false);
170
		gd.widthHint = 80;
194
		gd.widthHint = 100;
171
		_removePropertyButton.setLayoutData(gd);
195
		_removePropertyButton.setLayoutData(gd);
172
		_removePropertyButton.setEnabled(false);
196
		_removePropertyButton.setEnabled(false);
173
197
Lines 217-222 Link Here
217
		}
241
		}
218
	}
242
	}
219
243
244
	private void importProperty()
245
	{
246
		XSDBrowseDialog dialog = new XSDBrowseDialog(getForm().getShell());
247
		if (dialog.open() == Window.OK)
248
		{
249
			IFile xsdFile = (IFile) dialog.getFirstResult();
250
			// TODO Check for valid schema file
251
			XSDSchema importedSchema = XsdUtils.getSchema(xsdFile);
252
			PropertyImportWizard importPropertyWizard = new PropertyImportWizard(
253
					_editor.getCapabilityDomain(), importedSchema);
254
			WizardDialog wizardDialog = new WizardDialog(getForm().getShell(),
255
					importPropertyWizard);
256
			wizardDialog.open();
257
			_page.setDirty();
258
		}
259
	}
260
220
	private void editMetadata()
261
	private void editMetadata()
221
	{
262
	{
222
		CapabilityDomain capabilityDomain = (CapabilityDomain) _editor
263
		CapabilityDomain capabilityDomain = (CapabilityDomain) _editor
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/ImportValidationStatus.java (+51 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd;
14
15
/**
16
 * This class represents the validation status for importing functionality. 
17
 *
18
 */
19
20
public class ImportValidationStatus
21
{
22
23
	private String _errorMessage;
24
	private Object[] _causeOfError;
25
26
	/**
27
	 * Creates instance of this class. 
28
	 */
29
	public ImportValidationStatus(String errorMessage, Object[] causeOfError)
30
	{
31
		_errorMessage = errorMessage;
32
		_causeOfError = causeOfError;
33
	}
34
35
	/**
36
	 * Returns the error message. 
37
	 */
38
	public String getErrorMessage()
39
	{
40
		return _errorMessage;
41
	}
42
43
	/**
44
	 * Returns the objects that are reason for error. 
45
	 */
46
	public Object[] getCauseOfError()
47
	{
48
		return _causeOfError;
49
	}
50
51
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorageEditorInput.java (+69 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.internal;
14
15
import org.eclipse.core.resources.IStorage;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.PlatformObject;
18
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.ui.IPersistableElement;
20
import org.eclipse.ui.IStorageEditorInput;
21
22
/**
23
 * This class has been designed to use for opening any existing capability from
24
 * within MRT file.<br>
25
 * This class implements the IStorageEditorInput interface which is used to open
26
 * a file as a stream of bytes.<br>
27
 */
28
29
public class CapabilityStorageEditorInput extends PlatformObject implements
30
		IStorageEditorInput
31
{
32
33
	private ICapabilityStorage _storage;
34
35
	public CapabilityStorageEditorInput(ICapabilityStorage storage)
36
	{
37
		_storage = storage;
38
	}
39
40
	public IStorage getStorage() throws CoreException
41
	{
42
		return _storage;
43
	}
44
45
	public boolean exists()
46
	{
47
		return _storage.exists();
48
	}
49
50
	public ImageDescriptor getImageDescriptor()
51
	{
52
		return null;
53
	}
54
55
	public String getName()
56
	{
57
		return _storage.getName();
58
	}
59
60
	public IPersistableElement getPersistable()
61
	{
62
		return null;
63
	}
64
65
	public String getToolTipText()
66
	{
67
		return getName();
68
	}
69
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertySchemaContentProvider.java (+85 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd;
14
15
import java.util.HashMap;
16
import java.util.List;
17
import java.util.Map;
18
19
import org.eclipse.jface.viewers.ITreeContentProvider;
20
import org.eclipse.jface.viewers.Viewer;
21
22
/**
23
 * Content provider for capability properties. 
24
 *
25
 */
26
27
class PropertySchemaContentProvider implements ITreeContentProvider
28
{
29
	private final Map _parentMap;
30
31
	PropertySchemaContentProvider()
32
	{
33
		_parentMap = new HashMap();
34
	}
35
36
	public Object[] getChildren(Object parentElement)
37
	{
38
		if (parentElement instanceof List)
39
		{
40
			List l = (List) parentElement;
41
			return l.toArray();
42
		}
43
		else if (parentElement instanceof PropertyNamespace)
44
		{
45
			PropertyNamespace propNamespace = (PropertyNamespace) parentElement;
46
			Object[] elements = rememberChildren(parentElement, propNamespace
47
					.getProperties());
48
			return elements;
49
		}
50
		return new Object[0];
51
	}
52
53
	public Object getParent(Object element)
54
	{
55
		Object retVal = _parentMap.get(element);
56
		return retVal;
57
	}
58
59
	public boolean hasChildren(Object element)
60
	{
61
		return (getChildren(element).length > 0);
62
	}
63
64
	public Object[] getElements(Object inputElement)
65
	{
66
		return getChildren(inputElement);
67
	}
68
69
	public void dispose()
70
	{
71
	}
72
73
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
74
	{
75
	}
76
77
	private Object[] rememberChildren(Object parent, Object[] childrens)
78
	{
79
		for (int i = 0; i < childrens.length; i++)
80
		{
81
			_parentMap.put(childrens[i], parent);
82
		}
83
		return childrens;
84
	}
85
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java (+98 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl;
14
15
import java.util.LinkedList;
16
import java.util.List;
17
18
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
19
import org.eclipse.xsd.XSDImport;
20
import org.eclipse.xsd.XSDInclude;
21
import org.eclipse.xsd.XSDSchema;
22
23
/**
24
 * This merges the given XSD Schema and returns the array of new schemas.<br>
25
 * Array contains the original XSD schema and all the Imported schemas.<br>
26
 * All the included schmeas merged into original schema. 
27
 *
28
 */
29
30
public class XSDSchemaMerger
31
{
32
33
	private XSDSchema _schema;
34
	private List _allResultedSchema;
35
36
	public XSDSchemaMerger(XSDSchema schema)
37
	{
38
		_schema = schema;
39
		_allResultedSchema = new LinkedList();
40
		addSchema(_schema);
41
	}
42
43
	public XSDSchema[] merge()
44
	{
45
		XSDImport[] imports = XsdUtils.getAllXSDImports(_schema);
46
		for (int i = 0; i < imports.length; i++)
47
		{
48
			if (imports[i].getResolvedSchema() == null)
49
				continue;
50
			addSchema(imports[i].getResolvedSchema());
51
			XSDSchemaMerger merger = new XSDSchemaMerger(imports[i]
52
					.getResolvedSchema());
53
			XSDSchema[] schemas = merger.merge();
54
			for (int j = 0; j < schemas.length; j++)
55
				addSchema(schemas[j]);
56
		}
57
58
		XSDInclude[] includes = XsdUtils.getAllXSDIncludes(_schema);
59
		for (int i = 0; i < includes.length; i++)
60
		{
61
			if (includes[i].getResolvedSchema() == null)
62
				continue;
63
			addSchema(includes[i].getResolvedSchema());
64
			XSDSchemaMerger merger = new XSDSchemaMerger(includes[i]
65
					.getResolvedSchema());
66
			XSDSchema[] schemas = merger.merge();
67
			for (int j = 0; j < schemas.length; j++)
68
				addSchema(schemas[j]);
69
		}
70
71
		return (XSDSchema[]) _allResultedSchema
72
				.toArray(new XSDSchema[_allResultedSchema.size()]);
73
	}
74
75
	private void addSchema(XSDSchema givenSchema)
76
	{
77
		XSDSchema schema = getSchema(givenSchema.getTargetNamespace());
78
		if (schema != null)
79
		{
80
			List givenSchemaContents = givenSchema.getContents();
81
			for (int i = 0; i < givenSchemaContents.size(); i++)
82
				schema.getContents().add(givenSchemaContents.get(i));
83
		}
84
		else
85
			_allResultedSchema.add(givenSchema);
86
	}
87
88
	private XSDSchema getSchema(String targetNamespace)
89
	{
90
		for (int i = 0; i < _allResultedSchema.size(); i++)
91
		{
92
			XSDSchema schema = (XSDSchema) _allResultedSchema.get(i);
93
			if (schema.getTargetNamespace().equals(targetNamespace))
94
				return schema;
95
		}
96
		return null;
97
	}
98
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java (+318 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal;
14
15
import java.util.ArrayList;
16
import java.util.Iterator;
17
import java.util.LinkedList;
18
import java.util.List;
19
import java.util.Map;
20
21
import javax.wsdl.Definition;
22
import javax.wsdl.Fault;
23
import javax.wsdl.Input;
24
import javax.wsdl.Message;
25
import javax.wsdl.Operation;
26
import javax.wsdl.Output;
27
import javax.wsdl.Part;
28
import javax.wsdl.PortType;
29
import javax.xml.namespace.QName;
30
31
import org.eclipse.core.runtime.IProgressMonitor;
32
import org.eclipse.core.runtime.NullProgressMonitor;
33
import org.eclipse.emf.common.util.EList;
34
import org.eclipse.emf.common.util.URI;
35
import org.eclipse.emf.ecore.resource.Resource;
36
import org.eclipse.emf.ecore.resource.ResourceSet;
37
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
38
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl.XSDSchemaMerger;
39
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
40
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
41
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
42
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
43
import org.eclipse.xsd.XSDElementDeclaration;
44
import org.eclipse.xsd.XSDImport;
45
import org.eclipse.xsd.XSDInclude;
46
import org.eclipse.xsd.XSDSchema;
47
import org.eclipse.xsd.util.XSDResourceFactoryImpl;
48
49
/**
50
 * Command class to import operations into the capability.
51
 * 
52
 */
53
54
public class ImportOperationCommand
55
{
56
	private CapabilityDefinition _capabilityDefinition;
57
	private Definition _definition;
58
	private Operation[] _importedOperations;
59
	private URI _importedWsdlURI;
60
	private List _newOperations;
61
	private IProgressMonitor _monitor;
62
	private XSDSchema[] _importedWsdlSchemas = new XSDSchema[0];
63
64
	/**
65
	 * Creates a new object of this class.
66
	 */
67
	public ImportOperationCommand(CapabilityDefinition capabilityDefinition,
68
			Operation[] importedOperations, URI importedWsdlURI, IProgressMonitor monitor)
69
	{
70
		_capabilityDefinition = capabilityDefinition;
71
		_definition = _capabilityDefinition.getDefinition();
72
		_importedWsdlURI = importedWsdlURI;
73
		_importedOperations = importedOperations;
74
		_newOperations = new LinkedList();
75
		_monitor = monitor;
76
		_importedWsdlSchemas = loadSchemas(_importedWsdlURI);
77
		XSDSchema[] capabilityWsdlSchemas = _capabilityDefinition
78
				.getXSDSchemas();
79
		// TODO
80
		/*
81
		 * if(capabilityWsdlSchemas == null) // No wsdl types defined { Types
82
		 * types = WSDLFactory.eINSTANCE.createTypes();
83
		 * types.setEnclosingDefinition(_capabilityDefinition);
84
		 * _capabilityDefinition.setETypes(types); }
85
		 */
86
		if (monitor == null)
87
			_monitor = new NullProgressMonitor();
88
	}
89
90
	/**
91
	 * Creates a new object of this class.
92
	 */
93
	public ImportOperationCommand(CapabilityDefinition capabilityDefinition,
94
			Operation[] importedOperations, URI importedWsdlURI)
95
	{
96
		this(capabilityDefinition, importedOperations, importedWsdlURI, null);
97
	}
98
	
99
	/**
100
	 * Execute the command.
101
	 */
102
	public void execute()
103
	{
104
		_monitor.beginTask(Messages.IMPORTING_OPERATIONS,
105
				_importedOperations.length);
106
		for (int i = 0; i < _importedOperations.length; i++)
107
		{
108
			String taskName = Messages.bind(Messages.IMPORTING_OPERATION,
109
					_importedOperations[i].getName());
110
			_monitor.setTaskName(taskName);
111
			Operation newOperation = createNewOperation(_importedOperations[i]);
112
			_newOperations.add(newOperation);
113
			_monitor.worked(i + 1);
114
		}
115
	}
116
117
	private Operation createNewOperation(Operation importedOperation)
118
	{
119
		Operation newOperation = _definition.createOperation();
120
		newOperation.setUndefined(false);
121
		PortType port = _capabilityDefinition.getPortType();
122
		port.addOperation(newOperation);
123
		newOperation.setName(importedOperation.getName());
124
125
		createNewOperationInput(newOperation, importedOperation);
126
		createNewOperationOutput(newOperation, importedOperation);
127
		createNewOperationFaults(newOperation, importedOperation);
128
129
		return newOperation;
130
	}
131
132
	private void createNewOperationInput(Operation newOperation,
133
			Operation importedOperation)
134
	{
135
		Input newInput = _definition.createInput();
136
		newOperation.setUndefined(false);
137
		newOperation.setInput(newInput);
138
		newInput.setName(importedOperation.getInput().getName());
139
140
		Message importedMessage = importedOperation.getInput().getMessage();
141
		Message newMessage = createNewMessage(importedMessage);
142
		newInput.setMessage(newMessage);
143
		_capabilityDefinition.addMessage(newMessage);
144
145
		// TODO
146
		/*
147
		 * String opName = importedOperation.getName(); opName =
148
		 * opName.substring(0, 1).toUpperCase() + opName.substring(1); String
149
		 * tns = _capabilityDefinition.getTargetNamespace();
150
		 * if(!tns.endsWith("/")) tns = tns+"/"; String action =
151
		 * tns+opName+"Request";
152
		 * newInput.getElement().setAttributeNS(WsdmConstants.WSA_URI,
153
		 * WsdmConstants.WSA_ACTION_NAME, action);
154
		 */
155
	}
156
157
	private void createNewOperationOutput(Operation newOperation,
158
			Operation importedOperation)
159
	{
160
		if (importedOperation.getOutput() == null)
161
			return;
162
163
		Output newOutput = _definition.createOutput();
164
		newOperation.setOutput(newOutput);
165
		newOutput.setName(importedOperation.getOutput().getName());
166
167
		Message importedMessage = importedOperation.getOutput().getMessage();
168
		Message newMessage = createNewMessage(importedMessage);
169
		newOutput.setMessage(newMessage);
170
		_capabilityDefinition.addMessage(newMessage);
171
172
		// TODO
173
		/*
174
		 * String opName = importedOperation.getName(); opName =
175
		 * opName.substring(0, 1).toUpperCase() + opName.substring(1); String
176
		 * tns = _capabilityDefinition.getTargetNamespace();
177
		 * if(!tns.endsWith("/")) tns = tns+"/"; String action =
178
		 * tns+opName+"Response";
179
		 * newOutput.getElement().setAttributeNS(WsdmConstants.WSA_URI,
180
		 * WsdmConstants.WSA_ACTION_NAME, action);
181
		 */
182
	}
183
184
	private void createNewOperationFaults(Operation newOperation,
185
			Operation importedOperation)
186
	{
187
		Map importedFaultsMap = importedOperation.getFaults();
188
		if (importedFaultsMap == null || importedFaultsMap.size() == 0)
189
			return;
190
		Iterator it = importedFaultsMap.values().iterator();
191
		while (it.hasNext())
192
		{
193
			Object object = it.next();
194
			if (object instanceof Fault)
195
			{
196
				Fault importFault = (Fault) object;
197
				Fault newFault = _definition.createFault();
198
				newOperation.addFault(newFault);
199
				newFault.setName(importFault.getName());
200
201
				Message importedMessage = importFault.getMessage();
202
				Message newMessage = createNewMessage(importedMessage);
203
				newFault.setMessage(newMessage);
204
				_capabilityDefinition.addMessage(newMessage);
205
			}
206
		}
207
	}
208
209
	private Message createNewMessage(Message importedMessage)
210
	{
211
		  Definition definition = _capabilityDefinition.getDefinition();
212
		  Message existingMessage = WsdlUtils.getWSDLMessage(definition,importedMessage.getQName().getLocalPart()); 
213
		  if(existingMessage!=null)
214
			  return existingMessage; 
215
		  Message message = definition.createMessage();
216
		  message.setUndefined(false);
217
		  String messageLocalName = importedMessage.getQName().getLocalPart();
218
		  message.setQName(new QName(definition.getTargetNamespace(),messageLocalName));
219
		  
220
		  Part part = definition.createPart();
221
		  message.addPart(part); 
222
		  Part importedPart = (Part)importedMessage.getParts().values().iterator().next();
223
		  XSDSchema importedPartSchema = getImportedWSDLSchema(importedPart.getElementName().getNamespaceURI());
224
		  importSchemaForElement(importedPartSchema); 
225
		  String xsdNS = importedPart.getElementName().getNamespaceURI();
226
		  String elementName = importedPart.getElementName().getLocalPart();
227
		  XSDSchema elementSchema = _capabilityDefinition.getSchema(xsdNS); 
228
		  XSDElementDeclaration element = XsdUtils.getXSDElementDeclarationOfName(elementSchema, elementName);
229
		  _capabilityDefinition.createOrFindPrefix(element.getTargetNamespace(), null);
230
		  part.setName(importedPart.getName());
231
		  part.setElementName(new QName(xsdNS, elementName)); 
232
		  return message;
233
	}
234
	
235
	private XSDSchema getImportedWSDLSchema(String namespace)
236
	{
237
		for(int i=0;i<_importedWsdlSchemas.length;i++)
238
		{
239
			if(_importedWsdlSchemas[i].getTargetNamespace().equals(namespace))
240
				return _importedWsdlSchemas[i];
241
		}
242
		return null;
243
	}
244
245
	private void importSchemaForElement(XSDSchema elementSchema)
246
	{
247
		  XSDSchemaMerger merger =  new XSDSchemaMerger(elementSchema); 
248
		  XSDSchema[] mergedSchemas = merger.merge(); 
249
		  for(int i=0;i<mergedSchemas.length;i++) 
250
		  {
251
			  if(!isSchemaExistsInWsdl(mergedSchemas[i])) 
252
			  {
253
				  XSDSchema copySchema = createCopy(mergedSchemas[i]);
254
				  XSDSchema schema = _capabilityDefinition.createOrFindSchema(copySchema.getTargetNamespace());
255
				  schema.setElement(copySchema.getElement());
256
				  schema.updateElement(true); 
257
			 } 
258
		}		 
259
	}
260
261
	private boolean isSchemaExistsInWsdl(XSDSchema schema)
262
	{
263
		XSDSchema wsdlSchema = _capabilityDefinition.getSchema(schema
264
				.getTargetNamespace());
265
		if (wsdlSchema != null)
266
			return true;
267
		return false;
268
	}
269
270
	private XSDSchema createCopy(XSDSchema schema)
271
	{
272
		XSDSchema copySchema = (XSDSchema) schema.cloneConcreteComponent(true,
273
				false);
274
		List contents = copySchema.getContents();
275
		for (int i = 0; i < contents.size(); i++)
276
		{
277
			if (contents.get(i) instanceof XSDInclude)
278
				contents.remove(i);
279
			else if (contents.get(i) instanceof XSDImport)
280
			{
281
				XSDImport theImport = (XSDImport) contents.get(i);
282
				theImport.setSchemaLocation(null);
283
			}
284
		}
285
		copySchema.updateElement(true);
286
		return copySchema;
287
	}
288
289
	public Operation[] getNewOperations()
290
	{
291
		return (Operation[]) _newOperations
292
				.toArray(new Operation[_newOperations.size()]);
293
	}
294
	
295
	private XSDSchema[] loadSchemas(URI uri)
296
	{
297
		// Get a ResourceSet describing the XSD in the WSDL
298
		XSDSchema schema = null;
299
		ResourceSet resourceSet = new ResourceSetImpl();
300
		Resource resourceWsdl = null;
301
		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
302
				.put("*", new XSDResourceFactoryImpl());
303
		resourceWsdl = resourceSet.getResource(uri, true);
304
		EList list = resourceWsdl.getContents();
305
306
		List schemas = new ArrayList();
307
		for (int i = 0; i < list.size(); i++)
308
		{
309
			Object o = list.get(i);
310
			if (o instanceof XSDSchema)
311
			{
312
				schema = (XSDSchema) o;
313
				schemas.add(schema);
314
			}
315
		}
316
		return (XSDSchema[]) schemas.toArray(new XSDSchema[0]);
317
	}
318
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizardPage.java (+255 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd;
14
15
import java.util.Arrays;
16
import java.util.LinkedList;
17
import java.util.List;
18
19
import org.eclipse.jface.dialogs.Dialog;
20
import org.eclipse.jface.viewers.CheckStateChangedEvent;
21
import org.eclipse.jface.viewers.CheckboxTreeViewer;
22
import org.eclipse.jface.viewers.ICheckStateListener;
23
import org.eclipse.jface.viewers.StructuredSelection;
24
import org.eclipse.jface.wizard.IWizardPage;
25
import org.eclipse.jface.wizard.WizardPage;
26
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Label;
31
import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory;
32
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
33
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
34
import org.eclipse.xsd.XSDElementDeclaration;
35
import org.eclipse.xsd.XSDSchema;
36
37
/**
38
 * Wizard page to import properties from XSD file. 
39
 *
40
 */
41
42
public class PropertyImportWizardPage extends WizardPage
43
{
44
	private XSDSchema _importSchema;
45
	private PropertyNamespace[] _existingPropertyNs = new PropertyNamespace[0];
46
	private CheckboxTreeViewer _viewer;
47
	private PropertySchemaContentProvider _contentProvider;
48
	private Property[] _importedProperties;
49
50
	public PropertyImportWizardPage()
51
	{
52
		super("ImportPropertyWizardPage");
53
		setTitle(Messages.PROPERTY_IMPORT_WIZARD_PAGE_TITLE);
54
		setDescription(Messages.PROPERTY_IMPORT_WIZARD_PAGE_DESCRIPTION);
55
	}
56
57
	public PropertyImportWizardPage(XSDSchema importSchema,
58
			PropertyNamespace[] existingPropertyNs)
59
	{
60
		super("ImportPropertyWizardPage");
61
		setTitle(Messages.PROPERTY_IMPORT_WIZARD_PAGE_TITLE);
62
		setDescription(Messages.PROPERTY_IMPORT_WIZARD_PAGE_DESCRIPTION);
63
		_importSchema = importSchema;
64
		if (existingPropertyNs != null)
65
			_existingPropertyNs = existingPropertyNs;
66
	}
67
68
	public PropertyImportWizardPage(XSDSchema importSchema)
69
	{
70
		this(importSchema, null);
71
	}
72
73
	public void createControl(Composite parent)
74
	{
75
		initializeDialogUnits(parent);
76
		Composite container = new Composite(parent, SWT.NULL);
77
		container.setFont(parent.getFont());
78
		GridLayout layout = new GridLayout();
79
		container.setLayout(layout);
80
		layout.verticalSpacing = 9;
81
82
		Label availablePropertiesLabel = new Label(container, SWT.WRAP);
83
		availablePropertiesLabel.setText(Messages.AVAILABLE_PROPERTIES_LABEL);
84
		GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
85
		gd.minimumHeight = 15;
86
		availablePropertiesLabel.setLayoutData(gd);
87
88
		_viewer = new CheckboxTreeViewer(container, SWT.MULTI | SWT.BORDER);
89
		_contentProvider = new PropertySchemaContentProvider();
90
		_viewer.setContentProvider(_contentProvider);
91
		_viewer.setLabelProvider(new PropertySchemaLabelProvider(getShell()));
92
		_viewer.getControl().setLayoutData(
93
				new GridData(SWT.FILL, SWT.FILL, true, true));
94
		_viewer.addCheckStateListener(new ICheckStateListener()
95
		{
96
			public void checkStateChanged(CheckStateChangedEvent event)
97
			{
98
				handleCheckStateChanged(event);
99
			}
100
		});
101
		gd = new GridData(SWT.FILL, SWT.FILL, true, true);
102
		gd.heightHint = 200;
103
		gd.widthHint = 300;
104
		_viewer.getControl().setLayoutData(gd);
105
106
		initialize();
107
		// getShell().setSize(500, 100);
108
		setControl(container);
109
		Dialog.applyDialogFont(parent);
110
	}
111
112
	private void initialize()
113
	{
114
		_importedProperties = new Property[0];
115
		if (_importSchema != null)
116
		{
117
			// Get the Consolidated list of schemas
118
			// (Provided through constructor + Schemas collect from given
119
			// capability file)
120
			List allPropNamespaces = new LinkedList();
121
			PropertyNamespace importPropNamespace = createPropertyNamespaceFromImportedSchema();
122
			allPropNamespaces.addAll(Arrays.asList(_existingPropertyNs));
123
			allPropNamespaces.add(importPropNamespace);
124
			_viewer.setInput(allPropNamespaces);
125
		}
126
		// _viewer.expandToLevel(2);
127
		// Checked the Schemas provided by constructor
128
		doIntialCheckedElements();
129
		_viewer.setGrayedElements(_existingPropertyNs);
130
		updateStatus(null);
131
	}
132
133
	protected void doIntialCheckedElements()
134
	{
135
		for (int i = 0; i < _existingPropertyNs.length; i++)
136
			_viewer.setSubtreeChecked(_existingPropertyNs[i], true);
137
	}
138
139
	public void setImportSchema(XSDSchema importSchema)
140
	{
141
		_importSchema = importSchema;
142
		initialize();
143
	}
144
145
	private void handleCheckStateChanged(CheckStateChangedEvent event)
146
	{
147
		// We don't allow user to check uncheck any Properties provided in
148
		// constructor
149
		PropertyNamespace checkedElementNS = getNamespaceOfChekedElement(event
150
				.getElement());
151
		for (int i = 0; i < _existingPropertyNs.length; i++)
152
		{
153
			if (_existingPropertyNs[i].equals(checkedElementNS))
154
			{
155
				_viewer.setChecked(event.getElement(), !event.getChecked());
156
				return;
157
			}
158
		}
159
160
		_viewer.setSubtreeChecked(event.getElement(), event.getChecked());
161
		Property[] checkedProperties = getCheckedProperties();
162
		PropertyImportValidator validator = new PropertyImportValidator(
163
				checkedProperties);
164
		ImportValidationStatus status = validator.validate();
165
		updateStatus(null);
166
		if (status != null)
167
		{
168
			Object[] causeOfError = status.getCauseOfError();
169
			for (int i = 0; i < causeOfError.length; i++)
170
				_viewer.reveal(causeOfError[i]);
171
			_viewer.setSelection(new StructuredSelection(causeOfError));
172
			updateStatus(status.getErrorMessage());
173
		}
174
		_importedProperties = getSelectedProperties();
175
	}
176
177
	private void updateStatus(String message)
178
	{
179
		setErrorMessage(message);
180
		setPageComplete(message == null);
181
	}
182
183
	private PropertyNamespace getNamespaceOfChekedElement(Object checkedElement)
184
	{
185
		if (checkedElement instanceof PropertyNamespace)
186
			return (PropertyNamespace) checkedElement;
187
		Object parent = _contentProvider.getParent(checkedElement);
188
		while (!(parent instanceof PropertyNamespace))
189
			parent = _contentProvider.getParent(parent);
190
		return (PropertyNamespace) parent;
191
	}
192
193
	/**
194
	 * Returns all the checked xsd properties from viewer.
195
	 */
196
	private Property[] getCheckedProperties()
197
	{
198
		Object[] checkedElements = _viewer.getCheckedElements();
199
		List selectedOperationList = new LinkedList();
200
		for (int i = 0; i < checkedElements.length; i++)
201
		{
202
			if (checkedElements[i] instanceof Property)
203
				selectedOperationList.add(checkedElements[i]);
204
		}
205
		return (Property[]) selectedOperationList
206
				.toArray(new Property[selectedOperationList.size()]);
207
	}
208
209
	private Property[] getSelectedProperties()
210
	{
211
		Property[] checkedProperties = getCheckedProperties();
212
		List selectedProperties = new LinkedList();
213
		for (int i = 0; i < checkedProperties.length; i++)
214
		{
215
			PropertyNamespace checkedElementNS = getNamespaceOfChekedElement(checkedProperties[i]);
216
			boolean isImportProperty = true;
217
			for (int j = 0; j < _existingPropertyNs.length; j++)
218
			{
219
				if (_existingPropertyNs[j].equals(checkedElementNS))
220
				{
221
					isImportProperty = false;
222
					break;
223
				}
224
			}
225
			if (isImportProperty)
226
				selectedProperties.add(checkedProperties[i]);
227
		}
228
		return (Property[]) selectedProperties
229
				.toArray(new Property[selectedProperties.size()]);
230
	}
231
232
	public Property[] getImportedProperties()
233
	{
234
		return _importedProperties;
235
	}
236
237
	public IWizardPage getNextPage()
238
	{
239
		return null;
240
	}
241
242
	private PropertyNamespace createPropertyNamespaceFromImportedSchema()
243
	{
244
		PropertyNamespace propNamespace = new PropertyNamespace(_importSchema
245
				.getTargetNamespace());
246
		List importElements = _importSchema.getElementDeclarations();
247
		for (int i = 0; i < importElements.size(); i++)
248
		{
249
			Property property = CapabilitiesFactory.INSTANCE.createProperty();
250
			property.setElement((XSDElementDeclaration) importElements.get(i));
251
			propNamespace.addProperty(property);
252
		}
253
		return propNamespace;
254
	}
255
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/INewNameGenerator.java (+25 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator;
14
15
/**
16
 * Interface to generate a new name. 
17
 *
18
 */
19
20
public interface INewNameGenerator
21
{
22
23
	public String getNewName();
24
25
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportValidator.java (+225 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl;
14
15
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.Map;
18
19
import javax.wsdl.Fault;
20
import javax.wsdl.Message;
21
import javax.wsdl.Operation;
22
import javax.wsdl.Part;
23
import javax.xml.namespace.QName;
24
25
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.ImportValidationStatus;
26
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
27
import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils;
28
29
/**
30
 * Validator class to validate the imported operations.<br>
31
 * It performs the following validations.<br>
32
 * (1) Imported operation name should not conflicted with Abstract Capability Class method names.<br>
33
 * (2) Imported operation name should not be the same as one available in capability.<br>
34
 * (3) Since we are going to merge all the messages in one wsdl file. There should not be two messages having same name but different namespaces.<br>
35
 * (4) WSDL Messages should be of Doc-Literal type. 
36
 */
37
38
class OperationImportValidator
39
{
40
41
	private Operation[] _operations;
42
	private Map _map = new HashMap();
43
	public static final String XMLSCHEMA_2001_URI = "http://www.w3.org/2001/XMLSchema";
44
45
	/**
46
	 * Creates new object of this class. 
47
	 */
48
	public OperationImportValidator(Operation[] operations)
49
	{
50
		_operations = operations;
51
	}
52
53
	/**
54
	 * Validate the operations. 
55
	 */
56
	public ImportValidationStatus validate()
57
	{
58
		Map operationNames = new HashMap();
59
		if (_operations == null)
60
			return null;
61
		for (int i = 0; i < _operations.length; i++)
62
		{
63
			String operationName = _operations[i].getName();
64
65
			// Validate operation name against AbstractCapability methods
66
			if (CapUtils.isOperationNameConflicted(operationName))
67
			{
68
				String errorMessage = org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages
69
						.bind(
70
								org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages.CONFLICTED_OPERATION_WARN_,
71
								operationName);
72
				return new ImportValidationStatus(errorMessage, new Object[]
73
				{ _operations[i] });
74
			}
75
76
			// Validate duplicate operation name
77
			if (!operationNames.containsKey(operationName))
78
				operationNames.put(operationName, _operations[i]);
79
			else
80
			{
81
				String errorMessage = Messages.bind(
82
						Messages.DUPLICATE_OPERATION, operationName);
83
				Operation causeOfError_1 = (Operation) operationNames
84
						.get(operationName);
85
				Operation causeOfError_2 = _operations[i];
86
				return new ImportValidationStatus(errorMessage, new Object[]
87
				{ causeOfError_1, causeOfError_2 });
88
			}
89
90
			// Since we are going to merge all the messages in one wsdl file
91
			// There should not be two messages having same name but different
92
			// namespaces.
93
94
			// Validate Input Message
95
			if (_operations[i].getInput() != null)
96
			{
97
				Message inputMessage = _operations[i].getInput().getMessage();
98
				if (!isDocLiteralMessage(inputMessage))
99
				{
100
					String errorMessage = Messages.NOT_DOC_LITERAL_MESSAGE;
101
					return new ImportValidationStatus(errorMessage,
102
							new Object[]
103
							{ inputMessage });
104
				}
105
				Message conflictedMessage = validateConflictedMessage(inputMessage);
106
				if (conflictedMessage != null)
107
				{
108
					String newLine = System.getProperty("line.separator");
109
					String errorMessage = Messages.CONFLICTED_MESSAGE + newLine
110
							+ conflictedMessage.getQName().toString() + newLine
111
							+ inputMessage.getQName().toString();
112
					return new ImportValidationStatus(errorMessage,
113
							new Object[]
114
							{ conflictedMessage, inputMessage });
115
				}
116
			}
117
			else
118
			{
119
				String errorMessage = Messages.INPUT_MESSAGE_NOT_DEFINED;
120
				return new ImportValidationStatus(errorMessage, new Object[]
121
				{ _operations[i] });
122
			}
123
124
			// Validate Output Message
125
			if (_operations[i].getOutput() != null)
126
			{
127
				Message outputMessage = _operations[i].getOutput().getMessage();
128
				if (!isDocLiteralMessage(outputMessage))
129
				{
130
					String errorMessage = Messages.NOT_DOC_LITERAL_MESSAGE;
131
					return new ImportValidationStatus(errorMessage,
132
							new Object[]
133
							{ outputMessage });
134
				}
135
				Message conflictedMessage = validateConflictedMessage(outputMessage);
136
				if (conflictedMessage != null)
137
				{
138
					String newLine = System.getProperty("line.separator");
139
					String errorMessage = Messages.CONFLICTED_MESSAGE + newLine
140
							+ conflictedMessage.getQName().toString() + newLine
141
							+ outputMessage.getQName().toString();
142
					return new ImportValidationStatus(errorMessage,
143
							new Object[]
144
							{ conflictedMessage, outputMessage });
145
				}
146
			}
147
			else
148
			{
149
				String errorMessage = Messages.OUTPUT_MESSAGE_NOT_DEFINED;
150
				return new ImportValidationStatus(errorMessage, new Object[]
151
				{ _operations[i] });
152
			}
153
154
			// Validate Fault Messages
155
			Iterator faultsIt = _operations[i].getFaults().values().iterator();
156
			while (faultsIt.hasNext())
157
			{
158
				Object object = faultsIt.next();
159
				if (object instanceof Fault)
160
				{
161
					Fault fault = (Fault) object;
162
					Message faultMessage = fault.getMessage();
163
					if (!isDocLiteralMessage(faultMessage))
164
					{
165
						String errorMessage = Messages.NOT_DOC_LITERAL_MESSAGE;
166
						return new ImportValidationStatus(errorMessage,
167
								new Object[]
168
								{ faultMessage });
169
					}
170
					Message conflictedMessage = validateConflictedMessage(faultMessage);
171
					if (conflictedMessage != null)
172
					{
173
						String newLine = System.getProperty("line.separator");
174
						String errorMessage = Messages.CONFLICTED_MESSAGE
175
								+ newLine
176
								+ conflictedMessage.getQName().toString()
177
								+ newLine + faultMessage.getQName().toString();
178
						return new ImportValidationStatus(errorMessage,
179
								new Object[]
180
								{ conflictedMessage, faultMessage });
181
					}
182
				}
183
			}
184
		}
185
		return null;
186
	}
187
188
	private Message validateConflictedMessage(Message wsdlMessage)
189
	{
190
		String messageNS = wsdlMessage.getQName().getNamespaceURI();
191
		String messageName = wsdlMessage.getQName().getLocalPart();
192
		if (_map.get(messageName) == null)
193
		{
194
			_map.put(messageName, wsdlMessage);
195
			return null;
196
		}
197
		Message messageFromMap = (Message) _map.get(messageName);
198
		String nsFromMap = messageFromMap.getQName().getNamespaceURI();
199
		if (!nsFromMap.equals(messageNS))
200
			return messageFromMap;
201
		return null;
202
	}
203
204
	private boolean isDocLiteralMessage(Message wsdlMessage)
205
	{
206
		Map partsMap = wsdlMessage.getParts();
207
		if (partsMap == null || partsMap.size() != 1)
208
			return false;
209
		Part part_0 = (Part) partsMap.values().iterator().next();
210
		QName elementQName = part_0.getElementName();
211
		if (elementQName == null)
212
		{
213
			QName typeDef = part_0.getTypeName();
214
			if (typeDef == null)
215
				return false;
216
			boolean voidType = typeDef.getNamespaceURI().equals(
217
					XMLSCHEMA_2001_URI)
218
					&& typeDef.getLocalPart().equals("anyType");
219
			if (!voidType)
220
				return false;
221
		}
222
		return true;
223
	}
224
225
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizardPage.java (+280 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl;
14
15
import java.util.LinkedList;
16
import java.util.List;
17
import java.util.Map;
18
19
import javax.wsdl.Definition;
20
import javax.wsdl.Message;
21
import javax.wsdl.Operation;
22
import javax.wsdl.PortType;
23
24
import org.eclipse.emf.common.util.URI;
25
import org.eclipse.jface.dialogs.Dialog;
26
import org.eclipse.jface.viewers.CheckStateChangedEvent;
27
import org.eclipse.jface.viewers.CheckboxTreeViewer;
28
import org.eclipse.jface.viewers.ICheckStateListener;
29
import org.eclipse.jface.viewers.StructuredSelection;
30
import org.eclipse.jface.wizard.IWizardPage;
31
import org.eclipse.jface.wizard.WizardPage;
32
import org.eclipse.swt.SWT;
33
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.swt.widgets.Label;
37
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.ImportValidationStatus;
38
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
39
40
/**
41
 * Wizard page to import operations from WSDL file. 
42
 *
43
 */
44
45
public class OperationImportWizardPage extends WizardPage
46
{
47
	private CheckboxTreeViewer _viewer;
48
	private WsdlPortTypeContentProvider _contentProvider;
49
	private Definition _wsdlDefinition;
50
	private PortType[] _existingPortTypes = new PortType[0];
51
	private Operation[] _importedOperations;
52
	private URI _importedWsdlURI;
53
54
	public OperationImportWizardPage()
55
	{
56
		super("ImportOperationWizardPage");
57
		setTitle(Messages.OPERATION_IMPORT_WIZARD_PAGE_TITLE);
58
		setDescription(Messages.OPERATION_IMPORT_WIZARD_PAGE_DESCRIPTION);
59
	}
60
61
	public OperationImportWizardPage(Definition wsdlDefinition,
62
			PortType[] existingPortTypes)
63
	{
64
		super("ImportOperationWizardPage");
65
		setTitle(Messages.OPERATION_IMPORT_WIZARD_PAGE_TITLE);
66
		setDescription(Messages.OPERATION_IMPORT_WIZARD_PAGE_DESCRIPTION);
67
		_wsdlDefinition = wsdlDefinition;
68
		if (existingPortTypes != null)
69
			_existingPortTypes = existingPortTypes;
70
	}
71
72
	public OperationImportWizardPage(Definition wsdlDefinition)
73
	{
74
		this(wsdlDefinition, null);
75
	}
76
77
	public void createControl(Composite parent)
78
	{
79
		initializeDialogUnits(parent);
80
		Composite container = new Composite(parent, SWT.NULL);
81
		container.setFont(parent.getFont());
82
		GridLayout layout = new GridLayout();
83
		container.setLayout(layout);
84
		layout.verticalSpacing = 9;
85
86
		Label descriptionLabel = new Label(container, SWT.WRAP);
87
		descriptionLabel
88
				.setText(Messages.OPERATION_IMPORT_WIZARD_PAGE_INFO_LABEL);
89
		GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
90
		gd.minimumHeight = 30;
91
		descriptionLabel.setLayoutData(gd);
92
93
		Label availableOperationsLabel = new Label(container, SWT.WRAP);
94
		availableOperationsLabel.setText(Messages.AVAILABLE_OPERATIONS_LABEL);
95
		gd = new GridData(SWT.FILL, SWT.FILL, true, false);
96
		gd.minimumHeight = 15;
97
		availableOperationsLabel.setLayoutData(gd);
98
99
		_viewer = new CheckboxTreeViewer(container, SWT.MULTI | SWT.BORDER);
100
		_contentProvider = new WsdlPortTypeContentProvider();
101
		_viewer.setContentProvider(_contentProvider);
102
		_viewer.setLabelProvider(new WsdlPortTypeLabelProvider(getShell()));
103
		_viewer.getControl().setLayoutData(
104
				new GridData(SWT.FILL, SWT.FILL, true, true));
105
		_viewer.addCheckStateListener(new ICheckStateListener()
106
		{
107
			public void checkStateChanged(CheckStateChangedEvent event)
108
			{
109
				handleCheckStateChanged(event);
110
			}
111
		});
112
		gd = new GridData(SWT.FILL, SWT.FILL, true, true);
113
		gd.heightHint = 200;
114
		gd.widthHint = 300;
115
		_viewer.getControl().setLayoutData(gd);
116
117
		initialize();
118
		// getShell().setSize(500, 100);
119
		setControl(container);
120
		Dialog.applyDialogFont(parent);
121
	}
122
123
	private void initialize()
124
	{
125
		_importedOperations = new Operation[0];
126
		if (_wsdlDefinition != null)
127
		{
128
			// Get the Consolidated list of port types
129
			// (Provided through constructor + Port types collect from given
130
			// wsdl file)
131
			Map portTypeMap = _wsdlDefinition.getPortTypes();
132
			PortType[] portTypes = (PortType[]) portTypeMap.values().toArray(
133
					new PortType[portTypeMap.size()]);
134
			List ports = getConsolidatedPortList(portTypes);
135
			_viewer.setInput(ports);
136
		}
137
		// _viewer.expandToLevel(2);
138
		// Checked the Port types provided by constructor
139
		doIntialCheckedElements();
140
		_viewer.setGrayedElements(_existingPortTypes);
141
		updateStatus(null);
142
	}
143
144
	public void setWSDLDefinition(Definition definition)
145
	{
146
		_wsdlDefinition = definition;
147
		initialize();
148
	}
149
	
150
	public void setImportedWsdlURI(URI importedWsdlURI)
151
	{
152
		_importedWsdlURI = importedWsdlURI;
153
	}
154
	
155
	public URI getImportedWsdlURI()
156
	{
157
		return _importedWsdlURI;
158
	}
159
160
	private List getConsolidatedPortList(PortType[] ports)
161
	{
162
		List portTypes = new LinkedList();
163
		for (int i = 0; i < _existingPortTypes.length; i++)
164
			portTypes.add(_existingPortTypes[i]);
165
		if (ports == null)
166
			return portTypes;
167
		for (int i = 0; i < ports.length; i++)
168
			portTypes.add(ports[i]);
169
		return portTypes;
170
	}
171
172
	protected void doIntialCheckedElements()
173
	{
174
		for (int i = 0; i < _existingPortTypes.length; i++)
175
			_viewer.setSubtreeChecked(_existingPortTypes[i], true);
176
	}
177
178
	private void handleCheckStateChanged(CheckStateChangedEvent event)
179
	{
180
		// We don't allow user to check uncheck WSDL Messages
181
		if (event.getElement() instanceof Message)
182
		{
183
			_viewer.setChecked(event.getElement(), !event.getChecked());
184
			return;
185
		}
186
187
		// We don't allow user to check uncheck any Port Type provided in
188
		// constructor
189
		PortType port = getPortTypeOfChekedElement(event.getElement());
190
		for (int i = 0; i < _existingPortTypes.length; i++)
191
		{
192
			if (_existingPortTypes[i].equals(port))
193
			{
194
				_viewer.setChecked(event.getElement(), !event.getChecked());
195
				return;
196
			}
197
		}
198
199
		_viewer.setSubtreeChecked(event.getElement(), event.getChecked());
200
		Operation[] checkedOperations = getCheckedOperations();
201
		OperationImportValidator validator = new OperationImportValidator(
202
				checkedOperations);
203
		ImportValidationStatus status = validator.validate();
204
		updateStatus(null);
205
		if (status != null)
206
		{
207
			Object[] causeOfError = status.getCauseOfError();
208
			for (int i = 0; i < causeOfError.length; i++)
209
				_viewer.reveal(causeOfError[i]);
210
			_viewer.setSelection(new StructuredSelection(causeOfError));
211
			updateStatus(status.getErrorMessage());
212
		}
213
		_importedOperations = getSelectedOperation();
214
	}
215
216
	private void updateStatus(String message)
217
	{
218
		setErrorMessage(message);
219
		setPageComplete(message == null);
220
	}
221
222
	private PortType getPortTypeOfChekedElement(Object checkedElement)
223
	{
224
		if (checkedElement instanceof PortType)
225
			return (PortType) checkedElement;
226
		Object parent = _contentProvider.getParent(checkedElement);
227
		while (!(parent instanceof PortType))
228
			parent = _contentProvider.getParent(parent);
229
		return (PortType) parent;
230
	}
231
232
	/**
233
	 * Returns all the checked wsdl operations from viewer.
234
	 */
235
	private Operation[] getCheckedOperations()
236
	{
237
		Object[] checkedElements = _viewer.getCheckedElements();
238
		List selectedOperationList = new LinkedList();
239
		for (int i = 0; i < checkedElements.length; i++)
240
		{
241
			if (checkedElements[i] instanceof Operation)
242
				selectedOperationList.add(checkedElements[i]);
243
		}
244
		return (Operation[]) selectedOperationList
245
				.toArray(new Operation[selectedOperationList.size()]);
246
	}
247
248
	public Operation[] getImportedOperations()
249
	{
250
		return _importedOperations;
251
	}
252
253
	private Operation[] getSelectedOperation()
254
	{
255
		Operation[] checkedOperations = getCheckedOperations();
256
		List selectedOperations = new LinkedList();
257
		for (int i = 0; i < checkedOperations.length; i++)
258
		{
259
			PortType port = getPortTypeOfChekedElement(checkedOperations[i]);
260
			boolean isImportOperation = true;
261
			for (int j = 0; j < _existingPortTypes.length; j++)
262
			{
263
				if (_existingPortTypes[j].equals(port))
264
				{
265
					isImportOperation = false;
266
					break;
267
				}
268
			}
269
			if (isImportOperation)
270
				selectedOperations.add(checkedOperations[i]);
271
		}
272
		return (Operation[]) selectedOperations
273
				.toArray(new Operation[selectedOperations.size()]);
274
	}
275
276
	public IWizardPage getNextPage()
277
	{
278
		return null;
279
	}
280
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/WsdlPortTypeLabelProvider.java (+87 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl;
14
15
import javax.wsdl.Message;
16
import javax.wsdl.Operation;
17
import javax.wsdl.PortType;
18
19
import org.eclipse.jface.resource.ImageRegistry;
20
import org.eclipse.jface.viewers.ILabelProvider;
21
import org.eclipse.jface.viewers.LabelProvider;
22
import org.eclipse.swt.graphics.Image;
23
import org.eclipse.swt.widgets.Shell;
24
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
25
26
/**
27
 * Label provider for WSDL Port type and WSDL operations. 
28
 *
29
 */
30
31
class WsdlPortTypeLabelProvider extends LabelProvider implements
32
		ILabelProvider
33
{
34
35
	private ImageRegistry imageRegistry;
36
	private final static String PORT_KEY = "Port";
37
	private final static String OPERATION_KEY = "Operation";
38
	private final static String MESSAGE_KEY = "Message";
39
40
	WsdlPortTypeLabelProvider(Shell shell)
41
	{
42
		imageRegistry = new ImageRegistry(shell.getDisplay());
43
44
		Image portImage = EclipseUtils.loadImage(shell.getDisplay(),
45
				"icons/obj16/capability_obj.gif");
46
		imageRegistry.put(PORT_KEY, portImage);
47
48
		Image operationImage = EclipseUtils.loadImage(shell.getDisplay(),
49
				"icons/obj16/userOperation_obj.gif");
50
		imageRegistry.put(OPERATION_KEY, operationImage);
51
52
		Image messageImage = EclipseUtils.loadImage(shell.getDisplay(),
53
				"icons/obj16/sample.gif");
54
		imageRegistry.put(MESSAGE_KEY, messageImage);
55
	}
56
57
	public Image getImage(Object element)
58
	{
59
		if (element instanceof PortType)
60
			return imageRegistry.get(PORT_KEY);
61
		else if (element instanceof Operation)
62
			return imageRegistry.get(OPERATION_KEY);
63
		else if (element instanceof Message)
64
			return imageRegistry.get(MESSAGE_KEY);
65
		return null;
66
	}
67
68
	public String getText(Object element)
69
	{
70
		if (element instanceof PortType)
71
		{
72
			PortType port = (PortType) element;
73
			return port.getQName().toString();
74
		}
75
		else if (element instanceof Operation)
76
		{
77
			Operation operation = (Operation) element;
78
			return operation.getName();
79
		}
80
		else if (element instanceof Message)
81
		{
82
			Message message = (Message) element;
83
			return message.getQName().toString();
84
		}
85
		return element.toString();
86
	}
87
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportValidator.java (+75 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd;
14
15
import java.util.HashMap;
16
import java.util.Map;
17
18
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
19
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
20
import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils;
21
22
/**
23
 * Validator class to validate the imported properties.<br>
24
 * It performs the following validations.<br>
25
 * (1) Imported property name should be valid java identifier.<br>
26
 * (2) Imported property name should not be the same as one available in capability.<br>
27
 */
28
29
class PropertyImportValidator
30
{
31
	private Property[] _properties;
32
33
	/**
34
	 * Creates new object of this class. 
35
	 */
36
	PropertyImportValidator(Property[] properties)
37
	{
38
		_properties = properties;
39
	}
40
41
	/**
42
	 * Validate the properties. 
43
	 */
44
	public ImportValidationStatus validate()
45
	{
46
		Map propertyNames = new HashMap();
47
		if (_properties == null)
48
			return null;
49
		for (int i = 0; i < _properties.length; i++)
50
		{
51
			String propertyName = _properties[i].getElement().getName();
52
53
			// Validate valid java identifier
54
			String errorMessage = CapUtils.validateJavaIdentifier(propertyName);
55
			if (errorMessage != null)
56
				return new ImportValidationStatus(errorMessage, new Object[]
57
				{ _properties[i] });
58
59
			// Validate duplicate property name
60
			if (!propertyNames.containsKey(propertyName))
61
				propertyNames.put(propertyName, _properties[i]);
62
			else
63
			{
64
				errorMessage = Messages.bind(Messages.DUPLICATE_PROPERTY,
65
						propertyName);
66
				Property causeOfError_1 = (Property) propertyNames
67
						.get(propertyName);
68
				Property causeOfError_2 = _properties[i];
69
				return new ImportValidationStatus(errorMessage, new Object[]
70
				{ causeOfError_1, causeOfError_2 });
71
			}
72
		}
73
		return null;
74
	}
75
}
(-)src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/CapabilityModelImporterPage.java (+456 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.wizard.capability.internal;
14
15
import javax.wsdl.Definition;
16
import javax.wsdl.Operation;
17
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IWorkspaceRoot;
20
import org.eclipse.core.resources.ResourcesPlugin;
21
import org.eclipse.core.runtime.Path;
22
import org.eclipse.emf.common.util.URI;
23
import org.eclipse.jface.dialogs.Dialog;
24
import org.eclipse.jface.dialogs.MessageDialog;
25
import org.eclipse.jface.viewers.ISelection;
26
import org.eclipse.jface.window.Window;
27
import org.eclipse.jface.wizard.IWizardPage;
28
import org.eclipse.jface.wizard.WizardPage;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.events.ModifyEvent;
31
import org.eclipse.swt.events.ModifyListener;
32
import org.eclipse.swt.events.SelectionAdapter;
33
import org.eclipse.swt.events.SelectionEvent;
34
import org.eclipse.swt.layout.GridData;
35
import org.eclipse.swt.layout.GridLayout;
36
import org.eclipse.swt.widgets.Button;
37
import org.eclipse.swt.widgets.Composite;
38
import org.eclipse.swt.widgets.Text;
39
import org.eclipse.tptp.wsdm.tooling.dialog.provisional.WSDLBrowseDialog;
40
import org.eclipse.tptp.wsdm.tooling.dialog.provisional.XSDBrowseDialog;
41
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl.OperationImportWizardPage;
42
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.PropertyImportWizardPage;
43
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
44
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages;
45
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
46
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
47
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
48
import org.eclipse.xsd.XSDSchema;
49
50
/**
51
 * Wizard page to import capability from XSD and WSDL files.
52
 */
53
54
public class CapabilityModelImporterPage extends WizardPage
55
{
56
	private ISelection _selection;
57
58
	private NewCapabilityWizard _wizard;
59
60
	private Button _emptyCapability;
61
62
	private Button _fromXSD;
63
64
	private Text _xsdFilePathText;
65
66
	private Button _browseXSD;
67
68
	private Button _fromWSDL;
69
70
	private Text _wsdlFilePathText;
71
72
	private Button _browseWSDL;
73
74
	private Object[] _checkedItems;
75
76
	private Operation[] _importedOperations = new Operation[0];
77
78
	private boolean _canFlipToNextPage = false;
79
80
	/**
81
	 * Creates new object of this class.
82
	 */
83
	protected CapabilityModelImporterPage(ISelection selection,
84
			NewCapabilityWizard wizard)
85
	{
86
		super("wizardPage");
87
		_selection = selection;
88
		_wizard = wizard;
89
		setTitle(Messages.SELECT_CAPABILITY_IMPORTER);
90
	}
91
92
	/**
93
	 * Creates wizard controls.
94
	 */
95
	public void createControl(Composite parent)
96
	{
97
		initializeDialogUnits(parent);
98
		Composite container = new Composite(parent, SWT.NULL);
99
		container.setFont(parent.getFont());
100
		container.setLayout(new GridLayout());
101
		container.setLayoutData(new GridData());
102
103
		_emptyCapability = new Button(container, SWT.RADIO);
104
		_emptyCapability.setText(Messages.CREATE_EMPTY_CAPABILITY);
105
		_emptyCapability.addSelectionListener(new SelectionAdapter()
106
		{
107
			public void widgetSelected(SelectionEvent e)
108
			{
109
				handleEmptyCapabilityButtonSelection();
110
			}
111
		});
112
113
		createFromXSDControl(container);
114
		createFromWSDLControl(container);
115
116
		intialize();
117
118
		setControl(container);
119
		Dialog.applyDialogFont(parent);
120
	}
121
122
	private void handleEmptyCapabilityButtonSelection()
123
	{
124
		_fromXSD.setSelection(false);
125
		_browseXSD.setEnabled(false);
126
		_xsdFilePathText.setEnabled(false);
127
		_fromWSDL.setSelection(false);
128
		_browseWSDL.setEnabled(false);
129
		_wsdlFilePathText.setEnabled(false);
130
		setMessage(Messages.CREATE_EMPTY_CAPABILITY);
131
		_wizard.getOperationImportWizardPage().setPageComplete(true);
132
		_wizard.getPropertyImportWizardPage().setPageComplete(true);
133
		dialogChanged();
134
	}
135
136
	private void createFromXSDControl(Composite parent)
137
	{
138
		Composite fromXSDComposite = new Composite(parent, SWT.NULL);
139
		GridLayout layout = new GridLayout(2, false);
140
		layout.marginWidth = 0;
141
		fromXSDComposite.setLayout(layout);
142
		GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false);
143
		fromXSDComposite.setLayoutData(gd);
144
145
		_fromXSD = new Button(fromXSDComposite, SWT.RADIO);
146
		_fromXSD
147
				.setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.DEFINE_CAPABILITY_FROM_XSD);
148
		_fromXSD.addSelectionListener(new SelectionAdapter()
149
		{
150
			public void widgetSelected(SelectionEvent e)
151
			{
152
				handleFromXSDButtonSelection();
153
			}
154
		});
155
		gd = new GridData();
156
		gd.horizontalSpan = 2;
157
		_fromXSD.setLayoutData(gd);
158
159
		_xsdFilePathText = new Text(fromXSDComposite, SWT.BORDER);
160
		gd = new GridData(SWT.FILL, SWT.NONE, true, false);
161
		gd.horizontalIndent = 15;
162
		_xsdFilePathText.setLayoutData(gd);
163
		_xsdFilePathText.addModifyListener(new ModifyListener()
164
		{
165
			public void modifyText(ModifyEvent e)
166
			{
167
				dialogChanged();
168
			}
169
		});
170
171
		_browseXSD = createBrowseWorkspaceButton(fromXSDComposite);
172
		_browseXSD.addSelectionListener(new SelectionAdapter()
173
		{
174
			public void widgetSelected(SelectionEvent e)
175
			{
176
				handleXSDBrowse();
177
			}
178
		});
179
		_browseXSD.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
180
	}
181
182
	private void handleFromXSDButtonSelection()
183
	{
184
		_emptyCapability.setSelection(false);
185
		_browseXSD.setEnabled(true);
186
		_xsdFilePathText.setEnabled(true);
187
		_fromWSDL.setSelection(false);
188
		_browseWSDL.setEnabled(false);
189
		_wsdlFilePathText.setEnabled(false);
190
		setMessage(Messages.IMPORT_PROPERTIES_FROM_XSD);
191
		dialogChanged();
192
	}
193
194
	private void createFromWSDLControl(Composite parent)
195
	{
196
		Composite fromWSDLComposite = new Composite(parent, SWT.NULL);
197
		GridLayout layout = new GridLayout(2, false);
198
		layout.marginWidth = 0;
199
		fromWSDLComposite.setLayout(layout);
200
		GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false);
201
		fromWSDLComposite.setLayoutData(gd);
202
203
		_fromWSDL = new Button(fromWSDLComposite, SWT.RADIO);
204
		_fromWSDL
205
				.setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.DEFINE_CAPABILITY_FROM_WSDL);
206
		_fromWSDL.addSelectionListener(new SelectionAdapter()
207
		{
208
			public void widgetSelected(SelectionEvent e)
209
			{
210
				handleFromWSDLButtonSelection();
211
			}
212
		});
213
		gd = new GridData();
214
		gd.horizontalSpan = 2;
215
		_fromWSDL.setLayoutData(gd);
216
217
		_wsdlFilePathText = new Text(fromWSDLComposite, SWT.BORDER);
218
		gd = new GridData(SWT.FILL, SWT.NONE, true, false);
219
		gd.horizontalIndent = 15;
220
		_wsdlFilePathText.setLayoutData(gd);
221
		_wsdlFilePathText.addModifyListener(new ModifyListener()
222
		{
223
			public void modifyText(ModifyEvent e)
224
			{
225
				dialogChanged();
226
			}
227
		});
228
229
		_browseWSDL = createBrowseWorkspaceButton(fromWSDLComposite);
230
		_browseWSDL.addSelectionListener(new SelectionAdapter()
231
		{
232
			public void widgetSelected(SelectionEvent e)
233
			{
234
				handleWSDLBrowse();
235
			}
236
		});
237
		_browseWSDL.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
238
	}
239
240
	private void handleFromWSDLButtonSelection()
241
	{
242
		_emptyCapability.setSelection(false);
243
		_fromXSD.setSelection(false);
244
		_browseXSD.setEnabled(false);
245
		_xsdFilePathText.setEnabled(false);
246
		_browseWSDL.setEnabled(true);
247
		_wsdlFilePathText.setEnabled(true);
248
		setMessage(Messages.IMPORT_OPERATIONS_FROM_WSDL);
249
		dialogChanged();
250
	}
251
252
	private void intialize()
253
	{
254
		_emptyCapability.setSelection(true);
255
		_browseXSD.setEnabled(false);
256
		_xsdFilePathText.setEnabled(false);
257
		_browseWSDL.setEnabled(false);
258
		_wsdlFilePathText.setEnabled(false);
259
		setMessage(Messages.CREATE_EMPTY_CAPABILITY);
260
	}
261
262
	private Button createBrowseWorkspaceButton(Composite container)
263
	{
264
		Button browseButton = new Button(container, SWT.PUSH);
265
		browseButton.setText(Messages.BROWSE_WORKSPACE);
266
		GridData gd = new GridData(GridData.END);
267
		gd.grabExcessHorizontalSpace = true;
268
		browseButton.setLayoutData(gd);
269
		return browseButton;
270
	}
271
272
	private void handleXSDBrowse()
273
	{
274
		XSDBrowseDialog dialog = new XSDBrowseDialog(getShell());
275
		if (dialog.open() == Window.OK)
276
		{
277
			IFile browsedFile = (IFile) dialog.getFirstResult();
278
			XSDSchema xsdSchema = XsdUtils.getSchema(browsedFile);
279
			_xsdFilePathText.setText(browsedFile.getFullPath().toString());
280
			// TODO Check for valid file
281
		}
282
	}
283
284
	private void handleWSDLBrowse()
285
	{
286
		WSDLBrowseDialog dialog = new WSDLBrowseDialog(getShell());
287
		if (dialog.open() == Window.OK)
288
		{
289
			IFile browsedFile = (IFile) dialog.getFirstResult();
290
			try
291
			{
292
				WsdlUtils.getCapabilityDefinition(browsedFile);
293
			}
294
			catch (Exception e)
295
			{
296
				MessageDialog
297
						.openError(
298
								getShell(),
299
								"Error",
300
								org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.IMPROPER_WSDL_FILE);
301
				return;
302
			}
303
			_wsdlFilePathText.setText(browsedFile.getFullPath().toString());
304
		}
305
	}
306
307
	/**
308
	 * Returns the imported XSD schemas specified.
309
	 */
310
	/*
311
	 * protected XSDSchema[] getSchemaToImport() {
312
	 * if(_emptyCapability.getSelection() || _fromWSDL.getSelection()) return
313
	 * new XSDSchema[0]; return new XSDSchema[0]; }
314
	 */
315
316
	/**
317
	 * Returns the imported Operations specified.
318
	 */
319
	/*
320
	 * protected Operation[] getOperationsToImport() {
321
	 * if(_emptyCapability.getSelection() || _fromXSD.getSelection()) return new
322
	 * Operation[0]; return _importedOperations; }
323
	 */
324
325
	private void dialogChanged()
326
	{
327
		if (_fromXSD.getSelection())
328
		{
329
			String xsdFilePath = getXSDFilePath();
330
			if (!isValidWorkspaceFile(xsdFilePath))
331
			{
332
				updateStatus(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.SPECIFY_EXISTING_XSD);
333
				return;
334
			}
335
336
		}
337
		if (_fromWSDL.getSelection())
338
		{
339
			String wsdlFilePath = getWSDLFilePath();
340
			if (!isValidWorkspaceFile(wsdlFilePath))
341
			{
342
				updateStatus(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.SPECIFY_EXISTING_WSDL);
343
				return;
344
			}
345
		}
346
		updateStatus(null);
347
	}
348
349
	private void updateStatus(String message)
350
	{
351
		_canFlipToNextPage = true;
352
		if (message != null)
353
			_canFlipToNextPage = false;
354
		if (_emptyCapability.getSelection())
355
			_canFlipToNextPage = false;
356
		setErrorMessage(message);
357
		setPageComplete(message == null && _emptyCapability.getSelection());
358
	}
359
360
	private String getXSDFilePath()
361
	{
362
		return _xsdFilePathText.getText();
363
	}
364
365
	private String getWSDLFilePath()
366
	{
367
		return _wsdlFilePathText.getText();
368
	}
369
370
	private boolean isValidWorkspaceFile(String filePath)
371
	{
372
		try
373
		{
374
			IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
375
			IFile file = root.getFile(new Path(filePath));
376
			if (file == null || (!file.exists()))
377
				return false;
378
		}
379
		catch (Exception e)
380
		{
381
			return false;
382
		}
383
		return true;
384
	}
385
386
	public IWizardPage getNextPage()
387
	{
388
		if (_emptyCapability.getSelection())
389
		{
390
			return null;
391
		}
392
		if (_fromWSDL.getSelection())
393
		{
394
			try
395
			{
396
				_wizard.getPropertyImportWizardPage().setPageComplete(true);
397
				String wsdlFilePath = getWSDLFilePath();
398
				IFile wsdlFile = EclipseUtils.getIFile(wsdlFilePath);
399
				CapabilityDefinition capabilityDefinition = WsdlUtils
400
						.getCapabilityDefinition(wsdlFile);
401
				Definition wsdlDefinition = capabilityDefinition
402
						.getDefinition();
403
				OperationImportWizardPage page = _wizard
404
						.getOperationImportWizardPage();
405
				page.setWSDLDefinition(wsdlDefinition);
406
				page.setImportedWsdlURI(URI.createPlatformResourceURI(wsdlFile.getFullPath().toString()));
407
				setPageComplete(true);
408
				return page;
409
			}
410
			catch (Exception e)
411
			{
412
				e.printStackTrace();
413
			}
414
		}
415
		if (_fromXSD.getSelection())
416
		{
417
			try
418
			{
419
				_wizard.getOperationImportWizardPage().setPageComplete(true);
420
				String xsdFilePath = getXSDFilePath();
421
				IFile xsdFile = EclipseUtils.getIFile(xsdFilePath);
422
				XSDSchema importSchema = XsdUtils.getSchema(xsdFile);
423
				PropertyImportWizardPage page = _wizard
424
						.getPropertyImportWizardPage();
425
				page.setImportSchema(importSchema);
426
				setPageComplete(true);
427
				return page;
428
			}
429
			catch (Exception e)
430
			{
431
				e.printStackTrace();
432
			}
433
		}
434
		return super.getNextPage();
435
	}
436
437
	public boolean canFlipToNextPage()
438
	{
439
		return _canFlipToNextPage;
440
	}
441
442
	public boolean isEmptyCapabilityButtonSelected()
443
	{
444
		return _emptyCapability.getSelection();
445
	}
446
447
	public boolean isFromXSDButtonSelected()
448
	{
449
		return _fromXSD.getSelection();
450
	}
451
452
	public boolean isFromWSDLButtonSelected()
453
	{
454
		return _fromWSDL.getSelection();
455
	}
456
}
(-)src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/imports/internal/messages.properties (+37 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2007 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
# 
8
# Contributors:
9
# 	Balan Subramanian (bsubram@us.ibm.com)
10
#     IBM Corporation - initial API and implementation
11
###############################################################################
12
IMPORT_OPERATIONS = Import operations
13
IMPORTING_OPERATIONS = Importing operations
14
IMPORTING_OPERATION = Importing operation : {0}
15
OPERATION_IMPORT_WIZARD_PAGE_TITLE = Select operations to import
16
OPERATION_IMPORT_WIZARD_PAGE_DESCRIPTION = Select operations to import from WSDL file to defined this capability
17
OPERATION_IMPORT_WIZARD_PAGE_INFO_LABEL = Selected operations will be merged for the definition of this capability. Selected operation must not have same name to avoid conflict.
18
AVAILABLE_OPERATIONS_LABEL = Available WSDL file operations:
19
DUPLICATE_OPERATION = Duplicate operation : {0}
20
NOT_DOC_LITERAL_MESSAGE = Message is not of doc literal type
21
CONFLICTED_MESSAGE = Conflicted message :
22
INPUT_MESSAGE_NOT_DEFINED = Input message must be defined
23
OUTPUT_MESSAGE_NOT_DEFINED = Output message must be defined
24
IMPROPER_WSDL_FILE = Improper wsdl file
25
DEFINE_CAPABILITY_FROM_WSDL = Define capability from existing WSDL file:
26
SPECIFY_EXISTING_WSDL = Please specify existing WSDL file
27
28
IMPORT_PROPERTIES = Import properties
29
IMPORTING_PROPERTIES = Importing properties
30
IMPORTING_PROPERTY = Importing property : {0}
31
DUPLICATE_PROPERTY = Duplicate property : {0}
32
PROPERTY_IMPORT_WIZARD_PAGE_TITLE = Select properties to import
33
PROPERTY_IMPORT_WIZARD_PAGE_DESCRIPTION = Select properties to import from XSD file to defined this capability
34
AVAILABLE_PROPERTIES_LABEL = Available XSD file properties:
35
DEFINE_CAPABILITY_FROM_XSD = Define capability from existing XSD schema file:
36
SPECIFY_EXISTING_XSD = Please specify existing XSD schema file
37
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ImportPropertyCommand.java (+172 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal;
14
15
import java.util.LinkedList;
16
import java.util.List;
17
18
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.NullProgressMonitor;
20
import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory;
21
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
22
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
23
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
24
import org.eclipse.xsd.XSDComplexTypeDefinition;
25
import org.eclipse.xsd.XSDCompositor;
26
import org.eclipse.xsd.XSDElementDeclaration;
27
import org.eclipse.xsd.XSDFactory;
28
import org.eclipse.xsd.XSDModelGroup;
29
import org.eclipse.xsd.XSDParticle;
30
import org.eclipse.xsd.XSDSchema;
31
32
/**
33
 * Command class to import properties into the capability.
34
 * 
35
 */
36
37
public class ImportPropertyCommand
38
{
39
	private XSDElementDeclaration _resourcePropertyElement;
40
	private Property[] _importedProperties;
41
	private List _newProperties = new LinkedList();
42
	private List _newSchemas = new LinkedList();
43
	private IProgressMonitor _monitor;
44
45
	/**
46
	 * Creates a new object of this class.
47
	 */
48
	public ImportPropertyCommand(XSDElementDeclaration resourcePropertyElement,
49
			Property[] importedProperties, IProgressMonitor monitor)
50
	{
51
		_resourcePropertyElement = resourcePropertyElement;
52
		_importedProperties = importedProperties;
53
		_monitor = monitor;
54
		if (monitor == null)
55
			_monitor = new NullProgressMonitor();
56
	}
57
58
	/**
59
	 * Creates a new object of this class.
60
	 */
61
	public ImportPropertyCommand(XSDElementDeclaration resourcePropertyElement,
62
			Property[] importedProperties)
63
	{
64
		this(resourcePropertyElement, importedProperties, null);
65
	}
66
67
	/**
68
	 * Execute the command.
69
	 */
70
	public void execute()
71
	{
72
		_monitor.beginTask(Messages.IMPORTING_PROPERTIES,
73
				_importedProperties.length);
74
		for (int i = 0; i < _importedProperties.length; i++)
75
		{
76
			String taskName = Messages.bind(Messages.IMPORTING_PROPERTY,
77
					_importedProperties[i].getElement().getName());
78
			_monitor.setTaskName(taskName);
79
			Property newProperty = createNewProperty(_importedProperties[i]);
80
			_newProperties.add(newProperty);
81
			if (!_newSchemas.contains(newProperty.getElement().getSchema()))
82
				_newSchemas.add(newProperty.getElement().getSchema());
83
			_monitor.worked(i + 1);
84
		}
85
	}
86
87
	private Property createNewProperty(Property importedProperty)
88
	{
89
		// Get the location for Imported XSD Schema in local drive format
90
		XSDSchema importSchema = importedProperty.getElement().getSchema();
91
		// String schemaLocation =
92
		// XsdUtils.getLocalSystemSchemaLocation(importSchema);
93
94
		// Get the location for capability file
95
		// String capFileLocation = null;
96
		// try {
97
		// capFileLocation =
98
		// WsdlUtils.getLocalSystemWSDLLocation(_capabilityDefinition);
99
		// } catch (CoreException e) {
100
		// e.printStackTrace();
101
		// }
102
103
		// Create xsd:import element
104
		// String importSchemaLocation = EclipseUtils.getRelativePath(
105
		// capFileLocation, schemaLocation, '/');
106
		// XsdUtils.createImportStatement(_resourcePropertyElement.getSchema(),
107
		// importSchema.getTargetNamespace(), importSchemaLocation);
108
109
		XsdUtils.createImportStatement(_resourcePropertyElement.getSchema(),
110
				importSchema.getTargetNamespace(), importSchema.eResource()
111
						.getURI().toString());
112
113
		// Prepare resource property element
114
		XSDModelGroup modelGroup = getXSDModelGroup();
115
116
		// Add element to resource properties
117
		XSDElementDeclaration propertyRef = XSDFactory.eINSTANCE
118
				.createXSDElementDeclaration();
119
		propertyRef
120
				.setResolvedElementDeclaration(importedProperty.getElement());
121
		XSDParticle simpleElementParticle = XSDFactory.eINSTANCE
122
				.createXSDParticle();
123
		simpleElementParticle.setContent(propertyRef);
124
		modelGroup.getContents().add(simpleElementParticle);
125
126
		// Create Capability property representation
127
		Property newProperty = CapabilitiesFactory.INSTANCE.createProperty();
128
		newProperty.setElement(importedProperty.getElement());
129
		return newProperty;
130
	}
131
132
	private XSDModelGroup getXSDModelGroup()
133
	{
134
		XSDModelGroup modelGroup = null;
135
		if (_resourcePropertyElement.getAnonymousTypeDefinition() == null)
136
		{
137
			// Create New XSD Model Group
138
			modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
139
			modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
140
141
			XSDParticle xsdParticle = XSDFactory.eINSTANCE.createXSDParticle();
142
			xsdParticle.setContent(modelGroup);
143
144
			XSDComplexTypeDefinition complexTypeDefiniton = XSDFactory.eINSTANCE
145
					.createXSDComplexTypeDefinition();
146
			complexTypeDefiniton.setContent(xsdParticle);
147
			_resourcePropertyElement
148
					.setAnonymousTypeDefinition(complexTypeDefiniton);
149
		}
150
		else
151
		{
152
			// Get the XSD Model Group
153
			XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) _resourcePropertyElement
154
					.getAnonymousTypeDefinition();
155
			modelGroup = XsdUtils.getXSDModelGroup(typeDef);
156
		}
157
		return modelGroup;
158
	}
159
160
	public Property[] getNewProperties()
161
	{
162
		return (Property[]) _newProperties.toArray(new Property[_newProperties
163
				.size()]);
164
	}
165
166
	public XSDSchema[] getNewSchemas()
167
	{
168
		return (XSDSchema[]) _newSchemas.toArray(new XSDSchema[_newSchemas
169
				.size()]);
170
	}
171
172
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/WsdlPortTypeContentProvider.java (+118 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl;
14
15
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.LinkedList;
18
import java.util.List;
19
import java.util.Map;
20
21
import javax.wsdl.Fault;
22
import javax.wsdl.Operation;
23
import javax.wsdl.PortType;
24
25
import org.eclipse.jface.viewers.ITreeContentProvider;
26
import org.eclipse.jface.viewers.Viewer;
27
28
/**
29
 * Content provider for WSDL Port type and WSDL operations. 
30
 *
31
 */
32
33
class WsdlPortTypeContentProvider implements ITreeContentProvider
34
{
35
36
	private final Map _parentMap;
37
38
	WsdlPortTypeContentProvider()
39
	{
40
		_parentMap = new HashMap();
41
	}
42
43
	public Object[] getChildren(Object parentElement)
44
	{
45
		if (parentElement instanceof List)
46
		{
47
			List l = (List) parentElement;
48
			return l.toArray();
49
		}
50
		else if (parentElement instanceof PortType)
51
		{
52
			PortType port = (PortType) parentElement;
53
			Object[] operations = rememberChildren(parentElement, port
54
					.getOperations());
55
			return operations;
56
		}
57
		else if (parentElement instanceof Operation)
58
		{
59
			Operation operation = (Operation) parentElement;
60
			List messagesList = new LinkedList();
61
			if (operation.getInput() != null)
62
				messagesList.add(operation.getInput().getMessage());
63
			if (operation.getOutput() != null)
64
				messagesList.add(operation.getOutput().getMessage());
65
			Map faultsMap = operation.getFaults();
66
			Iterator it = faultsMap.values().iterator();
67
			while (it.hasNext())
68
			{
69
				Object object = it.next();
70
				if (object instanceof Fault)
71
				{
72
					Fault fault = (Fault) object;
73
					messagesList.add(fault.getMessage());
74
				}
75
			}
76
			Object[] messages = rememberChildren(parentElement, messagesList);
77
			return messages;
78
		}
79
		return new Object[0];
80
	}
81
82
	public Object getParent(Object element)
83
	{
84
		Object retVal = _parentMap.get(element);
85
		return retVal;
86
	}
87
88
	public boolean hasChildren(Object element)
89
	{
90
		return (getChildren(element).length > 0);
91
	}
92
93
	public Object[] getElements(Object inputElement)
94
	{
95
		return getChildren(inputElement);
96
	}
97
98
	public void dispose()
99
	{
100
	}
101
102
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
103
	{
104
	}
105
106
	private Object[] rememberChildren(Object parent, List childrens)
107
	{
108
		Object[] retVal = new Object[childrens.size()];
109
		for (int i = 0; i < retVal.length; i++)
110
		{
111
			Object child = childrens.get(i);
112
			_parentMap.put(child, parent);
113
			retVal[i] = child;
114
		}
115
		return retVal;
116
	}
117
118
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyNamespace.java (+52 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd;
14
15
import java.util.LinkedList;
16
import java.util.List;
17
18
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
19
20
/**
21
 * Internal representation of capability properties by namespace wise.  
22
 *
23
 */
24
25
class PropertyNamespace
26
{
27
	private String _namespace;
28
	private List _properties;
29
30
	PropertyNamespace(String namespace)
31
	{
32
		_namespace = namespace;
33
		_properties = new LinkedList();
34
	}
35
36
	public void addProperty(Property property)
37
	{
38
		if (property != null)
39
			_properties.add(property);
40
	}
41
42
	public Property[] getProperties()
43
	{
44
		return (Property[]) _properties
45
				.toArray(new Property[_properties.size()]);
46
	}
47
48
	public String getNamespace()
49
	{
50
		return _namespace;
51
	}
52
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizard.java (+139 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd;
14
15
import java.lang.reflect.InvocationTargetException;
16
import java.util.Arrays;
17
import java.util.HashMap;
18
import java.util.Iterator;
19
import java.util.LinkedList;
20
import java.util.List;
21
import java.util.Map;
22
23
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.jface.operation.IRunnableWithProgress;
25
import org.eclipse.jface.viewers.IStructuredSelection;
26
import org.eclipse.jface.wizard.Wizard;
27
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ImportPropertyCommand;
28
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
29
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
30
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
31
import org.eclipse.ui.INewWizard;
32
import org.eclipse.ui.IWorkbench;
33
import org.eclipse.xsd.XSDElementDeclaration;
34
import org.eclipse.xsd.XSDSchema;
35
36
/**
37
 * Wizard to import properties from XSD file. 
38
 *
39
 */
40
41
public class PropertyImportWizard extends Wizard implements INewWizard
42
{
43
44
	private CapabilityDomain _capabilityDomain;
45
	private XSDSchema _importSchema;
46
	private PropertyNamespace[] _existingPropertyNs = new PropertyNamespace[0];
47
	private PropertyImportWizardPage _importPage;
48
49
	public PropertyImportWizard(CapabilityDomain capabilityDomain,
50
			XSDSchema importSchema)
51
	{
52
		super();
53
		setWindowTitle(Messages.IMPORT_PROPERTIES);
54
		setNeedsProgressMonitor(true);
55
		_capabilityDomain = capabilityDomain;
56
		_importSchema = importSchema;
57
		_existingPropertyNs = createPropertiesNamespacesFromCapability();
58
	}
59
60
	public void addPages()
61
	{
62
		_importPage = new PropertyImportWizardPage(_importSchema,
63
				_existingPropertyNs);
64
		addPage(_importPage);
65
	}
66
67
	public boolean performFinish()
68
	{
69
		IRunnableWithProgress runnable = new IRunnableWithProgress()
70
		{
71
			public void run(IProgressMonitor monitor)
72
					throws InvocationTargetException, InterruptedException
73
			{
74
				performFinish(monitor);
75
			}
76
		};
77
		try
78
		{
79
			getContainer().run(true, false, runnable);
80
			return true;
81
		}
82
		catch (Exception e)
83
		{
84
			e.printStackTrace();
85
		}
86
		return false;
87
	}
88
89
	private void performFinish(IProgressMonitor monitor)
90
	{
91
		Property[] importedProperties = _importPage.getImportedProperties();
92
		ImportPropertyCommand command = new ImportPropertyCommand(
93
				_capabilityDomain.getResourcePropertyElement(),
94
				importedProperties, monitor);
95
		command.execute();
96
		Property[] newProperties = command.getNewProperties();
97
		_capabilityDomain.getCapability().getProperties().addAll(
98
				Arrays.asList(newProperties));
99
		XSDSchema[] newSchemas = command.getNewSchemas();
100
		for (int i = 0; i < newSchemas.length; i++)
101
			_capabilityDomain.addPropertySchema(newSchemas[i]);
102
	}
103
104
	public void init(IWorkbench workbench, IStructuredSelection selection)
105
	{
106
	}
107
108
	private PropertyNamespace[] createPropertiesNamespacesFromCapability()
109
	{
110
		Map propNamespacesMap = new HashMap();
111
		List properties = _capabilityDomain.getCapability().getProperties();
112
		for (int i = 0; i < properties.size(); i++)
113
		{
114
			Property property = (Property) properties.get(i);
115
			XSDElementDeclaration propertyElement = property.getElement();
116
			PropertyNamespace propertyNamespace = (PropertyNamespace) propNamespacesMap
117
					.get(propertyElement.getTargetNamespace());
118
			if (propertyNamespace == null)
119
			{
120
				propertyNamespace = new PropertyNamespace(propertyElement
121
						.getTargetNamespace());
122
				propNamespacesMap.put(propertyElement.getTargetNamespace(),
123
						propertyNamespace);
124
			}
125
			propertyNamespace.addProperty(property);
126
		}
127
128
		List propNamespacesList = new LinkedList();
129
		Iterator keyIt = propNamespacesMap.keySet().iterator();
130
		while (keyIt.hasNext())
131
		{
132
			Object key = keyIt.next();
133
			propNamespacesList.add(propNamespacesMap.get(key));
134
		}
135
136
		return (PropertyNamespace[]) propNamespacesList
137
				.toArray(new PropertyNamespace[propNamespacesList.size()]);
138
	}
139
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizard.java (+113 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl;
14
15
import java.lang.reflect.InvocationTargetException;
16
import java.util.Arrays;
17
import java.util.Map;
18
19
import javax.wsdl.Definition;
20
import javax.wsdl.Operation;
21
import javax.wsdl.PortType;
22
23
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.emf.common.util.URI;
25
import org.eclipse.jface.operation.IRunnableWithProgress;
26
import org.eclipse.jface.viewers.IStructuredSelection;
27
import org.eclipse.jface.wizard.Wizard;
28
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.ImportOperationCommand;
29
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
30
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
31
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
32
import org.eclipse.ui.INewWizard;
33
import org.eclipse.ui.IWorkbench;
34
35
/**
36
 * Wizard to import operations from WSDL file. 
37
 *
38
 */
39
40
public class OperationImportWizard extends Wizard implements INewWizard
41
{
42
43
	private CapabilityDomain _capabilityDomain;
44
	private Definition _wsdlDefinition;
45
	private PortType[] _existingPortTypes = new PortType[0];
46
	private OperationImportWizardPage _importPage;
47
	
48
	public OperationImportWizard(CapabilityDomain capabilityDomain,
49
			Definition definition)
50
	{
51
		super();
52
		setWindowTitle(Messages.IMPORT_OPERATIONS);
53
		setNeedsProgressMonitor(true);
54
		_capabilityDomain = capabilityDomain;
55
		_wsdlDefinition = definition;
56
		Map portsMap = capabilityDomain.getCapability().getWsdlDefinition()
57
				.getDefinition().getPortTypes();
58
		_existingPortTypes = (PortType[]) portsMap.values().toArray(
59
				new PortType[portsMap.size()]);
60
	}
61
62
	public void addPages()
63
	{
64
		_importPage = new OperationImportWizardPage(_wsdlDefinition,
65
				_existingPortTypes);
66
		addPage(_importPage);
67
	}
68
69
	public boolean performFinish()
70
	{
71
		IRunnableWithProgress runnable = new IRunnableWithProgress()
72
		{
73
			public void run(IProgressMonitor monitor)
74
					throws InvocationTargetException, InterruptedException
75
			{
76
				performFinish(monitor);
77
			}
78
		};
79
		try
80
		{
81
			getContainer().run(true, false, runnable);
82
			return true;
83
		}
84
		catch (Exception e)
85
		{
86
			e.printStackTrace();
87
		}
88
		return false;
89
	}
90
91
	private void performFinish(IProgressMonitor monitor)
92
	{
93
		Operation[] importOperations = _importPage.getImportedOperations();
94
		CapabilityDefinition capabilityDefinition = (CapabilityDefinition) _capabilityDomain
95
				.getCapability().getWsdlDefinition();
96
		URI importedWsdlURI = _importPage.getImportedWsdlURI();
97
		ImportOperationCommand command = new ImportOperationCommand(
98
				capabilityDefinition, importOperations, importedWsdlURI, monitor);
99
		command.execute();
100
		Operation[] newOperations = command.getNewOperations();
101
		_capabilityDomain.getCapability().getOperations().addAll(
102
				Arrays.asList(newOperations));
103
	}
104
105
	public void init(IWorkbench workbench, IStructuredSelection selection)
106
	{
107
	}
108
	
109
	public void setImportedWsdlURI(URI importedWsdlURI)
110
	{
111
		_importPage.setImportedWsdlURI(importedWsdlURI);
112
	}
113
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewIFileNameGenerator.java (+97 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator;
14
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IFolder;
17
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.runtime.CoreException;
20
21
/**
22
 * This class will generate a new name for IFile in given IResource. 
23
 */
24
25
public class NewIFileNameGenerator implements INewNameGenerator
26
{
27
	private IResource _resource;
28
	private String _namePattern;
29
30
	public NewIFileNameGenerator(IResource resource, String namePattern)
31
	{
32
		_resource = resource;
33
		if (namePattern == null || namePattern.trim().equals(""))
34
			namePattern = "NewFile.tmp";
35
		if (namePattern.indexOf('.') == -1)
36
		{
37
			namePattern = "NewFile.tmp";
38
		}
39
		_namePattern = namePattern;
40
	}
41
42
	public String getNewName()
43
	{
44
		IResource[] members = null;
45
		if (_resource instanceof IProject)
46
		{
47
			IProject project = (IProject) _resource;
48
			try
49
			{
50
				members = project.members();
51
			}
52
			catch (CoreException e)
53
			{
54
				return _namePattern;
55
			}
56
		}
57
		else if (_resource instanceof IFolder)
58
		{
59
			IFolder folder = (IFolder) _resource;
60
			try
61
			{
62
				members = folder.members();
63
			}
64
			catch (CoreException e)
65
			{
66
				return _namePattern;
67
			}
68
		}
69
70
		int count = 0;
71
		while (isFileExists(members, _namePattern))
72
		{
73
			String fileNameWithoutExtn = _namePattern.substring(0, _namePattern
74
					.lastIndexOf('.'));
75
			String fileExtn = _namePattern.substring(_namePattern
76
					.lastIndexOf('.') + 1);
77
			_namePattern = fileNameWithoutExtn + count + "." + fileExtn;
78
			count++;
79
		}
80
		return _namePattern;
81
	}
82
83
	private boolean isFileExists(IResource[] resources, String fileName)
84
	{
85
		for (int i = 0; i < resources.length; i++)
86
		{
87
			if (resources[i] instanceof IFile)
88
			{
89
				IFile file = (IFile) resources[i];
90
				if (file.getName().equals(fileName))
91
					return true;
92
			}
93
		}
94
		return false;
95
	}
96
97
}
(-)src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/imports/internal/Messages.java (+52 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal;
14
15
import org.eclipse.osgi.util.NLS;
16
17
public class Messages extends NLS
18
{
19
	private static final String BUNDLE_NAME = "org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.messages"; //$NON-NLS-1$
20
21
	public static String IMPORT_OPERATIONS;
22
	public static String IMPORTING_OPERATIONS;
23
	public static String IMPORTING_OPERATION;
24
	public static String OPERATION_IMPORT_WIZARD_PAGE_TITLE;
25
	public static String OPERATION_IMPORT_WIZARD_PAGE_DESCRIPTION;
26
	public static String OPERATION_IMPORT_WIZARD_PAGE_INFO_LABEL;
27
	public static String AVAILABLE_OPERATIONS_LABEL;
28
	public static String DUPLICATE_OPERATION;
29
	public static String NOT_DOC_LITERAL_MESSAGE;
30
	public static String CONFLICTED_MESSAGE;
31
	public static String INPUT_MESSAGE_NOT_DEFINED;
32
	public static String OUTPUT_MESSAGE_NOT_DEFINED;
33
	public static String IMPROPER_WSDL_FILE;
34
	public static String DEFINE_CAPABILITY_FROM_WSDL;
35
	public static String SPECIFY_EXISTING_WSDL;
36
37
	public static String IMPORT_PROPERTIES;
38
	public static String IMPORTING_PROPERTIES;
39
	public static String IMPORTING_PROPERTY;
40
	public static String DUPLICATE_PROPERTY;
41
	public static String PROPERTY_IMPORT_WIZARD_PAGE_TITLE;
42
	public static String PROPERTY_IMPORT_WIZARD_PAGE_DESCRIPTION;
43
	public static String AVAILABLE_PROPERTIES_LABEL;
44
	public static String DEFINE_CAPABILITY_FROM_XSD;
45
	public static String SPECIFY_EXISTING_XSD;
46
47
	static
48
	{
49
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
50
	}
51
52
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewWSDLMessageNameGenerator.java (+52 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator;
14
15
import javax.wsdl.Definition;
16
17
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
18
19
/**
20
 * This class will generate a new name for WSDL message in given WSDL definition. 
21
 */
22
23
public class NewWSDLMessageNameGenerator implements INewNameGenerator
24
{
25
	private Definition _definition;
26
	private String _namePattern;
27
28
	public NewWSDLMessageNameGenerator(Definition definition, String namePattern)
29
	{
30
		_definition = definition;
31
		if (namePattern == null || namePattern.trim().equals(""))
32
			namePattern = "NewMessage";
33
		_namePattern = namePattern;
34
	}
35
36
	public NewWSDLMessageNameGenerator(Definition definition)
37
	{
38
		this(definition, null);
39
	}
40
41
	public String getNewName()
42
	{
43
		int count = 0;
44
		while (WsdlUtils.getWSDLMessage(_definition, _namePattern) != null)
45
		{
46
			_namePattern = _namePattern + count;
47
			count++;
48
		}
49
		return _namePattern;
50
	}
51
52
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorage.java (+94 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.internal;
14
15
import java.io.InputStream;
16
17
import org.eclipse.core.resources.IStorage;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.Path;
21
import org.eclipse.core.runtime.PlatformObject;
22
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
23
24
/**
25
 * This class has been designed to use for opening any existing capability from
26
 * within MRT file.<br>
27
 * This class implements the IStorage interface which is used to represent a
28
 * storage object as a stream of bytes.<br>
29
 */
30
31
public class CapabilityStorage extends PlatformObject implements
32
		ICapabilityStorage
33
{
34
35
	private Capability _capability;
36
37
	public CapabilityStorage(Capability capability)
38
	{
39
		_capability = capability;
40
	}
41
42
	public InputStream getContents() throws CoreException
43
	{
44
		/*
45
		 * Definition definition =
46
		 * _capability.getWsdlDefinition().getDefinition(); String str =
47
		 * CapUtils.toString(definition.getDocumentationElement().getOwnerDocument());
48
		 * StringBufferInputStream stream = new StringBufferInputStream(str);
49
		 * return stream;
50
		 */
51
52
		// We use the getFullPath() method to load the definition in capability
53
		// editor
54
		return null;
55
	}
56
57
	public IPath getFullPath()
58
	{
59
		String path = null;
60
		if (_capability.getWsdlDefinition().getWSDLFileProtocalURI() != null)
61
			path = _capability.getWsdlDefinition().getWSDLFileProtocalURI()
62
					.toString();
63
		else if (_capability.getWsdlDefinition().getWSDLResourceProtocolURI() != null)
64
			path = _capability.getWsdlDefinition().getWSDLResourceProtocolURI()
65
					.toString();
66
		return new Path(path);
67
	}
68
69
	public String getName()
70
	{
71
		return _capability.getName();
72
	}
73
74
	public boolean isReadOnly()
75
	{
76
		if (getFullPath().toString().startsWith("platform:/plugin"))
77
			return true;
78
		return false;
79
	}
80
81
	public boolean exists()
82
	{
83
		// TODO Find out more efficient way to do this
84
		return _capability.getWsdlDefinition().getDefinition() != null;
85
	}
86
87
}
88
89
interface ICapabilityStorage extends IStorage
90
{
91
92
	boolean exists();
93
94
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertySchemaLabelProvider.java (+98 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd;
14
15
import org.eclipse.jface.resource.ImageRegistry;
16
import org.eclipse.jface.viewers.ILabelProvider;
17
import org.eclipse.jface.viewers.LabelProvider;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.widgets.Shell;
20
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
21
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
22
import org.eclipse.xsd.XSDElementDeclaration;
23
import org.eclipse.xsd.XSDSchema;
24
25
/**
26
 * Label provider for capability properties. 
27
 *
28
 */
29
30
class PropertySchemaLabelProvider extends LabelProvider implements
31
		ILabelProvider
32
{
33
	private ImageRegistry imageRegistry;
34
	private final static String PROPERTY_NAMESPACE_KEY = "PropertyNamespace";
35
	private final static String PROPERTY_KEY = "Property";
36
37
	PropertySchemaLabelProvider(Shell shell)
38
	{
39
		imageRegistry = new ImageRegistry(shell.getDisplay());
40
41
		Image propNamespaceImage = EclipseUtils.loadImage(shell.getDisplay(),
42
				"icons/obj16/capability_obj.gif");
43
		imageRegistry.put(PROPERTY_NAMESPACE_KEY, propNamespaceImage);
44
45
		Image propertyImage = EclipseUtils.loadImage(shell.getDisplay(),
46
				"icons/obj16/property_obj.gif");
47
		imageRegistry.put(PROPERTY_KEY, propertyImage);
48
	}
49
50
	public Image getImage(Object element)
51
	{
52
		if (element instanceof PropertyNamespace)
53
			return imageRegistry.get(PROPERTY_NAMESPACE_KEY);
54
		else if (element instanceof Property)
55
			return imageRegistry.get(PROPERTY_KEY);
56
		return null;
57
	}
58
59
	public String getText(Object element)
60
	{
61
		if (element instanceof PropertyNamespace)
62
		{
63
			/*
64
			 * XSDSchema schema = (XSDSchema) element; String schemaLocation =
65
			 * getSchemaLocation(schema); String namespace =
66
			 * schema.getTargetNamespace(); return namespace+" (
67
			 * "+schemaLocation+" )";
68
			 */
69
			PropertyNamespace propNamespace = (PropertyNamespace) element;
70
			return propNamespace.getNamespace();
71
		}
72
		else if (element instanceof Property)
73
		{
74
			Property property = (Property) element;
75
			XSDElementDeclaration propertyElement = property.getElement();
76
			return propertyElement.getName();
77
		}
78
		return element.toString();
79
	}
80
81
	private String getSchemaLocation(XSDSchema schema)
82
	{
83
		String location = schema.eResource().getURI().toString();
84
		if (location.startsWith("platform:/resource"))
85
		{
86
			int index = location.indexOf("platform:/resource")
87
					+ "platform:/resource".length();
88
			location = location.substring(index);
89
		}
90
		else if (location.startsWith("platform:/plugin"))
91
		{
92
			int index = location.indexOf("platform:/plugin")
93
					+ "platform:/plugin".length();
94
			location = location.substring(index);
95
		}
96
		return location;
97
	}
98
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewXSDElementNameGenerator.java (+51 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator;
14
15
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
16
import org.eclipse.xsd.XSDSchema;
17
18
/**
19
 * This class will generate a new name for XSD element in given schema. 
20
 */
21
22
public class NewXSDElementNameGenerator implements INewNameGenerator
23
{
24
	private XSDSchema _schema;
25
	private String _namePattern;
26
27
	public NewXSDElementNameGenerator(XSDSchema schema, String namePattern)
28
	{
29
		_schema = schema;
30
		if (namePattern == null || namePattern.trim().equals(""))
31
			namePattern = "NewElement";
32
		_namePattern = namePattern;
33
	}
34
35
	public NewXSDElementNameGenerator(XSDSchema schema)
36
	{
37
		this(schema, null);
38
	}
39
40
	public String getNewName()
41
	{
42
		int count = 0;
43
		while (XsdUtils.getXSDElementDeclarationOfName(_schema, _namePattern) != null)
44
		{
45
			_namePattern = _namePattern + count;
46
			count++;
47
		}
48
		return _namePattern;
49
	}
50
51
}
(-)src/org/eclipse/tptp/wsdm/model/Wsdl4jSchemaToXsdSchema.java (-160 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.model;
14
15
import java.util.ArrayList;
16
import java.util.Iterator;
17
import java.util.List;
18
import java.util.Map;
19
20
//import javax.wsdl.extensions.schema.Schema;
21
//import javax.wsdl.extensions.schema.SchemaImport;
22
//import javax.wsdl.extensions.schema.SchemaReference;
23
24
import org.eclipse.xsd.XSDFactory;
25
import org.eclipse.xsd.XSDImport;
26
import org.eclipse.xsd.XSDInclude;
27
import org.eclipse.xsd.XSDSchema;
28
import org.eclipse.xsd.impl.XSDSchemaImpl;
29
30
public class Wsdl4jSchemaToXsdSchema
31
{
32
	/*private Schema _schema;
33
	private XSDSchema _xsdSchema;
34
	private XSDInclude[] _allIncludes;
35
	private XSDImport[] _allImports;
36
	private String _wsdlLocation;
37
	
38
	public Wsdl4jSchemaToXsdSchema(Schema schema, String wsdlLocation)
39
	{
40
		_schema = schema;	
41
		_wsdlLocation = wsdlLocation;
42
	}
43
44
	public XSDSchema getXSDSchema()
45
	{
46
		//_xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
47
		//_xsdSchema.setSchemaLocation(_wsdlLocation);
48
		//_xsdSchema.setElement(_schema.getElement());		
49
		//resolveIncludes();
50
		//resolveImports();
51
		//return _xsdSchema;
52
		_xsdSchema = XSDSchemaImpl.createSchema(_schema.getElement());
53
		_xsdSchema.setSchemaLocation(_wsdlLocation);
54
		_xsdSchema.setElement(_schema.getElement());
55
		return _xsdSchema;
56
	}
57
	
58
	private void resolveIncludes()
59
	{
60
		_allIncludes = getAllXSDIncludes();
61
		List wsdlSchemaIncludes = _schema.getIncludes();
62
		for(int i=0;i<wsdlSchemaIncludes.size();i++)
63
		{
64
			SchemaReference schemaRef = (SchemaReference) wsdlSchemaIncludes.get(i);
65
			String locationURI = schemaRef.getSchemaLocationURI();
66
			XSDInclude include = getXSDInclude(locationURI);
67
			if(include!=null)
68
			{
69
				XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
70
				xsdSchema.setSchemaLocation(include.getSchemaLocation());
71
				xsdSchema.setElement(schemaRef.getReferencedSchema().getElement());
72
				include.setResolvedSchema(xsdSchema);
73
			}
74
		}
75
	}
76
	
77
	private void resolveImports()
78
	{
79
		_allImports = getAllXSDImports();
80
		Map wsdlSchemaImports = _schema.getImports();
81
		Iterator iterator = wsdlSchemaImports.values().iterator();
82
		while(iterator.hasNext())
83
		{
84
			Object object = iterator.next();
85
			if(object instanceof List)
86
			{
87
				List list = (List) object;
88
				for(int i=0;i<list.size();i++)
89
				{
90
					if(list.get(i) instanceof SchemaImport)
91
					{
92
						SchemaImport schemaImport = (SchemaImport) list.get(i);
93
						XSDImport theImport = getXSDImport(schemaImport.getNamespaceURI(), schemaImport.getSchemaLocationURI());
94
						if(theImport!=null)
95
						{
96
							XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
97
							xsdSchema.setSchemaLocation(theImport.getSchemaLocation());
98
							xsdSchema.setElement(schemaImport.getReferencedSchema().getElement());
99
							theImport.setResolvedSchema(xsdSchema);
100
						}
101
					}
102
				}
103
			}			
104
		}		
105
	}
106
	
107
	private XSDInclude getXSDInclude(String locationURI)
108
	{
109
		for(int i=0;i<_allIncludes.length;i++)
110
		{
111
			if(_allIncludes[i].getSchemaLocation().equals(locationURI))
112
				return _allIncludes[i];
113
		}
114
		return null;
115
	}
116
	
117
	private XSDImport getXSDImport(String namespace, String locationURI)
118
	{
119
		for(int i=0;i<_allImports.length;i++)
120
		{
121
			if(_allImports[i].getNamespace().equals(namespace) &&					
122
					_allImports[i].getSchemaLocation().equals(locationURI))
123
				return _allImports[i];
124
		}
125
		return null;
126
	}
127
	
128
	private XSDInclude[] getAllXSDIncludes()
129
	{
130
		List xsdIncludes = new ArrayList();
131
		List contents = _xsdSchema.getContents();
132
		if (contents == null || contents.size() == 0)
133
			return (XSDInclude[]) xsdIncludes
134
					.toArray(new XSDInclude[xsdIncludes.size()]);
135
		for (int i = 0; i < contents.size(); i++)
136
		{
137
			if (contents.get(i) instanceof XSDInclude)
138
				xsdIncludes.add(contents.get(i));
139
		}
140
		return (XSDInclude[]) xsdIncludes.toArray(new XSDInclude[xsdIncludes
141
				.size()]);
142
	}
143
	
144
	private XSDImport[] getAllXSDImports()
145
	{
146
		List xsdImports = new ArrayList();
147
		List contents = _xsdSchema.getContents();
148
		if (contents == null || contents.size() == 0)
149
			return (XSDImport[]) xsdImports.toArray(new XSDImport[xsdImports
150
					.size()]);
151
		for (int i = 0; i < contents.size(); i++)
152
		{
153
			if (contents.get(i) instanceof XSDImport)
154
				xsdImports.add(contents.get(i));
155
		}
156
		return (XSDImport[]) xsdImports
157
				.toArray(new XSDImport[xsdImports.size()]);
158
	}*/
159
	
160
}
(-)src/org/eclipse/tptp/wsdm/model/MetadataDescriptor.java (+4 lines)
Lines 44-49 Link Here
44
import org.eclipse.tptp.wsdm.tooling.model.muwsPart2.GatheringTimeType;
44
import org.eclipse.tptp.wsdm.tooling.model.muwsPart2.GatheringTimeType;
45
import org.eclipse.tptp.wsdm.tooling.model.muwsPart2.TimeScopeType;
45
import org.eclipse.tptp.wsdm.tooling.model.muwsPart2.TimeScopeType;
46
46
47
/**
48
 * Metadescriptor class for capability. 
49
 */
50
47
public class MetadataDescriptor
51
public class MetadataDescriptor
48
{
52
{
49
	private ExtendedMetaData _extendedMetaData;
53
	private ExtendedMetaData _extendedMetaData;
(-)src/org/eclipse/tptp/wsdm/model/WSDLDefinition.java (+17 lines)
Lines 34-39 Link Here
34
import org.eclipse.xsd.XSDSchema;
34
import org.eclipse.xsd.XSDSchema;
35
import org.eclipse.xsd.util.XSDResourceFactoryImpl;
35
import org.eclipse.xsd.util.XSDResourceFactoryImpl;
36
36
37
/**
38
 * Its a wrapper class for WSDL4j Definition object. 
39
 *
40
 */
41
37
public class WSDLDefinition
42
public class WSDLDefinition
38
{
43
{
39
	protected Definition _definition;
44
	protected Definition _definition;
Lines 301-322 Link Here
301
		return _resourceProtocolUri;
306
		return _resourceProtocolUri;
302
	}
307
	}
303
	
308
	
309
	/**
310
	 * Sets WSDL definition object. 
311
	 */
304
	public void setDefinition(Definition definition)
312
	public void setDefinition(Definition definition)
305
	{
313
	{
306
		_definition = definition;
314
		_definition = definition;
307
		_definedSchemaList = new LinkedList();
315
		_definedSchemaList = new LinkedList();
308
	}
316
	}
309
	
317
	
318
	/**
319
	 * Returns WSDL definition object. 
320
	 */
310
	public Definition getDefinition()
321
	public Definition getDefinition()
311
	{
322
	{
312
		return _definition;
323
		return _definition;
313
	}
324
	}
314
	
325
	
326
	/**
327
	 * Adds a new WSDL message to definition object. 
328
	 */
315
	public void addMessage(Message message)
329
	public void addMessage(Message message)
316
	{
330
	{
317
		_definition.addMessage(message);		
331
		_definition.addMessage(message);		
318
	}
332
	}
319
333
334
	/**
335
	 * Adds a new namespace to definition object. 
336
	 */
320
	public void addNamespace(String prefix, String nsUri)
337
	public void addNamespace(String prefix, String nsUri)
321
	{
338
	{
322
		_definition.addNamespace(prefix, nsUri);
339
		_definition.addNamespace(prefix, nsUri);

Return to bug 165544