Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 58038 Details for
Bug 165544
WSDM Tooling: Enhanced importing of WSDLs and schemas
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch
patch.txt (text/plain), 168.55 KB, created by
Saurabh Dravid
on 2007-02-01 13:02:52 EST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Saurabh Dravid
Created:
2007-02-01 13:02:52 EST
Size:
168.55 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.wsdm.editor >Index: src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/internal/messages.properties >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/internal/messages.properties,v >retrieving revision 1.1 >diff -u -r1.1 messages.properties >--- src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/internal/messages.properties 1 Feb 2007 05:04:45 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/internal/messages.properties 1 Feb 2007 18:01:01 -0000 >@@ -90,7 +90,7 @@ > RMD_SOURCE = RMDSource > > FAILED_TO_SAVE_MCAP_FILE_ERROR_ = IWAT0542E Failed to save MCAP file >-IMPROPER_WSDL_FILE_ERROR_ = IWAT0547E Capability WSDL file is not a proper WSLD file >+IMPROPER_WSDL_FILE_ERROR_ = IWAT0547E Capability WSDL file is not a proper WSDL file > RMD_FILE_DOESNT_EXISTS_ERROR_ = IWAT0548E RMD file doesn't exists > FAILED_TO_LOAD_RMD_ERROR_ = IWAT0549E Failed to load the RMD file > INVALID_IEDITOR_ERROR_ = IWAT0550E Invalid Input: Must be IFileEditorInput >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/NewProjectWizard.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/NewProjectWizard.java,v >retrieving revision 1.1 >diff -u -r1.1 NewProjectWizard.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/NewProjectWizard.java 1 Feb 2007 05:04:44 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/NewProjectWizard.java 1 Feb 2007 18:00:55 -0000 >@@ -34,7 +34,7 @@ > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.wizard.Wizard; > import org.eclipse.swt.graphics.Image; >-import org.eclipse.tptp.wsdm.tooling.editor.mrt.internal.ManageableResourceTypeEditorPlugin; >+import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; > import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; > import org.eclipse.ui.INewWizard; >@@ -51,8 +51,6 @@ > > private static ILog LOG = null; > >- private static String PLUGIN_ID = ManageableResourceTypeEditorPlugin.PLUGIN_ID; >- > private GenerationOptionsPage _generationOptionsPage; > > private String _projectName; >@@ -263,12 +261,12 @@ > private void handle(String message, Exception e) > { > _generationOptionsPage.setErrorMessage(message); >- Status status = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, >- message, e); >+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, >+ IStatus.OK, message, e); > > if (LOG == null) > { >- LOG = ManageableResourceTypeEditorPlugin.getDefault().getLog(); >+ LOG = Activator.getPlugin().getLog(); > } > LOG.log(status); > } >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/GenerationOptionsPage.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/GenerationOptionsPage.java,v >retrieving revision 1.1 >diff -u -r1.1 GenerationOptionsPage.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/GenerationOptionsPage.java 1 Feb 2007 05:04:44 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/GenerationOptionsPage.java 1 Feb 2007 18:00:55 -0000 >@@ -74,7 +74,6 @@ > import org.eclipse.swt.widgets.Table; > import org.eclipse.swt.widgets.Text; > import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; >-import org.eclipse.tptp.wsdm.tooling.editor.mrt.internal.ManageableResourceTypeEditorPlugin; > import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.Validation; >@@ -248,7 +247,7 @@ > > IExtensionRegistry er = Platform.getExtensionRegistry(); > IExtensionPoint ep = er.getExtensionPoint(Activator.PLUGIN_ID, >- ManageableResourceTypeEditorPlugin.EXT_PT); >+ Activator.CODEGEN_EXT_PT); > IExtension[] extensions = ep.getExtensions(); > > for (int i = 0; i < extensions.length; i++) >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/AbstractCapabilityEditor.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/AbstractCapabilityEditor.java,v >retrieving revision 1.1 >diff -u -r1.1 AbstractCapabilityEditor.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/AbstractCapabilityEditor.java 1 Feb 2007 05:04:41 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/AbstractCapabilityEditor.java 1 Feb 2007 18:00:56 -0000 >@@ -18,9 +18,9 @@ > import javax.wsdl.Operation; > > import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IStorage; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.Path; > import org.eclipse.emf.common.util.URI; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.tptp.wsdm.model.MetadataDescriptor; >@@ -47,6 +47,7 @@ > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IEditorSite; > import org.eclipse.ui.IFileEditorInput; >+import org.eclipse.ui.IStorageEditorInput; > import org.eclipse.ui.PartInitException; > import org.eclipse.ui.part.MultiPageEditorPart; > import org.eclipse.xsd.XSDElementDeclaration; >@@ -118,26 +119,33 @@ > { > buildModel(); > _overviewPage = createOverviewPage(); >+ _pages.add(_overviewPage); > > _propertyPage = createPropertyPage(); >+ _pages.add(_propertyPage); > > _operationPage = createOperationPage(); >+ _pages.add(_operationPage); > > _topicPage = createTopicPage(); >+ _pages.add(_topicPage); > > if (loadWSDLSourcePage()) > { > _wsdlSourcePage = createWSDLSourcePage(); >+ _pages.add(_wsdlSourcePage); > _create_wsdl_source = true; > } > if (loadXSDSourcePage()) > { > _xsdSourcePage = createXSDSourcePage(); >+ _pages.add(_xsdSourcePage); > _create_xsd_source = true; > } > if (loadRMDSourcePage()) > { > _rmdSourcePage = createRMDSourcePage(); >+ _pages.add(_rmdSourcePage); > _create_rmd_source = true; > } > firePropertyChange(IEditorPart.PROP_DIRTY); >@@ -290,31 +298,37 @@ > return; > } > } >- // TODO >- // else if(getEditorInput() instanceof IStorageEditorInput) >- // { >- // IStorageEditorInput input = (IStorageEditorInput)getEditorInput(); >- // IStorage storage = null; >- // try >- // { >- // storage = input.getStorage(); >- // _read_only = storage.isReadOnly(); >- // } >- // catch (CoreException e1) >- // { >- // e1.printStackTrace(); >- // } >- // URI capFileURI = URI.createURI(storage.getFullPath().toString()); >- // try >- // { >- // wsdlDefinition = WsdlUtils.getWSDLDefinition(capFileURI); >- // } >- // catch (Exception e) >- // { >- // org.eclipse.wsdl.capability.util.WsdmToolingLog.logError(Messages.IMPROPER_WSDL_FILE_ERROR_,e); >- // return; >- // } >- // } >+ else if (getEditorInput() instanceof IStorageEditorInput) >+ { >+ IStorageEditorInput input = (IStorageEditorInput) getEditorInput(); >+ IStorage storage = null; >+ try >+ { >+ storage = input.getStorage(); >+ _read_only = storage.isReadOnly(); >+ } >+ catch (CoreException e1) >+ { >+ e1.printStackTrace(); >+ } >+ URI capFileURI = URI.createURI(storage.getFullPath().toString()); >+ try >+ { >+ capabilityDefinition = WsdlUtils >+ .getCapabilityDefinition(capFileURI); >+ if (capFileURI.toString().startsWith("platform:/resource")) >+ { >+ IFile macpFile = EclipseUtils.getIFile(capFileURI >+ .toString()); >+ _capabilityDomain.setCapabilityIFile(macpFile); >+ } >+ } >+ catch (Exception e) >+ { >+ WsdmToolingLog.logError(Messages.IMPROPER_WSDL_FILE_ERROR_, e); >+ return; >+ } >+ } > else > return; > >@@ -361,18 +375,26 @@ > if (metadataDescriptorLocation != null > && metadataDescriptorName != null) > { >- URI capabilityFileLocationURI = capabilityDefinition >- .getWSDLFileProtocalURI(); >- URI rmdFileLocationURI = URI.createURI(capabilityFileLocationURI >- .trimSegments(1).toString() >- + "/" + metadataDescriptorLocation); >+ URI rmdFileLocationURI = null; >+ if (capabilityDefinition.getWSDLFileProtocalURI() != null) >+ { >+ URI capabilityFileLocationURI = capabilityDefinition >+ .getWSDLFileProtocalURI(); >+ rmdFileLocationURI = URI.createURI(capabilityFileLocationURI >+ .trimSegments(1).toString() >+ + "/" + metadataDescriptorLocation); >+ } >+ else if (capabilityDefinition.getWSDLResourceProtocolURI() != null) >+ { >+ URI capabilityFileLocationURI = capabilityDefinition >+ .getWSDLResourceProtocolURI(); >+ rmdFileLocationURI = URI.createURI(capabilityFileLocationURI >+ .trimSegments(1).toString() >+ + "/" + metadataDescriptorLocation); >+ } > rmdRoot = MetaDataUtils.getDocumentRoot(rmdFileLocationURI); > if (rmdRoot != null) > { >- IFile capabilityFile = _capabilityDomain.getCapabilityIFile(); >- IFile rmdFile = capabilityFile.getParent().getFile( >- new Path(metadataDescriptorLocation)); >- _capabilityDomain.setCapabilityRmdIFile(rmdFile); > MetadataDescriptor rmdDescriptor = new MetadataDescriptor( > capability, rmdRoot, metadataDescriptorName); > } >@@ -669,15 +691,25 @@ > } > > // Remove rmd file of capability >- IFile rmdFile = _capabilityDomain.getCapabilityRmdIFile(); >- if (rmdFile != null && rmdFile.exists()) >+ if (_capabilityDomain.getCapability().getMetadata() != null) > { >- String title = Messages.CONFIRM_DELETE; >- String message = Messages.bind(Messages.FILE_DELETE_QUESTION, >- rmdFile.getName()); >- if (MessageDialog >- .openQuestion(getSite().getShell(), title, message)) >- rmdFile.delete(true, null); >+ MetadataDescriptor rmdDescriptor = _capabilityDomain >+ .getCapability().getMetadata(); >+ DocumentRoot rmdRoot = rmdDescriptor.getDocumentRoot(); >+ if (rmdRoot != null) >+ { >+ String rmdRootURIPath = rmdRoot.eResource().getURI().toString(); >+ IFile rmdFile = EclipseUtils.getIFile(rmdRootURIPath); >+ if (rmdFile != null && rmdFile.exists()) >+ { >+ String title = Messages.CONFIRM_DELETE; >+ String message = Messages.bind( >+ Messages.FILE_DELETE_QUESTION, rmdFile.getName()); >+ if (MessageDialog.openQuestion(getSite().getShell(), title, >+ message)) >+ rmdFile.delete(true, null); >+ } >+ } > } > } > >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityDomain.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityDomain.java,v >retrieving revision 1.1 >diff -u -r1.1 CapabilityDomain.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityDomain.java 1 Feb 2007 05:04:41 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityDomain.java 1 Feb 2007 18:00:56 -0000 >@@ -45,8 +45,6 @@ > > private IFile _capabilityFile; > >- private IFile _rmdFile; >- > private Bundle _artifactsPlugin; > > /** >@@ -77,14 +75,6 @@ > } > > /** >- * Returns the capability rmd file. >- */ >- public IFile getCapabilityRmdIFile() >- { >- return _rmdFile; >- } >- >- /** > * Returns the property schema of capability. > */ > public XSDSchema getPropertySchema() >@@ -141,14 +131,6 @@ > } > > /** >- * Sets the capability rmd file. >- */ >- public void setCapabilityRmdIFile(IFile rmdFile) >- { >- _rmdFile = rmdFile; >- } >- >- /** > * Sets the property schema for capability. > */ > public void setPropertySchema(XSDSchema propertySchema) >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityEditor.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityEditor.java,v >retrieving revision 1.1 >diff -u -r1.1 CapabilityEditor.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityEditor.java 1 Feb 2007 05:04:41 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityEditor.java 1 Feb 2007 18:00:57 -0000 >@@ -76,7 +76,6 @@ > _operationPageIndex = addPage(operationPage.getForm()); > setPageText(_operationPageIndex, Messages.OPERATIONS); > addPropertyListener(operationPage); >- _pages.add(operationPage); > return operationPage; > } > >@@ -91,7 +90,6 @@ > _overviewPageIndex = addPage(overviewPage.getForm()); > setPageText(_overviewPageIndex, Messages.OVERVIEW); > addPropertyListener(overviewPage); >- _pages.add(overviewPage); > return overviewPage; > } > >@@ -106,7 +104,6 @@ > _propertyPageIndex = addPage(propertyPage.getForm()); > setPageText(_propertyPageIndex, Messages.PROPERTIES); > addPropertyListener(propertyPage); >- _pages.add(propertyPage); > return propertyPage; > } > >@@ -120,7 +117,6 @@ > _topicPageIndex = addPage(topicPage.getForm()); > setPageText(_topicPageIndex, Messages.TOPICS); > addPropertyListener(topicPage); >- _pages.add(topicPage); > return topicPage; > } > >@@ -133,7 +129,6 @@ > rmdSourcePage.create(); > _rmdSourcePageIndex = addPage(rmdSourcePage.getControl()); > setPageText(_rmdSourcePageIndex, Messages.RMD_SOURCE); >- _pages.add(rmdSourcePage); > return rmdSourcePage; > } > >@@ -146,7 +141,6 @@ > sourcePage.create(); > _wsdlSourcePageIndex = addPage(sourcePage.getControl()); > setPageText(_wsdlSourcePageIndex, Messages.WSDL_SOURCE); >- _pages.add(sourcePage); > return sourcePage; > } > >@@ -159,7 +153,6 @@ > sourcePage.create(); > _xsdSourcePageIndex = addPage(sourcePage.getControl()); > setPageText(_xsdSourcePageIndex, Messages.XSD_SOURCE); >- _pages.add(sourcePage); > return sourcePage; > } > >@@ -214,8 +207,7 @@ > List topicSpaces = _capabilityDomain.getCapability() > .getTopicSpaces(); > propertyMetaDataDescriptor.saveTopicSpaces(topicSpaces); >- IFile rmdFile = _capabilityDomain.getCapabilityRmdIFile(); >- MetaDataUtils.save(propertyMetaDataDescriptor, rmdFile, monitor); >+ MetaDataUtils.save(propertyMetaDataDescriptor, monitor); > } > } > >Index: src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java,v >retrieving revision 1.1 >diff -u -r1.1 WsdlUtils.java >--- src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java 1 Feb 2007 05:04:45 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java 1 Feb 2007 18:01:02 -0000 >@@ -39,6 +39,7 @@ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.emf.common.util.URI; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.EclipseEnvironment; > import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages; > import org.eclipse.xsd.XSDComplexTypeDefinition; >@@ -51,7 +52,6 @@ > import org.w3c.dom.Document; > import org.w3c.dom.Element; > import org.w3c.dom.NodeList; >-import org.xml.sax.InputSource; > import org.xml.sax.SAXException; > > import com.ibm.wsdl.extensions.schema.SchemaConstants; >@@ -83,18 +83,38 @@ > public static CapabilityDefinition getCapabilityDefinition(IFile wsdlFile) > throws Exception > { >- String wsdlFileLocation = wsdlFile.getRawLocation().toString(); >- InputStream is = wsdlFile.getContents(); >- InputSource source = new InputSource(is); >+ String iFileLocation = wsdlFile.getFullPath().toString(); >+ String path = "platform:/resource" + iFileLocation; >+ URI wsdlFileURI = URI.createURI(path); >+ return getCapabilityDefinition(wsdlFileURI); >+ } >+ >+ /** >+ * Returns the EMF based object Definition of the given WSDL file. >+ * >+ * @param wsdlFile >+ * Any WSDL file available in eclipse workbench >+ * >+ * @return EMF based Definition object >+ * @throws Exception >+ */ >+ public static CapabilityDefinition getCapabilityDefinition(URI wsdlFileURI) >+ throws Exception >+ { >+ EclipseEnvironment eclipseEnv = new EclipseEnvironment(); >+ String path = wsdlFileURI.toString(); >+ Document document = org.apache.muse.ws.wsdl.WsdlUtils.createWSDL( >+ eclipseEnv, path, true); >+ Element cleanDocument = org.apache.muse.ws.wsdl.WsdlUtils >+ .removeSchemaReferences(document.getDocumentElement()); >+ cleanDocument = org.apache.muse.ws.wsdl.WsdlUtils >+ .removeWsdlReferences(cleanDocument); > WSDLFactory factory = WSDLFactory.newInstance(); > WSDLReader reader = factory.newWSDLReader(); >- Definition definition = reader.readWSDL(wsdlFileLocation, source); >+ Definition definition = reader.readWSDL(null, cleanDocument); > CapabilityDefinition capabilityDefinition = new CapabilityDefinition( > definition); >- String iFileLocation = wsdlFile.getFullPath().toString(); >- URI resourceProtocolURI = URI.createURI("platform:/resource" >- + iFileLocation); >- capabilityDefinition.setWSDLResourceProtocolURI(resourceProtocolURI); >+ capabilityDefinition.setWSDLResourceProtocolURI(wsdlFileURI); > return capabilityDefinition; > } > >@@ -298,7 +318,8 @@ > .getXSDModelGroup(complexTypeDefinition); > return XsdUtils.getElementDeclarations(modelGroup); > } >- return new XSDElementDeclaration[] { element }; >+ return new XSDElementDeclaration[] >+ { element }; > } > > /** >@@ -562,4 +583,24 @@ > return element; > } > >+ public static Message getWSDLMessage(Definition definition, >+ String messageName) >+ { >+ Map messagesMap = definition.getMessages(); >+ if (messagesMap == null || messagesMap.size() == 0) >+ return null; >+ Iterator it = messagesMap.values().iterator(); >+ while (it.hasNext()) >+ { >+ Object object = it.next(); >+ if (object instanceof Message) >+ { >+ Message message = (Message) object; >+ if (message.getQName().getLocalPart().equals(messageName)) >+ return message; >+ } >+ } >+ return null; >+ } >+ > } >Index: src/org/eclipse/tptp/wsdm/tooling/util/internal/IFile2Capability.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/util/internal/IFile2Capability.java,v >retrieving revision 1.1 >diff -u -r1.1 IFile2Capability.java >--- src/org/eclipse/tptp/wsdm/tooling/util/internal/IFile2Capability.java 1 Feb 2007 05:04:45 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/util/internal/IFile2Capability.java 1 Feb 2007 18:01:01 -0000 >@@ -12,86 +12,55 @@ > > package org.eclipse.tptp.wsdm.tooling.util.internal; > >-import java.io.InputStream; >-import java.util.LinkedList; >-import java.util.List; >- > import javax.wsdl.Definition; > import javax.wsdl.factory.WSDLFactory; > import javax.wsdl.xml.WSDLReader; > > import org.eclipse.core.resources.IFile; > import org.eclipse.emf.common.util.URI; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.EclipseEnvironment; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >-import org.xml.sax.InputSource; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; > >-public class IFile2Capability >+public class IFile2Capability extends Definition2Capability > { > protected IFile _mcapFile; >- protected Capability _capability; >- protected List _errorDiagonistics = new LinkedList(); >- protected List _warningDiagonistics = new LinkedList(); > > public IFile2Capability(IFile mcapFile) > { >+ super(parse(mcapFile)); > _mcapFile = mcapFile; > } > > public Capability getCapability() > { >- Definition definition = parse(); >- Definition2Capability def2Cap = new Definition2Capability(definition); > URI capabilityURI = URI.createPlatformResourceURI(_mcapFile > .getFullPath().toString()); >- _capability = def2Cap.getCapability(capabilityURI); >- _errorDiagonistics.addAll(def2Cap.getErrorDiagonistics()); >- _warningDiagonistics.addAll(def2Cap.getWarningDiagonistics()); >- return _capability; >+ return getCapability(capabilityURI); > } > >- private Definition parse() >+ private static Definition parse(IFile mcapFile) > { > try > { >- String wsdlFileLocation = _mcapFile.getRawLocation().toString(); >- InputStream is = _mcapFile.getContents(); >- InputSource source = new InputSource(is); >+ EclipseEnvironment eclipseEnv = new EclipseEnvironment(); >+ String iFileLocation = mcapFile.getFullPath().toString(); >+ String path = "platform:/resource" + iFileLocation; >+ Document document = org.apache.muse.ws.wsdl.WsdlUtils.createWSDL( >+ eclipseEnv, path, true); >+ Element cleanDocument = org.apache.muse.ws.wsdl.WsdlUtils >+ .removeSchemaReferences(document.getDocumentElement()); >+ cleanDocument = org.apache.muse.ws.wsdl.WsdlUtils >+ .removeWsdlReferences(cleanDocument); > WSDLFactory factory = WSDLFactory.newInstance(); > WSDLReader reader = factory.newWSDLReader(); >- Definition definition = reader.readWSDL(wsdlFileLocation, source); >+ Definition definition = reader.readWSDL(null, cleanDocument); > return definition; > } > catch (Exception e) > { >- prepareErrorDiagnostics(e.getMessage()); > } >- > return null; > } >- >- /** >- * Returns the error diagnostics list. >- */ >- public List getErrorDiagonistics() >- { >- return _errorDiagonistics; >- } >- >- /** >- * Returns the warning diagnostics list. >- */ >- public List getWarningDiagonistics() >- { >- return _warningDiagonistics; >- } >- >- protected void prepareErrorDiagnostics(String message) >- { >- _errorDiagonistics.add(message); >- } >- >- protected void prepareWarningDiagnostics(String message) >- { >- _warningDiagonistics.add(message); >- } > } >Index: src/org/eclipse/tptp/wsdm/tooling/util/internal/MrtUtils.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/util/internal/MrtUtils.java,v >retrieving revision 1.1 >diff -u -r1.1 MrtUtils.java >--- src/org/eclipse/tptp/wsdm/tooling/util/internal/MrtUtils.java 1 Feb 2007 05:04:45 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/util/internal/MrtUtils.java 1 Feb 2007 18:01:01 -0000 >@@ -34,6 +34,7 @@ > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.emf.ecore.resource.ResourceSet; > import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >+import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; > import org.eclipse.tptp.wsdm.tooling.editor.internal.CategoryCollection; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; > import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >@@ -160,9 +161,9 @@ > public static Collection getWSRPCapabilityUris(boolean includeOptional) > { > List retVal = new LinkedList(); >- String ns = "org.eclipse.tptp.wsdm.model"; > IExtensionPoint iep = Platform.getExtensionRegistry() >- .getExtensionPoint(ns, "mrCapability"); >+ .getExtensionPoint(Activator.MODEL_PLUGIN_ID, >+ Activator.MR_CAPABILITY_EXT_PT); > if (iep != null) > { > IExtension[] extensions = iep.getExtensions(); >@@ -189,9 +190,9 @@ > public static Collection getMandatoryCapabilityUris(boolean includeOptional) > { > List retVal = new LinkedList(); >- String ns = "org.eclipse.tptp.wsdm.model"; > IExtensionPoint iep = Platform.getExtensionRegistry() >- .getExtensionPoint(ns, "mrCapability"); >+ .getExtensionPoint(Activator.MODEL_PLUGIN_ID, >+ Activator.MR_CAPABILITY_EXT_PT); > if (iep != null) > { > IExtension[] extensions = iep.getExtensions(); >@@ -222,9 +223,9 @@ > */ > public static boolean isCapabilityEditable(String name) > { >- String ns = "org.eclipse.tptp.wsdm.model"; > IExtensionPoint iep = Platform.getExtensionRegistry() >- .getExtensionPoint(ns, "mrCapability"); >+ .getExtensionPoint(Activator.MODEL_PLUGIN_ID, >+ Activator.MR_CAPABILITY_EXT_PT); > if (iep != null) > { > IExtension[] extensions = iep.getExtensions(); >@@ -254,9 +255,9 @@ > */ > public static boolean isSystemCapability(String name) > { >- String ns = "org.eclipse.tptp.wsdm.model"; > IExtensionPoint iep = Platform.getExtensionRegistry() >- .getExtensionPoint(ns, "mrCapability"); >+ .getExtensionPoint(Activator.MODEL_PLUGIN_ID, >+ Activator.MR_CAPABILITY_EXT_PT); > if (iep != null) > { > IExtension[] extensions = iep.getExtensions(); >@@ -284,9 +285,9 @@ > public static List getMrCapabilityWsdls() > { > List retVal = new LinkedList(); >- String ns = "org.eclipse.tptp.wsdm.model"; > IExtensionPoint iep = Platform.getExtensionRegistry() >- .getExtensionPoint(ns, "mrCapability"); >+ .getExtensionPoint(Activator.MODEL_PLUGIN_ID, >+ Activator.MR_CAPABILITY_EXT_PT); > if (iep != null) > { > IExtension[] extensions = iep.getExtensions(); >@@ -312,9 +313,9 @@ > public static List getMandatoryWsdls(boolean includeOptional) > { > List retVal = new LinkedList(); >- String ns = "org.eclipse.tptp.wsdm.model"; > IExtensionPoint iep = Platform.getExtensionRegistry() >- .getExtensionPoint(ns, "mrCapability"); >+ .getExtensionPoint(Activator.MODEL_PLUGIN_ID, >+ Activator.MR_CAPABILITY_EXT_PT); > if (iep != null) > { > IExtension[] extensions = iep.getExtensions(); >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ChangeOperationReturnTypeCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ChangeOperationReturnTypeCommand.java,v >retrieving revision 1.1 >diff -u -r1.1 ChangeOperationReturnTypeCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ChangeOperationReturnTypeCommand.java 1 Feb 2007 05:04:36 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ChangeOperationReturnTypeCommand.java 1 Feb 2007 18:00:55 -0000 >@@ -26,6 +26,9 @@ > import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataType; > import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataTypesCollection; > import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; >+import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.INewNameGenerator; >+import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.NewWSDLMessageNameGenerator; >+import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.NewXSDElementNameGenerator; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; > import org.eclipse.xsd.XSDElementDeclaration; > import org.eclipse.xsd.XSDFactory; >@@ -87,7 +90,10 @@ > { > message = definition.createMessage(); > String ns = definition.getTargetNamespace(); >- message.setQName(new QName(ns, responseName)); >+ INewNameGenerator generator = new NewWSDLMessageNameGenerator( >+ definition, responseName); >+ String messageName = generator.getNewName(); >+ message.setQName(new QName(ns, messageName)); > definition.addMessage(message); > output.setMessage(message); > } >@@ -109,10 +115,12 @@ > } > } > _element = XSDFactory.eINSTANCE.createXSDElementDeclaration(); >- _element.setName(responseName); >- > XSDSchema schema = capabilityDefinition > .createOrFindSchema(definition.getTargetNamespace()); >+ INewNameGenerator generator = new NewXSDElementNameGenerator( >+ schema, responseName); >+ String elementName = generator.getNewName(); >+ _element.setName(elementName); > schema.getContents().add(_element); > part_0.setElementName(new QName(_element.getTargetNamespace(), > _element.getName())); >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ListSection.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ListSection.java,v >retrieving revision 1.1 >diff -u -r1.1 ListSection.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ListSection.java 1 Feb 2007 05:04:34 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ListSection.java 1 Feb 2007 18:00:57 -0000 >@@ -15,8 +15,11 @@ > import java.util.Collection; > import java.util.List; > >+import javax.wsdl.Definition; > import javax.wsdl.Operation; > >+import org.eclipse.core.resources.IFile; >+import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.resource.ImageRegistry; > import org.eclipse.jface.viewers.IStructuredContentProvider; > import org.eclipse.jface.viewers.LabelProvider; >@@ -24,6 +27,7 @@ > import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.window.Window; >+import org.eclipse.jface.wizard.WizardDialog; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.ControlAdapter; > import org.eclipse.swt.events.ControlEvent; >@@ -38,10 +42,12 @@ > import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.swt.widgets.Table; >+import org.eclipse.tptp.wsdm.tooling.dialog.provisional.WSDLBrowseDialog; > import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.AddOperationCommand; > import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.ChangeInputParamTypeCommand; > import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.ChangeOperationReturnTypeCommand; > import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.RemoveOperationCommand; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl.OperationImportWizard; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.AbstractCapabilityEditor; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataType; >@@ -51,6 +57,7 @@ > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; > import org.eclipse.tptp.wsdm.tooling.viewers.internal.IViewerClient; > import org.eclipse.tptp.wsdm.tooling.viewers.internal.StructuredTableViewer; > import org.eclipse.ui.forms.widgets.FormToolkit; >@@ -71,6 +78,8 @@ > > private Button _addOperationButton; > >+ private Button _importOperationButton; >+ > private Button _removeOperationButton; > > private Label _errorLabel; >@@ -143,10 +152,26 @@ > } > }); > gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- gd.widthHint = 50; >+ gd.widthHint = 100; > _addOperationButton.setLayoutData(gd); > _addOperationButton.setEnabled(!_editor.isReadOnly()); > >+ _importOperationButton = createPushButton( >+ _buttonClient, >+ toolkit, >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.IMPORT_OPERATIONS, >+ new Listener() >+ { >+ public void handleEvent(Event event) >+ { >+ importOperation(); >+ } >+ }); >+ gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >+ gd.widthHint = 100; >+ _importOperationButton.setLayoutData(gd); >+ _importOperationButton.setEnabled(!_editor.isReadOnly()); >+ > _removeOperationButton = createPushButton( > _buttonClient, > toolkit, >@@ -159,7 +184,7 @@ > } > }); > gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- gd.widthHint = 50; >+ gd.widthHint = 100; > _removeOperationButton.setLayoutData(gd); > _removeOperationButton.setEnabled(false); > >@@ -206,6 +231,36 @@ > } > } > >+ private void importOperation() >+ { >+ WSDLBrowseDialog dialog = new WSDLBrowseDialog(getForm().getShell()); >+ if (dialog.open() == Window.OK) >+ { >+ IFile wsdlFile = (IFile) dialog.getFirstResult(); >+ Definition wsdlDefinition = null; >+ try >+ { >+ wsdlDefinition = WsdlUtils.getCapabilityDefinition(wsdlFile) >+ .getDefinition(); >+ } >+ catch (Exception e) >+ { >+ MessageDialog >+ .openError( >+ getForm().getShell(), >+ "Error", >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.IMPROPER_WSDL_FILE); >+ return; >+ } >+ OperationImportWizard importOperationWizard = new OperationImportWizard( >+ _editor.getCapabilityDomain(), wsdlDefinition); >+ WizardDialog wizardDialog = new WizardDialog(getForm().getShell(), >+ importOperationWizard); >+ wizardDialog.open(); >+ _page.setDirty(); >+ } >+ } >+ > private void removeOperation() > { > CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewOperationDialog.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewOperationDialog.java,v >retrieving revision 1.1 >diff -u -r1.1 NewOperationDialog.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewOperationDialog.java 1 Feb 2007 05:04:34 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewOperationDialog.java 1 Feb 2007 18:00:58 -0000 >@@ -60,6 +60,9 @@ > import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataTypesContentProvider; > import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.NewNameGenerator; >+import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.INewNameGenerator; >+import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.NewWSDLMessageNameGenerator; >+import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.NewXSDElementNameGenerator; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils; >@@ -119,9 +122,9 @@ > private CapabilityDomain _capabilityDomain; > > // TODO Check it out >- // private static final String BASE_FAULT_FILE = >- // "platform:/plugin/org.apache.muse.tools/artifacts/managementCapabilities/WS-BaseFaults-1_2.xsd"; >- private final String BASE_FAULT_FILE = "artifacts/managementCapabilities/WS-BaseFaults-1_2.xsd"; >+ private static final String BASE_FAULT_FILE = "platform:/plugin/org.apache.muse.tools/artifacts/managementCapabilities/WS-BaseFaults-1_2.xsd"; >+ // private final String BASE_FAULT_FILE = >+ // "artifacts/managementCapabilities/WS-BaseFaults-1_2.xsd"; > > private DataType _returnType; > >@@ -253,8 +256,8 @@ > gd.horizontalSpan = ((GridLayout) rhsComposite.getLayout()).numColumns; > _paramViewer.getControl().setLayoutData(gd); > >- String[] header = new String[] { Messages.PARAM_NAME, >- Messages.PARAM_TYPE }; >+ String[] header = new String[] >+ { Messages.PARAM_NAME, Messages.PARAM_TYPE }; > for (int i = 0; i < header.length; i++) > { > TableColumn col = new TableColumn(_paramViewer.getTable(), >@@ -511,7 +514,7 @@ > .getTargetNamespace()); > _capabilityDefinition.createOrFindPrefix(WsdmConstants.WSBF_NS, "wsbf"); > XsdUtils.createImportStatement(_typesSchema, WsdmConstants.WSBF_NS, >- getBaseFaultFileURI()); >+ BASE_FAULT_FILE); > > _operation.setName(_methodName.getText()); > >@@ -600,6 +603,10 @@ > { > String tns = _capabilityDomain.getCapability().getNamespace(); > Message message = _capabilityDefinition.getDefinition().createMessage(); >+ Definition _definition = _capabilityDefinition.getDefinition(); >+ INewNameGenerator nameGenerator = new NewWSDLMessageNameGenerator( >+ _definition, name); >+ name = nameGenerator.getNewName(); > message.setQName(new QName(tns, name)); > message.setUndefined(false); > >@@ -618,7 +625,11 @@ > { > XSDElementDeclaration inputParamHolderElement = XSDFactory.eINSTANCE > .createXSDElementDeclaration(); >- inputParamHolderElement.setName(_methodName.getText()); >+ String name = _methodName.getText(); >+ INewNameGenerator generator = new NewXSDElementNameGenerator( >+ _typesSchema, name); >+ name = generator.getNewName(); >+ inputParamHolderElement.setName(name); > _typesSchema.getContents().add(inputParamHolderElement); > if (_paramList.size() == 0) > { >@@ -655,7 +666,11 @@ > { > XSDElementDeclaration outputTypeElement = XSDFactory.eINSTANCE > .createXSDElementDeclaration(); >- outputTypeElement.setName(_methodName.getText() + "Response"); >+ String name = _methodName.getText() + "Response"; >+ INewNameGenerator generator = new NewXSDElementNameGenerator( >+ _typesSchema, name); >+ name = generator.getNewName(); >+ outputTypeElement.setName(name); > _typesSchema.getContents().add(outputTypeElement); > _returnType = (DataType) getSelectedViewerObject(); > return outputTypeElement; >@@ -665,7 +680,11 @@ > { > XSDElementDeclaration faultElement = XSDFactory.eINSTANCE > .createXSDElementDeclaration(); >- faultElement.setName(_methodName.getText() + "Fault"); >+ String name = _methodName.getText() + "Fault"; >+ INewNameGenerator generator = new NewXSDElementNameGenerator( >+ _typesSchema, name); >+ name = generator.getNewName(); >+ faultElement.setName(name); > _typesSchema.getContents().add(faultElement); > > XSDComplexTypeDefinition complexTypeDefinition = XSDFactory.eINSTANCE >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/util/internal/MetaDataUtils.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/util/internal/MetaDataUtils.java,v >retrieving revision 1.1 >diff -u -r1.1 MetaDataUtils.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/util/internal/MetaDataUtils.java 1 Feb 2007 05:04:50 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/util/internal/MetaDataUtils.java 1 Feb 2007 18:01:00 -0000 >@@ -48,6 +48,7 @@ > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.impl.MetadataDescriptorFactoryImpl; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.util.MetadataDescriptorResourceImpl; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.MyMetadataDescriptorResourceFactoryImpl; > import org.eclipse.tptp.wsdm.tooling.util.internal.RmdUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; >@@ -420,10 +421,21 @@ > } > > public static void save(MetadataDescriptor metadataDescriptor, >- IFile rmdFile, IProgressMonitor monitor) >+ IProgressMonitor monitor) > { > DocumentRoot _root = metadataDescriptor.getDocumentRoot(); >- RmdUtils.serializeAndFormat(_root, rmdFile, monitor); >+ String rmdRootURIPath = _root.eResource().getURI().toString(); >+ IFile rmdFile = null; >+ try >+ { >+ rmdFile = EclipseUtils.getIFile(rmdRootURIPath); >+ } >+ catch (CoreException e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ if (rmdFile != null) >+ RmdUtils.serializeAndFormat(_root, rmdFile, monitor); > } > > public static MetadataDescriptor createMetaDataDescriptor( >Index: src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/ManageableResourceTypeEditorPlugin.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/ManageableResourceTypeEditorPlugin.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/ManageableResourceTypeEditorPlugin.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/ManageableResourceTypeEditorPlugin.java 1 Feb 2007 05:04:34 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,71 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.editor.mrt.internal; >- >-import org.eclipse.ui.plugin.AbstractUIPlugin; >-import org.osgi.framework.BundleContext; >- >-/** >- * The activator class controls the plug-in life cycle >- */ >-public class ManageableResourceTypeEditorPlugin extends AbstractUIPlugin >-{ >- >- // The plug-in ID >- public static final String PLUGIN_ID = "org.eclipse.tptp.wsdm.tooling.editor.mrt"; >- >- public static final String EXT_PT = "codeGeneration"; >- >- // The shared instance >- private static ManageableResourceTypeEditorPlugin PLUGIN; >- >- /** >- * The constructor >- */ >- public ManageableResourceTypeEditorPlugin() >- { >- PLUGIN = this; >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) >- */ >- public void start(BundleContext context) throws Exception >- { >- super.start(context); >- PLUGIN = this; >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) >- */ >- public void stop(BundleContext context) throws Exception >- { >- PLUGIN = null; >- super.stop(context); >- } >- >- /** >- * Returns the shared instance >- * >- * @return the shared instance >- */ >- public static ManageableResourceTypeEditorPlugin getDefault() >- { >- return PLUGIN; >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java,v >retrieving revision 1.1 >diff -u -r1.1 NewCapabilityWizard.java >--- src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java 1 Feb 2007 05:04:42 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java 1 Feb 2007 18:01:03 -0000 >@@ -19,6 +19,7 @@ > import java.util.HashMap; > import java.util.Map; > >+import javax.wsdl.Operation; > import javax.wsdl.PortType; > import javax.wsdl.Types; > import javax.xml.namespace.QName; >@@ -38,9 +39,16 @@ > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.ImportOperationCommand; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ImportPropertyCommand; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl.OperationImportWizardPage; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.PropertyImportWizardPage; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityEditor; > import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils; > import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; >+import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.INewNameGenerator; >+import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.NewIFileNameGenerator; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DocumentRoot; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils; >@@ -71,7 +79,11 @@ > > private NewCapabilityWizardPage _newCapPage; > >- // private CapabilityFileWizardPage _capFilesPage; >+ private CapabilityModelImporterPage _importerPage; >+ >+ private PropertyImportWizardPage _importPropertyPage; >+ >+ private OperationImportWizardPage _importOperationPage; > > private ISelection _selection; > >@@ -105,8 +117,14 @@ > _newCapPage = new NewCapabilityWizardPage(_selection, this); > addPage(_newCapPage); > >- // _capFilesPage = new CapabilityFileWizardPage(_selection, this); >- // addPage(_capFilesPage); >+ _importerPage = new CapabilityModelImporterPage(_selection, this); >+ addPage(_importerPage); >+ >+ _importPropertyPage = new PropertyImportWizardPage(); >+ addPage(_importPropertyPage); >+ >+ _importOperationPage = new OperationImportWizardPage(); >+ addPage(_importOperationPage); > } > > /** >@@ -123,14 +141,16 @@ > capPrefix = "tns"; > String capNS = _newCapPage.getNamespace(); > String targetCapFileName = _newCapPage.getTargetFileName(); >- // String xsdFilePath = _capFilesPage.getXSDFilePath(); >- // String xsdFileName = _capFilesPage.getXSDFileName(); >- // String rmdFilePath = _capFilesPage.getRMDFilePath(); >- // String rmdFileName = _capFilesPage.getRMDFileName(); >- String xsdFilePath = containerName + "/" + capabilityName + ".xsd"; >- String xsdFileName = capabilityName + ".xsd"; >- String rmdFilePath = containerName + "/" + capabilityName + ".rmd"; >- String rmdFileName = capabilityName + ".rmd"; >+ >+ IResource resource = ResourcesPlugin.getWorkspace().getRoot() >+ .findMember(new Path(containerName)); >+ INewNameGenerator generator = new NewIFileNameGenerator(resource, >+ capabilityName + ".xsd"); >+ String xsdFileName = generator.getNewName(); >+ generator = new NewIFileNameGenerator(resource, capabilityName + ".rmd"); >+ String rmdFileName = generator.getNewName(); >+ String xsdFilePath = containerName + "/" + xsdFileName; >+ String rmdFilePath = containerName + "/" + rmdFileName; > > String capNamespace = capNS; > String xsdNS = capNS; >@@ -146,6 +166,14 @@ > capFilePath = containerName + targetCapFileName; > } > >+ Property[] importedProperties = new Property[0]; >+ Operation[] importedOperations = new Operation[0]; >+ >+ if (_importerPage.isFromXSDButtonSelected()) >+ importedProperties = _importPropertyPage.getImportedProperties(); >+ else if (_importerPage.isFromWSDLButtonSelected()) >+ importedOperations = _importOperationPage.getImportedOperations(); >+ > _options.put(CapabilityWizardKeys.CONTAINER_NAME_KEY, containerName); > _options.put(CapabilityWizardKeys.CAP_NS_KEY, capNamespace); > _options.put(CapabilityWizardKeys.CAP_PREFIX_KEY, capPrefix); >@@ -161,6 +189,11 @@ > _options.put(CapabilityWizardKeys.RMD_FILE_NAME_KEY, rmdFileName); > _options.put(CapabilityWizardKeys.RMD_NS_KEY, rmdNS); > >+ _options.put(CapabilityWizardKeys.IMPORT_PROPERTY_KEY, >+ importedProperties); >+ _options.put(CapabilityWizardKeys.IMPORT_OPERATION_KEY, >+ importedOperations); >+ > IRunnableWithProgress shouldOverwriteOperation = new IRunnableWithProgress() > { > public void run(IProgressMonitor monitor) >@@ -473,6 +506,12 @@ > resourcePropertyElement.setName(capName + "Properties"); > resourcePropertyElement.setTypeDefinition(null); > schema.getContents().add(resourcePropertyElement); >+ >+ Property[] importedProperties = (Property[]) _options >+ .get(CapabilityWizardKeys.IMPORT_PROPERTY_KEY); >+ ImportPropertyCommand command = new ImportPropertyCommand( >+ resourcePropertyElement, importedProperties); >+ command.execute(); > } > > private void createAnnotation(XSDSchema schema) >@@ -503,6 +542,13 @@ > portType.setQName(new QName(capNS, capName + "PortType")); > portType.setUndefined(false); > _wsdlCapDefinition.getDefinition().addPortType(portType); >+ >+ Operation[] importOperations = (Operation[]) _options >+ .get(CapabilityWizardKeys.IMPORT_OPERATION_KEY); >+ >+ ImportOperationCommand command = new ImportOperationCommand( >+ _wsdlCapDefinition, importOperations); >+ command.execute(); > } > > private void wsdlEdit() >@@ -533,10 +579,15 @@ > return _newCapPage; > } > >- /* >- * protected CapabilityFileWizardPage getCapabilityFileWizardPage() { return >- * _capFilesPage; } >- */ >+ public OperationImportWizardPage getOperationImportWizardPage() >+ { >+ return _importOperationPage; >+ } >+ >+ public PropertyImportWizardPage getPropertyImportWizardPage() >+ { >+ return _importPropertyPage; >+ } > } > > class CapabilityWizardKeys >@@ -569,4 +620,8 @@ > static final String IMPORT_XSD_KEY = "IMPORT_XSD"; > > static final String IMPORT_WSDL_KEY = "IMPORT_WSDL"; >+ >+ static final String IMPORT_PROPERTY_KEY = "IMPORT_PROPERTY"; >+ >+ static final String IMPORT_OPERATION_KEY = "IMPORT_OPERATION"; > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/internal/Activator.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/internal/Activator.java,v >retrieving revision 1.1 >diff -u -r1.1 Activator.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/internal/Activator.java 1 Feb 2007 05:04:48 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/internal/Activator.java 1 Feb 2007 18:01:00 -0000 >@@ -25,9 +25,27 @@ > public final class Activator extends EMFPlugin > { > >- // The plug-in ID >+ // The model plug-in ID >+ public static final String MODEL_PLUGIN_ID = "org.eclipse.tptp.wsdm.model"; >+ >+ // The editor plug-in ID > public static final String PLUGIN_ID = "org.eclipse.tptp.wsdm.editor"; > >+ // Management capability extension point >+ public static final String MR_CAPABILITY_EXT_PT = "mrCapability"; >+ >+ // Capability validator extension point >+ public static final String CAPABILITY_VALIDATOR_EXT_PT = "capabilityValidator"; >+ >+ // MRT validator extension point >+ public static final String MRT_VALIDATOR_EXT_PT = "mrtValidator"; >+ >+ // DD validator extension point >+ public static final String DD_VALIDATOR_EXT_PT = "ddeValidator"; >+ >+ // Codegen extension point >+ public static final String CODEGEN_EXT_PT = "codeGeneration"; >+ > /** > * Keep track of the singleton. <!-- begin-user-doc --> <!-- end-user-doc > * --> >@@ -51,7 +69,8 @@ > */ > public Activator() > { >- super(new ResourceLocator[] {}); >+ super(new ResourceLocator[] >+ {}); > } > > /** >Index: src/org/eclipse/tptp/wsdm/tooling/validation/util/internal/ValidationUtils.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/validation/util/internal/ValidationUtils.java,v >retrieving revision 1.1 >diff -u -r1.1 ValidationUtils.java >--- src/org/eclipse/tptp/wsdm/tooling/validation/util/internal/ValidationUtils.java 1 Feb 2007 05:04:41 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/validation/util/internal/ValidationUtils.java 1 Feb 2007 18:01:02 -0000 >@@ -18,6 +18,7 @@ > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IExtension; > import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IExtensionRegistry; > import org.eclipse.core.runtime.Platform; > import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; > import org.eclipse.tptp.wsdm.tooling.nls.messages.validation.internal.Messages; >@@ -37,29 +38,15 @@ > public class ValidationUtils > { > >- public static final String CAPABILITY_VALIDATOR_EXT_POINTID = "capabilityValidator"; >- >- public static final String MRT_VALIDATOR_EXT_POINTID = "mrtValidator"; >- >- public static final String DDE_VALIDATOR_EXT_POINTID = "ddeValidator"; >- >- /** >- * Returns IExtensionPoint of given name. >- */ >- public static IExtensionPoint getExtensionPoint(String point) >- { >- String pluginID = Activator.getPlugin().getBundle().getSymbolicName(); >- return Platform.getExtensionRegistry().getExtensionPoint(pluginID, >- point); >- } >- > /** > * Returns all the capability validators by reading the plugin registry. > */ > public static ICapabilityValidator[] getAllCapabilityValidators() > { > List validators = new ArrayList(); >- IExtensionPoint iep = getExtensionPoint(CAPABILITY_VALIDATOR_EXT_POINTID); >+ IExtensionRegistry er = Platform.getExtensionRegistry(); >+ IExtensionPoint iep = er.getExtensionPoint(Activator.PLUGIN_ID, >+ Activator.CAPABILITY_VALIDATOR_EXT_PT); > if (iep == null) > { > WsdmToolingLog.logWarning(Messages.COULDNT_FIND_CAP_VALIDATOR_EXT); >@@ -97,7 +84,9 @@ > public static IMrtValidator[] getAllMrtValidators() > { > List validators = new ArrayList(); >- IExtensionPoint iep = getExtensionPoint(MRT_VALIDATOR_EXT_POINTID); >+ IExtensionRegistry er = Platform.getExtensionRegistry(); >+ IExtensionPoint iep = er.getExtensionPoint(Activator.PLUGIN_ID, >+ Activator.MRT_VALIDATOR_EXT_PT); > if (iep == null) > { > WsdmToolingLog.logWarning(Messages.COULDNT_FIND_MRT_VALIDATOR_EXT); >@@ -135,7 +124,9 @@ > public static IDdeValidator[] getAllDdeValidators() > { > List validators = new ArrayList(); >- IExtensionPoint iep = getExtensionPoint(DDE_VALIDATOR_EXT_POINTID); >+ IExtensionRegistry er = Platform.getExtensionRegistry(); >+ IExtensionPoint iep = er.getExtensionPoint(Activator.PLUGIN_ID, >+ Activator.DD_VALIDATOR_EXT_PT); > if (iep == null) > { > WsdmToolingLog.logWarning(Messages.COULDNT_FIND_DDE_VALIDATOR_EXT); >Index: src/org/eclipse/tptp/wsdm/tooling/validation/capability/internal/CapabilityValidator.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/validation/capability/internal/CapabilityValidator.java,v >retrieving revision 1.1 >diff -u -r1.1 CapabilityValidator.java >--- src/org/eclipse/tptp/wsdm/tooling/validation/capability/internal/CapabilityValidator.java 1 Feb 2007 05:04:46 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/validation/capability/internal/CapabilityValidator.java 1 Feb 2007 18:01:02 -0000 >@@ -51,34 +51,4 @@ > } > return report; > } >- >- /** >- * Perform RMD validation >- */ >- /* >- * public IValidationReport validateRMD(Definition definition, DocumentRoot >- * root) { CapabilityRMDValidator rmdValidator = new >- * CapabilityRMDValidator(); IValidationReport rmdReport = >- * rmdValidator.validate(definition, root); return rmdReport; } >- */ >- >- /** >- * Perform WSDL validation >- */ >- /* >- * public IValidationReport validateWSDL(Definition definition) { >- * CapabilityWSDLValidator wsdlValidator = new CapabilityWSDLValidator(); >- * IValidationReport wsdlReport = wsdlValidator.validate(definition); return >- * wsdlReport; } >- */ >- >- /** >- * Perform XSD validation >- */ >- /* >- * public IValidationReport validateXSD(Definition definition, XSDSchema >- * propertySchema) { CapabilityXSDValidator xsdValidator = new >- * CapabilityXSDValidator(); IValidationReport xsdReport = >- * xsdValidator.validate(definition, propertySchema); return xsdReport; } >- */ > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/ListSection.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/ListSection.java,v >retrieving revision 1.1 >diff -u -r1.1 ListSection.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/ListSection.java 1 Feb 2007 05:04:40 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/ListSection.java 1 Feb 2007 18:00:59 -0000 >@@ -14,9 +14,11 @@ > > import java.util.List; > >+import org.eclipse.core.resources.IFile; > import org.eclipse.jface.viewers.SelectionChangedEvent; > import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.jface.window.Window; >+import org.eclipse.jface.wizard.WizardDialog; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.ControlAdapter; > import org.eclipse.swt.events.ControlEvent; >@@ -29,12 +31,14 @@ > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Tree; >+import org.eclipse.tptp.wsdm.tooling.dialog.provisional.XSDBrowseDialog; > import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.AddPropertyCommand; > import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangeModifiabilityCommand; > import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangeMutabilityCommand; > import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangePropertyCardinalityCommand; > import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangePropertyTypeCommand; > import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.RemovePropertyCommand; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.PropertyImportWizard; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.AbstractCapabilityEditor; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.AbstractPageSection; >@@ -42,11 +46,13 @@ > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.IUIPage; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.property.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; > import org.eclipse.tptp.wsdm.tooling.viewers.internal.IViewerClient; > import org.eclipse.tptp.wsdm.tooling.viewers.internal.StructuredTreeViewer; > import org.eclipse.ui.forms.widgets.FormToolkit; > import org.eclipse.ui.forms.widgets.ScrolledForm; > import org.eclipse.xsd.XSDElementDeclaration; >+import org.eclipse.xsd.XSDSchema; > > /** > * >@@ -65,6 +71,8 @@ > > private Button _addPropertyButton; > >+ private Button _importPropertyButton; >+ > private Button _editMetadataButton; > > private Button _removePropertyButton; >@@ -138,10 +146,26 @@ > } > }); > gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- gd.widthHint = 80; >+ gd.widthHint = 100; > _addPropertyButton.setLayoutData(gd); > _addPropertyButton.setEnabled(!_editor.isReadOnly()); > >+ _importPropertyButton = createPushButton( >+ _buttonClient, >+ toolkit, >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.IMPORT_PROPERTIES, >+ new Listener() >+ { >+ public void handleEvent(Event event) >+ { >+ importProperty(); >+ } >+ }); >+ gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >+ gd.widthHint = 100; >+ _importPropertyButton.setLayoutData(gd); >+ _importPropertyButton.setEnabled(!_editor.isReadOnly()); >+ > _editMetadataButton = createPushButton(_buttonClient, toolkit, > Messages.EDIT_METADATA_LABEL, new Listener() > { >@@ -151,7 +175,7 @@ > } > }); > gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- gd.widthHint = 80; >+ gd.widthHint = 100; > _editMetadataButton.setLayoutData(gd); > _editMetadataButton.setEnabled(false); > >@@ -167,7 +191,7 @@ > } > }); > gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- gd.widthHint = 80; >+ gd.widthHint = 100; > _removePropertyButton.setLayoutData(gd); > _removePropertyButton.setEnabled(false); > >@@ -217,6 +241,23 @@ > } > } > >+ private void importProperty() >+ { >+ XSDBrowseDialog dialog = new XSDBrowseDialog(getForm().getShell()); >+ if (dialog.open() == Window.OK) >+ { >+ IFile xsdFile = (IFile) dialog.getFirstResult(); >+ // TODO Check for valid schema file >+ XSDSchema importedSchema = XsdUtils.getSchema(xsdFile); >+ PropertyImportWizard importPropertyWizard = new PropertyImportWizard( >+ _editor.getCapabilityDomain(), importedSchema); >+ WizardDialog wizardDialog = new WizardDialog(getForm().getShell(), >+ importPropertyWizard); >+ wizardDialog.open(); >+ _page.setDirty(); >+ } >+ } >+ > private void editMetadata() > { > CapabilityDomain capabilityDomain = (CapabilityDomain) _editor >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/ImportValidationStatus.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/ImportValidationStatus.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/ImportValidationStatus.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/ImportValidationStatus.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd; >+ >+public class ImportValidationStatus >+{ >+ >+ private String _errorMessage; >+ private Object[] _causeOfError; >+ >+ public ImportValidationStatus(String errorMessage, Object[] causeOfError) >+ { >+ _errorMessage = errorMessage; >+ _causeOfError = causeOfError; >+ } >+ >+ public String getErrorMessage() >+ { >+ return _errorMessage; >+ } >+ >+ public Object[] getCauseOfError() >+ { >+ return _causeOfError; >+ } >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorageEditorInput.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorageEditorInput.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorageEditorInput.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorageEditorInput.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,69 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.internal; >+ >+import org.eclipse.core.resources.IStorage; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.PlatformObject; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.ui.IPersistableElement; >+import org.eclipse.ui.IStorageEditorInput; >+ >+/** >+ * This class has been designed to use for opening any existing capability from >+ * within MRT file.<br> >+ * This class implements the IStorageEditorInput interface which is used to open >+ * a file as a stream of bytes.<br> >+ */ >+ >+public class CapabilityStorageEditorInput extends PlatformObject implements >+ IStorageEditorInput >+{ >+ >+ private ICapabilityStorage _storage; >+ >+ public CapabilityStorageEditorInput(ICapabilityStorage storage) >+ { >+ _storage = storage; >+ } >+ >+ public IStorage getStorage() throws CoreException >+ { >+ return _storage; >+ } >+ >+ public boolean exists() >+ { >+ return _storage.exists(); >+ } >+ >+ public ImageDescriptor getImageDescriptor() >+ { >+ return null; >+ } >+ >+ public String getName() >+ { >+ return _storage.getName(); >+ } >+ >+ public IPersistableElement getPersistable() >+ { >+ return null; >+ } >+ >+ public String getToolTipText() >+ { >+ return getName(); >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertySchemaContentProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertySchemaContentProvider.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertySchemaContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertySchemaContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,80 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd; >+ >+import java.util.HashMap; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.Viewer; >+ >+public class PropertySchemaContentProvider implements ITreeContentProvider >+{ >+ private final Map _parentMap; >+ >+ public PropertySchemaContentProvider() >+ { >+ _parentMap = new HashMap(); >+ } >+ >+ public Object[] getChildren(Object parentElement) >+ { >+ if (parentElement instanceof List) >+ { >+ List l = (List) parentElement; >+ return l.toArray(); >+ } >+ else if (parentElement instanceof PropertyNamespace) >+ { >+ PropertyNamespace propNamespace = (PropertyNamespace) parentElement; >+ Object[] elements = rememberChildren(parentElement, propNamespace >+ .getProperties()); >+ return elements; >+ } >+ return new Object[0]; >+ } >+ >+ public Object getParent(Object element) >+ { >+ Object retVal = _parentMap.get(element); >+ return retVal; >+ } >+ >+ public boolean hasChildren(Object element) >+ { >+ return (getChildren(element).length > 0); >+ } >+ >+ public Object[] getElements(Object inputElement) >+ { >+ return getChildren(inputElement); >+ } >+ >+ public void dispose() >+ { >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) >+ { >+ } >+ >+ private Object[] rememberChildren(Object parent, Object[] childrens) >+ { >+ for (int i = 0; i < childrens.length; i++) >+ { >+ _parentMap.put(childrens[i], parent); >+ } >+ return childrens; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,91 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl; >+ >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; >+import org.eclipse.xsd.XSDImport; >+import org.eclipse.xsd.XSDInclude; >+import org.eclipse.xsd.XSDSchema; >+ >+public class XSDSchemaMerger >+{ >+ >+ private XSDSchema _schema; >+ private List _allResultedSchema; >+ >+ public XSDSchemaMerger(XSDSchema schema) >+ { >+ _schema = schema; >+ _allResultedSchema = new LinkedList(); >+ addSchema(_schema); >+ } >+ >+ public XSDSchema[] merge() >+ { >+ XSDImport[] imports = XsdUtils.getAllXSDImports(_schema); >+ for (int i = 0; i < imports.length; i++) >+ { >+ if (imports[i].getResolvedSchema() == null) >+ continue; >+ addSchema(imports[i].getResolvedSchema()); >+ XSDSchemaMerger merger = new XSDSchemaMerger(imports[i] >+ .getResolvedSchema()); >+ XSDSchema[] schemas = merger.merge(); >+ for (int j = 0; j < schemas.length; j++) >+ addSchema(schemas[j]); >+ } >+ >+ XSDInclude[] includes = XsdUtils.getAllXSDIncludes(_schema); >+ for (int i = 0; i < includes.length; i++) >+ { >+ if (includes[i].getResolvedSchema() == null) >+ continue; >+ addSchema(includes[i].getResolvedSchema()); >+ XSDSchemaMerger merger = new XSDSchemaMerger(includes[i] >+ .getResolvedSchema()); >+ XSDSchema[] schemas = merger.merge(); >+ for (int j = 0; j < schemas.length; j++) >+ addSchema(schemas[j]); >+ } >+ >+ return (XSDSchema[]) _allResultedSchema >+ .toArray(new XSDSchema[_allResultedSchema.size()]); >+ } >+ >+ private void addSchema(XSDSchema givenSchema) >+ { >+ XSDSchema schema = getSchema(givenSchema.getTargetNamespace()); >+ if (schema != null) >+ { >+ List givenSchemaContents = givenSchema.getContents(); >+ for (int i = 0; i < givenSchemaContents.size(); i++) >+ schema.getContents().add(givenSchemaContents.get(i)); >+ } >+ else >+ _allResultedSchema.add(givenSchema); >+ } >+ >+ private XSDSchema getSchema(String targetNamespace) >+ { >+ for (int i = 0; i < _allResultedSchema.size(); i++) >+ { >+ XSDSchema schema = (XSDSchema) _allResultedSchema.get(i); >+ if (schema.getTargetNamespace().equals(targetNamespace)) >+ return schema; >+ } >+ return null; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,260 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal; >+ >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+import java.util.Map; >+ >+import javax.wsdl.Definition; >+import javax.wsdl.Fault; >+import javax.wsdl.Input; >+import javax.wsdl.Message; >+import javax.wsdl.Operation; >+import javax.wsdl.Output; >+import javax.wsdl.PortType; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; >+import org.eclipse.xsd.XSDElementDeclaration; >+import org.eclipse.xsd.XSDImport; >+import org.eclipse.xsd.XSDInclude; >+import org.eclipse.xsd.XSDSchema; >+ >+public class ImportOperationCommand >+{ >+ private CapabilityDefinition _capabilityDefinition; >+ private Definition _definition; >+ private Operation[] _importedOperations; >+ private List _newOperations; >+ private IProgressMonitor _monitor; >+ >+ public ImportOperationCommand(CapabilityDefinition capabilityDefinition, >+ Operation[] importedOperations, IProgressMonitor monitor) >+ { >+ _capabilityDefinition = capabilityDefinition; >+ _definition = _capabilityDefinition.getDefinition(); >+ _importedOperations = importedOperations; >+ _newOperations = new LinkedList(); >+ _monitor = monitor; >+ XSDSchema[] capabilityWsdlSchemas = _capabilityDefinition >+ .getXSDSchemas(); >+ // TODO >+ /* >+ * if(capabilityWsdlSchemas == null) // No wsdl types defined { Types >+ * types = WSDLFactory.eINSTANCE.createTypes(); >+ * types.setEnclosingDefinition(_capabilityDefinition); >+ * _capabilityDefinition.setETypes(types); } >+ */ >+ if (monitor == null) >+ _monitor = new NullProgressMonitor(); >+ } >+ >+ public ImportOperationCommand(CapabilityDefinition capabilityDefinition, >+ Operation[] importedOperations) >+ { >+ this(capabilityDefinition, importedOperations, null); >+ } >+ >+ public void execute() >+ { >+ _monitor.beginTask(Messages.IMPORTING_OPERATIONS, >+ _importedOperations.length); >+ for (int i = 0; i < _importedOperations.length; i++) >+ { >+ String taskName = Messages.bind(Messages.IMPORTING_OPERATION, >+ _importedOperations[i].getName()); >+ _monitor.setTaskName(taskName); >+ Operation newOperation = createNewOperation(_importedOperations[i]); >+ _newOperations.add(newOperation); >+ _monitor.worked(i + 1); >+ } >+ } >+ >+ private Operation createNewOperation(Operation importedOperation) >+ { >+ Operation newOperation = _definition.createOperation(); >+ newOperation.setUndefined(false); >+ PortType port = _capabilityDefinition.getPortType(); >+ port.addOperation(newOperation); >+ newOperation.setName(importedOperation.getName()); >+ >+ createNewOperationInput(newOperation, importedOperation); >+ createNewOperationOutput(newOperation, importedOperation); >+ createNewOperationFaults(newOperation, importedOperation); >+ >+ return newOperation; >+ } >+ >+ private void createNewOperationInput(Operation newOperation, >+ Operation importedOperation) >+ { >+ Input newInput = _definition.createInput(); >+ newOperation.setUndefined(false); >+ newOperation.setInput(newInput); >+ newInput.setName(importedOperation.getInput().getName()); >+ >+ Message importedMessage = importedOperation.getInput().getMessage(); >+ Message newMessage = createNewMessage(importedMessage); >+ newInput.setMessage(newMessage); >+ _capabilityDefinition.addMessage(newMessage); >+ >+ // TODO >+ /* >+ * String opName = importedOperation.getName(); opName = >+ * opName.substring(0, 1).toUpperCase() + opName.substring(1); String >+ * tns = _capabilityDefinition.getTargetNamespace(); >+ * if(!tns.endsWith("/")) tns = tns+"/"; String action = >+ * tns+opName+"Request"; >+ * newInput.getElement().setAttributeNS(WsdmConstants.WSA_URI, >+ * WsdmConstants.WSA_ACTION_NAME, action); >+ */ >+ } >+ >+ private void createNewOperationOutput(Operation newOperation, >+ Operation importedOperation) >+ { >+ if (importedOperation.getOutput() == null) >+ return; >+ >+ Output newOutput = _definition.createOutput(); >+ newOperation.setOutput(newOutput); >+ newOutput.setName(importedOperation.getOutput().getName()); >+ >+ Message importedMessage = importedOperation.getOutput().getMessage(); >+ Message newMessage = createNewMessage(importedMessage); >+ newOutput.setMessage(newMessage); >+ _capabilityDefinition.addMessage(newMessage); >+ >+ // TODO >+ /* >+ * String opName = importedOperation.getName(); opName = >+ * opName.substring(0, 1).toUpperCase() + opName.substring(1); String >+ * tns = _capabilityDefinition.getTargetNamespace(); >+ * if(!tns.endsWith("/")) tns = tns+"/"; String action = >+ * tns+opName+"Response"; >+ * newOutput.getElement().setAttributeNS(WsdmConstants.WSA_URI, >+ * WsdmConstants.WSA_ACTION_NAME, action); >+ */ >+ } >+ >+ private void createNewOperationFaults(Operation newOperation, >+ Operation importedOperation) >+ { >+ Map importedFaultsMap = importedOperation.getFaults(); >+ if (importedFaultsMap == null || importedFaultsMap.size() == 0) >+ return; >+ Iterator it = importedFaultsMap.values().iterator(); >+ while (it.hasNext()) >+ { >+ Object object = it.next(); >+ if (object instanceof Fault) >+ { >+ Fault importFault = (Fault) object; >+ Fault newFault = _definition.createFault(); >+ newOperation.addFault(newFault); >+ newFault.setName(importFault.getName()); >+ >+ Message importedMessage = importFault.getMessage(); >+ Message newMessage = createNewMessage(importedMessage); >+ newFault.setMessage(newMessage); >+ _capabilityDefinition.addMessage(newMessage); >+ } >+ } >+ } >+ >+ private Message createNewMessage(Message importedMessage) >+ { >+ // TODO >+ /* >+ * Message existingMessage = >+ * WsdlUtils.getWSDLMessage(_capabilityDefinition, >+ * importedMessage.getQName().getLocalPart()); if(existingMessage!=null) >+ * return existingMessage; Message message = >+ * WSDLFactory.eINSTANCE.createMessage(); >+ * message.setEnclosingDefinition(_capabilityDefinition); String >+ * messageLocalName = importedMessage.getQName().getLocalPart(); >+ * message.setQName(new >+ * QName(_capabilityDefinition.getTargetNamespace(),messageLocalName)); >+ * Part part = WSDLFactory.eINSTANCE.createPart(); >+ * part.setEnclosingDefinition(_capabilityDefinition); >+ * message.addPart(part); Part importedPart = (Part) >+ * importedMessage.getEParts().get(0); >+ * importSchemaForElement(importedPart.getElementDeclaration()); String >+ * xsdNS = importedPart.getElementDeclaration().getTargetNamespace(); >+ * String elementName = importedPart.getElementDeclaration().getName(); >+ * XSDSchema elementSchema = WsdlUtils.getSchema(_capabilityDefinition, >+ * xsdNS); XSDElementDeclaration element = >+ * XsdUtils.getXSDElementDeclarationOfName(elementSchema, elementName); >+ * WsdlUtils.createOrFindPrefix(_capabilityDefinition, >+ * element.getTargetNamespace(), null); >+ * part.setName(importedPart.getName()); >+ * part.setElementDeclaration(element); part.setElementName(new >+ * QName(xsdNS, elementName)); return message; >+ */ >+ return _definition.createMessage(); >+ } >+ >+ private void importSchemaForElement(XSDElementDeclaration element) >+ { >+ // TODO >+ /* >+ * XSDSchema elementSchema = element.getSchema(); XSDSchemaMerger merger = >+ * new XSDSchemaMerger(elementSchema); XSDSchema[] mergedSchemas = >+ * merger.merge(); for(int i=0;i<mergedSchemas.length;i++) { >+ * if(!isSchemaExistsInWsdl(mergedSchemas[i])) { >+ * XSDSchemaExtensibilityElement schemaElement = WSDLFactory.eINSTANCE >+ * .createXSDSchemaExtensibilityElement(); >+ * schemaElement.setEnclosingDefinition(_capabilityDefinition); >+ * XSDSchema copySchema = createCopy(mergedSchemas[i]); >+ * schemaElement.setSchema(copySchema); >+ * _capabilityDefinition.getTypes().addExtensibilityElement(schemaElement); } } >+ */ >+ } >+ >+ private boolean isSchemaExistsInWsdl(XSDSchema schema) >+ { >+ XSDSchema wsdlSchema = _capabilityDefinition.getSchema(schema >+ .getTargetNamespace()); >+ if (wsdlSchema != null) >+ return true; >+ return false; >+ } >+ >+ private XSDSchema createCopy(XSDSchema schema) >+ { >+ XSDSchema copySchema = (XSDSchema) schema.cloneConcreteComponent(true, >+ false); >+ List contents = copySchema.getContents(); >+ for (int i = 0; i < contents.size(); i++) >+ { >+ if (contents.get(i) instanceof XSDInclude) >+ contents.remove(i); >+ else if (contents.get(i) instanceof XSDImport) >+ { >+ XSDImport theImport = (XSDImport) contents.get(i); >+ theImport.setSchemaLocation(null); >+ } >+ } >+ return copySchema; >+ } >+ >+ public Operation[] getNewOperations() >+ { >+ return (Operation[]) _newOperations >+ .toArray(new Operation[_newOperations.size()]); >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizardPage.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizardPage.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizardPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizardPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,250 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd; >+ >+import java.util.Arrays; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.viewers.CheckStateChangedEvent; >+import org.eclipse.jface.viewers.CheckboxTreeViewer; >+import org.eclipse.jface.viewers.ICheckStateListener; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; >+import org.eclipse.xsd.XSDElementDeclaration; >+import org.eclipse.xsd.XSDSchema; >+ >+public class PropertyImportWizardPage extends WizardPage >+{ >+ private XSDSchema _importSchema; >+ private PropertyNamespace[] _existingPropertyNs = new PropertyNamespace[0]; >+ private CheckboxTreeViewer _viewer; >+ private PropertySchemaContentProvider _contentProvider; >+ private Property[] _importedProperties; >+ >+ public PropertyImportWizardPage() >+ { >+ super("ImportPropertyWizardPage"); >+ setTitle(Messages.PROPERTY_IMPORT_WIZARD_PAGE_TITLE); >+ setDescription(Messages.PROPERTY_IMPORT_WIZARD_PAGE_DESCRIPTION); >+ } >+ >+ public PropertyImportWizardPage(XSDSchema importSchema, >+ PropertyNamespace[] existingPropertyNs) >+ { >+ super("ImportPropertyWizardPage"); >+ setTitle(Messages.PROPERTY_IMPORT_WIZARD_PAGE_TITLE); >+ setDescription(Messages.PROPERTY_IMPORT_WIZARD_PAGE_DESCRIPTION); >+ _importSchema = importSchema; >+ if (existingPropertyNs != null) >+ _existingPropertyNs = existingPropertyNs; >+ } >+ >+ public PropertyImportWizardPage(XSDSchema importSchema) >+ { >+ this(importSchema, null); >+ } >+ >+ public void createControl(Composite parent) >+ { >+ initializeDialogUnits(parent); >+ Composite container = new Composite(parent, SWT.NULL); >+ container.setFont(parent.getFont()); >+ GridLayout layout = new GridLayout(); >+ container.setLayout(layout); >+ layout.verticalSpacing = 9; >+ >+ Label availablePropertiesLabel = new Label(container, SWT.WRAP); >+ availablePropertiesLabel.setText(Messages.AVAILABLE_PROPERTIES_LABEL); >+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false); >+ gd.minimumHeight = 15; >+ availablePropertiesLabel.setLayoutData(gd); >+ >+ _viewer = new CheckboxTreeViewer(container, SWT.MULTI | SWT.BORDER); >+ _contentProvider = new PropertySchemaContentProvider(); >+ _viewer.setContentProvider(_contentProvider); >+ _viewer.setLabelProvider(new PropertySchemaLabelProvider(getShell())); >+ _viewer.getControl().setLayoutData( >+ new GridData(SWT.FILL, SWT.FILL, true, true)); >+ _viewer.addCheckStateListener(new ICheckStateListener() >+ { >+ public void checkStateChanged(CheckStateChangedEvent event) >+ { >+ handleCheckStateChanged(event); >+ } >+ }); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gd.heightHint = 200; >+ gd.widthHint = 300; >+ _viewer.getControl().setLayoutData(gd); >+ >+ initialize(); >+ // getShell().setSize(500, 100); >+ setControl(container); >+ Dialog.applyDialogFont(parent); >+ } >+ >+ private void initialize() >+ { >+ _importedProperties = new Property[0]; >+ if (_importSchema != null) >+ { >+ // Get the Consolidated list of schemas >+ // (Provided through constructor + Schemas collect from given >+ // capability file) >+ List allPropNamespaces = new LinkedList(); >+ PropertyNamespace importPropNamespace = createPropertyNamespaceFromImportedSchema(); >+ allPropNamespaces.addAll(Arrays.asList(_existingPropertyNs)); >+ allPropNamespaces.add(importPropNamespace); >+ _viewer.setInput(allPropNamespaces); >+ } >+ // _viewer.expandToLevel(2); >+ // Checked the Schemas provided by constructor >+ doIntialCheckedElements(); >+ _viewer.setGrayedElements(_existingPropertyNs); >+ updateStatus(null); >+ } >+ >+ protected void doIntialCheckedElements() >+ { >+ for (int i = 0; i < _existingPropertyNs.length; i++) >+ _viewer.setSubtreeChecked(_existingPropertyNs[i], true); >+ } >+ >+ public void setImportSchema(XSDSchema importSchema) >+ { >+ _importSchema = importSchema; >+ initialize(); >+ } >+ >+ private void handleCheckStateChanged(CheckStateChangedEvent event) >+ { >+ // We don't allow user to check uncheck any Properties provided in >+ // constructor >+ PropertyNamespace checkedElementNS = getNamespaceOfChekedElement(event >+ .getElement()); >+ for (int i = 0; i < _existingPropertyNs.length; i++) >+ { >+ if (_existingPropertyNs[i].equals(checkedElementNS)) >+ { >+ _viewer.setChecked(event.getElement(), !event.getChecked()); >+ return; >+ } >+ } >+ >+ _viewer.setSubtreeChecked(event.getElement(), event.getChecked()); >+ Property[] checkedProperties = getCheckedProperties(); >+ PropertyImportValidator validator = new PropertyImportValidator( >+ checkedProperties); >+ ImportValidationStatus status = validator.validate(); >+ updateStatus(null); >+ if (status != null) >+ { >+ Object[] causeOfError = status.getCauseOfError(); >+ for (int i = 0; i < causeOfError.length; i++) >+ _viewer.reveal(causeOfError[i]); >+ _viewer.setSelection(new StructuredSelection(causeOfError)); >+ updateStatus(status.getErrorMessage()); >+ } >+ _importedProperties = getSelectedProperties(); >+ } >+ >+ private void updateStatus(String message) >+ { >+ setErrorMessage(message); >+ setPageComplete(message == null); >+ } >+ >+ private PropertyNamespace getNamespaceOfChekedElement(Object checkedElement) >+ { >+ if (checkedElement instanceof PropertyNamespace) >+ return (PropertyNamespace) checkedElement; >+ Object parent = _contentProvider.getParent(checkedElement); >+ while (!(parent instanceof PropertyNamespace)) >+ parent = _contentProvider.getParent(parent); >+ return (PropertyNamespace) parent; >+ } >+ >+ /** >+ * Returns all the checked xsd properties from viewer. >+ */ >+ private Property[] getCheckedProperties() >+ { >+ Object[] checkedElements = _viewer.getCheckedElements(); >+ List selectedOperationList = new LinkedList(); >+ for (int i = 0; i < checkedElements.length; i++) >+ { >+ if (checkedElements[i] instanceof Property) >+ selectedOperationList.add(checkedElements[i]); >+ } >+ return (Property[]) selectedOperationList >+ .toArray(new Property[selectedOperationList.size()]); >+ } >+ >+ private Property[] getSelectedProperties() >+ { >+ Property[] checkedProperties = getCheckedProperties(); >+ List selectedProperties = new LinkedList(); >+ for (int i = 0; i < checkedProperties.length; i++) >+ { >+ PropertyNamespace checkedElementNS = getNamespaceOfChekedElement(checkedProperties[i]); >+ boolean isImportProperty = true; >+ for (int j = 0; j < _existingPropertyNs.length; j++) >+ { >+ if (_existingPropertyNs[j].equals(checkedElementNS)) >+ { >+ isImportProperty = false; >+ break; >+ } >+ } >+ if (isImportProperty) >+ selectedProperties.add(checkedProperties[i]); >+ } >+ return (Property[]) selectedProperties >+ .toArray(new Property[selectedProperties.size()]); >+ } >+ >+ public Property[] getImportedProperties() >+ { >+ return _importedProperties; >+ } >+ >+ public IWizardPage getNextPage() >+ { >+ return null; >+ } >+ >+ private PropertyNamespace createPropertyNamespaceFromImportedSchema() >+ { >+ PropertyNamespace propNamespace = new PropertyNamespace(_importSchema >+ .getTargetNamespace()); >+ List importElements = _importSchema.getElementDeclarations(); >+ for (int i = 0; i < importElements.size(); i++) >+ { >+ Property property = CapabilitiesFactory.INSTANCE.createProperty(); >+ property.setElement((XSDElementDeclaration) importElements.get(i)); >+ propNamespace.addProperty(property); >+ } >+ return propNamespace; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/INewNameGenerator.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/INewNameGenerator.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/INewNameGenerator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/INewNameGenerator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,20 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator; >+ >+public interface INewNameGenerator >+{ >+ >+ public String getNewName(); >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportValidator.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportValidator.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportValidator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportValidator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,210 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl; >+ >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; >+ >+import javax.wsdl.Fault; >+import javax.wsdl.Message; >+import javax.wsdl.Operation; >+import javax.wsdl.Part; >+import javax.xml.namespace.QName; >+ >+import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.ImportValidationStatus; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils; >+ >+public class OperationImportValidator >+{ >+ >+ private Operation[] _operations; >+ private Map _map = new HashMap(); >+ public static final String XMLSCHEMA_2001_URI = "http://www.w3.org/2001/XMLSchema"; >+ >+ public OperationImportValidator(Operation[] operations) >+ { >+ _operations = operations; >+ } >+ >+ public ImportValidationStatus validate() >+ { >+ Map operationNames = new HashMap(); >+ if (_operations == null) >+ return null; >+ for (int i = 0; i < _operations.length; i++) >+ { >+ String operationName = _operations[i].getName(); >+ >+ // Validate operation name against AbstractCapability methods >+ if (CapUtils.isOperationNameConflicted(operationName)) >+ { >+ String errorMessage = org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages >+ .bind( >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages.CONFLICTED_OPERATION_WARN_, >+ operationName); >+ return new ImportValidationStatus(errorMessage, new Object[] >+ { _operations[i] }); >+ } >+ >+ // Validate duplicate operation name >+ if (!operationNames.containsKey(operationName)) >+ operationNames.put(operationName, _operations[i]); >+ else >+ { >+ String errorMessage = Messages.bind( >+ Messages.DUPLICATE_OPERATION, operationName); >+ Operation causeOfError_1 = (Operation) operationNames >+ .get(operationName); >+ Operation causeOfError_2 = _operations[i]; >+ return new ImportValidationStatus(errorMessage, new Object[] >+ { causeOfError_1, causeOfError_2 }); >+ } >+ >+ // 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. >+ >+ // Validate Input Message >+ if (_operations[i].getInput() != null) >+ { >+ Message inputMessage = _operations[i].getInput().getMessage(); >+ if (!isDocLiteralMessage(inputMessage)) >+ { >+ String errorMessage = Messages.NOT_DOC_LITERAL_MESSAGE; >+ return new ImportValidationStatus(errorMessage, >+ new Object[] >+ { inputMessage }); >+ } >+ Message conflictedMessage = validateConflictedMessage(inputMessage); >+ if (conflictedMessage != null) >+ { >+ String newLine = System.getProperty("line.separator"); >+ String errorMessage = Messages.CONFLICTED_MESSAGE + newLine >+ + conflictedMessage.getQName().toString() + newLine >+ + inputMessage.getQName().toString(); >+ return new ImportValidationStatus(errorMessage, >+ new Object[] >+ { conflictedMessage, inputMessage }); >+ } >+ } >+ else >+ { >+ String errorMessage = Messages.INPUT_MESSAGE_NOT_DEFINED; >+ return new ImportValidationStatus(errorMessage, new Object[] >+ { _operations[i] }); >+ } >+ >+ // Validate Output Message >+ if (_operations[i].getOutput() != null) >+ { >+ Message outputMessage = _operations[i].getOutput().getMessage(); >+ if (!isDocLiteralMessage(outputMessage)) >+ { >+ String errorMessage = Messages.NOT_DOC_LITERAL_MESSAGE; >+ return new ImportValidationStatus(errorMessage, >+ new Object[] >+ { outputMessage }); >+ } >+ Message conflictedMessage = validateConflictedMessage(outputMessage); >+ if (conflictedMessage != null) >+ { >+ String newLine = System.getProperty("line.separator"); >+ String errorMessage = Messages.CONFLICTED_MESSAGE + newLine >+ + conflictedMessage.getQName().toString() + newLine >+ + outputMessage.getQName().toString(); >+ return new ImportValidationStatus(errorMessage, >+ new Object[] >+ { conflictedMessage, outputMessage }); >+ } >+ } >+ else >+ { >+ String errorMessage = Messages.OUTPUT_MESSAGE_NOT_DEFINED; >+ return new ImportValidationStatus(errorMessage, new Object[] >+ { _operations[i] }); >+ } >+ >+ // Validate Fault Messages >+ Iterator faultsIt = _operations[i].getFaults().values().iterator(); >+ while (faultsIt.hasNext()) >+ { >+ Object object = faultsIt.next(); >+ if (object instanceof Fault) >+ { >+ Fault fault = (Fault) object; >+ Message faultMessage = fault.getMessage(); >+ if (!isDocLiteralMessage(faultMessage)) >+ { >+ String errorMessage = Messages.NOT_DOC_LITERAL_MESSAGE; >+ return new ImportValidationStatus(errorMessage, >+ new Object[] >+ { faultMessage }); >+ } >+ Message conflictedMessage = validateConflictedMessage(faultMessage); >+ if (conflictedMessage != null) >+ { >+ String newLine = System.getProperty("line.separator"); >+ String errorMessage = Messages.CONFLICTED_MESSAGE >+ + newLine >+ + conflictedMessage.getQName().toString() >+ + newLine + faultMessage.getQName().toString(); >+ return new ImportValidationStatus(errorMessage, >+ new Object[] >+ { conflictedMessage, faultMessage }); >+ } >+ } >+ } >+ } >+ return null; >+ } >+ >+ private Message validateConflictedMessage(Message wsdlMessage) >+ { >+ String messageNS = wsdlMessage.getQName().getNamespaceURI(); >+ String messageName = wsdlMessage.getQName().getLocalPart(); >+ if (_map.get(messageName) == null) >+ { >+ _map.put(messageName, wsdlMessage); >+ return null; >+ } >+ Message messageFromMap = (Message) _map.get(messageName); >+ String nsFromMap = messageFromMap.getQName().getNamespaceURI(); >+ if (!nsFromMap.equals(messageNS)) >+ return messageFromMap; >+ return null; >+ } >+ >+ private boolean isDocLiteralMessage(Message wsdlMessage) >+ { >+ Map partsMap = wsdlMessage.getParts(); >+ if (partsMap == null || partsMap.size() != 1) >+ return false; >+ Part part_0 = (Part) partsMap.values().iterator().next(); >+ QName elementQName = part_0.getElementName(); >+ if (elementQName == null) >+ { >+ QName typeDef = part_0.getTypeName(); >+ if (typeDef == null) >+ return false; >+ boolean voidType = typeDef.getNamespaceURI().equals( >+ XMLSCHEMA_2001_URI) >+ && typeDef.getLocalPart().equals("anyType"); >+ if (!voidType) >+ return false; >+ } >+ return true; >+ } >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizardPage.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizardPage.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizardPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizardPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,263 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl; >+ >+import java.util.LinkedList; >+import java.util.List; >+import java.util.Map; >+ >+import javax.wsdl.Definition; >+import javax.wsdl.Message; >+import javax.wsdl.Operation; >+import javax.wsdl.PortType; >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.viewers.CheckStateChangedEvent; >+import org.eclipse.jface.viewers.CheckboxTreeViewer; >+import org.eclipse.jface.viewers.ICheckStateListener; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.ImportValidationStatus; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; >+ >+public class OperationImportWizardPage extends WizardPage >+{ >+ private CheckboxTreeViewer _viewer; >+ private WsdlPortTypeContentProvider _contentProvider; >+ private Definition _wsdlDefinition; >+ private PortType[] _existingPortTypes = new PortType[0]; >+ private Operation[] _importedOperations; >+ >+ public OperationImportWizardPage() >+ { >+ super("ImportOperationWizardPage"); >+ setTitle(Messages.OPERATION_IMPORT_WIZARD_PAGE_TITLE); >+ setDescription(Messages.OPERATION_IMPORT_WIZARD_PAGE_DESCRIPTION); >+ } >+ >+ public OperationImportWizardPage(Definition wsdlDefinition, >+ PortType[] existingPortTypes) >+ { >+ super("ImportOperationWizardPage"); >+ setTitle(Messages.OPERATION_IMPORT_WIZARD_PAGE_TITLE); >+ setDescription(Messages.OPERATION_IMPORT_WIZARD_PAGE_DESCRIPTION); >+ _wsdlDefinition = wsdlDefinition; >+ if (existingPortTypes != null) >+ _existingPortTypes = existingPortTypes; >+ } >+ >+ public OperationImportWizardPage(Definition wsdlDefinition) >+ { >+ this(wsdlDefinition, null); >+ } >+ >+ public void createControl(Composite parent) >+ { >+ initializeDialogUnits(parent); >+ Composite container = new Composite(parent, SWT.NULL); >+ container.setFont(parent.getFont()); >+ GridLayout layout = new GridLayout(); >+ container.setLayout(layout); >+ layout.verticalSpacing = 9; >+ >+ Label descriptionLabel = new Label(container, SWT.WRAP); >+ descriptionLabel >+ .setText(Messages.OPERATION_IMPORT_WIZARD_PAGE_INFO_LABEL); >+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false); >+ gd.minimumHeight = 30; >+ descriptionLabel.setLayoutData(gd); >+ >+ Label availableOperationsLabel = new Label(container, SWT.WRAP); >+ availableOperationsLabel.setText(Messages.AVAILABLE_OPERATIONS_LABEL); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, false); >+ gd.minimumHeight = 15; >+ availableOperationsLabel.setLayoutData(gd); >+ >+ _viewer = new CheckboxTreeViewer(container, SWT.MULTI | SWT.BORDER); >+ _contentProvider = new WsdlPortTypeContentProvider(); >+ _viewer.setContentProvider(_contentProvider); >+ _viewer.setLabelProvider(new WsdlPortTypeLabelProvider(getShell())); >+ _viewer.getControl().setLayoutData( >+ new GridData(SWT.FILL, SWT.FILL, true, true)); >+ _viewer.addCheckStateListener(new ICheckStateListener() >+ { >+ public void checkStateChanged(CheckStateChangedEvent event) >+ { >+ handleCheckStateChanged(event); >+ } >+ }); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gd.heightHint = 200; >+ gd.widthHint = 300; >+ _viewer.getControl().setLayoutData(gd); >+ >+ initialize(); >+ // getShell().setSize(500, 100); >+ setControl(container); >+ Dialog.applyDialogFont(parent); >+ } >+ >+ private void initialize() >+ { >+ _importedOperations = new Operation[0]; >+ if (_wsdlDefinition != null) >+ { >+ // Get the Consolidated list of port types >+ // (Provided through constructor + Port types collect from given >+ // wsdl file) >+ Map portTypeMap = _wsdlDefinition.getPortTypes(); >+ PortType[] portTypes = (PortType[]) portTypeMap.values().toArray( >+ new PortType[portTypeMap.size()]); >+ List ports = getConsolidatedPortList(portTypes); >+ _viewer.setInput(ports); >+ } >+ // _viewer.expandToLevel(2); >+ // Checked the Port types provided by constructor >+ doIntialCheckedElements(); >+ _viewer.setGrayedElements(_existingPortTypes); >+ updateStatus(null); >+ } >+ >+ public void setWSDLDefinition(Definition definition) >+ { >+ _wsdlDefinition = definition; >+ initialize(); >+ } >+ >+ private List getConsolidatedPortList(PortType[] ports) >+ { >+ List portTypes = new LinkedList(); >+ for (int i = 0; i < _existingPortTypes.length; i++) >+ portTypes.add(_existingPortTypes[i]); >+ if (ports == null) >+ return portTypes; >+ for (int i = 0; i < ports.length; i++) >+ portTypes.add(ports[i]); >+ return portTypes; >+ } >+ >+ protected void doIntialCheckedElements() >+ { >+ for (int i = 0; i < _existingPortTypes.length; i++) >+ _viewer.setSubtreeChecked(_existingPortTypes[i], true); >+ } >+ >+ private void handleCheckStateChanged(CheckStateChangedEvent event) >+ { >+ // We don't allow user to check uncheck WSDL Messages >+ if (event.getElement() instanceof Message) >+ { >+ _viewer.setChecked(event.getElement(), !event.getChecked()); >+ return; >+ } >+ >+ // We don't allow user to check uncheck any Port Type provided in >+ // constructor >+ PortType port = getPortTypeOfChekedElement(event.getElement()); >+ for (int i = 0; i < _existingPortTypes.length; i++) >+ { >+ if (_existingPortTypes[i].equals(port)) >+ { >+ _viewer.setChecked(event.getElement(), !event.getChecked()); >+ return; >+ } >+ } >+ >+ _viewer.setSubtreeChecked(event.getElement(), event.getChecked()); >+ Operation[] checkedOperations = getCheckedOperations(); >+ OperationImportValidator validator = new OperationImportValidator( >+ checkedOperations); >+ ImportValidationStatus status = validator.validate(); >+ updateStatus(null); >+ if (status != null) >+ { >+ Object[] causeOfError = status.getCauseOfError(); >+ for (int i = 0; i < causeOfError.length; i++) >+ _viewer.reveal(causeOfError[i]); >+ _viewer.setSelection(new StructuredSelection(causeOfError)); >+ updateStatus(status.getErrorMessage()); >+ } >+ _importedOperations = getSelectedOperation(); >+ } >+ >+ private void updateStatus(String message) >+ { >+ setErrorMessage(message); >+ setPageComplete(message == null); >+ } >+ >+ private PortType getPortTypeOfChekedElement(Object checkedElement) >+ { >+ if (checkedElement instanceof PortType) >+ return (PortType) checkedElement; >+ Object parent = _contentProvider.getParent(checkedElement); >+ while (!(parent instanceof PortType)) >+ parent = _contentProvider.getParent(parent); >+ return (PortType) parent; >+ } >+ >+ /** >+ * Returns all the checked wsdl operations from viewer. >+ */ >+ private Operation[] getCheckedOperations() >+ { >+ Object[] checkedElements = _viewer.getCheckedElements(); >+ List selectedOperationList = new LinkedList(); >+ for (int i = 0; i < checkedElements.length; i++) >+ { >+ if (checkedElements[i] instanceof Operation) >+ selectedOperationList.add(checkedElements[i]); >+ } >+ return (Operation[]) selectedOperationList >+ .toArray(new Operation[selectedOperationList.size()]); >+ } >+ >+ public Operation[] getImportedOperations() >+ { >+ return _importedOperations; >+ } >+ >+ private Operation[] getSelectedOperation() >+ { >+ Operation[] checkedOperations = getCheckedOperations(); >+ List selectedOperations = new LinkedList(); >+ for (int i = 0; i < checkedOperations.length; i++) >+ { >+ PortType port = getPortTypeOfChekedElement(checkedOperations[i]); >+ boolean isImportOperation = true; >+ for (int j = 0; j < _existingPortTypes.length; j++) >+ { >+ if (_existingPortTypes[j].equals(port)) >+ { >+ isImportOperation = false; >+ break; >+ } >+ } >+ if (isImportOperation) >+ selectedOperations.add(checkedOperations[i]); >+ } >+ return (Operation[]) selectedOperations >+ .toArray(new Operation[selectedOperations.size()]); >+ } >+ >+ public IWizardPage getNextPage() >+ { >+ return null; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/WsdlPortTypeLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/WsdlPortTypeLabelProvider.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/WsdlPortTypeLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/WsdlPortTypeLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,82 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl; >+ >+import javax.wsdl.Message; >+import javax.wsdl.Operation; >+import javax.wsdl.PortType; >+ >+import org.eclipse.jface.resource.ImageRegistry; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >+ >+public class WsdlPortTypeLabelProvider extends LabelProvider implements >+ ILabelProvider >+{ >+ >+ private ImageRegistry imageRegistry; >+ private final static String PORT_KEY = "Port"; >+ private final static String OPERATION_KEY = "Operation"; >+ private final static String MESSAGE_KEY = "Message"; >+ >+ public WsdlPortTypeLabelProvider(Shell shell) >+ { >+ imageRegistry = new ImageRegistry(shell.getDisplay()); >+ >+ Image portImage = EclipseUtils.loadImage(shell.getDisplay(), >+ "icons/obj16/capability_obj.gif"); >+ imageRegistry.put(PORT_KEY, portImage); >+ >+ Image operationImage = EclipseUtils.loadImage(shell.getDisplay(), >+ "icons/obj16/userOperation_obj.gif"); >+ imageRegistry.put(OPERATION_KEY, operationImage); >+ >+ Image messageImage = EclipseUtils.loadImage(shell.getDisplay(), >+ "icons/obj16/sample.gif"); >+ imageRegistry.put(MESSAGE_KEY, messageImage); >+ } >+ >+ public Image getImage(Object element) >+ { >+ if (element instanceof PortType) >+ return imageRegistry.get(PORT_KEY); >+ else if (element instanceof Operation) >+ return imageRegistry.get(OPERATION_KEY); >+ else if (element instanceof Message) >+ return imageRegistry.get(MESSAGE_KEY); >+ return null; >+ } >+ >+ public String getText(Object element) >+ { >+ if (element instanceof PortType) >+ { >+ PortType port = (PortType) element; >+ return port.getQName().toString(); >+ } >+ else if (element instanceof Operation) >+ { >+ Operation operation = (Operation) element; >+ return operation.getName(); >+ } >+ else if (element instanceof Message) >+ { >+ Message message = (Message) element; >+ return message.getQName().toString(); >+ } >+ return element.toString(); >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportValidator.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportValidator.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportValidator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportValidator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,62 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils; >+ >+public class PropertyImportValidator >+{ >+ private Property[] _properties; >+ >+ public PropertyImportValidator(Property[] properties) >+ { >+ _properties = properties; >+ } >+ >+ public ImportValidationStatus validate() >+ { >+ Map propertyNames = new HashMap(); >+ if (_properties == null) >+ return null; >+ for (int i = 0; i < _properties.length; i++) >+ { >+ String propertyName = _properties[i].getElement().getName(); >+ >+ // Validate valid java identifier >+ String errorMessage = CapUtils.validateJavaIdentifier(propertyName); >+ if (errorMessage != null) >+ return new ImportValidationStatus(errorMessage, new Object[] >+ { _properties[i] }); >+ >+ // Validate duplicate property name >+ if (!propertyNames.containsKey(propertyName)) >+ propertyNames.put(propertyName, _properties[i]); >+ else >+ { >+ errorMessage = Messages.bind(Messages.DUPLICATE_PROPERTY, >+ propertyName); >+ Property causeOfError_1 = (Property) propertyNames >+ .get(propertyName); >+ Property causeOfError_2 = _properties[i]; >+ return new ImportValidationStatus(errorMessage, new Object[] >+ { causeOfError_1, causeOfError_2 }); >+ } >+ } >+ return null; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/CapabilityModelImporterPage.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/CapabilityModelImporterPage.java >diff -N src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/CapabilityModelImporterPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/CapabilityModelImporterPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,454 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.wizard.capability.internal; >+ >+import javax.wsdl.Definition; >+import javax.wsdl.Operation; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.window.Window; >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.tptp.wsdm.tooling.dialog.provisional.WSDLBrowseDialog; >+import org.eclipse.tptp.wsdm.tooling.dialog.provisional.XSDBrowseDialog; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl.OperationImportWizardPage; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.PropertyImportWizardPage; >+import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; >+import org.eclipse.xsd.XSDSchema; >+ >+/** >+ * Wizard page to import capability from XSD and WSDL files. >+ */ >+ >+public class CapabilityModelImporterPage extends WizardPage >+{ >+ private ISelection _selection; >+ >+ private NewCapabilityWizard _wizard; >+ >+ private Button _emptyCapability; >+ >+ private Button _fromXSD; >+ >+ private Text _xsdFilePathText; >+ >+ private Button _browseXSD; >+ >+ private Button _fromWSDL; >+ >+ private Text _wsdlFilePathText; >+ >+ private Button _browseWSDL; >+ >+ private Object[] _checkedItems; >+ >+ private Operation[] _importedOperations = new Operation[0]; >+ >+ private boolean _canFlipToNextPage = false; >+ >+ /** >+ * Creates new object of this class. >+ */ >+ protected CapabilityModelImporterPage(ISelection selection, >+ NewCapabilityWizard wizard) >+ { >+ super("wizardPage"); >+ _selection = selection; >+ _wizard = wizard; >+ setTitle(Messages.SELECT_CAPABILITY_IMPORTER); >+ } >+ >+ /** >+ * Creates wizard controls. >+ */ >+ public void createControl(Composite parent) >+ { >+ initializeDialogUnits(parent); >+ Composite container = new Composite(parent, SWT.NULL); >+ container.setFont(parent.getFont()); >+ container.setLayout(new GridLayout()); >+ container.setLayoutData(new GridData()); >+ >+ _emptyCapability = new Button(container, SWT.RADIO); >+ _emptyCapability.setText(Messages.CREATE_EMPTY_CAPABILITY); >+ _emptyCapability.addSelectionListener(new SelectionAdapter() >+ { >+ public void widgetSelected(SelectionEvent e) >+ { >+ handleEmptyCapabilityButtonSelection(); >+ } >+ }); >+ >+ createFromXSDControl(container); >+ createFromWSDLControl(container); >+ >+ intialize(); >+ >+ setControl(container); >+ Dialog.applyDialogFont(parent); >+ } >+ >+ private void handleEmptyCapabilityButtonSelection() >+ { >+ _fromXSD.setSelection(false); >+ _browseXSD.setEnabled(false); >+ _xsdFilePathText.setEnabled(false); >+ _fromWSDL.setSelection(false); >+ _browseWSDL.setEnabled(false); >+ _wsdlFilePathText.setEnabled(false); >+ setMessage(Messages.CREATE_EMPTY_CAPABILITY); >+ _wizard.getOperationImportWizardPage().setPageComplete(true); >+ _wizard.getPropertyImportWizardPage().setPageComplete(true); >+ dialogChanged(); >+ } >+ >+ private void createFromXSDControl(Composite parent) >+ { >+ Composite fromXSDComposite = new Composite(parent, SWT.NULL); >+ GridLayout layout = new GridLayout(2, false); >+ layout.marginWidth = 0; >+ fromXSDComposite.setLayout(layout); >+ GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false); >+ fromXSDComposite.setLayoutData(gd); >+ >+ _fromXSD = new Button(fromXSDComposite, SWT.RADIO); >+ _fromXSD >+ .setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.DEFINE_CAPABILITY_FROM_XSD); >+ _fromXSD.addSelectionListener(new SelectionAdapter() >+ { >+ public void widgetSelected(SelectionEvent e) >+ { >+ handleFromXSDButtonSelection(); >+ } >+ }); >+ gd = new GridData(); >+ gd.horizontalSpan = 2; >+ _fromXSD.setLayoutData(gd); >+ >+ _xsdFilePathText = new Text(fromXSDComposite, SWT.BORDER); >+ gd = new GridData(SWT.FILL, SWT.NONE, true, false); >+ gd.horizontalIndent = 15; >+ _xsdFilePathText.setLayoutData(gd); >+ _xsdFilePathText.addModifyListener(new ModifyListener() >+ { >+ public void modifyText(ModifyEvent e) >+ { >+ dialogChanged(); >+ } >+ }); >+ >+ _browseXSD = createBrowseWorkspaceButton(fromXSDComposite); >+ _browseXSD.addSelectionListener(new SelectionAdapter() >+ { >+ public void widgetSelected(SelectionEvent e) >+ { >+ handleXSDBrowse(); >+ } >+ }); >+ _browseXSD.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); >+ } >+ >+ private void handleFromXSDButtonSelection() >+ { >+ _emptyCapability.setSelection(false); >+ _browseXSD.setEnabled(true); >+ _xsdFilePathText.setEnabled(true); >+ _fromWSDL.setSelection(false); >+ _browseWSDL.setEnabled(false); >+ _wsdlFilePathText.setEnabled(false); >+ setMessage(Messages.IMPORT_PROPERTIES_FROM_XSD); >+ dialogChanged(); >+ } >+ >+ private void createFromWSDLControl(Composite parent) >+ { >+ Composite fromWSDLComposite = new Composite(parent, SWT.NULL); >+ GridLayout layout = new GridLayout(2, false); >+ layout.marginWidth = 0; >+ fromWSDLComposite.setLayout(layout); >+ GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false); >+ fromWSDLComposite.setLayoutData(gd); >+ >+ _fromWSDL = new Button(fromWSDLComposite, SWT.RADIO); >+ _fromWSDL >+ .setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.DEFINE_CAPABILITY_FROM_WSDL); >+ _fromWSDL.addSelectionListener(new SelectionAdapter() >+ { >+ public void widgetSelected(SelectionEvent e) >+ { >+ handleFromWSDLButtonSelection(); >+ } >+ }); >+ gd = new GridData(); >+ gd.horizontalSpan = 2; >+ _fromWSDL.setLayoutData(gd); >+ >+ _wsdlFilePathText = new Text(fromWSDLComposite, SWT.BORDER); >+ gd = new GridData(SWT.FILL, SWT.NONE, true, false); >+ gd.horizontalIndent = 15; >+ _wsdlFilePathText.setLayoutData(gd); >+ _wsdlFilePathText.addModifyListener(new ModifyListener() >+ { >+ public void modifyText(ModifyEvent e) >+ { >+ dialogChanged(); >+ } >+ }); >+ >+ _browseWSDL = createBrowseWorkspaceButton(fromWSDLComposite); >+ _browseWSDL.addSelectionListener(new SelectionAdapter() >+ { >+ public void widgetSelected(SelectionEvent e) >+ { >+ handleWSDLBrowse(); >+ } >+ }); >+ _browseWSDL.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); >+ } >+ >+ private void handleFromWSDLButtonSelection() >+ { >+ _emptyCapability.setSelection(false); >+ _fromXSD.setSelection(false); >+ _browseXSD.setEnabled(false); >+ _xsdFilePathText.setEnabled(false); >+ _browseWSDL.setEnabled(true); >+ _wsdlFilePathText.setEnabled(true); >+ setMessage(Messages.IMPORT_OPERATIONS_FROM_WSDL); >+ dialogChanged(); >+ } >+ >+ private void intialize() >+ { >+ _emptyCapability.setSelection(true); >+ _browseXSD.setEnabled(false); >+ _xsdFilePathText.setEnabled(false); >+ _browseWSDL.setEnabled(false); >+ _wsdlFilePathText.setEnabled(false); >+ setMessage(Messages.CREATE_EMPTY_CAPABILITY); >+ } >+ >+ private Button createBrowseWorkspaceButton(Composite container) >+ { >+ Button browseButton = new Button(container, SWT.PUSH); >+ browseButton.setText(Messages.BROWSE_WORKSPACE); >+ GridData gd = new GridData(GridData.END); >+ gd.grabExcessHorizontalSpace = true; >+ browseButton.setLayoutData(gd); >+ return browseButton; >+ } >+ >+ private void handleXSDBrowse() >+ { >+ XSDBrowseDialog dialog = new XSDBrowseDialog(getShell()); >+ if (dialog.open() == Window.OK) >+ { >+ IFile browsedFile = (IFile) dialog.getFirstResult(); >+ XSDSchema xsdSchema = XsdUtils.getSchema(browsedFile); >+ _xsdFilePathText.setText(browsedFile.getFullPath().toString()); >+ // TODO Check for valid file >+ } >+ } >+ >+ private void handleWSDLBrowse() >+ { >+ WSDLBrowseDialog dialog = new WSDLBrowseDialog(getShell()); >+ if (dialog.open() == Window.OK) >+ { >+ IFile browsedFile = (IFile) dialog.getFirstResult(); >+ try >+ { >+ WsdlUtils.getCapabilityDefinition(browsedFile); >+ } >+ catch (Exception e) >+ { >+ MessageDialog >+ .openError( >+ getShell(), >+ "Error", >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.IMPROPER_WSDL_FILE); >+ return; >+ } >+ _wsdlFilePathText.setText(browsedFile.getFullPath().toString()); >+ } >+ } >+ >+ /** >+ * Returns the imported XSD schemas specified. >+ */ >+ /* >+ * protected XSDSchema[] getSchemaToImport() { >+ * if(_emptyCapability.getSelection() || _fromWSDL.getSelection()) return >+ * new XSDSchema[0]; return new XSDSchema[0]; } >+ */ >+ >+ /** >+ * Returns the imported Operations specified. >+ */ >+ /* >+ * protected Operation[] getOperationsToImport() { >+ * if(_emptyCapability.getSelection() || _fromXSD.getSelection()) return new >+ * Operation[0]; return _importedOperations; } >+ */ >+ >+ private void dialogChanged() >+ { >+ if (_fromXSD.getSelection()) >+ { >+ String xsdFilePath = getXSDFilePath(); >+ if (!isValidWorkspaceFile(xsdFilePath)) >+ { >+ updateStatus(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.SPECIFY_EXISTING_XSD); >+ return; >+ } >+ >+ } >+ if (_fromWSDL.getSelection()) >+ { >+ String wsdlFilePath = getWSDLFilePath(); >+ if (!isValidWorkspaceFile(wsdlFilePath)) >+ { >+ updateStatus(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages.SPECIFY_EXISTING_WSDL); >+ return; >+ } >+ } >+ updateStatus(null); >+ } >+ >+ private void updateStatus(String message) >+ { >+ _canFlipToNextPage = true; >+ if (message != null) >+ _canFlipToNextPage = false; >+ if (_emptyCapability.getSelection()) >+ _canFlipToNextPage = false; >+ setErrorMessage(message); >+ setPageComplete(message == null && _emptyCapability.getSelection()); >+ } >+ >+ private String getXSDFilePath() >+ { >+ return _xsdFilePathText.getText(); >+ } >+ >+ private String getWSDLFilePath() >+ { >+ return _wsdlFilePathText.getText(); >+ } >+ >+ private boolean isValidWorkspaceFile(String filePath) >+ { >+ try >+ { >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ IFile file = root.getFile(new Path(filePath)); >+ if (file == null || (!file.exists())) >+ return false; >+ } >+ catch (Exception e) >+ { >+ return false; >+ } >+ return true; >+ } >+ >+ public IWizardPage getNextPage() >+ { >+ if (_emptyCapability.getSelection()) >+ { >+ return null; >+ } >+ if (_fromWSDL.getSelection()) >+ { >+ try >+ { >+ _wizard.getPropertyImportWizardPage().setPageComplete(true); >+ String wsdlFilePath = getWSDLFilePath(); >+ IFile wsdlFile = EclipseUtils.getIFile(wsdlFilePath); >+ CapabilityDefinition capabilityDefinition = WsdlUtils >+ .getCapabilityDefinition(wsdlFile); >+ Definition wsdlDefinition = capabilityDefinition >+ .getDefinition(); >+ OperationImportWizardPage page = _wizard >+ .getOperationImportWizardPage(); >+ page.setWSDLDefinition(wsdlDefinition); >+ setPageComplete(true); >+ return page; >+ } >+ catch (Exception e) >+ { >+ e.printStackTrace(); >+ } >+ } >+ if (_fromXSD.getSelection()) >+ { >+ try >+ { >+ _wizard.getOperationImportWizardPage().setPageComplete(true); >+ String xsdFilePath = getXSDFilePath(); >+ IFile xsdFile = EclipseUtils.getIFile(xsdFilePath); >+ XSDSchema importSchema = XsdUtils.getSchema(xsdFile); >+ PropertyImportWizardPage page = _wizard >+ .getPropertyImportWizardPage(); >+ page.setImportSchema(importSchema); >+ setPageComplete(true); >+ return page; >+ } >+ catch (Exception e) >+ { >+ e.printStackTrace(); >+ } >+ } >+ return super.getNextPage(); >+ } >+ >+ public boolean canFlipToNextPage() >+ { >+ return _canFlipToNextPage; >+ } >+ >+ public boolean isEmptyCapabilityButtonSelected() >+ { >+ return _emptyCapability.getSelection(); >+ } >+ >+ public boolean isFromXSDButtonSelected() >+ { >+ return _fromXSD.getSelection(); >+ } >+ >+ public boolean isFromWSDLButtonSelected() >+ { >+ return _fromWSDL.getSelection(); >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/imports/internal/messages.properties >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/imports/internal/messages.properties >diff -N src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/imports/internal/messages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/imports/internal/messages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+############################################################################### >+# Copyright (c) 2007 IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# Balan Subramanian (bsubram@us.ibm.com) >+# IBM Corporation - initial API and implementation >+############################################################################### >+IMPORT_OPERATIONS = Import operations >+IMPORTING_OPERATIONS = Importing operations >+IMPORTING_OPERATION = Importing operation : {0} >+OPERATION_IMPORT_WIZARD_PAGE_TITLE = Select operations to import >+OPERATION_IMPORT_WIZARD_PAGE_DESCRIPTION = Select operations to import from WSDL file to defined this capability >+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. >+AVAILABLE_OPERATIONS_LABEL = Available WSDL file operations: >+DUPLICATE_OPERATION = Duplicate operation : {0} >+NOT_DOC_LITERAL_MESSAGE = Message is not of doc literal type >+CONFLICTED_MESSAGE = Conflicted message : >+INPUT_MESSAGE_NOT_DEFINED = Input message must be defined >+OUTPUT_MESSAGE_NOT_DEFINED = Output message must be defined >+IMPROPER_WSDL_FILE = Improper wsdl file >+DEFINE_CAPABILITY_FROM_WSDL = Define capability from existing WSDL file: >+SPECIFY_EXISTING_WSDL = Please specify existing WSDL file >+ >+IMPORT_PROPERTIES = Import properties >+IMPORTING_PROPERTIES = Importing properties >+IMPORTING_PROPERTY = Importing property : {0} >+DUPLICATE_PROPERTY = Duplicate property : {0} >+PROPERTY_IMPORT_WIZARD_PAGE_TITLE = Select properties to import >+PROPERTY_IMPORT_WIZARD_PAGE_DESCRIPTION = Select properties to import from XSD file to defined this capability >+AVAILABLE_PROPERTIES_LABEL = Available XSD file properties: >+DEFINE_CAPABILITY_FROM_XSD = Define capability from existing XSD schema file: >+SPECIFY_EXISTING_XSD = Please specify existing XSD schema file >+ >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ImportPropertyCommand.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ImportPropertyCommand.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ImportPropertyCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ImportPropertyCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,158 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal; >+ >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; >+import org.eclipse.xsd.XSDComplexTypeDefinition; >+import org.eclipse.xsd.XSDCompositor; >+import org.eclipse.xsd.XSDElementDeclaration; >+import org.eclipse.xsd.XSDFactory; >+import org.eclipse.xsd.XSDModelGroup; >+import org.eclipse.xsd.XSDParticle; >+import org.eclipse.xsd.XSDSchema; >+ >+public class ImportPropertyCommand >+{ >+ private XSDElementDeclaration _resourcePropertyElement; >+ private Property[] _importedProperties; >+ private List _newProperties = new LinkedList(); >+ private List _newSchemas = new LinkedList(); >+ private IProgressMonitor _monitor; >+ >+ public ImportPropertyCommand(XSDElementDeclaration resourcePropertyElement, >+ Property[] importedProperties, IProgressMonitor monitor) >+ { >+ _resourcePropertyElement = resourcePropertyElement; >+ _importedProperties = importedProperties; >+ _monitor = monitor; >+ if (monitor == null) >+ _monitor = new NullProgressMonitor(); >+ } >+ >+ public ImportPropertyCommand(XSDElementDeclaration resourcePropertyElement, >+ Property[] importedProperties) >+ { >+ this(resourcePropertyElement, importedProperties, null); >+ } >+ >+ public void execute() >+ { >+ _monitor.beginTask(Messages.IMPORTING_PROPERTIES, >+ _importedProperties.length); >+ for (int i = 0; i < _importedProperties.length; i++) >+ { >+ String taskName = Messages.bind(Messages.IMPORTING_PROPERTY, >+ _importedProperties[i].getElement().getName()); >+ _monitor.setTaskName(taskName); >+ Property newProperty = createNewProperty(_importedProperties[i]); >+ _newProperties.add(newProperty); >+ if (!_newSchemas.contains(newProperty.getElement().getSchema())) >+ _newSchemas.add(newProperty.getElement().getSchema()); >+ _monitor.worked(i + 1); >+ } >+ } >+ >+ private Property createNewProperty(Property importedProperty) >+ { >+ // Get the location for Imported XSD Schema in local drive format >+ XSDSchema importSchema = importedProperty.getElement().getSchema(); >+ // String schemaLocation = >+ // XsdUtils.getLocalSystemSchemaLocation(importSchema); >+ >+ // Get the location for capability file >+ // String capFileLocation = null; >+ // try { >+ // capFileLocation = >+ // WsdlUtils.getLocalSystemWSDLLocation(_capabilityDefinition); >+ // } catch (CoreException e) { >+ // e.printStackTrace(); >+ // } >+ >+ // Create xsd:import element >+ // String importSchemaLocation = EclipseUtils.getRelativePath( >+ // capFileLocation, schemaLocation, '/'); >+ // XsdUtils.createImportStatement(_resourcePropertyElement.getSchema(), >+ // importSchema.getTargetNamespace(), importSchemaLocation); >+ >+ XsdUtils.createImportStatement(_resourcePropertyElement.getSchema(), >+ importSchema.getTargetNamespace(), importSchema.eResource() >+ .getURI().toString()); >+ >+ // Prepare resource property element >+ XSDModelGroup modelGroup = getXSDModelGroup(); >+ >+ // Add element to resource properties >+ XSDElementDeclaration propertyRef = XSDFactory.eINSTANCE >+ .createXSDElementDeclaration(); >+ propertyRef >+ .setResolvedElementDeclaration(importedProperty.getElement()); >+ XSDParticle simpleElementParticle = XSDFactory.eINSTANCE >+ .createXSDParticle(); >+ simpleElementParticle.setContent(propertyRef); >+ modelGroup.getContents().add(simpleElementParticle); >+ >+ // Create Capability property representation >+ Property newProperty = CapabilitiesFactory.INSTANCE.createProperty(); >+ newProperty.setElement(importedProperty.getElement()); >+ return newProperty; >+ } >+ >+ private XSDModelGroup getXSDModelGroup() >+ { >+ XSDModelGroup modelGroup = null; >+ if (_resourcePropertyElement.getAnonymousTypeDefinition() == null) >+ { >+ // Create New XSD Model Group >+ modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup(); >+ modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL); >+ >+ XSDParticle xsdParticle = XSDFactory.eINSTANCE.createXSDParticle(); >+ xsdParticle.setContent(modelGroup); >+ >+ XSDComplexTypeDefinition complexTypeDefiniton = XSDFactory.eINSTANCE >+ .createXSDComplexTypeDefinition(); >+ complexTypeDefiniton.setContent(xsdParticle); >+ _resourcePropertyElement >+ .setAnonymousTypeDefinition(complexTypeDefiniton); >+ } >+ else >+ { >+ // Get the XSD Model Group >+ XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) _resourcePropertyElement >+ .getAnonymousTypeDefinition(); >+ modelGroup = XsdUtils.getXSDModelGroup(typeDef); >+ } >+ return modelGroup; >+ } >+ >+ public Property[] getNewProperties() >+ { >+ return (Property[]) _newProperties.toArray(new Property[_newProperties >+ .size()]); >+ } >+ >+ public XSDSchema[] getNewSchemas() >+ { >+ return (XSDSchema[]) _newSchemas.toArray(new XSDSchema[_newSchemas >+ .size()]); >+ } >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/WsdlPortTypeContentProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/WsdlPortTypeContentProvider.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/WsdlPortTypeContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/WsdlPortTypeContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,113 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl; >+ >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+import java.util.Map; >+ >+import javax.wsdl.Fault; >+import javax.wsdl.Operation; >+import javax.wsdl.PortType; >+ >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.Viewer; >+ >+public class WsdlPortTypeContentProvider implements ITreeContentProvider >+{ >+ >+ private final Map _parentMap; >+ >+ public WsdlPortTypeContentProvider() >+ { >+ _parentMap = new HashMap(); >+ } >+ >+ public Object[] getChildren(Object parentElement) >+ { >+ if (parentElement instanceof List) >+ { >+ List l = (List) parentElement; >+ return l.toArray(); >+ } >+ else if (parentElement instanceof PortType) >+ { >+ PortType port = (PortType) parentElement; >+ Object[] operations = rememberChildren(parentElement, port >+ .getOperations()); >+ return operations; >+ } >+ else if (parentElement instanceof Operation) >+ { >+ Operation operation = (Operation) parentElement; >+ List messagesList = new LinkedList(); >+ if (operation.getInput() != null) >+ messagesList.add(operation.getInput().getMessage()); >+ if (operation.getOutput() != null) >+ messagesList.add(operation.getOutput().getMessage()); >+ Map faultsMap = operation.getFaults(); >+ Iterator it = faultsMap.values().iterator(); >+ while (it.hasNext()) >+ { >+ Object object = it.next(); >+ if (object instanceof Fault) >+ { >+ Fault fault = (Fault) object; >+ messagesList.add(fault.getMessage()); >+ } >+ } >+ Object[] messages = rememberChildren(parentElement, messagesList); >+ return messages; >+ } >+ return new Object[0]; >+ } >+ >+ public Object getParent(Object element) >+ { >+ Object retVal = _parentMap.get(element); >+ return retVal; >+ } >+ >+ public boolean hasChildren(Object element) >+ { >+ return (getChildren(element).length > 0); >+ } >+ >+ public Object[] getElements(Object inputElement) >+ { >+ return getChildren(inputElement); >+ } >+ >+ public void dispose() >+ { >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) >+ { >+ } >+ >+ private Object[] rememberChildren(Object parent, List childrens) >+ { >+ Object[] retVal = new Object[childrens.size()]; >+ for (int i = 0; i < retVal.length; i++) >+ { >+ Object child = childrens.get(i); >+ _parentMap.put(child, parent); >+ retVal[i] = child; >+ } >+ return retVal; >+ } >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyNamespace.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyNamespace.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyNamespace.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyNamespace.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd; >+ >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+ >+public class PropertyNamespace >+{ >+ private String _namespace; >+ private List _properties; >+ >+ public PropertyNamespace(String namespace) >+ { >+ _namespace = namespace; >+ _properties = new LinkedList(); >+ } >+ >+ public void addProperty(Property property) >+ { >+ if (property != null) >+ _properties.add(property); >+ } >+ >+ public Property[] getProperties() >+ { >+ return (Property[]) _properties >+ .toArray(new Property[_properties.size()]); >+ } >+ >+ public String getNamespace() >+ { >+ return _namespace; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizard.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizard.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,134 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd; >+ >+import java.lang.reflect.InvocationTargetException; >+import java.util.Arrays; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ImportPropertyCommand; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; >+import org.eclipse.ui.INewWizard; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.xsd.XSDElementDeclaration; >+import org.eclipse.xsd.XSDSchema; >+ >+public class PropertyImportWizard extends Wizard implements INewWizard >+{ >+ >+ private CapabilityDomain _capabilityDomain; >+ private XSDSchema _importSchema; >+ private PropertyNamespace[] _existingPropertyNs = new PropertyNamespace[0]; >+ private PropertyImportWizardPage _importPage; >+ >+ public PropertyImportWizard(CapabilityDomain capabilityDomain, >+ XSDSchema importSchema) >+ { >+ super(); >+ setWindowTitle(Messages.IMPORT_PROPERTIES); >+ setNeedsProgressMonitor(true); >+ _capabilityDomain = capabilityDomain; >+ _importSchema = importSchema; >+ _existingPropertyNs = createPropertiesNamespacesFromCapability(); >+ } >+ >+ public void addPages() >+ { >+ _importPage = new PropertyImportWizardPage(_importSchema, >+ _existingPropertyNs); >+ addPage(_importPage); >+ } >+ >+ public boolean performFinish() >+ { >+ IRunnableWithProgress runnable = new IRunnableWithProgress() >+ { >+ public void run(IProgressMonitor monitor) >+ throws InvocationTargetException, InterruptedException >+ { >+ performFinish(monitor); >+ } >+ }; >+ try >+ { >+ getContainer().run(true, false, runnable); >+ return true; >+ } >+ catch (Exception e) >+ { >+ e.printStackTrace(); >+ } >+ return false; >+ } >+ >+ private void performFinish(IProgressMonitor monitor) >+ { >+ Property[] importedProperties = _importPage.getImportedProperties(); >+ ImportPropertyCommand command = new ImportPropertyCommand( >+ _capabilityDomain.getResourcePropertyElement(), >+ importedProperties, monitor); >+ command.execute(); >+ Property[] newProperties = command.getNewProperties(); >+ _capabilityDomain.getCapability().getProperties().addAll( >+ Arrays.asList(newProperties)); >+ XSDSchema[] newSchemas = command.getNewSchemas(); >+ for (int i = 0; i < newSchemas.length; i++) >+ _capabilityDomain.addPropertySchema(newSchemas[i]); >+ } >+ >+ public void init(IWorkbench workbench, IStructuredSelection selection) >+ { >+ } >+ >+ private PropertyNamespace[] createPropertiesNamespacesFromCapability() >+ { >+ Map propNamespacesMap = new HashMap(); >+ List properties = _capabilityDomain.getCapability().getProperties(); >+ for (int i = 0; i < properties.size(); i++) >+ { >+ Property property = (Property) properties.get(i); >+ XSDElementDeclaration propertyElement = property.getElement(); >+ PropertyNamespace propertyNamespace = (PropertyNamespace) propNamespacesMap >+ .get(propertyElement.getTargetNamespace()); >+ if (propertyNamespace == null) >+ { >+ propertyNamespace = new PropertyNamespace(propertyElement >+ .getTargetNamespace()); >+ propNamespacesMap.put(propertyElement.getTargetNamespace(), >+ propertyNamespace); >+ } >+ propertyNamespace.addProperty(property); >+ } >+ >+ List propNamespacesList = new LinkedList(); >+ Iterator keyIt = propNamespacesMap.keySet().iterator(); >+ while (keyIt.hasNext()) >+ { >+ Object key = keyIt.next(); >+ propNamespacesList.add(propNamespacesMap.get(key)); >+ } >+ >+ return (PropertyNamespace[]) propNamespacesList >+ .toArray(new PropertyNamespace[propNamespacesList.size()]); >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizard.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizard.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,101 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl; >+ >+import java.lang.reflect.InvocationTargetException; >+import java.util.Arrays; >+import java.util.Map; >+ >+import javax.wsdl.Definition; >+import javax.wsdl.Operation; >+import javax.wsdl.PortType; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal.ImportOperationCommand; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; >+import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; >+import org.eclipse.ui.INewWizard; >+import org.eclipse.ui.IWorkbench; >+ >+public class OperationImportWizard extends Wizard implements INewWizard >+{ >+ >+ private CapabilityDomain _capabilityDomain; >+ private Definition _wsdlDefinition; >+ private PortType[] _existingPortTypes = new PortType[0]; >+ private OperationImportWizardPage _importPage; >+ >+ public OperationImportWizard(CapabilityDomain capabilityDomain, >+ Definition definition) >+ { >+ super(); >+ setWindowTitle(Messages.IMPORT_OPERATIONS); >+ setNeedsProgressMonitor(true); >+ _capabilityDomain = capabilityDomain; >+ _wsdlDefinition = definition; >+ Map portsMap = capabilityDomain.getCapability().getWsdlDefinition() >+ .getDefinition().getPortTypes(); >+ _existingPortTypes = (PortType[]) portsMap.values().toArray( >+ new PortType[portsMap.size()]); >+ } >+ >+ public void addPages() >+ { >+ _importPage = new OperationImportWizardPage(_wsdlDefinition, >+ _existingPortTypes); >+ addPage(_importPage); >+ } >+ >+ public boolean performFinish() >+ { >+ IRunnableWithProgress runnable = new IRunnableWithProgress() >+ { >+ public void run(IProgressMonitor monitor) >+ throws InvocationTargetException, InterruptedException >+ { >+ performFinish(monitor); >+ } >+ }; >+ try >+ { >+ getContainer().run(true, false, runnable); >+ return true; >+ } >+ catch (Exception e) >+ { >+ e.printStackTrace(); >+ } >+ return false; >+ } >+ >+ private void performFinish(IProgressMonitor monitor) >+ { >+ Operation[] importOperations = _importPage.getImportedOperations(); >+ CapabilityDefinition capabilityDefinition = (CapabilityDefinition) _capabilityDomain >+ .getCapability().getWsdlDefinition(); >+ ImportOperationCommand command = new ImportOperationCommand( >+ capabilityDefinition, importOperations, monitor); >+ command.execute(); >+ Operation[] newOperations = command.getNewOperations(); >+ _capabilityDomain.getCapability().getOperations().addAll( >+ Arrays.asList(newOperations)); >+ } >+ >+ public void init(IWorkbench workbench, IStructuredSelection selection) >+ { >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewIFileNameGenerator.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewIFileNameGenerator.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewIFileNameGenerator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewIFileNameGenerator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,93 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+ >+public class NewIFileNameGenerator implements INewNameGenerator >+{ >+ private IResource _resource; >+ private String _namePattern; >+ >+ public NewIFileNameGenerator(IResource resource, String namePattern) >+ { >+ _resource = resource; >+ if (namePattern == null || namePattern.trim().equals("")) >+ namePattern = "NewFile.tmp"; >+ if (namePattern.indexOf('.') == -1) >+ { >+ namePattern = "NewFile.tmp"; >+ } >+ _namePattern = namePattern; >+ } >+ >+ public String getNewName() >+ { >+ IResource[] members = null; >+ if (_resource instanceof IProject) >+ { >+ IProject project = (IProject) _resource; >+ try >+ { >+ members = project.members(); >+ } >+ catch (CoreException e) >+ { >+ return _namePattern; >+ } >+ } >+ else if (_resource instanceof IFolder) >+ { >+ IFolder folder = (IFolder) _resource; >+ try >+ { >+ members = folder.members(); >+ } >+ catch (CoreException e) >+ { >+ return _namePattern; >+ } >+ } >+ >+ int count = 0; >+ while (isFileExists(members, _namePattern)) >+ { >+ String fileNameWithoutExtn = _namePattern.substring(0, _namePattern >+ .lastIndexOf('.')); >+ String fileExtn = _namePattern.substring(_namePattern >+ .lastIndexOf('.') + 1); >+ _namePattern = fileNameWithoutExtn + count + "." + fileExtn; >+ count++; >+ } >+ return _namePattern; >+ } >+ >+ private boolean isFileExists(IResource[] resources, String fileName) >+ { >+ for (int i = 0; i < resources.length; i++) >+ { >+ if (resources[i] instanceof IFile) >+ { >+ IFile file = (IFile) resources[i]; >+ if (file.getName().equals(fileName)) >+ return true; >+ } >+ } >+ return false; >+ } >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/imports/internal/Messages.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/imports/internal/Messages.java >diff -N src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/imports/internal/Messages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/imports/internal/Messages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,52 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal; >+ >+import org.eclipse.osgi.util.NLS; >+ >+public class Messages extends NLS >+{ >+ private static final String BUNDLE_NAME = "org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.messages"; //$NON-NLS-1$ >+ >+ public static String IMPORT_OPERATIONS; >+ public static String IMPORTING_OPERATIONS; >+ public static String IMPORTING_OPERATION; >+ public static String OPERATION_IMPORT_WIZARD_PAGE_TITLE; >+ public static String OPERATION_IMPORT_WIZARD_PAGE_DESCRIPTION; >+ public static String OPERATION_IMPORT_WIZARD_PAGE_INFO_LABEL; >+ public static String AVAILABLE_OPERATIONS_LABEL; >+ public static String DUPLICATE_OPERATION; >+ public static String NOT_DOC_LITERAL_MESSAGE; >+ public static String CONFLICTED_MESSAGE; >+ public static String INPUT_MESSAGE_NOT_DEFINED; >+ public static String OUTPUT_MESSAGE_NOT_DEFINED; >+ public static String IMPROPER_WSDL_FILE; >+ public static String DEFINE_CAPABILITY_FROM_WSDL; >+ public static String SPECIFY_EXISTING_WSDL; >+ >+ public static String IMPORT_PROPERTIES; >+ public static String IMPORTING_PROPERTIES; >+ public static String IMPORTING_PROPERTY; >+ public static String DUPLICATE_PROPERTY; >+ public static String PROPERTY_IMPORT_WIZARD_PAGE_TITLE; >+ public static String PROPERTY_IMPORT_WIZARD_PAGE_DESCRIPTION; >+ public static String AVAILABLE_PROPERTIES_LABEL; >+ public static String DEFINE_CAPABILITY_FROM_XSD; >+ public static String SPECIFY_EXISTING_XSD; >+ >+ static >+ { >+ NLS.initializeMessages(BUNDLE_NAME, Messages.class); >+ } >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewWSDLMessageNameGenerator.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewWSDLMessageNameGenerator.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewWSDLMessageNameGenerator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewWSDLMessageNameGenerator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator; >+ >+import javax.wsdl.Definition; >+ >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; >+ >+public class NewWSDLMessageNameGenerator implements INewNameGenerator >+{ >+ private Definition _definition; >+ private String _namePattern; >+ >+ public NewWSDLMessageNameGenerator(Definition definition, String namePattern) >+ { >+ _definition = definition; >+ if (namePattern == null || namePattern.trim().equals("")) >+ namePattern = "NewMessage"; >+ _namePattern = namePattern; >+ } >+ >+ public NewWSDLMessageNameGenerator(Definition definition) >+ { >+ this(definition, null); >+ } >+ >+ public String getNewName() >+ { >+ int count = 0; >+ while (WsdlUtils.getWSDLMessage(_definition, _namePattern) != null) >+ { >+ _namePattern = _namePattern + count; >+ count++; >+ } >+ return _namePattern; >+ } >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorage.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorage.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,94 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.internal; >+ >+import java.io.InputStream; >+ >+import org.eclipse.core.resources.IStorage; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.PlatformObject; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >+ >+/** >+ * This class has been designed to use for opening any existing capability from >+ * within MRT file.<br> >+ * This class implements the IStorage interface which is used to represent a >+ * storage object as a stream of bytes.<br> >+ */ >+ >+public class CapabilityStorage extends PlatformObject implements >+ ICapabilityStorage >+{ >+ >+ private Capability _capability; >+ >+ public CapabilityStorage(Capability capability) >+ { >+ _capability = capability; >+ } >+ >+ public InputStream getContents() throws CoreException >+ { >+ /* >+ * Definition definition = >+ * _capability.getWsdlDefinition().getDefinition(); String str = >+ * CapUtils.toString(definition.getDocumentationElement().getOwnerDocument()); >+ * StringBufferInputStream stream = new StringBufferInputStream(str); >+ * return stream; >+ */ >+ >+ // We use the getFullPath() method to load the definition in capability >+ // editor >+ return null; >+ } >+ >+ public IPath getFullPath() >+ { >+ String path = null; >+ if (_capability.getWsdlDefinition().getWSDLFileProtocalURI() != null) >+ path = _capability.getWsdlDefinition().getWSDLFileProtocalURI() >+ .toString(); >+ else if (_capability.getWsdlDefinition().getWSDLResourceProtocolURI() != null) >+ path = _capability.getWsdlDefinition().getWSDLResourceProtocolURI() >+ .toString(); >+ return new Path(path); >+ } >+ >+ public String getName() >+ { >+ return _capability.getName(); >+ } >+ >+ public boolean isReadOnly() >+ { >+ if (getFullPath().toString().startsWith("platform:/plugin")) >+ return true; >+ return false; >+ } >+ >+ public boolean exists() >+ { >+ // TODO Find out more efficient way to do this >+ return _capability.getWsdlDefinition().getDefinition() != null; >+ } >+ >+} >+ >+interface ICapabilityStorage extends IStorage >+{ >+ >+ boolean exists(); >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertySchemaLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertySchemaLabelProvider.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertySchemaLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertySchemaLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,93 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd; >+ >+import org.eclipse.jface.resource.ImageRegistry; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >+import org.eclipse.xsd.XSDElementDeclaration; >+import org.eclipse.xsd.XSDSchema; >+ >+public class PropertySchemaLabelProvider extends LabelProvider implements >+ ILabelProvider >+{ >+ private ImageRegistry imageRegistry; >+ private final static String PROPERTY_NAMESPACE_KEY = "PropertyNamespace"; >+ private final static String PROPERTY_KEY = "Property"; >+ >+ public PropertySchemaLabelProvider(Shell shell) >+ { >+ imageRegistry = new ImageRegistry(shell.getDisplay()); >+ >+ Image propNamespaceImage = EclipseUtils.loadImage(shell.getDisplay(), >+ "icons/obj16/capability_obj.gif"); >+ imageRegistry.put(PROPERTY_NAMESPACE_KEY, propNamespaceImage); >+ >+ Image propertyImage = EclipseUtils.loadImage(shell.getDisplay(), >+ "icons/obj16/property_obj.gif"); >+ imageRegistry.put(PROPERTY_KEY, propertyImage); >+ } >+ >+ public Image getImage(Object element) >+ { >+ if (element instanceof PropertyNamespace) >+ return imageRegistry.get(PROPERTY_NAMESPACE_KEY); >+ else if (element instanceof Property) >+ return imageRegistry.get(PROPERTY_KEY); >+ return null; >+ } >+ >+ public String getText(Object element) >+ { >+ if (element instanceof PropertyNamespace) >+ { >+ /* >+ * XSDSchema schema = (XSDSchema) element; String schemaLocation = >+ * getSchemaLocation(schema); String namespace = >+ * schema.getTargetNamespace(); return namespace+" ( >+ * "+schemaLocation+" )"; >+ */ >+ PropertyNamespace propNamespace = (PropertyNamespace) element; >+ return propNamespace.getNamespace(); >+ } >+ else if (element instanceof Property) >+ { >+ Property property = (Property) element; >+ XSDElementDeclaration propertyElement = property.getElement(); >+ return propertyElement.getName(); >+ } >+ return element.toString(); >+ } >+ >+ private String getSchemaLocation(XSDSchema schema) >+ { >+ String location = schema.eResource().getURI().toString(); >+ if (location.startsWith("platform:/resource")) >+ { >+ int index = location.indexOf("platform:/resource") >+ + "platform:/resource".length(); >+ location = location.substring(index); >+ } >+ else if (location.startsWith("platform:/plugin")) >+ { >+ int index = location.indexOf("platform:/plugin") >+ + "platform:/plugin".length(); >+ location = location.substring(index); >+ } >+ return location; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewXSDElementNameGenerator.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewXSDElementNameGenerator.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewXSDElementNameGenerator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewXSDElementNameGenerator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator; >+ >+import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; >+import org.eclipse.xsd.XSDSchema; >+ >+public class NewXSDElementNameGenerator implements INewNameGenerator >+{ >+ private XSDSchema _schema; >+ private String _namePattern; >+ >+ public NewXSDElementNameGenerator(XSDSchema schema, String namePattern) >+ { >+ _schema = schema; >+ if (namePattern == null || namePattern.trim().equals("")) >+ namePattern = "NewElement"; >+ _namePattern = namePattern; >+ } >+ >+ public NewXSDElementNameGenerator(XSDSchema schema) >+ { >+ this(schema, null); >+ } >+ >+ public String getNewName() >+ { >+ int count = 0; >+ while (XsdUtils.getXSDElementDeclarationOfName(_schema, _namePattern) != null) >+ { >+ _namePattern = _namePattern + count; >+ count++; >+ } >+ return _namePattern; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 165544
:
58038
|
58095
|
58849
|
59774
|
64199